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/base/include/adminsettings_include.php

    r357 r485  
    4343class settings{ 
    4444        var $db; 
    45          
     45 
    4646        function settings($db){ 
    47          
     47 
    4848                $this->db = $db; 
    49          
    50         } 
    51          
    52          
     49 
     50        } 
     51 
     52 
    5353        function getSettings(){ 
    5454                $therecord = array(); 
    55                  
     55 
    5656                $querystatement = "SELECT `name`, `value` FROM `settings`"; 
    5757                $queryresult = $this->db->query($querystatement); 
    58                  
     58 
    5959                while($setting = $this->db->fetchArray($queryresult)) 
    6060                        $therecord[$setting["name"]] = $setting["value"]; 
    61                          
     61 
    6262                return $therecord; 
    6363        } 
    64          
    65          
     64 
     65 
    6666        function updateSettings($variables){ 
    67          
     67 
    6868                global $phpbms; 
    69                  
     69 
    7070                if(!isset($variables["persistent_login"])) $variables["persistent_login"]=0; 
    71                  
     71 
    7272                //include any procesing that needs to be done by modules 
    7373                foreach($phpbms->modules as $module => $moduleinfo) 
     
    7777                                        $extraUpdate = new $class($this->db); 
    7878                                        $variables = $extraUpdate->updateSettings($variables); 
    79                                          
     79 
    8080                                }//end if 
    81          
     81 
    8282                // Update the settings records 
    8383                foreach($variables as $settingname => $settingvalue){ 
    8484                        if(defined(strtoupper($settingname))){ 
    8585                                if(constant(strtoupper($settingname)) != $settingvalue){ 
    86                                  
     86 
    8787                                        $updatestatement = " 
    88                                                 UPDATE  
    89                                                         settings  
    90                                                 SET  
    91                                                         value ='".$settingvalue."'  
    92                                                 WHERE  
     88                                                UPDATE 
     89                                                        settings 
     90                                                SET 
     91                                                        value ='".$settingvalue."' 
     92                                                WHERE 
    9393                                                        name='".mysql_real_escape_string($settingname)."'"; 
    94                                                          
     94 
    9595                                        $updateresult = $this->db->query($updatestatement); 
    96                                          
     96 
    9797                                        if(!$this->db->affectedRows()){ 
    9898 
    9999                                                //check to see why the update did not work 
    100100                                                $querystatement = " 
    101                                                         SELECT  
     101                                                        SELECT 
    102102                                                                name 
    103103                                                        FROM 
     
    105105                                                        WHERE 
    106106                                                                name = '".mysql_real_escape_string($settingname)."'"; 
    107                                                  
     107 
    108108                                                $queryresult = $this->db->query($querystatement); 
    109                                                  
     109 
    110110                                                if(!$this->db->numRows($queryresult)){ 
    111                                                  
     111 
    112112                                                        //insert the setting if need be 
    113113                                                        $insertstatement =" 
     
    120120                                                                                '".mysql_real_escape_string($settingname)."' 
    121121                                                                        }"; 
    122                                                                          
     122 
    123123                                                        $this->db-query($insertstatement); 
    124                                                          
     124 
    125125                                                }//end if 
    126                                          
     126 
    127127                                        }//end if 
    128                                          
     128 
    129129                                }//end if 
    130130                        } 
    131131                }//end foreach 
    132                  
     132 
    133133                // deal with logo graphic. 
    134134                if(isset($_FILES["printedlogo"])){ 
    135                         if($_FILES["printedlogo"]["type"] == "image/png" || $_FILES["printedlogo"]["type"] == "image/jpeg"){ 
     135 
     136                        $validFileTypes = array( 
     137                                "image/png", 
     138                                "image/x-png", 
     139                                "image/jpg", 
     140                                "image/jpeg", 
     141                                "imagep/jpeg", 
     142                        ); 
     143 
     144                        if(in_array($_FILES["printedlogo"]["type"], $validFileTypes)){ 
     145 
    136146                                if (function_exists('file_get_contents')) { 
     147 
    137148                                        $file = mysql_real_escape_string(file_get_contents($_FILES['printedlogo']['tmp_name'])); 
     149 
    138150                                } else { 
     151 
    139152                                        // If using PHP < 4.3.0 use the following: 
    140153                                        $file = mysql_real_escape_string(fread(fopen($_FILES['printedlogo']['tmp_name'], 'r'), filesize($_FILES['printedlogo']['tmp_name']))); 
    141                                 } 
     154 
     155                                }//endif 
     156 
    142157                                if($_FILES["printedlogo"]["type"] == "image/jpeg") 
    143158                                        $name = "logo.jpg"; 
    144159                                else 
    145160                                        $name = "logo.png"; 
    146                                          
    147                                 $querystatement="UPDATE `files` SET `file` = '".$file."', `type` = '".$_FILES["printedlogo"]["type"]."', `name`='".$name."' WHERE id=1"; 
    148                                 $queryresult=$this->db->query($querystatement); 
    149                         } 
    150                 }                
     161 
     162                                $updatestatement = " 
     163                                        UPDATE 
     164                                                `files` 
     165                                        SET 
     166                                                `file` = '".$file."', 
     167                                                `type` = '".$_FILES["printedlogo"]["type"]."', 
     168                                                `name`='".$name."' 
     169                                        WHERE 
     170                                                id = 1"; 
     171 
     172                                $this->db->query($updatestatement); 
     173 
     174                        }//endif file types 
     175 
     176                }//endif file exists 
    151177 
    152178                return true; 
    153                  
     179 
    154180        }//end method 
    155          
     181 
    156182 
    157183        function updateEncyptionSeed($newseed,$currpassword,$userid){ 
    158          
     184 
    159185                $userid = (int) $userid; 
    160          
     186 
    161187                //first let's make sure the password matches 
    162188                $querystatement="SELECT id FROM users WHERE id=".$userid." AND password=ENCODE('".$currpassword."','".ENCRYPTION_SEED."')"; 
     
    165191                if(!$this->db->numRows($queryresult)) 
    166192                        return "Encryption Seed not Updated: Invalid Current Password"; 
    167                  
     193 
    168194                //let's update the encryption seed then 
    169195                $querystatement="UPDATE settings SET value='".$newseed."' WHERE name='encryption_seed'"; 
    170196                $queryresult=$this->db->query($querystatement); 
    171                          
     197 
    172198                //last, reencode the current password 
    173199                $querystatement="UPDATE users SET password=ENCODE('".$currpassword."','".$newseed."') WHERE id=".$userid; 
     
    177203                $querystatement="UPDATE users SET password = ENCODE(DECODE(password,'".ENCRYPTION_SEED."'),'".$newseed."') WHERE id !=".$userid; 
    178204                $queryresult=$this->db->query($querystatement); 
    179                          
     205 
    180206                return "Encryption Seed Updated."; 
    181         }        
     207        } 
    182208 
    183209 
     
    185211 
    186212                $variables = addSlashesToArray($variables); 
    187                  
     213 
    188214                switch($variables["command"]){ 
    189215                        case "update settings": 
     
    191217                                        $statusmessage="Settings Updated"; 
    192218                        break; 
    193                          
     219 
    194220                        case "update encryption seed": 
    195221                                if(isset($variables["changeseed"])) 
     
    201227 
    202228        }//end method 
    203          
    204          
     229 
     230 
    205231        function displayStylesheets($stylesheet){ 
    206232 
    207233                $thedir="../../common/stylesheet"; 
    208234                $thedir_stream = @opendir($thedir); 
    209                  
     235 
    210236                while($entry = @ readdir($thedir_stream)){ 
    211237                        if ($entry!="." and  $entry!=".." and is_dir($thedir."/".$entry)) { 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.