phpBMS

root/trunk/phpbms/advancedsearch.php

Revision 704, 5.9 KB (checked in by brieb, 2 years ago)
  • Fixed several SQL injection vulnerabilities
  • Fixed several XSS vulnerabilities due to PHP_SELF and REQUREST_URI
  • Fixed severa path disclosure errors
  • Property svn:keywords set to LastChangedBy LastChangedDate LastChangedRevision
Line 
1<?php
2/*
3 $Rev$ | $LastChangedBy$
4 $LastChangedDate$
5 +-------------------------------------------------------------------------+
6 | Copyright (c) 2004 - 2010, 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
40class advancedSearch{
41
42    var $db;
43    var $tabledefid;
44
45    function advancedSearch($db, $tabledefid){
46
47        $this->db = $db;
48        $this->tabledefid = (int) $tabledefid;
49
50    }//end function
51
52
53    function display(){
54
55        $querystatement = "
56            SELECT
57                `querytable`
58            FROM
59                `tabledefs`
60            WHERE
61                id=".$this->tabledefid;
62
63        $queryresult = $this->db->query($querystatement);
64
65        $thetabledef = $this->db->fetchArray($queryresult);
66
67        //Grab query for all columns
68        $querystatement = "
69            SELECT
70                *
71            FROM
72                ".$thetabledef["querytable"]."
73            LIMIT 1";
74
75        $queryresult = $this->db->query($querystatement);
76
77        $numfields = $this->db->numFields($queryresult);
78
79        for ($i=0;$i<$numfields;$i++)
80            $fieldlist[]=$this->db->fieldTable($queryresult,$i).".".$this->db->fieldName($queryresult,$i);
81
82        ?>
83        <p align="right" style="float:right">
84                <input id="ASsearchbutton" type="button" onclick="performAdvancedSearch(this)" class="Buttons" disabled="disabled" value="search" />
85        </p>
86
87        <p>match <select id="ASanyall" onchange="updateAS()">
88                <option value="and" selected="selected">all</option>
89                <option value="or">any</option>
90        </select> of the following rules:</p>
91        <div id="theASCs">
92                <div id="ASC1">
93                        <select id="ASC1field" onchange="updateAS()">
94                                <?php
95                                        foreach($fieldlist as $field){
96                                                echo "<option value=\"".$field."\" >".$field."</option>\n";}?>
97                        </select>
98                        <select id="ASC1operator" onchange="updateAS()">
99                                 <option value="=" selected="selected">=</option>
100                                 <option value="!=">!=</option>
101                                 <option value=">">&gt;</option>
102                                 <option value="<">&lt;</option>
103                                 <option value=">=">&gt;=</option>
104                                 <option value="<=">&lt;=</option>
105                                 <option value="like">like</option>
106                                 <option value="not like">not like</option>
107                        </select>
108                        <input type="text" id="ASC1text" size="30" maxlength="255" onkeyup="updateAS()" value="" />
109                        <button type="button" id="ASC1minus" class="graphicButtons buttonMinusDisabled" onclick="removeLineAS(this)"><span>-</span></button>
110                        <button type="button" id="ASC1plus" class="graphicButtons buttonPlus" onclick="addlineAS()"><span>+</span></button>
111                </div>
112        </div>
113        <p>
114                sql where clause<br/>
115                <textarea id="ASSQL" style="width:99%" cols="90" rows="3" onkeyup="ASEnableSave(this)"></textarea>
116        </p><?php
117
118    }//end function
119
120}//end class
121
122
123/**
124 * PROCESSING ==================================================================
125 */
126require("include/session.php");
127
128if(!isset($_GET["cmd"]) || !isset($_GET["tid"]))
129    $error = new appError(200, "passed parameters missing");
130
131$as = new advancedSearch($db, $_GET["tid"]);
132$as->display();
133?>
Note: See TracBrowser for help on using the browser.
Scanned by Orvant Copyright © 2010 Kreotek, LLC. All Rights reserved.