navigation  interaction  search

 other resources

root/tags/phpbms-0.92/autofill.php

Revision 285 (checked in by brieb, 1 year ago)

Merging object oriented branch back into trunk.

  • Property svn:keywords set to LastChangedBy LastChangedDate LastChangedRevision
Line 
1 <?php
2 /*
3  $Rev$ | $LastChangedBy$
4  $LastChangedDate$
5  +-------------------------------------------------------------------------+
6  | Copyright (c) 2004 - 2007, Kreotek LLC                                  |
7  | All rights reserved.                                                    |
8  +-------------------------------------------------------------------------+
9  |                                                                         |
10  | Redistribution and use in source and binary forms, with or without      |
11  | modification, are permitted provided that the following conditions are  |
12  | met:                                                                    |
13  |                                                                         |
14  | - Redistributions of source code must retain the above copyright        |
15  |   notice, this list of conditions and the following disclaimer.         |
16  |                                                                         |
17  | - Redistributions in binary form must reproduce the above copyright     |
18  |   notice, this list of conditions and the following disclaimer in the   |
19  |   documentation and/or other materials provided with the distribution.  |
20  |                                                                         |
21  | - Neither the name of Kreotek LLC nor the names of its contributore may |
22  |   be used to endorse or promote products derived from this software     |
23  |   without specific prior written permission.                            |
24  |                                                                         |
25  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
26  | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
27  | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
28  | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
29  | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
30  | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
31  | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
32  | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
33  | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
34  | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
35  | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
36  |                                                                         |
37  +-------------------------------------------------------------------------+
38 */
39     require("include/session.php");
40
41     function getAutofillXML($db,$what,$displayfield,$xtrafield,$tabledefid,$thefield,$whereclause){
42         $tblquerystatement="SELECT maintable FROM tabledefs WHERE id=".$tabledefid;
43         $queryresult=$db->query($tblquerystatement);
44         $therecord=$db->fetchArray($queryresult);
45         
46         $querystatement="SELECT ".stripslashes($displayfield)." as display,
47                         ".stripslashes($xtrafield)." as xtra ";
48         if($thefield)
49             $querystatement.=", ".$thefield." as thefield";           
50         $querystatement.=" FROM ".$therecord["maintable"]." WHERE ";
51         if($whereclause)
52             $querystatement.=" (".stripslashes($whereclause).") AND ";
53         $querystatement.=stripslashes($displayfield)." ";
54         if($thefield)
55                 $querystatement.="=\"".$what."\"";
56         else
57                 $querystatement.="LIKE \"".$what."%\"";
58         $querystatement.="ORDER BY ".stripslashes($displayfield);
59         if($thefield)
60             $querystatement.=" LIMIT 1";           
61         else
62             $querystatement.=" LIMIT 10";           
63             
64         $queryresult=$db->query($querystatement);
65         if(!$queryresult){
66             echo $querystatement;
67             $numrows=0;die();}
68         else {
69             $numrows=$db->numRows($queryresult);
70         }
71                 
72         header('Content-Type: text/xml');
73         ?>
74 <?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?>
75 <response>
76 <numrec><?php echo $numrows ?></numrec>
77     <?php if($numrows){
78         while($therecord=$db->fetchArray($queryresult)) {
79     ?><rec>
80 <fld>display</fld>
81 <val><?php echo xmlEncode($therecord["display"])?></val>
82 <fld>extra</fld>
83 <val><?php echo xmlEncode($therecord["xtra"])?></val><?php
84     if(isset($therecord["thefield"])) {
85     ?><fld>thefield</fld><val><?php echo xmlEncode($therecord["thefield"])?></val><?php
86     }
87 ?></rec><?php } //end while
88         }//end if
89     ?></response><?php
90     }//end function
91
92     if(isset($_GET["l"])){
93         $_GET=addSlashesToArray($_GET);
94         if(!isset($_GET["gf"]))$_GET["gf"]="";
95         if(!isset($_GET["wc"]))$_GET["wc"]="";
96         getAutofillXML($db,$_GET["l"],$_GET["fl"],$_GET["xt"],$_GET["tid"],$_GET["gf"],$_GET["wc"]);
97     }
98 ?>
Note: See TracBrowser for help on using the browser.
Copyright © 2006-2007 Kreotek, LLC. All Rights reserved.