From: <tim...@us...> - 2010-12-27 11:34:05
|
Revision: 4453 http://web-erp.svn.sourceforge.net/web-erp/?rev=4453&view=rev Author: tim_schofield Date: 2010-12-27 11:33:59 +0000 (Mon, 27 Dec 2010) Log Message: ----------- Re-apply code wrongly removed, to make the databse upgrade system work properly. Please leave unless you have something better. Modified Paths: -------------- trunk/UpgradeDatabase.php trunk/includes/GetConfig.php trunk/includes/UserLogin.php Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2010-12-27 07:30:17 UTC (rev 4452) +++ trunk/UpgradeDatabase.php 2010-12-27 11:33:59 UTC (rev 4453) @@ -1,6 +1,6 @@ <?php -//$PageSecurity = 15; +$PageSecurity = 15; include('includes/session.inc'); Modified: trunk/includes/GetConfig.php =================================================================== --- trunk/includes/GetConfig.php 2010-12-27 07:30:17 UTC (rev 4452) +++ trunk/includes/GetConfig.php 2010-12-27 11:33:59 UTC (rev 4453) @@ -5,7 +5,7 @@ if(isset($ForceConfigReload) and $ForceConfigReload==TRUE OR !isset($_SESSION['CompanyDefaultsLoaded'])) { global $db; // It is global, we may not be. - $sql = 'SELECT confname, confvalue FROM config'; + $sql = 'SELECT confname, confvalue FROM config'; $ErrMsg = _('Could not get the configuration parameters from the database because'); $ConfigResult = DB_query($sql,$db,$ErrMsg); while( $myrow = DB_fetch_row($ConfigResult) ) { @@ -21,7 +21,7 @@ $_SESSION['DBUpdateNumber']=-1; header('Location: UpgradeDatabase.php'); //divert to the db upgrade if the DBUpdateNumber is not in the config table } - + DB_free_result($ConfigResult); // no longer needed /*Maybe we should check config directories exist and try to create if not */ @@ -32,14 +32,21 @@ $sql='SELECT script, security FROM pagesecurity'; $ErrMsg = _('Could not get the page security details from the database because'); $result=DB_query($sql, $db); - } else if (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php') { + } else if (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php') { header('Location: UpgradeDatabase.php'); //divert to upgrade database if the pagesecurity table does not exist } while ($myrow=DB_fetch_array($result)) { $_SESSION[$myrow['script']]=$myrow['security']; } - + $sql="SELECT confvalue FROM config WHERE confname='DBUpdateNumber'"; + $result=DB_query($sql, $db); + if (DB_num_rows($result)==0) { + $_SESSION['DBUpdateNumber']=-1; + } else { + $myrow=DB_fetch_array($result); + $_SESSION['DBUpdateNumber']=$myrow['confvalue']; + } /* Also reads all the company data set up in the company record and returns an array */ $sql= 'SELECT coyname, @@ -68,7 +75,7 @@ gllink_stock FROM companies WHERE coycode=1'; - + $ErrMsg = _('An error occurred accessing the database to retrieve the company information'); $ReadCoyResult = DB_query($sql,$db,$ErrMsg); @@ -81,26 +88,31 @@ } } //end if force reload or not set already -$sql='SELECT id, - host, - port, - heloaddress, - username, - password, - timeout, - auth - FROM emailsettings'; +$sql="SHOW tables WHERE Tables_in_".$_SESSION['DatabaseName']."='emailsettings'"; $result=DB_query($sql, $db); -$myrow=DB_fetch_array($result); +if (DB_num_rows($result)>0) { + $sql='SELECT id, + host, + port, + heloaddress, + username, + password, + timeout, + auth + FROM emailsettings'; + $result=DB_query($sql, $db); + $myrow=DB_fetch_array($result); -$_SESSION['SMTPSettings']['host']=$myrow['host']; -$_SESSION['SMTPSettings']['port']=$myrow['port']; -$_SESSION['SMTPSettings']['heloaddress']=$myrow['heloaddress']; -$_SESSION['SMTPSettings']['username']=$myrow['username']; -$_SESSION['SMTPSettings']['password']=$myrow['password']; -$_SESSION['SMTPSettings']['timeout']=$myrow['timeout']; -$_SESSION['SMTPSettings']['auth']=$myrow['auth']; - + $_SESSION['SMTPSettings']['host']=$myrow['host']; + $_SESSION['SMTPSettings']['port']=$myrow['port']; + $_SESSION['SMTPSettings']['heloaddress']=$myrow['heloaddress']; + $_SESSION['SMTPSettings']['username']=$myrow['username']; + $_SESSION['SMTPSettings']['password']=$myrow['password']; + $_SESSION['SMTPSettings']['timeout']=$myrow['timeout']; + $_SESSION['SMTPSettings']['auth']=$myrow['auth']; +} else if (basename($_SERVER['SCRIPT_NAME'])!='UpgradeDatabase.php') { + header("Location: UpgradeDatabase.php"); +} /* These variable if required are in config.php Modified: trunk/includes/UserLogin.php =================================================================== --- trunk/includes/UserLogin.php 2010-12-27 07:30:17 UTC (rev 4452) +++ trunk/includes/UserLogin.php 2010-12-27 11:33:59 UTC (rev 4453) @@ -36,21 +36,7 @@ if (!isset($Name) or $Name == '') { return UL_SHOWLOGIN; } - $sql = "SELECT customerid, - lastvisitdate, - pagesize, - defaultlocation, - branchcode, - modulesallowed, - blocked, - realname, - theme, - displayrecordsmax, - userid, - language, - salesman, - pdflanguage, - fullaccess + $sql = "SELECT * FROM www_users WHERE www_users.userid='" . $Name . "' AND (www_users.password='" . CryptPass($Password) . "' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |