From: <rc...@us...> - 2017-01-05 18:23:33
|
Revision: 7717 http://sourceforge.net/p/web-erp/reponame/7717 Author: rchacon Date: 2017-01-05 18:23:30 +0000 (Thu, 05 Jan 2017) Log Message: ----------- For strict Standards, removes the "&" before the variable in DB_fetch_row() and in DB_fetch_array() in ConnectDB_XXX.inc. Thanks Tim. Modified Paths: -------------- trunk/doc/Change.log trunk/includes/ConnectDB_mysql.inc trunk/includes/ConnectDB_mysqli.inc trunk/includes/ConnectDB_postgres.inc Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2017-01-05 00:11:17 UTC (rev 7716) +++ trunk/doc/Change.log 2017-01-05 18:23:30 UTC (rev 7717) @@ -1,5 +1,6 @@ webERP Change Log +05/01/17 RChacon: For strict Standards, removes the "&" before the variable in DB_fetch_row() and in DB_fetch_array() in ConnectDB_XXX.inc. Thanks Tim. 21/12/16 RChacon: In PurchasesReport.php, fix date comparison and title. Thanks Tim. 20/12/16 RChacon: Standardise to "Print" button. 20/12/16 RChacon: Add a report of purchases from suppliers for the range of selected dates. Modified: trunk/includes/ConnectDB_mysql.inc =================================================================== --- trunk/includes/ConnectDB_mysql.inc 2017-01-05 00:11:17 UTC (rev 7716) +++ trunk/includes/ConnectDB_mysql.inc 2017-01-05 18:23:30 UTC (rev 7717) @@ -2,58 +2,58 @@ /* $Id$ */ /* Database abstraction for mysql */ -define ('LIKE','LIKE'); +define('LIKE', 'LIKE'); -global $db; // Make sure it IS global, regardless of our context -if (!isset($mysqlport)){ +global $db;// Make sure it IS global, regardless of our context +if(!isset($mysqlport)) { $mysqlport = 3306; } -$db = mysql_connect($host.':'.$mysqlport , $DBUser, $DBPassword); +$db = mysql_connect($host . ':' . $mysqlport, $DBUser, $DBPassword); //this statement sets the charset to be used for sending data to and from the db server //if not set, both mysql server and mysql client/library may assume otherwise mysql_set_charset('utf8', $db); -//$varabc = mysql_client_encoding($db); +//$varabc = mysql_client_encoding($db); //printf("client encoding is %s\n", $varabc); -if ( !$db ) { +if(!$db) { echo '<br />' . _('The configuration in the file config.php for the database user name and password do not provide the information required to connect to the database server'); session_unset(); session_destroy(); - echo '<p>' . _('Click') . ' ' . '<a href="index.php">' . _('here') . '</a>' . ' ' ._('to try logging in again') . '</p>'; + echo '<p>' . _('Click') . ' ' . '<a href="index.php">' . _('here') . '</a>' . ' ' ._('to try logging in again') . '</p>'; exit; } /* Update to allow RecurringSalesOrdersProcess.php to run via cron */ -if (isset($DatabaseName)) { +if(isset($DatabaseName)) { - if (! mysql_select_db($_SESSION['DatabaseName'],$db)) { + if(! mysql_select_db($_SESSION['DatabaseName'],$db)) { echo '<br />' . _('The company name entered does not correspond to a database on the database server specified in the config.php configuration file. Try logging in with a different company name'); echo '<br /><a href="index.php">' . _('Back to login page') . '</A>'; - unset ($_SESSION['DatabaseName']); + unset($_SESSION['DatabaseName']); exit; } } else { - if (! mysql_select_db($_SESSION['DatabaseName'],$db)) { + if(! mysql_select_db($_SESSION['DatabaseName'],$db)) { echo '<br />' . _('The company name entered does not correspond to a database on the database server specified in the config.php configuration file. Try logging in with a different company name'); echo '<br /><a href="index.php">' . _('Back to login page') . '</A>'; - unset ($_SESSION['DatabaseName']); + unset($_SESSION['DatabaseName']); exit; } } -require_once ($PathPrefix .'includes/MiscFunctions.php'); +require_once($PathPrefix . 'includes/MiscFunctions.php'); //DB wrapper functions to change only once for whole application -function DB_query ($SQL, +function DB_query($SQL, $ErrorMessage='', $DebugMessage= '', $Transaction=false, - $TrapErrors=true){ + $TrapErrors=true) { global $debug; global $PathPrefix; @@ -62,38 +62,38 @@ $result=mysql_query($SQL,$db); $_SESSION['LastInsertId'] = mysql_insert_id($db); - if ($DebugMessage == '') { + if($DebugMessage == '') { $DebugMessage = _('The SQL that failed was'); } - if (DB_error_no() != 0 AND $TrapErrors==true){ - if ($TrapErrors){ + if(DB_error_no() != 0 AND $TrapErrors==true) { + if($TrapErrors) { require_once($PathPrefix . 'includes/header.inc'); } - prnMsg($ErrorMessage . '<br />' . DB_error_msg(),'error', _('Database Error')); - if ($debug==1){ - prnMsg($DebugMessage. '<br />' . $SQL . '<br />','error',_('Database SQL Failure')); + prnMsg($ErrorMessage . '<br />' . DB_error_msg(), 'error', _('Database Error')); + if($debug == 1) { + prnMsg($DebugMessage . '<br />' . $SQL . '<br />', 'error', _('Database SQL Failure')); } - if ($Transaction){ + if($Transaction) { $SQL = 'rollback'; $Result = DB_query($SQL); - if (DB_error_no() !=0){ + if(DB_error_no() != 0) { prnMsg(_('Error Rolling Back Transaction'), '', _('Database Rollback Error') ); } } - if ($TrapErrors){ + if($TrapErrors) { include($PathPrefix . 'includes/footer.inc'); exit; } - } elseif (isset($_SESSION['MonthsAuditTrail']) and (DB_error_no()==0 AND $_SESSION['MonthsAuditTrail']>0)){ + } elseif(isset($_SESSION['MonthsAuditTrail']) and (DB_error_no()==0 AND $_SESSION['MonthsAuditTrail']>0)) { $SQLArray = explode(' ', $SQL); - if (($SQLArray[0] == 'INSERT') + if(($SQLArray[0] == 'INSERT') OR ($SQLArray[0] == 'UPDATE') OR ($SQLArray[0] == 'DELETE')) { - if ($SQLArray[2]!='audittrail'){ // to ensure the auto delete of audit trail history is not logged + if($SQLArray[2] != 'audittrail') { // to ensure the auto delete of audit trail history is not logged $AuditSQL = "INSERT INTO audittrail (transactiondate, userid, querystring) @@ -110,50 +110,48 @@ } -function DB_fetch_row (&$ResultIndex) { - - $RowPointer=mysql_fetch_row($ResultIndex); +function DB_fetch_row($ResultIndex) { + $RowPointer = mysql_fetch_row($ResultIndex); Return $RowPointer; } -function DB_fetch_assoc (&$ResultIndex) { - - $RowPointer=mysql_fetch_assoc($ResultIndex); +function DB_fetch_assoc(&$ResultIndex) { + $RowPointer = mysql_fetch_assoc($ResultIndex); Return $RowPointer; } -function DB_fetch_array(&$ResultIndex) { +function DB_fetch_array($ResultIndex) { $RowPointer = mysql_fetch_array($ResultIndex); Return $RowPointer; } -function DB_data_seek (&$ResultIndex,$Record) { +function DB_data_seek(&$ResultIndex,$Record) { mysql_data_seek($ResultIndex,$Record); } -function DB_free_result (&$ResultIndex){ +function DB_free_result(&$ResultIndex) { mysql_free_result($ResultIndex); } -function DB_num_rows (&$ResultIndex){ +function DB_num_rows(&$ResultIndex) { return mysql_num_rows($ResultIndex); } -function DB_affected_rows(&$ResultIndex){ +function DB_affected_rows(&$ResultIndex) { return mysql_affected_rows($ResultIndex); } -function DB_error_no(){ +function DB_error_no() { global $db; return mysql_errno($db); } -function DB_error_msg(){ +function DB_error_msg() { global $db; return mysql_error($db); } -function DB_Last_Insert_ID(&$Conn='',$table, $fieldname){ +function DB_Last_Insert_ID(&$Conn='',$table, $fieldname) { // return mysql_insert_id($db); if (isset($_SESSION['LastInsertId'])) { $Last_Insert_ID = $_SESSION['LastInsertId']; @@ -164,30 +162,29 @@ return $Last_Insert_ID; } -function DB_escape_string($String){ +function DB_escape_string($String) { return mysql_real_escape_string($String); } -function DB_show_tables(&$Conn=''){ +function DB_show_tables(&$Conn='') { $Result = DB_query('SHOW TABLES'); Return $Result; } -function DB_show_fields($TableName, &$Conn=''){ +function DB_show_fields($TableName, &$Conn='') { $Result = DB_query("DESCRIBE $TableName"); Return $Result; } -function interval( $val, $Inter ){ +function interval( $val, $Inter ) { global $DBType; return "\n".'interval ' . $val . ' '. $Inter."\n"; } -function DB_Maintenance(){ - +function DB_Maintenance() { prnMsg(_('The system has just run the regular database administration and optimisation routine.'),'info'); $TablesResult = DB_query('SHOW TABLES'); - while ($myrow = DB_fetch_row($TablesResult)){ + while ($myrow = DB_fetch_row($TablesResult)) { $Result = DB_query('OPTIMIZE TABLE ' . $myrow[0]); } @@ -196,31 +193,31 @@ WHERE confname='DB_Maintenance_LastRun'"); } - -function DB_Txn_Begin(){ +function DB_Txn_Begin() { global $db; mysql_query("SET autocommit=0",$db); mysql_query("START TRANSACTION",$db); } -function DB_Txn_Commit(){ +function DB_Txn_Commit() { global $db; mysql_query("COMMIT",$db); mysql_query("SET autocommit=1",$db); } -function DB_Txn_Rollback(){ +function DB_Txn_Rollback() { global $db; - mysql_query("ROLLBACK",$db); + mysql_query("ROLLBACK",$db); } -function DB_IgnoreForeignKeys(){ +function DB_IgnoreForeignKeys() { global $db; mysql_query("SET FOREIGN_KEY_CHECKS=0",$db); } -function DB_ReinstateForeignKeys(){ + +function DB_ReinstateForeignKeys() { global $db; mysql_query("SET FOREIGN_KEY_CHECKS=1",$db); } -?> \ No newline at end of file +?> Modified: trunk/includes/ConnectDB_mysqli.inc =================================================================== --- trunk/includes/ConnectDB_mysqli.inc 2017-01-05 00:11:17 UTC (rev 7716) +++ trunk/includes/ConnectDB_mysqli.inc 2017-01-05 18:23:30 UTC (rev 7717) @@ -7,9 +7,9 @@ 20071102 Add $db to DB_escape_string(); */ -define ('LIKE','LIKE'); +define ('LIKE', 'LIKE'); -if (!isset($mysqlport)){ +if(!isset($mysqlport)) { $mysqlport = 3306; } global $db; // Make sure it IS global, regardless of our context @@ -23,7 +23,7 @@ mysqli_set_charset($db, 'utf8'); /* check connection */ -if (mysqli_connect_errno()) { +if(mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); session_unset(); session_destroy(); @@ -31,21 +31,21 @@ exit(); } -if ( !$db ) { +if(!$db) { echo '<br />' . _('The configuration in the file config.php for the database user name and password do not provide the information required to connect to the database server'); exit; } /* Update to allow RecurringSalesOrdersProcess.php to run via cron */ -if (isset($DatabaseName)) { - if (!mysqli_select_db($db,$DatabaseName)) { +if(isset($DatabaseName)) { + if(!mysqli_select_db($db,$DatabaseName)) { echo '<br />' . _('The company name entered does not correspond to a database on the database server specified in the config.php configuration file. Try logging in with a different company name'); echo '<br /><a href="index.php">' . _('Back to login page') . '</A>'; unset ($DatabaseName); exit; } } else { - if (!mysqli_select_db($db,$_SESSION['DatabaseName'])) { + if(!mysqli_select_db($db,$_SESSION['DatabaseName'])) { echo '<br />' . _('The company name entered does not correspond to a database on the database server specified in the config.php configuration file. Try logging in with a different company name'); echo '<br /><a href="index.php">' . _('Back to login page') . '</A>'; @@ -56,11 +56,11 @@ //DB wrapper functions to change only once for whole application -function DB_query ($SQL, +function DB_query($SQL, $ErrorMessage='', $DebugMessage= '', $Transaction=false, - $TrapErrors=true){ + $TrapErrors=true) { global $debug; global $PathPrefix; @@ -70,40 +70,40 @@ $_SESSION['LastInsertId'] = mysqli_insert_id($db); - if ($DebugMessage == '') { + if($DebugMessage == '') { $DebugMessage = _('The SQL that failed was'); } - if (DB_error_no() != 0 AND $TrapErrors==true){ - if ($TrapErrors){ + if(DB_error_no() != 0 AND $TrapErrors==true) { + if($TrapErrors) { require_once($PathPrefix . 'includes/header.inc'); } prnMsg($ErrorMessage . '<br />' . DB_error_msg(),'error', _('Database Error'). ' ' .DB_error_no()); - if ($debug==1){ + if($debug==1) { prnMsg($DebugMessage. '<br />' . $SQL . '<br />','error',_('Database SQL Failure')); } - if ($Transaction){ + if($Transaction) { $SQL = 'rollback'; $Result = DB_query($SQL); - if (DB_error_no() !=0){ + if(DB_error_no() != 0) { prnMsg(_('Error Rolling Back Transaction'), 'error', _('Database Rollback Error'). ' ' .DB_error_no() ); }else{ prnMsg(_('Rolling Back Transaction OK'), 'error', _('Database Rollback Due to Error Above')); } } - if ($TrapErrors){ + if($TrapErrors) { include($PathPrefix . 'includes/footer.inc'); exit; } - } elseif (isset($_SESSION['MonthsAuditTrail']) and (DB_error_no()==0 AND $_SESSION['MonthsAuditTrail']>0) AND (DB_affected_rows($result)>0)){ + } elseif(isset($_SESSION['MonthsAuditTrail']) and (DB_error_no()==0 AND $_SESSION['MonthsAuditTrail']>0) AND (DB_affected_rows($result)>0)) { $SQLArray = explode(' ', $SQL); - if (($SQLArray[0] == 'INSERT') + if(($SQLArray[0] == 'INSERT') OR ($SQLArray[0] == 'UPDATE') OR ($SQLArray[0] == 'DELETE')) { - if ($SQLArray[2]!='audittrail'){ // to ensure the auto delete of audit trail history is not logged + if($SQLArray[2] != 'audittrail') { // to ensure the auto delete of audit trail history is not logged $AuditSQL = "INSERT INTO audittrail (transactiondate, userid, querystring) @@ -116,57 +116,56 @@ } } return $result; - } -function DB_fetch_row (&$ResultIndex) { +function DB_fetch_row($ResultIndex) { $RowPointer=mysqli_fetch_row($ResultIndex); Return $RowPointer; } -function DB_fetch_assoc (&$ResultIndex) { +function DB_fetch_assoc(&$ResultIndex) { $RowPointer=mysqli_fetch_assoc($ResultIndex); Return $RowPointer; } -function DB_fetch_array(&$ResultIndex) { +function DB_fetch_array($ResultIndex) { $RowPointer = mysqli_fetch_array($ResultIndex); Return $RowPointer; } -function DB_data_seek (&$ResultIndex,$Record) { +function DB_data_seek(&$ResultIndex,$Record) { mysqli_data_seek($ResultIndex,$Record); } -function DB_free_result (&$ResultIndex){ - if (is_resource($ResultIndex)) { +function DB_free_result(&$ResultIndex) { + if(is_resource($ResultIndex)) { mysqli_free_result($ResultIndex); } } -function DB_num_rows (&$ResultIndex){ +function DB_num_rows(&$ResultIndex) { return mysqli_num_rows($ResultIndex); } -function DB_affected_rows(&$ResultIndex){ +function DB_affected_rows(&$ResultIndex) { global $db; return mysqli_affected_rows($db); } -function DB_error_no(){ +function DB_error_no() { global $db; return mysqli_errno($db); } -function DB_error_msg(){ +function DB_error_msg() { global $db; return mysqli_error($db); } -function DB_Last_Insert_ID($Conn='', $Table, $FieldName){ +function DB_Last_Insert_ID($Conn='', $Table, $FieldName) { // return mysqli_insert_id($Conn); - if (isset($_SESSION['LastInsertId'])) { + if(isset($_SESSION['LastInsertId'])) { $Last_Insert_ID = $_SESSION['LastInsertId']; } else { $Last_Insert_ID = 0; @@ -175,33 +174,32 @@ return $Last_Insert_ID; } -function DB_escape_string($String){ +function DB_escape_string($String) { global $db; return mysqli_real_escape_string($db, $String); } -function DB_show_tables($Conn=''){ +function DB_show_tables($Conn='') { global $db; $Result = DB_query('SHOW TABLES'); Return $Result; } -function DB_show_fields($TableName, $Conn=''){ +function DB_show_fields($TableName, $Conn='') { $Result = DB_query("DESCRIBE $TableName"); Return $Result; } -function interval( $val, $Inter ){ +function interval($val, $Inter) { global $dbtype; - return "\n".'interval ' . $val . ' '. $Inter."\n"; + return "\n".'interval ' . $val . ' ' . $Inter . "\n"; } -function DB_Maintenance(){ - +function DB_Maintenance() { prnMsg(_('The system has just run the regular database administration and optimisation routine.'),'info'); $TablesResult = DB_query("SHOW TABLES"); - while ($myrow = DB_fetch_row($TablesResult)){ + while ($myrow = DB_fetch_row($TablesResult)) { $Result = DB_query('OPTIMIZE TABLE ' . $myrow[0]); } @@ -210,28 +208,30 @@ WHERE confname='DB_Maintenance_LastRun'"); } -function DB_Txn_Begin(){ +function DB_Txn_Begin() { global $db; mysqli_query($db,'SET autocommit=0'); mysqli_query($db,'START TRANSACTION'); } -function DB_Txn_Commit(){ +function DB_Txn_Commit() { global $db; mysqli_query($db,'COMMIT'); mysqli_query($db,'SET autocommit=1'); } -function DB_Txn_Rollback(){ +function DB_Txn_Rollback() { global $db; mysqli_query($db,'ROLLBACK'); } -function DB_IgnoreForeignKeys(){ + +function DB_IgnoreForeignKeys() { global $db; mysqli_query($db,'SET FOREIGN_KEY_CHECKS=0'); } -function DB_ReinstateForeignKeys(){ + +function DB_ReinstateForeignKeys() { global $db; mysqli_query($db, 'SET FOREIGN_KEY_CHECKS=1'); } -?> \ No newline at end of file +?> Modified: trunk/includes/ConnectDB_postgres.inc =================================================================== --- trunk/includes/ConnectDB_postgres.inc 2017-01-05 00:11:17 UTC (rev 7716) +++ trunk/includes/ConnectDB_postgres.inc 2017-01-05 18:23:30 UTC (rev 7717) @@ -6,14 +6,14 @@ /* $PgConnStr = $PgConnStr = "host=".$host." dbname=".$_SESSION['DatabaseName']; */ $PgConnStr = 'dbname='.$_SESSION['DatabaseName']; -if ( isset($host) && ($host != "")) { +if( isset($host) && ($host != "")) { $PgConnStr = 'host='.$host.' '.$PgConnStr; } -if ( isset( $DBUser ) && ($DBUser != "") ) { +if( isset( $DBUser ) && ($DBUser != "") ) { // if we have a user we need to use password if supplied $PgConnStr .= " user=".$DBUser; - if ( isset( $DBPassword ) && ($DBPassword != "") ) { + if( isset( $DBPassword ) && ($DBPassword != "") ) { $PgConnStr .= " password=".$DBPassword; } } @@ -21,8 +21,8 @@ global $db; // Make sure it IS global, regardless of our context $db = pg_connect( $PgConnStr ); -if ( !$db ) { - if ($debug==1){ +if( !$db ) { + if($debug==1) { echo '<BR>' . $PgConnStr . '<BR>'; } echo '<BR>' . _('The company name entered together with the configuration in the file config.php for the database user name and password do not provide the information required to connect to the database.') . '<BR><BR>' . _(' Try logging in with an alternative company name.'); @@ -39,32 +39,32 @@ $ErrorMessage='', $DebugMessage= '', $Transaction=false, - $TrapErrors=true){ + $TrapErrors=true) { global $debug; global $PathPrefix; $result = pg_query($db, $SQL); - if ($DebugMessage == '') { + if($DebugMessage == '') { $DebugMessage = _('The SQL that failed was:'); } - //if (DB_error_no($Conn) != 0){ - if ( !$result AND $TrapErrors){ - if ($TrapErrors){ + //if(DB_error_no($Conn) != 0) { + if( !$result AND $TrapErrors) { + if($TrapErrors) { require_once($PathPrefix . 'includes/header.inc'); } prnMsg($ErrorMessage . '<BR>' . DB_error_msg(),'error', _('DB ERROR:')); - if ($debug==1){ + if($debug==1) { echo '<BR>' . $DebugMessage. "<BR>$SQL<BR>"; } - if ($Transaction){ + if($Transaction) { $SQL = 'rollback'; $Result = DB_query($SQL); - if (DB_error_no($Conn) !=0){ + if(DB_error_no($Conn) !=0) { prnMsg('<br />' . _('Error Rolling Back Transaction!!'), '', _('DB DEBUG:') ); } } - if ($TrapErrors){ + if($TrapErrors) { include($PathPrefix . 'includes/footer.inc'); exit; } @@ -73,43 +73,42 @@ } -function DB_fetch_row (&$ResultIndex) { +function DB_fetch_row($ResultIndex) { $RowPointer=pg_fetch_row($ResultIndex); Return $RowPointer; } -function DB_fetch_assoc (&$ResultIndex) { - +function DB_fetch_assoc(&$ResultIndex) { $RowPointer=pg_fetch_assoc($ResultIndex); Return $RowPointer; } -function DB_fetch_array(&$ResultIndex) { +function DB_fetch_array($ResultIndex) { $RowPointer = pg_fetch_array($ResultIndex); Return $RowPointer; } -function DB_data_seek (&$ResultIndex,$Record) { +function DB_data_seek(&$ResultIndex,$Record) { pg_result_seek($ResultIndex,$Record); } -function DB_free_result (&$ResultIndex){ +function DB_free_result(&$ResultIndex) { pg_free_result($ResultIndex); } -function DB_num_rows (&$ResultIndex){ +function DB_num_rows(&$ResultIndex) { return pg_num_rows($ResultIndex); } // Added by MGT -function DB_affected_rows (&$ResultIndex){ +function DB_affected_rows(&$ResultIndex) { return pg_affected_rows($ResultIndex); } -function DB_error_no(){ +function DB_error_no() { return DB_error_msg() == ""?0:-1; } -function DB_error_msg(){ +function DB_error_msg() { return pg_last_error($db); } @@ -120,7 +119,7 @@ return $Res; } -function DB_escape_string($String){ +function DB_escape_string($String) { Return pg_escape_string(htmlspecialchars($String, ENT_COMPAT, 'ISO-8859-1')); } @@ -128,18 +127,18 @@ global $dbtype; return "\n(CAST( (" . $val . ") as text ) || ' ". $Inter ."')::interval\n"; } -function DB_show_tables (&$Conn){ +function DB_show_tables(&$Conn) { $Result =DB_query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"); Return $Result; } -function DB_show_fields($TableName,&$Conn){ +function DB_show_fields($TableName,&$Conn) { $Result = DB_query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name='" . $TableName . "'"); - if (DB_num_rows($Result)==1){ + if(DB_num_rows($Result)==1) { $Result = DB_query("SELECT column_name FROM information_schema.columns WHERE table_name ='$TableName'"); Return $Result; } } -function DB_Maintenance(){ +function DB_Maintenance() { prnMsg(_('The system has just run the regular database administration and optimisation routine'),'info'); @@ -150,4 +149,4 @@ WHERE confname='DB_Maintenance_LastRun'"); } -?> \ No newline at end of file +?> |