phpBMS

Show
Ignore:
Timestamp:
08/27/07 14:05:27 (5 years ago)
Author:
brieb
Message:

Merging object oriented branch back into trunk.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/choicelist.php

    r218 r285  
    3939        require_once("include/session.php"); 
    4040         
    41         function deleteList($listname){ 
    42                 global $dblink; 
     41         
     42        class choiceList{ 
     43                var $db; 
     44                 
     45                function choiceList($db){ 
     46                        $this->db = $db; 
     47                } 
     48         
     49         
     50                function deleteList($listname){ 
     51                        $querystatement="DELETE FROM choices WHERE listname=\"".$listname."\" "; 
     52                        $queryresult=$this->db->query($querystatement); 
    4353 
    44                 $querystatement="DELETE FROM choices WHERE listname=\"".$listname."\" "; 
    45                 $queryresult=mysql_query($querystatement,$dblink); 
    46                 if(!$queryresult)  
    47                         reportError(100,"SQL Statement Could not be executed."); 
    48                 else 
    4954                        echo "ok"; 
    50         } 
    51          
    52         function addToList($listname,$value){ 
    53                 global $dblink; 
     55                } 
    5456 
    55                 $querystatement="INSERT INTO choices (listname,thevalue) VALUES(\"".$listname."\",\"".$value."\") "; 
    56                 $queryresult=mysql_query($querystatement,$dblink); 
    57                 if(!$querystatement)  
    58                         reportError(100,"SQL Statement Could not be executed."); 
    59                 else 
     57 
     58                function addToList($listname,$value){ 
     59                        $querystatement="INSERT INTO choices (listname,thevalue) VALUES(\"".$listname."\",\"".$value."\") "; 
     60                        $queryresult=$this->db->query($querystatement); 
     61 
    6062                        echo "ok"; 
    61         } 
     63                } 
    6264 
    63         function displayList($queryresult,$blankvalue){ 
    64                 while($therecord=mysql_fetch_array($queryresult)){ 
    65                         $display=$therecord["thevalue"]; 
    66                         $theclass=""; 
    67                         if($therecord["thevalue"]==""){ 
    68                                 $display="<".$blankvalue.">"; 
    69                                 $theclass=" class=\"choiceListBlank\" "; 
    70                         } 
    71                         ?><option value="<?php echo $therecord["thevalue"]?>" <?php echo $theclass?>><?php echo $display?></option><?php 
    72                 }//end while 
    73          
    74         } 
    75          
     65 
     66                function displayList($queryresult,$blankvalue){ 
     67                        while($therecord=$this->db->fetchArray($queryresult)){ 
     68                                $display=$therecord["thevalue"]; 
     69                                $theclass=""; 
     70                                if($therecord["thevalue"]==""){ 
     71                                        $display="&lt;".$blankvalue."&gt;"; 
     72                                        $theclass=" class=\"choiceListBlank\" "; 
     73                                } 
     74                                ?><option value="<?php echo $therecord["thevalue"]?>" <?php echo $theclass?>><?php echo $display?></option><?php 
     75                        }//end while 
     76                 
     77                } 
     78                 
    7679        function displayBox($listname,$blankvalue,$listid){ 
    77                 global $dblink; 
     80                $blankvalue = str_replace("<","",$blankvalue); 
     81                $blankvalue = str_replace(">","",$blankvalue); 
    7882                 
    79                 $blankvalue=str_replace("<","",$blankvalue); 
    80                 $blankvalue=str_replace(">","",$blankvalue); 
    81                  
    82                 $querystatement="SELECT thevalue FROM choices WHERE listname=\"".$listname."\" ORDER BY thevalue;"; 
    83                 $queryresult=mysql_query($querystatement,$dblink); 
    84                 if(!$querystatement) reportError(100,"SQL Statement Could not be executed."); 
     83                $querystatement = "SELECT thevalue FROM choices WHERE listname=\"".$listname."\" ORDER BY thevalue;"; 
     84                $queryresult = $this->db->query($querystatement); 
    8585?> 
    8686        <p id="MLListP"> 
    8787                <select id="MLlist" name="MLList" size="12" onchange="updateML(this)"> 
    88                         <?php displayList($queryresult,$blankvalue)?> 
     88                        <?php $this->displayList($queryresult,$blankvalue)?> 
    8989                </select> 
    9090        </p> 
     
    102102        <p id="MLStatus" class="small">&nbsp;</p> 
    103103        <div align="right"> 
    104                 <input type="button" id="MLok" name="MLok" value="ok" class="Buttons" style="width:75px;" onclick="clickOK('<?php echo $_SESSION["app_path"]?>','<?php echo $listid?>','<?php echo $listname?>')"/> 
     104                <input type="button" id="MLok" name="MLok" value="ok" class="Buttons" style="width:75px;" onclick="clickOK('<?php echo APP_PATH?>','<?php echo $listid?>','<?php echo $listname?>')"/> 
    105105                <input type="button" id="MLcancel" name="MLcancel" value="cancel" class="Buttons" style="width:75px;" onclick="closeBox('<?php echo $listid?>');"/>&nbsp; 
    106106        </div> 
    107107<?php   }//end function 
     108                 
     109        }//end class 
     110         
     111         
     112 
     113         
     114 
    108115 
    109116        if(!isset($_GET["cm"]))  
     
    112119        if(!isset($_GET["ln"])) 
    113120                $_GET["ln"]="shippingmethod"; 
     121 
    114122        if(!isset($_GET["bv"])) 
    115123                $_GET["bv"]="none"; 
     124         
     125        $theList = new choiceList($db); 
     126         
    116127        switch($_GET["cm"]){ 
    117128                case "shw": 
    118                         displayBox($_GET["ln"],$_GET["bv"],$_GET["lid"]); 
     129                        $theList->displayBox($_GET["ln"],$_GET["bv"],$_GET["lid"]); 
    119130                break; 
    120131                case "del": 
    121                         deleteList($_GET["ln"]); 
     132                        $theList->deleteList($_GET["ln"]); 
    122133                break; 
    123134                case "add": 
    124                         addToList($_GET["ln"],$_GET["val"]); 
     135                        $theList->addToList($_GET["ln"],$_GET["val"]); 
    125136                break; 
    126137        } 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.