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

    r402 r485  
    3737 +-------------------------------------------------------------------------+ 
    3838*/ 
     39 
     40// Turn on/or off debugging 
    3941@ define("APP_DEBUG",true); 
    4042if(APP_DEBUG) 
    4143        error_reporting(E_ALL); 
    4244 
     45 
     46// Error Class - This class reports errors.  It can also log these errors 
     47// to the phpBMS log table in some cases. 
    4348class appError{ 
     49 
    4450        var $number=0; 
    4551        var $title=""; 
     
    4854        var $logerror=true; 
    4955        var $format="xhtml"; 
    50          
     56 
     57        //init 
    5158        function appError($number=0,$details="",$title="",$display=false,$stop=true,$logerror=true,$format="xhtml"){ 
     59 
    5260                $this->title = $title; 
    53                  
    54                  
    5561                $this->details = $details; 
    56                  
    5762                $this->stop = $stop; 
    58                                  
     63 
    5964                $this->logerror = $logerror; 
    6065                $this->format = $format; 
    6166                $this->number = $number; 
    62                                  
     67 
     68                // find a predetermined title; 
    6369                if($this->number<0){ 
     70 
    6471                        switch($number){ 
     72                                case -300: 
     73                                        $this->title = "settings.php file not readable"; 
     74                                        $this->details = 
     75                                        'If this is the initial installation of the program, 
     76                                        you may wan to run the installer.  Use your web browser to navigate to:<br /><br /> 
     77 
     78                                        <a href="'.APP_PATH.'install">phpBMS Installation</a><br /><br /> 
     79 
     80                                        If your application already has a settings.php file in the main phpbms directory, you may need to give your web server rights to read the file.'; 
     81                                        break; 
    6582                                case -400: 
    6683                                case -410: 
     
    7188                                case -460: 
    7289                                        $this->title="Database Error"; 
    73                                 break; 
    74                         } 
    75                 }  
    76                  
     90                                        break; 
     91                        }//end case; 
     92 
     93                }//endif this->number 
     94 
    7795                if($display || APP_DEBUG) $this->display($format); 
    7896                if($logerror) $this->logError(); 
    7997                if($this->stop) exit; 
    80         } 
    81          
    82         function display($format=NULL){ 
    83  
    84                 if($format==NULL) 
    85                         $format=$this->format; 
    86          
     98 
     99        }//eend function init 
     100 
     101 
     102        //This function outputs the error to screen either in 
     103        // XHTML, plain text, or JSON format 
     104        function display($format = NULL){ 
     105 
     106                if($format == NULL) 
     107                        $format = $this->format; 
     108 
    87109                switch(strtolower($format)){ 
     110 
    88111                        case "json": 
    89112 
    90                                 echo "{\n"; 
    91                                 echo "\"error\" : { \"id\" : ".$this->number; 
    92                                 if($this->title) 
    93                                         echo ", \"title\" : \"".addslashes($this->title)."\""; 
    94                                 if($this->details) 
    95                                         echo ", \"details\" : \"".addslashes($this->details)."\""; 
    96                                 echo "\n}"; 
    97  
    98                         break; 
    99                          
     113                                $return["id"] = $this->number; 
     114                                $return["title"] = $this->title; 
     115                                $return["details"] = $this->details; 
     116 
     117                                echo json_encode($return); 
     118 
     119                                break; 
     120 
    100121                        case "xhtml": 
    101122 
    102                                 $this->details = str_replace("\n","<br />", htmlspecialchars($this->details,ENT_COMPAT,"UTF-8")); 
     123                                // Unsure if this line is needed, as it limits what we can do with detail print out 
     124                                //$this->details = str_replace("\n","<br />", htmlspecialchars($this->details,ENT_COMPAT,"UTF-8")); 
    103125 
    104126                                if(defined("APP_PATH")){ 
     127 
    105128                                        if(!defined("STYLESHEET")) 
    106129                                                define("STYLESHEET","mozilla"); 
    107                                 ?><link href="<?php echo APP_PATH ?>common/stylesheet/<?php echo STYLESHEET ?>/base.css" rel="stylesheet" type="text/css" /><?php 
     130 
     131                                        ?><link href="<?php echo APP_PATH ?>common/stylesheet/<?php echo STYLESHEET ?>/base.css" rel="stylesheet" type="text/css" /><?php 
     132 
    108133                                } else { 
    109                                         //if the app_path is not defined, we can try including the mozilla stylesheet, relative to  
     134 
     135                                        //if the app_path is not defined, we can try including the mozilla stylesheet, relative to 
    110136                                        // the assumed phpbms root 
    111                                 ?><link href="common/stylesheet/mozilla/base.css" rel="stylesheet" type="text/css" /><?php  
     137                                        ?><link href="common/stylesheet/mozilla/base.css" rel="stylesheet" type="text/css" /><?php 
     138 
    112139                                }//end if 
     140 
    113141                                ?><div class="bodyline"> 
    114142                                        <h1><span>phpBMS Error: <?php echo $this->number; if($this->title) echo " ".$this->title?></span></h1> 
     
    118146                                        </div> 
    119147                                        <?php  } //end if?> 
    120                                 </div><?php  
    121  
    122                         break; 
    123                          
     148                                </div><?php 
     149 
     150                                break; 
     151 
    124152                        default: 
    125                          
     153 
    126154                                echo "phpBMS Error: ".$this->number; 
    127155                                if($this->title) echo ": ".$this->title; 
    128156                                if($this->details) echo  " - ".$this->details; 
    129                                  
    130                         break; 
     157 
     158                                break; 
    131159                }//end switch 
    132160        }// end dispaly function 
    133          
     161 
     162 
     163        // this function logs the error in the phpBMS log table 
    134164        function logError(){ 
     165 
    135166                $message = $_SERVER["REQUEST_URI"]."\n"; 
    136167                $message .= $this->number; 
     168 
    137169                if($this->title) 
    138170                        $message.=": ".$this->title; 
     171 
    139172                if($this->details) 
    140173                        $message.="\n\n".$this->details; 
    141                                                  
     174 
    142175                $log = new phpbmsLog($message,"ERROR"); 
     176 
    143177        }//end logError 
    144          
     178 
    145179}//end appError class 
    146180 
     181 
     182// This is the class for logging items tot the phpBMS 
     183// log table; 
    147184class phpbmsLog{ 
    148          
    149         var $db=NULL; 
    150         var $type="ERROR"; 
    151         var $value=""; 
    152         var $userid=2; 
    153          
     185 
     186        var $db = NULL; 
     187        var $type = "ERROR"; 
     188        var $value = ""; 
     189        var $userid = 2; 
     190 
    154191        function phpbmsLog($value=NULL,$type=NULL,$userid=NULL,$db=NULL,$sendLog=true){ 
    155192 
     
    158195                if($db){ 
    159196                        if(is_object($db)){ 
    160                                 $this->db=$db; 
    161          
     197 
     198                                $this->db = $db; 
     199 
    162200                                $this->db->showError=false; 
    163201                                $this->db->logError=false; 
    164202                                $this->db->stopOnError=false; 
    165                         } 
    166                 } 
    167                 else{ 
     203 
     204                        }//endif object 
     205 
     206                } else { 
     207 
    168208                        if(class_exists("db")){ 
     209 
    169210                                $this->db= new db(false); 
    170          
     211 
    171212                                $this->db->showError=false; 
    172213                                $this->db->logError=false; 
    173214                                $this->db->stopOnError=false; 
    174          
     215 
    175216                                $this->db->connect(); 
    176217                                $this->db->selectSchema(); 
    177                         } else  
     218 
     219                        } else 
    178220                                return false; 
    179                 } 
    180                  
     221 
     222                }//endif db 
     223 
    181224                if($value) 
    182                         $this->value=$value; 
     225                        $this->value = $value; 
     226 
    183227                if($type) 
    184                         $this->type=$type; 
     228                        $this->type = $type; 
     229 
    185230                if($userid) 
    186                         $this->userid=((int) $userid); 
    187                  
     231                        $this->userid = ((int) $userid); 
     232 
    188233                if($sendLog) 
    189234                        return $this->sendLog(); 
    190235                else 
    191236                        return true; 
    192                  
    193         }//end function 
    194          
     237 
     238        }//end function init 
     239 
     240 
     241        // inserts record into log table 
    195242        function sendLog(){ 
    196                          
    197                 $ip=$_SERVER["REMOTE_ADDR"]; 
    198          
    199                 $querystatement="INSERT INTO `log` (`type`,`value`,`userid`,`ip`) VALUES ("; 
    200                 $querystatement.="\"".mysql_real_escape_string($this->type)."\", "; 
    201                 $querystatement.="\"".mysql_real_escape_string($this->value)."\", "; 
    202                 $querystatement.=$this->userid.", "; 
    203                 $querystatement.="\"".$ip."\")"; 
    204                  
    205                 $this->db->query($querystatement); 
    206                  
    207         } 
    208 }//end phpbmslog 
    209  
    210  
    211  
     243 
     244                $ip = $_SERVER["REMOTE_ADDR"]; 
     245 
     246                $insertstatement = " 
     247                        INSERT INTO 
     248                                `log` 
     249                        (`type`, `value`, `userid`, `ip`) VALUES ( 
     250                                '".mysql_real_escape_string($this->type)."', 
     251                                '".mysql_real_escape_string($this->value)."', 
     252                                ".$this->userid.", 
     253                                '".$ip."' 
     254                        )"; 
     255 
     256                $this->db->query($insertstatement); 
     257 
     258        }//end function sendLog 
     259 
     260}//end class phpbmslog 
     261 
     262 
     263// This class handles the loading of the database, session and application 
     264// variables, as well as verifying API level logins 
    212265class phpbmsSession{ 
    213266 
    214         var $db=null; 
     267        var $db = null; 
    215268 
    216269        function loadDBSettings($reportError = true){ 
     270 
    217271                // This functions looks for the settings.php file, and loads 
    218272                // the database variables as constants.  As an added benefit 
    219273                // it adds the phpBMS root as an included path. 
    220                  
    221                 $path=""; 
    222                 $count=1; 
     274 
    223275 
    224276                //need to look for settings file... only go up a total of 10 directories 
    225                 $currdirectory= getcwd(); 
    226                  
    227                 while(!file_exists("settings.php") and ($count<10)){ 
     277                $currdirectory = getcwd(); 
     278 
     279                //Prep the setting of the application path; 
     280                $currentURL = explode("/",$_SERVER["PHP_SELF"]); 
     281                array_pop($currentURL); 
     282 
     283                $count = 0; 
     284                $path = ""; 
     285 
     286                //We need to find the applications root 
     287                while(!file_exists("phpbmsversion.php") && $count < 9){ 
     288 
    228289                        $path.="../"; 
    229290                        @ chdir("../"); 
    230291                        $count++; 
    231                 } 
    232                  
     292 
     293                }//end while 
     294 
     295                //Now set the Web location (APP_PATH) 
     296                $appPath = "/"; 
     297                for($i = 0; $i < count($currentURL) - $count; $i++) 
     298                        if($currentURL[$i]) 
     299                                $appPath .= $currentURL[$i]."/"; 
     300 
     301                define("APP_PATH", $appPath); 
     302 
    233303                $settingsfile =  @ fopen("settings.php","r"); 
     304 
    234305                if($settingsfile){ 
    235                         //loop through the settings file and load variables into the session  
     306 
     307                        //loop through the settings file and load variables into the session 
    236308                        while( !feof($settingsfile)) { 
    237                                 $line=NULL; 
    238                                 $key=NULL; 
    239                                 $value=NULL; 
    240                                 $line=fscanf($settingsfile,"%[^=]=%[^[]]",$key,$value); 
     309 
     310                                $line = NULL; 
     311                                $key = NULL; 
     312                                $value = NULL; 
     313                                $line = @ fscanf($settingsfile,"%[^=]=%[^[]]",$key,$value); 
     314 
    241315                                if ($line){ 
     316 
    242317                                        $key=trim($key); 
    243318                                        $value=trim($value); 
    244                                         if($key!="" and !strpos($key,"]")){      
     319 
     320                                        if($key!="" and !strpos($key,"]")){ 
     321 
    245322                                                $startpos=strpos($value,"\""); 
    246323                                                $endpos=strrpos($value,"\""); 
     324 
    247325                                                if($endpos!=false) 
    248326                                                        $value=substr($value,$startpos+1,$endpos-$startpos-1); 
    249                                                 if(strpos($key,"mysql_")===0){ 
     327 
     328                                                if(strpos($key,"mysql_")===0) 
    250329                                                        define(strtoupper($key),$value); 
    251                                                 } 
    252                                         } 
    253                                 } 
    254                         } 
    255                          
     330 
     331                                        }//endif key 
     332 
     333                                }//endif line 
     334 
     335                        }//endwhile 
     336 
    256337                        @ fclose($settingsfile); 
    257338 
     
    261342 
    262343                        //this adds the phpbms root to the include path 
    263                         if ( ! defined( "PATH_SEPARATOR" ) ) { 
    264                            
    265                           //if we cannot determin the OS, we will assume its unix 
    266                           if(!isset($_ENV["OS"])) 
    267                                   $_ENV["OS"] = "unix"; 
    268                            
    269                           if ( strpos( $_ENV["OS"], "Win" ) !== false ) 
    270                                 define( "PATH_SEPARATOR", ";" ); 
    271                           else  
    272                                 define( "PATH_SEPARATOR", ":" ); 
    273                            
     344                        if ( !defined( "PATH_SEPARATOR" ) ) { 
     345 
     346                                //if we cannot determin the OS, we will assume its unix 
     347                                if(!isset($_ENV["OS"])) 
     348                                        $_ENV["OS"] = "unix"; 
     349 
     350                                if ( strpos( $_ENV["OS"], "Win" ) !== false ) 
     351                                        define( "PATH_SEPARATOR", ";" ); 
     352                                else 
     353                                        define( "PATH_SEPARATOR", ":" ); 
     354 
    274355                        }//end if 
    275356 
    276                         $pathToAdd=@ getcwd(); 
    277                         ini_set("include_path",ini_get("include_path").PATH_SEPARATOR.$pathToAdd); 
    278                          
    279                         //Now to set the path 
    280                         $pathrev = strrev($_SERVER["PHP_SELF"]); 
    281                         $choppos=0; 
    282  
    283                         for($x=0;$x<$count;$x++) 
    284                                 $choppos = strpos($pathrev,"/",$choppos+1); 
    285                         define("APP_PATH",strrev(substr($pathrev,$choppos))); 
    286                          
     357                        $pathToAdd = @ getcwd(); 
     358 
     359                        //Now we include the root application path to php's include path 
     360                        if(ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.$pathToAdd) === false && $reportError) 
     361                                $error = new appError(-310, "Your implementation of PHP does not allow changing of the include path. You may need to modify your PHP settings to allow phpBMS to modify this php ini setting. If you are using a web hosting company, you may need to contact them to allow this.", "Cannot add to include path", true, true, false); 
     362 
     363 
     364                        //return directory to current directory 
    287365                        @ chdir ($currdirectory); 
     366 
    288367                        return $path; 
     368 
    289369                } else { 
     370 
    290371                        if($reportError) 
    291                                 $error= new appError(-300,"You may need to run the install process, or set the permission on your settings file correctly.","Settings File Could Not Be Read",true,true,false); 
     372                                $error = new appError(-300,"","",true,true,false); 
     373 
    292374                        return false; 
    293                 } 
     375 
     376                }//endif settingsfile 
     377 
    294378        }//end function 
    295          
     379 
     380 
    296381        function loadSettings($encoding = "utf8"){ 
    297                 // We are going to make sure that we are using utf8  
     382 
     383                // We are going to make sure that we are using utf8 
    298384                // but it works only in mySQL 5, so we supress errors 
    299385                // when trying it. 
    300386                if($this->db==NULL) 
    301387                        $error=new appError(-310,"","Database not loaded"); 
    302                  
     388 
    303389                $this->db->logError = false; 
    304390                $this->db->stopOnError = false; 
    305          
     391 
    306392                $this->db->setEncoding($encoding); 
    307          
     393 
    308394                $this->db->logError = true; 
    309          
     395 
    310396                $querystatement = "SELECT name,value FROM settings"; 
    311397 
     
    313399 
    314400                if(!$queryresult){ 
     401 
    315402                        $error= new appError(-310,"If you have not ran the update script for phpBMS, please run it before logging in.","Could Not Retrieve Settings From Database"); 
    316403                        return false; 
     404 
    317405                } else { 
     406 
    318407                        while($therecord=$this->db->fetchArray($queryresult)){ 
    319                          
     408 
    320409                                //old versions used a reserved constant in certain php versions 
    321410                                if($therecord["name"] == "currency_symbol") 
    322411                                        $therecord["name"] = "currency_sym"; 
    323                                          
     412 
    324413                                if(!defined(strtoupper($therecord["name"]))) 
    325414                                        define(strtoupper($therecord["name"]),$therecord["value"]); 
     
    330419                        if(!isset($_SERVER['REQUEST_URI'])) { 
    331420                                $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; 
    332                                  
     421 
    333422                                if(!defined("HOUR_FORMAT")) 
    334423                                        define("HOUR_FORMAT","%I"); 
    335                          
     424 
    336425                                // Append the query string if it exists and isn't null 
    337426                                if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) 
     
    342431 
    343432                        return true; 
    344                 } 
    345         } 
    346  
    347  
     433 
     434                }//endif queryresult 
     435 
     436        }//end function 
     437 
     438 
     439        // This is in a function in case we want to do sessions differently in the future 
    348440        function startSession(){ 
    349                 // This is in a function in case we want to do sessions differently in the future                
    350                  
     441 
    351442                session_name("phpBMS".preg_replace('/\W/',"",APPLICATION_NAME)."v096ID"); 
    352443                session_start(); 
    353         } 
    354  
    355  
    356         function verifyAPIlogin($user,$pass){ 
    357                 $thereturn=false; 
     444 
     445        }//end function startSesion 
     446 
     447 
     448        function verifyAPIlogin($user, $pass){ 
     449 
     450                $thereturn = false; 
    358451                $this->db->stopOnError = false; 
    359                  
    360                 $querystatement = "SELECT id, firstname, lastname, email, phone, department, employeenumber, admin 
    361                                                 FROM users  
    362                                                 WHERE login!=\"Scheduler\" AND login=\"".mysql_real_escape_string($user)."\"  
    363                                                 AND password=ENCODE(\"".mysql_real_escape_string($pass)."\",\"".mysql_real_escape_string(ENCRYPTION_SEED)."\")  
    364                                                 AND revoked=0 AND portalaccess=1"; 
     452 
     453                $querystatement = " 
     454                        SELECT 
     455                                id, 
     456                                firstname, 
     457                                lastname, 
     458                                email, 
     459                                phone, 
     460                                department, 
     461                                employeenumber, 
     462                                admin 
     463                        FROM 
     464                                users 
     465                        WHERE 
     466                                login != 'Scheduler' 
     467                                AND login = '".mysql_real_escape_string($user)."' 
     468                                AND password = ENCODE('".mysql_real_escape_string($pass)."', '".mysql_real_escape_string(ENCRYPTION_SEED)."') 
     469                                AND revoked = 0 
     470                                AND portalaccess = 1"; 
     471 
    365472                $queryresult = $this->db->query($querystatement); 
     473 
    366474                if(!$queryresult) { 
     475 
    367476                        $error = new appError(-720,"","Error retrieving user record",true,true,true,"json"); 
    368477                        return false; 
    369                 } 
    370                  
     478 
     479                }//endif 
     480 
    371481                if($this->db->numRows($queryresult)){ 
     482 
    372483                        //We found a record that matches in the database 
    373484                        // populate the session and go in 
    374                         $_SESSION["userinfo"]=$this->db->fetchArray($queryresult); 
    375                  
    376                         $querystatement="UPDATE users SET modifieddate=modifieddate, lastlogin=Now() WHERE id = ".$_SESSION["userinfo"]["id"]; 
    377                         $queryresult=@ $this->db->query($querystatement); 
    378                         if(!$queryresult) { 
     485                        $_SESSION["userinfo"] = $this->db->fetchArray($queryresult); 
     486 
     487                        $querystatement = " 
     488                                UPDATE 
     489                                        users 
     490                                SET 
     491                                        modifieddate=modifieddate, 
     492                                        lastlogin=Now() 
     493                                WHERE 
     494                                        id = ".$_SESSION["userinfo"]["id"]; 
     495 
     496                        $queryresult = @ $this->db->query($querystatement); 
     497 
     498                        if(!$queryresult) 
    379499                                $error = new appError(-730,"","Error Updating User Login Time",true,true,true,"json"); 
    380                         } else 
    381                                 $thereturn=true; 
    382                 } 
    383                 return $thereturn;       
    384         } 
    385          
    386 }//end loginSession class 
    387  
    388  
    389 // Start Code 
    390 //================================================================================================================= 
    391 //php <4.3.0 compatibility 
    392 if(!function_exists("mysql_real_escape_string")){ 
    393         function mysql_real_escape_string($string){ 
    394                 return mysql_escape_string($string); 
    395         } 
    396          
    397    function utf8_replaceEntity($result){ 
    398            $value = (int)$result[1]; 
    399            $string = ''; 
    400            
    401            $len = round(pow($value,1/8)); 
    402            
    403            for($i=$len;$i>0;$i--){ 
    404                    $part = ($value & (255>>2)) | pow(2,7); 
    405                    if ( $i == 1 ) $part |= 255<<(8-$len); 
    406                    
    407                    $string = chr($part) . $string; 
    408                    
    409                    $value >>= 6; 
    410            } 
    411            
    412            return $string; 
    413    } 
    414    
    415         if(!function_exists("mysql_real_escape_string")){ 
    416                 function html_entity_decode($string){ 
    417                         return preg_replace_callback('/&#([0-9]+);/u','utf8_replaceEntity',$string); 
    418                 }//end function 
    419         }//end if 
    420  
    421 }// end PHP<4.3 compatibility 
     500                        else 
     501                                $thereturn = true; 
     502 
     503                }//endif numrows 
     504 
     505                return $thereturn; 
     506 
     507        }//end function verifyAPIlogin 
     508 
     509 
     510        //Check to see if install folders are present.  If so, do not continue. 
     511        function checkForInstallDirs($errorFormat = "xhtml"){ 
     512 
     513                //first lets check for the main programs install folder 
     514                if(file_exists("install") && is_dir("install")) 
     515                        $error = new appError(-353,"You must remove the install directory and all modules' install directories before phpBMS can run.","Main Install Directory Present",true,true,true,$errorFormat); 
     516 
     517                $thedir= @ opendir("modules"); 
     518 
     519                while($entry = readdir($thedir)){ 
     520 
     521                        if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("modules/".$entry)){ 
     522 
     523                                if(file_exists("modules/".$entry."/install") && is_dir("modules/".$entry."/install")){ 
     524 
     525                                        $error = new appError(-354,"You must remove the install directory and all modules' install directories before phpBMS can run.","Module '".$entry."' Install Directory Present",true,true,true,$errorFormat); 
     526 
     527                                }//endif 
     528 
     529                        }//endif 
     530 
     531                }//end if 
     532 
     533        }//end function checkForInstallDirs 
     534 
     535}//end phpbmsSession class 
     536 
    422537 
    423538 
    424539// Start Login verification Code 
    425 //================================================================================================================= 
     540//============================================================================== 
    426541if(!isset($sqlEncoding)) 
    427542        $sqlEncoding = "utf8"; 
    428543 
    429544if(!defined("noStartup")){ 
     545 
    430546        $scriptname = basename($_SERVER["PHP_SELF"]); 
    431547        $phpbmsSession = new phpbmsSession; 
    432          
     548 
    433549        //Testing for API login 
    434550        if(strpos($scriptname,"api_")!==false){ 
    435551                if(isset($_POST["phpbmsusername"]) && isset($_POST["phpbmspassword"])){ 
     552 
    436553                        $phpbmsSession->loadDBSettings(APP_DEBUG); 
    437                          
     554 
     555                        if(!APP_DEBUG) 
     556                                $phpbmsSession->checkForInstallDirs("json"); 
     557 
    438558                        include_once("include/db.php"); 
    439559                        $db = new db(); 
    440560                        $phpbmsSession->db = $db; 
    441561 
    442                         include_once("common_functions.php");                    
     562                        include_once("common_functions.php"); 
    443563                        $phpbmsSession->loadSettings($sqlEncoding); 
    444564                        $phpbms = new phpbms($db); 
    445          
    446          
     565 
     566 
    447567                        if(!$phpbmsSession->verifyAPILogin($_POST["phpbmsusername"],$_POST["phpbmspassword"])) 
    448568                                $error = new appError(-700,"","Login credentials incorrect",true,true,true,"json"); 
     569 
    449570                } else 
    450571                        $error= new appError(-710,"","No login credentials passed",true,true,true,"json"); 
     572 
    451573        } else { 
    452          
     574 
    453575                $phpbmsSession->loadDBSettings(APP_DEBUG); 
    454          
    455          
     576 
     577                if(!APP_DEBUG) 
     578                        $phpbmsSession->checkForInstallDirs(); 
     579 
     580                //start database 
    456581                include_once("include/db.php"); 
    457582                $db = new db(); 
    458                  
     583 
    459584                $phpbmsSession->db = $db; 
    460                  
     585 
     586                //load application settings from table 
    461587                $phpbmsSession->loadSettings($sqlEncoding); 
    462                  
     588 
    463589                include_once("common_functions.php"); 
    464590                $phpbms = new phpbms($db); 
    465                  
     591 
    466592                if(!isset($noSession)) 
    467593                        $phpbmsSession->startSession(); 
    468                  
     594 
    469595                if (!isset($_SESSION["userinfo"]) && $scriptname != "index.php") { 
    470                  
     596 
    471597                        if(isset($loginNoKick)){ 
     598 
    472599                                if(!isset($loginNoDisplayError)) 
    473600                                        exit(); 
     601 
    474602                        } else{ 
     603 
    475604                                goURL(APP_PATH."index.php"); 
    476                         } 
    477                 } 
    478                  
    479         } 
    480          
    481         $db->stopOnError=true; 
     605 
     606                        }//endif 
     607 
     608                }//endif iseet userinfo 
     609 
     610        }//endif 
     611 
     612        $db->stopOnError = true; 
     613 
    482614}//end if 
    483615 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.