phpBMS

Show
Ignore:
Timestamp:
04/07/09 11:44:18 (3 years ago)
Author:
nate
Message:
  • Merged Nathan branch back into trunk.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/recurringinvoices/install/update.php

    r427 r485  
    3737 +-------------------------------------------------------------------------+ 
    3838*/ 
    39 error_reporting(E_ALL); 
    40 define("APP_DEBUG",false); 
    41 define("noStartup",true); 
    42  
    43 include("../../../install/install_include.php"); 
    44 include("../../../include/session.php"); 
    45  
    46         function doUpdate($db) { 
    47          
    48                 $module = array( 
    49                         "title" => "Recurring Invoices", 
    50                         "name" => "recurringinvoices" 
    51                 ); 
    52          
    53                 $thereturn="Updating ".$module["title"]." Module\n"; 
    54                  
    55                 if(!verifyAdminLogin($db,$_GET["u"],$_GET["p"])){ 
    56                  
    57                         $thereturn="Update Requires Administrative Access.\n\n"; 
    58                         return $thereturn; 
    59                          
    60                 }//end if 
    61                                  
    62                 $newVersion = $_GET["v"]; 
    63                  
    64                 $querystatement="SELECT version FROM modules WHERE name = '".$module["name"]."'"; 
    65                 $queryresult=$db->query($querystatement); 
    66  
    67                 if($db->numRows($queryresult)) { 
    68                          
    69                         $ver=$db->fetchArray($queryresult); 
    70                         while($ver["version"] != $newVersion){ 
    71                          
    72                                 switch($ver["version"]){ 
    73                                  
    74                                         // ================================================================================================ 
    75                                         case "1.0": 
    76                                                 $nextVersion = "1.01"; 
    77                                                  
    78                                                 $thereturn.="Updating ".$module["title"]." Module to ".$nextVersion."\n"; 
    79                          
    80                                                 $thereturn.= processSQLfile($db,"updatev1.01.sql"); 
    81          
    82                                                 //Updating Module Table 
    83                                                 $querystatement=" 
    84                                                         UPDATE  
    85                                                                 modules  
    86                                                         SET  
    87                                                                 version='".$nextVersion."' 
    88                                                         WHERE  
    89                                                                 name = '".$module["name"]."'"; 
    90                                                                  
    91                                                 $queryresult = $db->query($querystatement); 
    92                                                  
    93                                                 $thereturn.=" - Updated module record with new version \n"; 
    94                                                  
    95                                                 $thereturn.="Update of ".$module["name"]." to ".$nextVersion." Finished\n\n"; 
    96                                  
    97                                                 $ver["version"] = $nextVersion; 
    98                  
    99                                                 break; 
    100                                                  
    101                                         // ================================================================================================ 
    102                                         case "1.01": 
    103                                                 $nextVersion = "1.02"; 
    104                                                  
    105                                                 $thereturn.="Updating ".$module["title"]." Module to ".$nextVersion."\n"; 
    106                          
    107                                                 //$thereturn.= processSQLfile($db,"updatev1.01.sql"); 
    108          
    109                                                 //Updating Module Table 
    110                                                 $querystatement=" 
    111                                                         UPDATE  
    112                                                                 modules  
    113                                                         SET  
    114                                                                 version='".$nextVersion."' 
    115                                                         WHERE  
    116                                                                 name = '".$module["name"]."'"; 
    117                                                                  
    118                                                 $queryresult = $db->query($querystatement); 
    119                                                  
    120                                                 $thereturn.=" - Updated module record with new version \n"; 
    121                                                  
    122                                                 $thereturn.="Update of ".$module["name"]." to ".$nextVersion." Finished\n\n"; 
    123                                  
    124                                                 $ver["version"] = $nextVersion; 
    125                  
    126                                                 break; 
    127                                         // ================================================================================================ 
    128                                         case "1.02": 
    129                                                 $nextVersion = "1.03"; 
    130                                                  
    131                                                 $thereturn.="Updating ".$module["title"]." Module to ".$nextVersion."\n"; 
    132                          
    133                                                 $thereturn.= processSQLfile($db,"updatev1.03.sql"); 
    134          
    135                                                 //Updating Module Table 
    136                                                 $querystatement=" 
    137                                                         UPDATE  
    138                                                                 modules  
    139                                                         SET  
    140                                                                 version='".$nextVersion."' 
    141                                                         WHERE  
    142                                                                 name = '".$module["name"]."'"; 
    143                                                                  
    144                                                 $queryresult = $db->query($querystatement); 
    145                                                  
    146                                                 $thereturn.=" - Updated module record with new version \n"; 
    147                                                  
    148                                                 $thereturn.="Update of ".$module["name"]." to ".$nextVersion." Finished\n\n"; 
    149                                  
    150                                                 $ver["version"] = $nextVersion; 
    151                  
    152                                                 break; 
    153                                          
    154                                 }//end switch 
    155                                  
    156                         }//end while 
    157                          
    158                 } else  
    159                         $thereturn = "Cannot update module ".$module["title"].": Module not installed."; 
    160  
    161                 return $thereturn; 
    162  
    163         }//end update            
    164  
    165         //PROCESSING 
    166         // =================================================================================================== 
    167          
    168         $phpbmsSession = new phpbmsSession; 
    169         $success = $phpbmsSession->loadDBSettings(false); 
    170  
    171         include_once("include/db.php"); 
    172         $db = new db(false); 
    173         $db->stopOnError = false; 
    174         $db->showError = false; 
    175         $db->logError = false; 
    176  
    177         if($success !== false){ 
    178                  
    179                 if(!$db->connect()) 
    180                         $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password.";                   
    181                 else { 
    182  
    183                         if(!$db->selectSchema()) 
    184                                 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected";                       
    185                         else { 
    186  
    187                                 $phpbmsSession->db = $db; 
    188                                 $phpbmsSession->loadSettings(); 
    189                                  
    190                                 $thereturn = doUpdate($db);      
    191  
    192                         }//endif 
    193                          
    194                 }//end if 
    195                  
    196         } else 
    197                 $thereturn = "Could not access settings.php";    
    198                                  
    199                 header('Content-Type: text/xml'); 
    200                 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 
    201 <response><?php echo $thereturn?></response> 
     39$theModule = new updateModuleAjax($this->db, $this->phpbmsSession, "recurringinvoices", "../modules/recurringinvoices/install/"); 
     40$theModule->updateVersions = array( 
     41                                        1.01, 
     42                                        1.03 
     43                                ); 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.