changes for mysql 5.7 with strict mode

Dieser Commit ist enthalten in:
Oldperl 2018-02-13 19:45:20 +00:00
Ursprung 2a933cea61
Commit dec7056fca
4 geänderte Dateien mit 230 neuen und 231 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -17,8 +18,7 @@
*
* $Id: class.activeusers.php 362 2015-10-05 16:31:26Z oldperl $;
*/
if(!defined('CON_FRAMEWORK')) {
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
@ -37,16 +37,16 @@ class ActiveUsers {
* @param object $auth
*
* @return
**/
* */
function ActiveUsers($oDb, $oCfg, $oAuth) {
$this->oCfg= $oCfg;
$this->oAuth= $oAuth;
$this->oDb= $oDb;
$this->oCfg = $oCfg;
$this->oAuth = $oAuth;
$this->oDb = $oDb;
// init db object
if (!is_object($this->oDb) || (is_null($this->oDb))) {
$this->oDb= new DB_ConLite;
$this->oDb = new DB_ConLite;
}
if (!is_resource($this->oDb->Link_ID)) {
@ -54,7 +54,7 @@ class ActiveUsers {
}
// Load the userid
$this->iUserId= $this->oAuth->auth["uid"];
$this->iUserId = $this->oAuth->auth["uid"];
}
/**
@ -65,13 +65,13 @@ class ActiveUsers {
*
*
* @return
**/
* */
function startUsersTracking() {
// Delete all Contains in the table "online_user" that is older as timeout(current is 60 minutes)
$this->deleteInactiveUser();
$bResult= $this->findUser($this->iUserId);
$bResult = $this->findUser($this->iUserId);
if ($bResult) {
// update the curent user
$this->updateUser($this->iUserId);
@ -87,11 +87,11 @@ class ActiveUsers {
* @param object $db - Contenido Database Object
*
* @return Returns true if successful else false
**/
* */
function insertOnlineUser($sUserId) {
$userid = (string) $sUserId;
$sql= "INSERT INTO `" . $this->oCfg["tab"]["online_user"] . "`(`user_id`,`lastaccessed`) VALUES('".Contenido_Security::escapeDB($userid, $this->oDb)."', NOW())";
$sql = "INSERT INTO `" . $this->oCfg["tab"]["online_user"] . "`(`user_id`,`lastaccessed`) VALUES('" . Contenido_Security::escapeDB($userid, $this->oDb) . "', NOW())";
if ($this->oDb->query($sql)) {
return true;
@ -106,15 +106,15 @@ class ActiveUsers {
* @param integer $iUserId - Is the User-Id (get from auth object)
*
* @return Returns true if this User is found, else false
**/
* */
function findUser($sUserId) {
$userid = (string) $sUserId;
$bReturn = false;
$sql= "SELECT user_id FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE `user_id`='".Contenido_Security::escapeDB($userid, $this->oDb)."'";
$sql = "SELECT user_id FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE `user_id`='" . Contenido_Security::escapeDB($userid, $this->oDb) . "'";
$this->oDb->query($sql);
if ($this->oDb->next_record()) {
$bReturn= true;
$bReturn = true;
}
return $bReturn;
}
@ -125,29 +125,28 @@ class ActiveUsers {
*
*
* @return Returns array of user-information
**/
* */
function findAllUser() {
$aAllUser= array ();
$aUser= array ();
$sWebsiteName= "";
$aAllUser = array();
$aUser = array();
$sWebsiteName = "";
// get all user_ids
$sql= "SELECT `user_id` FROM `" . $this->oCfg["tab"]["online_user"]."`";
$sql = "SELECT `user_id` FROM `" . $this->oCfg["tab"]["online_user"] . "`";
if ($this->oDb->query($sql) && $this->oDb->Errno == 0) {
if ($this->oDb->num_rows() > 0) {
while ($this->oDb->next_record()) { // Table Online User
$aUser[]= "'" . $this->oDb->f('user_id') . "'";
$aUser[] = "'" . $this->oDb->f('user_id') . "'";
}
}
}
// get data of those users
$aAllUser= array ();
$aAllUser = array();
$sSqlIn= implode(', ', $aUser); // '1','2','5','8'
$sql= "SELECT user_id, realname, username, perms " .
$sSqlIn = implode(', ', $aUser); // '1','2','5','8'
$sql = "SELECT user_id, realname, username, perms " .
"FROM " . $this->oCfg["tab"]["phplib_auth_user_md5"] . " " .
"WHERE user_id IN(" . $sSqlIn . ")";
@ -156,25 +155,24 @@ class ActiveUsers {
if ($this->oDb->num_rows() > 0) {
while ($this->oDb->next_record()) { // Table Online User
$sWebsiteNames = '';
$sUserId= $this->oDb->f("user_id");
$aAllUser[$sUserId]['realname']= $this->oDb->f("realname");
$aAllUser[$sUserId]['username']= $this->oDb->f("username");
$sPerms= $this->oDb->f("perms");
$sUserId = $this->oDb->f("user_id");
$aAllUser[$sUserId]['realname'] = $this->oDb->f("realname");
$aAllUser[$sUserId]['username'] = $this->oDb->f("username");
$sPerms = $this->oDb->f("perms");
$aPerms= explode(",", $sPerms); //Alle Rechte als array in aPerms packen
$aPerms = explode(",", $sPerms); //Alle Rechte als array in aPerms packen
if (in_array("sysadmin", $aPerms)) {
$aAllUser[$sUserId]['perms']= 'Systemadministrator';
$aAllUser[$sUserId]['perms'] = 'Systemadministrator';
} else {
$bIsAdmin= false;
$iCounter= 0;
$bIsAdmin = false;
$iCounter = 0;
foreach ($aPerms as $sPerm) {
$aResults = array();
if (preg_match('/^admin\[(\d+)\]$/', $sPerm, $aResults)) {
$iClientId= $aResults[1];
$bIsAdmin= true;
$iClientId = $aResults[1];
$bIsAdmin = true;
$sWebsiteName = $this->getWebsiteName($iClientId);
if ($iCounter == 0 && $sWebsiteName != "") {
$sWebsiteNames .= $sWebsiteName;
@ -182,11 +180,10 @@ class ActiveUsers {
$sWebsiteNames .= ', ' . $sWebsiteName;
}
$aAllUser[$sUserId]['perms']= "Administrator (" . $sWebsiteNames . ")";
$aAllUser[$sUserId]['perms'] = "Administrator (" . $sWebsiteNames . ")";
$iCounter++;
} else if (preg_match('/^client\[(\d+)\]$/', $sPerm, $aResults) && !$bIsAdmin) {
$iClientId= $aResults[1];
$iClientId = $aResults[1];
$sWebsiteName = $this->getWebsiteName($iClientId);
if ($iCounter == 0 && $sWebsiteName != "") {
$sWebsiteNames .= $sWebsiteName;
@ -194,16 +191,12 @@ class ActiveUsers {
$sWebsiteNames .= ', ' . $sWebsiteName;
}
$aAllUser[$sUserId]['perms']= '(' . $sWebsiteNames . ')';
$aAllUser[$sUserId]['perms'] = '(' . $sWebsiteNames . ')';
$iCounter++;
}
}
}
}
}
}
@ -216,16 +209,15 @@ class ActiveUsers {
* @param integer $iUserId - Is the User-Id (get from auth object)
*
* @return Returns true if successful, else false
**/
* */
function updateUser($sUserId) {
$userid= (string) $sUserId;
$sql= "UPDATE `" . $this->oCfg["tab"]["online_user"] . "` SET `lastaccessed`=NOW() WHERE `user_id`='".Contenido_Security::escapeDB($userid, $this->oDb)."'";
$userid = (string) $sUserId;
$sql = "UPDATE `" . $this->oCfg["tab"]["online_user"] . "` SET `lastaccessed`=NOW() WHERE `user_id`='" . Contenido_Security::escapeDB($userid, $this->oDb) . "'";
if ($this->oDb->query($sql)) {
return true;
} else
return false;
}
/**
@ -234,21 +226,20 @@ class ActiveUsers {
*
*
* @return Returns true if successful else false
**/
* */
function deleteInactiveUser() {
cInclude("config", "config.misc.php");
$iSetTimeOut= $this->oCfg["backend"]["timeout"];
$iSetTimeOut = $this->oCfg["backend"]["timeout"];
if ($iSetTimeOut == 0)
$iSetTimeOut= 10;
$sql= "";
$sql= "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE DATE_SUB(now(), INTERVAL '$iSetTimeOut' Minute) >= `lastaccessed`";
$iSetTimeOut = 10;
$sql = "";
$sql = "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE DATE_SUB(now(), INTERVAL '$iSetTimeOut' Minute) >= `lastaccessed`";
if ($this->oDb->query($sql)) {
return true;
} else {
return false;
}
}
/**
@ -256,13 +247,13 @@ class ActiveUsers {
*
*
* @return Returns if exists a number of users
**/
* */
function getNumberOfUsers() {
$iAnzahl= 0;
$sql= "SELECT user_id FROM `" . $this->oCfg["tab"]["online_user"]."`";
$iAnzahl = 0;
$sql = "SELECT user_id FROM `" . $this->oCfg["tab"]["online_user"] . "`";
if ($this->oDb->query($sql)) {
$iAnzahl= $this->oDb->num_rows();
$iAnzahl = $this->oDb->num_rows();
}
return $iAnzahl;
@ -274,18 +265,17 @@ class ActiveUsers {
* @param integer $iUserId - Is the User-Id (get from auth object)
*
* @return Returns true if successful, else false
**/
* */
function deleteUser($sUserId) {
$userid= (string) $sUserId;
$sql= "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE `user_id` = '".Contenido_Security::escapeDB($userid, $this->oDb)."'";
$userid = (string) $sUserId;
$sql = "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE `user_id` = '" . Contenido_Security::escapeDB($userid, $this->oDb) . "'";
if ($this->oDb->query($sql)) {
return true;
} else {
return false;
}
}
/**
@ -298,5 +288,7 @@ class ActiveUsers {
$oClient = new cApiClient($iIdClient);
return $oClient->get('name');
}
}
?>

Datei anzeigen

@ -86,6 +86,8 @@ abstract class cItemBaseAbstract {
*/
protected $_className;
protected $_bDebug;
/**
* Sets some common properties
*

Datei anzeigen

@ -50,9 +50,9 @@ if (!isRunningFromWeb() || function_exists("runJob") || $area == "cronjobs")
$sSql = "UPDATE " . $cfg['tab']['frontendusers'] . "
SET active = 0
WHERE
(valid_to < NOW() AND valid_to != '0000-00-00' AND valid_to != '1000-01-01')
(valid_to < NOW() AND valid_to != '1000-01-01')
OR
(valid_from > NOW() AND valid_from != '0000-00-00' AND valid_from != '1000-01-01')";
(valid_from > NOW() AND valid_from != '1000-01-01')";
//echo $sSql;
$db->query($sSql);

Datei anzeigen

@ -125,6 +125,11 @@ $cfg['AvailableCharsets'] = array(
'SHIFT_JIS'
);
// (bool) Flag to use native i18n.
// Note: Enabling this could create unwanted side effects, because of
// native gettext() behavior.
$cfg['native_i18n'] = false;
/* Error handling settings
* ----------------------------------