-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathewlookup7.php
113 lines (102 loc) · 2.77 KB
/
ewlookup7.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
define("EW_DEFAULT_LOCALE", "es_ES", TRUE);
@setlocale(LC_ALL, EW_DEFAULT_LOCALE);
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
$lookup = new clookup;
$lookup->Page_Main();
//
// Page class for lookup
//
class clookup {
// Page ID
var $PageID = "lookup";
// Page object name
var $PageObjName = "lookup";
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
return ew_CurrentPage() . "?";
}
// Main
function Page_Main() {
$qs = new cQueryString();
if ($qs->Count > 0) {
$Sql = $qs->getValue("s");
$Sql = TEAdecrypt($Sql, EW_RANDOM_KEY);
if ($Sql <> "") {
// Get the filter values (for "IN")
$Value = ew_AdjustSql($qs->getConvertedValue("f"));
if ($Value <> "") {
$arValue = explode(",", $Value);
$FldType = $qs->getValue("lft"); // Filter field data type
if (is_numeric($FldType))
$FldType = intval($FldType);
$cnt = count($arValue);
for ($i=0; $i<$cnt; $i++) {
$arValue[$i] = ew_QuotedValue($arValue[$i], $FldType);
}
$Sql = str_replace("{filter_value}", implode(",", $arValue), $Sql);
}
// get the query value (for "LIKE" or "=")
$Value = ew_AdjustSql($qs->getConvertedValue("q"));
if ($Value <> "")
$Sql = str_replace("{query_value}", $Value, $Sql);
$this->GetLookupValues($Sql);
}
} else {
die("Missing querystring.");
}
}
// Get lookup values
function GetLookupValues($Sql) {
$rsarr = array();
$rowcnt = 0;
$conn = ew_Connect();
if ($rs = $conn->Execute($Sql)) {
$rowcnt = $rs->RecordCount();
$fldcnt = $rs->FieldCount();
$rsarr = $rs->GetRows();
$rs->Close();
}
$conn->Close();
// Output
if (is_array($rsarr) && $rowcnt > 0) {
for ($i=0; $i<$rowcnt; $i++) {
for ($j=0; $j<$fldcnt; $j++) {
$str = strval($rsarr[$i][$j]);
$str = $this->RemoveDelimiters($str);
echo ew_ConvertToUtf8($str . EW_FIELD_DELIMITER);
}
echo ew_ConvertToUtf8(EW_RECORD_DELIMITER);
}
}
}
// Process values
function RemoveDelimiters($s) {
$wrkstr = $s;
if (strlen($wrkstr) > 0) {
$wrkstr = str_replace("\r", " ", $wrkstr);
$wrkstr = str_replace("\n", " ", $wrkstr);
$wrkstr = str_replace(EW_RECORD_DELIMITER, "", $wrkstr);
$wrkstr = str_replace(EW_FIELD_DELIMITER, " ", $wrkstr);
}
return $wrkstr;
}
}
?>