changes for mysql 5.7 with strict mode
Dieser Commit ist enthalten in:
Ursprung
2a933cea61
Commit
dec7056fca
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project:
|
* Project:
|
||||||
* Contenido Content Management System
|
* Contenido Content Management System
|
||||||
|
@ -17,8 +18,7 @@
|
||||||
*
|
*
|
||||||
* $Id: class.activeusers.php 362 2015-10-05 16:31:26Z oldperl $;
|
* $Id: class.activeusers.php 362 2015-10-05 16:31:26Z oldperl $;
|
||||||
*/
|
*/
|
||||||
|
if (!defined('CON_FRAMEWORK')) {
|
||||||
if(!defined('CON_FRAMEWORK')) {
|
|
||||||
die('Illegal call');
|
die('Illegal call');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,16 +37,16 @@ class ActiveUsers {
|
||||||
* @param object $auth
|
* @param object $auth
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
**/
|
* */
|
||||||
function ActiveUsers($oDb, $oCfg, $oAuth) {
|
function ActiveUsers($oDb, $oCfg, $oAuth) {
|
||||||
|
|
||||||
$this->oCfg= $oCfg;
|
$this->oCfg = $oCfg;
|
||||||
$this->oAuth= $oAuth;
|
$this->oAuth = $oAuth;
|
||||||
$this->oDb= $oDb;
|
$this->oDb = $oDb;
|
||||||
|
|
||||||
// init db object
|
// init db object
|
||||||
if (!is_object($this->oDb) || (is_null($this->oDb))) {
|
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)) {
|
if (!is_resource($this->oDb->Link_ID)) {
|
||||||
|
@ -54,7 +54,7 @@ class ActiveUsers {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the userid
|
// Load the userid
|
||||||
$this->iUserId= $this->oAuth->auth["uid"];
|
$this->iUserId = $this->oAuth->auth["uid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,13 +65,13 @@ class ActiveUsers {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
**/
|
* */
|
||||||
function startUsersTracking() {
|
function startUsersTracking() {
|
||||||
|
|
||||||
// Delete all Contains in the table "online_user" that is older as timeout(current is 60 minutes)
|
// Delete all Contains in the table "online_user" that is older as timeout(current is 60 minutes)
|
||||||
$this->deleteInactiveUser();
|
$this->deleteInactiveUser();
|
||||||
|
|
||||||
$bResult= $this->findUser($this->iUserId);
|
$bResult = $this->findUser($this->iUserId);
|
||||||
if ($bResult) {
|
if ($bResult) {
|
||||||
// update the curent user
|
// update the curent user
|
||||||
$this->updateUser($this->iUserId);
|
$this->updateUser($this->iUserId);
|
||||||
|
@ -87,11 +87,11 @@ class ActiveUsers {
|
||||||
* @param object $db - Contenido Database Object
|
* @param object $db - Contenido Database Object
|
||||||
*
|
*
|
||||||
* @return Returns true if successful else false
|
* @return Returns true if successful else false
|
||||||
**/
|
* */
|
||||||
function insertOnlineUser($sUserId) {
|
function insertOnlineUser($sUserId) {
|
||||||
|
|
||||||
$userid = (string) $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)) {
|
if ($this->oDb->query($sql)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -106,15 +106,15 @@ class ActiveUsers {
|
||||||
* @param integer $iUserId - Is the User-Id (get from auth object)
|
* @param integer $iUserId - Is the User-Id (get from auth object)
|
||||||
*
|
*
|
||||||
* @return Returns true if this User is found, else false
|
* @return Returns true if this User is found, else false
|
||||||
**/
|
* */
|
||||||
function findUser($sUserId) {
|
function findUser($sUserId) {
|
||||||
|
|
||||||
$userid = (string) $sUserId;
|
$userid = (string) $sUserId;
|
||||||
$bReturn = false;
|
$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);
|
$this->oDb->query($sql);
|
||||||
if ($this->oDb->next_record()) {
|
if ($this->oDb->next_record()) {
|
||||||
$bReturn= true;
|
$bReturn = true;
|
||||||
}
|
}
|
||||||
return $bReturn;
|
return $bReturn;
|
||||||
}
|
}
|
||||||
|
@ -125,29 +125,28 @@ class ActiveUsers {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return Returns array of user-information
|
* @return Returns array of user-information
|
||||||
**/
|
* */
|
||||||
function findAllUser() {
|
function findAllUser() {
|
||||||
|
|
||||||
$aAllUser= array ();
|
$aAllUser = array();
|
||||||
$aUser= array ();
|
$aUser = array();
|
||||||
$sWebsiteName= "";
|
$sWebsiteName = "";
|
||||||
// get all user_ids
|
// 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->query($sql) && $this->oDb->Errno == 0) {
|
||||||
|
|
||||||
if ($this->oDb->num_rows() > 0) {
|
if ($this->oDb->num_rows() > 0) {
|
||||||
while ($this->oDb->next_record()) { // Table Online User
|
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
|
// get data of those users
|
||||||
$aAllUser= array ();
|
$aAllUser = array();
|
||||||
|
|
||||||
$sSqlIn= implode(', ', $aUser); // '1','2','5','8'
|
$sSqlIn = implode(', ', $aUser); // '1','2','5','8'
|
||||||
$sql= "SELECT user_id, realname, username, perms " .
|
$sql = "SELECT user_id, realname, username, perms " .
|
||||||
"FROM " . $this->oCfg["tab"]["phplib_auth_user_md5"] . " " .
|
"FROM " . $this->oCfg["tab"]["phplib_auth_user_md5"] . " " .
|
||||||
"WHERE user_id IN(" . $sSqlIn . ")";
|
"WHERE user_id IN(" . $sSqlIn . ")";
|
||||||
|
|
||||||
|
@ -156,25 +155,24 @@ class ActiveUsers {
|
||||||
if ($this->oDb->num_rows() > 0) {
|
if ($this->oDb->num_rows() > 0) {
|
||||||
while ($this->oDb->next_record()) { // Table Online User
|
while ($this->oDb->next_record()) { // Table Online User
|
||||||
$sWebsiteNames = '';
|
$sWebsiteNames = '';
|
||||||
$sUserId= $this->oDb->f("user_id");
|
$sUserId = $this->oDb->f("user_id");
|
||||||
$aAllUser[$sUserId]['realname']= $this->oDb->f("realname");
|
$aAllUser[$sUserId]['realname'] = $this->oDb->f("realname");
|
||||||
$aAllUser[$sUserId]['username']= $this->oDb->f("username");
|
$aAllUser[$sUserId]['username'] = $this->oDb->f("username");
|
||||||
$sPerms= $this->oDb->f("perms");
|
$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)) {
|
if (in_array("sysadmin", $aPerms)) {
|
||||||
$aAllUser[$sUserId]['perms']= 'Systemadministrator';
|
$aAllUser[$sUserId]['perms'] = 'Systemadministrator';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$bIsAdmin= false;
|
$bIsAdmin = false;
|
||||||
$iCounter= 0;
|
$iCounter = 0;
|
||||||
foreach ($aPerms as $sPerm) {
|
foreach ($aPerms as $sPerm) {
|
||||||
$aResults = array();
|
$aResults = array();
|
||||||
if (preg_match('/^admin\[(\d+)\]$/', $sPerm, $aResults)) {
|
if (preg_match('/^admin\[(\d+)\]$/', $sPerm, $aResults)) {
|
||||||
$iClientId= $aResults[1];
|
$iClientId = $aResults[1];
|
||||||
$bIsAdmin= true;
|
$bIsAdmin = true;
|
||||||
$sWebsiteName = $this->getWebsiteName($iClientId);
|
$sWebsiteName = $this->getWebsiteName($iClientId);
|
||||||
if ($iCounter == 0 && $sWebsiteName != "") {
|
if ($iCounter == 0 && $sWebsiteName != "") {
|
||||||
$sWebsiteNames .= $sWebsiteName;
|
$sWebsiteNames .= $sWebsiteName;
|
||||||
|
@ -182,11 +180,10 @@ class ActiveUsers {
|
||||||
$sWebsiteNames .= ', ' . $sWebsiteName;
|
$sWebsiteNames .= ', ' . $sWebsiteName;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aAllUser[$sUserId]['perms']= "Administrator (" . $sWebsiteNames . ")";
|
$aAllUser[$sUserId]['perms'] = "Administrator (" . $sWebsiteNames . ")";
|
||||||
$iCounter++;
|
$iCounter++;
|
||||||
|
|
||||||
} else if (preg_match('/^client\[(\d+)\]$/', $sPerm, $aResults) && !$bIsAdmin) {
|
} else if (preg_match('/^client\[(\d+)\]$/', $sPerm, $aResults) && !$bIsAdmin) {
|
||||||
$iClientId= $aResults[1];
|
$iClientId = $aResults[1];
|
||||||
$sWebsiteName = $this->getWebsiteName($iClientId);
|
$sWebsiteName = $this->getWebsiteName($iClientId);
|
||||||
if ($iCounter == 0 && $sWebsiteName != "") {
|
if ($iCounter == 0 && $sWebsiteName != "") {
|
||||||
$sWebsiteNames .= $sWebsiteName;
|
$sWebsiteNames .= $sWebsiteName;
|
||||||
|
@ -194,16 +191,12 @@ class ActiveUsers {
|
||||||
$sWebsiteNames .= ', ' . $sWebsiteName;
|
$sWebsiteNames .= ', ' . $sWebsiteName;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aAllUser[$sUserId]['perms']= '(' . $sWebsiteNames . ')';
|
$aAllUser[$sUserId]['perms'] = '(' . $sWebsiteNames . ')';
|
||||||
$iCounter++;
|
$iCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,16 +209,15 @@ class ActiveUsers {
|
||||||
* @param integer $iUserId - Is the User-Id (get from auth object)
|
* @param integer $iUserId - Is the User-Id (get from auth object)
|
||||||
*
|
*
|
||||||
* @return Returns true if successful, else false
|
* @return Returns true if successful, else false
|
||||||
**/
|
* */
|
||||||
function updateUser($sUserId) {
|
function updateUser($sUserId) {
|
||||||
|
|
||||||
$userid= (string) $sUserId;
|
$userid = (string) $sUserId;
|
||||||
$sql= "UPDATE `" . $this->oCfg["tab"]["online_user"] . "` SET `lastaccessed`=NOW() WHERE `user_id`='".Contenido_Security::escapeDB($userid, $this->oDb)."'";
|
$sql = "UPDATE `" . $this->oCfg["tab"]["online_user"] . "` SET `lastaccessed`=NOW() WHERE `user_id`='" . Contenido_Security::escapeDB($userid, $this->oDb) . "'";
|
||||||
if ($this->oDb->query($sql)) {
|
if ($this->oDb->query($sql)) {
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,21 +226,20 @@ class ActiveUsers {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return Returns true if successful else false
|
* @return Returns true if successful else false
|
||||||
**/
|
* */
|
||||||
function deleteInactiveUser() {
|
function deleteInactiveUser() {
|
||||||
|
|
||||||
cInclude("config", "config.misc.php");
|
cInclude("config", "config.misc.php");
|
||||||
$iSetTimeOut= $this->oCfg["backend"]["timeout"];
|
$iSetTimeOut = $this->oCfg["backend"]["timeout"];
|
||||||
if ($iSetTimeOut == 0)
|
if ($iSetTimeOut == 0)
|
||||||
$iSetTimeOut= 10;
|
$iSetTimeOut = 10;
|
||||||
$sql= "";
|
$sql = "";
|
||||||
$sql= "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE DATE_SUB(now(), INTERVAL '$iSetTimeOut' Minute) >= `lastaccessed`";
|
$sql = "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE DATE_SUB(now(), INTERVAL '$iSetTimeOut' Minute) >= `lastaccessed`";
|
||||||
if ($this->oDb->query($sql)) {
|
if ($this->oDb->query($sql)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -256,13 +247,13 @@ class ActiveUsers {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return Returns if exists a number of users
|
* @return Returns if exists a number of users
|
||||||
**/
|
* */
|
||||||
function getNumberOfUsers() {
|
function getNumberOfUsers() {
|
||||||
|
|
||||||
$iAnzahl= 0;
|
$iAnzahl = 0;
|
||||||
$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)) {
|
if ($this->oDb->query($sql)) {
|
||||||
$iAnzahl= $this->oDb->num_rows();
|
$iAnzahl = $this->oDb->num_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $iAnzahl;
|
return $iAnzahl;
|
||||||
|
@ -274,18 +265,17 @@ class ActiveUsers {
|
||||||
* @param integer $iUserId - Is the User-Id (get from auth object)
|
* @param integer $iUserId - Is the User-Id (get from auth object)
|
||||||
*
|
*
|
||||||
* @return Returns true if successful, else false
|
* @return Returns true if successful, else false
|
||||||
**/
|
* */
|
||||||
function deleteUser($sUserId) {
|
function deleteUser($sUserId) {
|
||||||
|
|
||||||
$userid= (string) $sUserId;
|
$userid = (string) $sUserId;
|
||||||
$sql= "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE `user_id` = '".Contenido_Security::escapeDB($userid, $this->oDb)."'";
|
$sql = "DELETE FROM `" . $this->oCfg["tab"]["online_user"] . "` WHERE `user_id` = '" . Contenido_Security::escapeDB($userid, $this->oDb) . "'";
|
||||||
|
|
||||||
if ($this->oDb->query($sql)) {
|
if ($this->oDb->query($sql)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,5 +288,7 @@ class ActiveUsers {
|
||||||
$oClient = new cApiClient($iIdClient);
|
$oClient = new cApiClient($iIdClient);
|
||||||
return $oClient->get('name');
|
return $oClient->get('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -86,6 +86,8 @@ abstract class cItemBaseAbstract {
|
||||||
*/
|
*/
|
||||||
protected $_className;
|
protected $_className;
|
||||||
|
|
||||||
|
protected $_bDebug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets some common properties
|
* Sets some common properties
|
||||||
*
|
*
|
||||||
|
|
|
@ -50,9 +50,9 @@ if (!isRunningFromWeb() || function_exists("runJob") || $area == "cronjobs")
|
||||||
$sSql = "UPDATE " . $cfg['tab']['frontendusers'] . "
|
$sSql = "UPDATE " . $cfg['tab']['frontendusers'] . "
|
||||||
SET active = 0
|
SET active = 0
|
||||||
WHERE
|
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
|
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;
|
//echo $sSql;
|
||||||
$db->query($sSql);
|
$db->query($sSql);
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,11 @@ $cfg['AvailableCharsets'] = array(
|
||||||
'SHIFT_JIS'
|
'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
|
/* Error handling settings
|
||||||
* ----------------------------------
|
* ----------------------------------
|
||||||
|
|
Laden…
In neuem Issue referenzieren