| 1 |
<?php |
|---|
| 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 |
require("include/session.php"); |
|---|
| 38 |
require("include/common_functions.php"); |
|---|
| 39 |
|
|---|
| 40 |
function getAutofillXML($what,$displayfield,$xtrafield,$tabledefid,$thefield,$whereclause){ |
|---|
| 41 |
global $dblink; |
|---|
| 42 |
|
|---|
| 43 |
$tblquerystatement="SELECT maintable FROM tabledefs WHERE id=".$tabledefid; |
|---|
| 44 |
$queryresult=mysql_query($tblquerystatement,$dblink); |
|---|
| 45 |
$therecord=mysql_fetch_array($queryresult); |
|---|
| 46 |
|
|---|
| 47 |
$querystatement="SELECT ".stripslashes($displayfield)." as display, |
|---|
| 48 |
".stripslashes($xtrafield)." as xtra "; |
|---|
| 49 |
if($thefield) |
|---|
| 50 |
$querystatement.=", ".$thefield." as thefield"; |
|---|
| 51 |
$querystatement.=" FROM ".$therecord["maintable"]." WHERE "; |
|---|
| 52 |
if($whereclause) |
|---|
| 53 |
$querystatement.=" (".stripslashes($whereclause).") AND "; |
|---|
| 54 |
$querystatement.=stripslashes($displayfield)." "; |
|---|
| 55 |
if($thefield) |
|---|
| 56 |
$querystatement.="=\"".$what."\""; |
|---|
| 57 |
else |
|---|
| 58 |
$querystatement.="LIKE \"".$what."%\""; |
|---|
| 59 |
$querystatement.="ORDER BY ".stripslashes($displayfield); |
|---|
| 60 |
if($thefield) |
|---|
| 61 |
$querystatement.=" LIMIT 1"; |
|---|
| 62 |
else |
|---|
| 63 |
$querystatement.=" LIMIT 10"; |
|---|
| 64 |
|
|---|
| 65 |
$queryresult=mysql_query($querystatement,$dblink); |
|---|
| 66 |
if(!$queryresult){ |
|---|
| 67 |
echo $querystatement; |
|---|
| 68 |
$numrows=0;die();} |
|---|
| 69 |
else { |
|---|
| 70 |
$numrows=mysql_num_rows($queryresult); |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
header('Content-Type: text/xml'); |
|---|
| 74 |
?> |
|---|
| 75 |
<?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> |
|---|
| 76 |
<response> |
|---|
| 77 |
<numrec><?php echo $numrows ?></numrec> |
|---|
| 78 |
<?php if($numrows){ |
|---|
| 79 |
while($therecord=mysql_fetch_array($queryresult)) { |
|---|
| 80 |
?><rec> |
|---|
| 81 |
<fld>display</fld> |
|---|
| 82 |
<val><?php echo xmlEncode($therecord["display"])?></val> |
|---|
| 83 |
<fld>extra</fld> |
|---|
| 84 |
<val><?php echo xmlEncode($therecord["xtra"])?></val><?php |
|---|
| 85 |
if(isset($therecord["thefield"])) { |
|---|
| 86 |
?><fld>thefield</fld><val><?php echo xmlEncode($therecord["thefield"])?></val><?php |
|---|
| 87 |
} |
|---|
| 88 |
?></rec><?php } |
|---|
| 89 |
} |
|---|
| 90 |
?></response><?php |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
if(isset($_GET["l"])){ |
|---|
| 94 |
$_GET=addSlashesToArray($_GET); |
|---|
| 95 |
if(!isset($_GET["gf"]))$_GET["gf"]=""; |
|---|
| 96 |
if(!isset($_GET["wc"]))$_GET["wc"]=""; |
|---|
| 97 |
getAutofillXML($_GET["l"],$_GET["fl"],$_GET["xt"],$_GET["tid"],$_GET["gf"],$_GET["wc"]); |
|---|
| 98 |
} |
|---|
| 99 |
?> |
|---|