From: <var...@us...> - 2014-07-17 09:11:17
|
Revision: 8970 http://sourceforge.net/p/phpwiki/code/8970 Author: vargenau Date: 2014-07-17 09:11:09 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Add return argument Modified Paths: -------------- trunk/lib/DbSession/ADODB.php trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession/dba.php Modified: trunk/lib/DbSession/ADODB.php =================================================================== --- trunk/lib/DbSession/ADODB.php 2014-07-17 09:02:29 UTC (rev 8969) +++ trunk/lib/DbSession/ADODB.php 2014-07-17 09:11:09 UTC (rev 8970) @@ -156,7 +156,7 @@ */ function write($id, $sess_data) { - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); $table = $this->_table; Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2014-07-17 09:02:29 UTC (rev 8969) +++ trunk/lib/DbSession/PDO.php 2014-07-17 09:11:09 UTC (rev 8970) @@ -133,7 +133,7 @@ */ function write($id, $sess_data) { - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); $table = $this->_table; Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2014-07-17 09:02:29 UTC (rev 8969) +++ trunk/lib/DbSession/SQL.php 2014-07-17 09:11:09 UTC (rev 8970) @@ -142,7 +142,7 @@ */ function write($id, $sess_data) { - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); //$dbh->unlock(false,1); Modified: trunk/lib/DbSession/dba.php =================================================================== --- trunk/lib/DbSession/dba.php 2014-07-17 09:02:29 UTC (rev 8969) +++ trunk/lib/DbSession/dba.php 2014-07-17 09:11:09 UTC (rev 8970) @@ -94,7 +94,7 @@ function write($id, $sess_data) { - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); $time = time(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-12-04 16:12:59
|
Revision: 9418 http://sourceforge.net/p/phpwiki/code/9418 Author: vargenau Date: 2014-12-04 16:12:50 +0000 (Thu, 04 Dec 2014) Log Message: ----------- Harmonize lib/DbSession/*.php Modified Paths: -------------- trunk/lib/DbSession/ADODB.php trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession/dba.php Modified: trunk/lib/DbSession/ADODB.php =================================================================== --- trunk/lib/DbSession/ADODB.php 2014-12-04 15:51:47 UTC (rev 9417) +++ trunk/lib/DbSession/ADODB.php 2014-12-04 16:12:50 UTC (rev 9418) @@ -64,6 +64,7 @@ return $this->_dbh->Execute($sql); } + // adds surrounding quotes function quote($string) { return $this->_dbh->qstr($string); @@ -124,11 +125,12 @@ if (!empty($res) and preg_match('|^[a-zA-Z0-9/+=]+$|', $res)) $res = base64_decode($res); if (strlen($res) > 4000) { - trigger_error("Overlarge session data! " . strlen($res) . - " gt. 4000", E_USER_WARNING); + // trigger_error("Overlarge session data! ".strlen($res). " gt. 4000", E_USER_WARNING); $res = preg_replace('/s:6:"_cache";O:12:"WikiDB_cache".+}$/', "", $res); $res = preg_replace('/s:12:"_cached_html";s:.+",s:4:"hits"/', 's:4:"hits"', $res); - if (strlen($res) > 4000) $res = ''; + if (strlen($res) > 4000) { + $res = ''; + } } return $res; } @@ -232,7 +234,7 @@ return true; } - // WhoIsOnline support. + // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API function currentSessions() { Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2014-12-04 15:51:47 UTC (rev 9417) +++ trunk/lib/DbSession/PDO.php 2014-12-04 16:12:50 UTC (rev 9418) @@ -1,4 +1,23 @@ <?php +/* + * Copyright 2005 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ /** * Db sessions for PDO, based on pear DB Sessions. @@ -27,7 +46,7 @@ function & _connect() { - $dbh =& $this->_dbh; + $dbh = &$this->_dbh; if (!$dbh or !is_object($dbh)) { global $DBParams; $db = new WikiDB_backend_PDO($DBParams); @@ -42,6 +61,7 @@ return $this->_backend->query($sql); } + // adds surrounding quotes function quote($string) { return $this->_backend->quote($string); @@ -90,7 +110,6 @@ */ public function read($id) { - //$this->log("_read($id)"); $dbh = $this->_connect(); $table = $this->_table; $sth = $dbh->prepare("SELECT sess_data FROM $table WHERE sess_id=?"); @@ -105,8 +124,7 @@ $res = base64_decode($res); } if (strlen($res) > 4000) { - trigger_error("Overlarge session data! " . strlen($res) . - " gt. 4000", E_USER_WARNING); + // trigger_error("Overlarge session data! ".strlen($res). " gt. 4000", E_USER_WARNING); $res = preg_replace('/s:6:"_cache";O:12:"WikiDB_cache".+}$/', "", $res); $res = preg_replace('/s:12:"_cached_html";s:.+",s:4:"hits"/', 's:4:"hits"', $res); if (strlen($res) > 4000) { @@ -228,7 +246,7 @@ return true; } - // WhoIsOnline support. + // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API function currentSessions() { Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2014-12-04 15:51:47 UTC (rev 9417) +++ trunk/lib/DbSession/SQL.php 2014-12-04 16:12:50 UTC (rev 9418) @@ -1,7 +1,26 @@ <?php +/* + * Copyright 2005 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ -/** - * DB sessions for pear DB +/* + * Copyright 2005 $ThePhpWikiProgrammingTeam * * History * @@ -15,9 +34,8 @@ { public $_backend_type = "SQL"; - function __construct(&$dbh, $table) + function __construct($dbh, $table) { - $this->_dbh = $dbh; $this->_table = $table; @@ -106,16 +124,18 @@ $res = $dbh->getOne("SELECT sess_data FROM $table WHERE sess_id=$qid"); $this->_disconnect(); - if (DB::isError($res) || empty($res)) + if (DB::isError($res) || empty($res)) { return ''; + } if (is_a($dbh, 'DB_pgsql')) - //if (preg_match('|^[a-zA-Z0-9/+=]+$|', $res)) $res = base64_decode($res); if (strlen($res) > 4000) { // trigger_error("Overlarge session data! ".strlen($res). " gt. 4000", E_USER_WARNING); $res = preg_replace('/s:6:"_cache";O:12:"WikiDB_cache".+}$/', "", $res); $res = preg_replace('/s:12:"_cached_html";s:.+",s:4:"hits"/', 's:4:"hits"', $res); - if (strlen($res) > 4000) $res = ''; + if (strlen($res) > 4000) { + $res = ''; + } } return $res; } @@ -145,7 +165,6 @@ if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); - //$dbh->unlock(false,1); $table = $this->_table; $qid = $dbh->quote($id); $qip = $dbh->quote($request->get('REMOTE_ADDR')); @@ -158,7 +177,7 @@ $sess_data = base64_encode($sess_data); $qdata = $dbh->quote($sess_data); - /* AffectedRows with sessions seems to be instable on certain platforms. + /* AffectedRows with sessions seems to be unstable on certain platforms. * Enable the safe and slow USE_SAFE_DBSESSION then. */ if (USE_SAFE_DBSESSION) { Modified: trunk/lib/DbSession/dba.php =================================================================== --- trunk/lib/DbSession/dba.php 2014-12-04 15:51:47 UTC (rev 9417) +++ trunk/lib/DbSession/dba.php 2014-12-04 16:12:50 UTC (rev 9418) @@ -1,4 +1,23 @@ <?php +/* + * Copyright 2005 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ /** DBA Sessions * session: @@ -15,7 +34,7 @@ { public $_backend_type = "dba"; - function __construct(&$dbh, $table) + function __construct($dbh, $table) { $this->_dbh = $dbh; ini_set('session.save_handler', 'user'); @@ -63,18 +82,41 @@ } } - function open($save_path, $session_name) + /** + * Opens a session. + * + * Actually this function is a fake for session_set_save_handle. + * @param string $save_path a path to stored files + * @param string $session_name a name of the concrete file + * @return boolean true just a variable to notify PHP that everything + * is good. + */ + public function open($save_path, $session_name) { $dbh = $this->_connect(); $dbh->open(); } - function close() + /** + * Closes a session. + * + * This function is called just after <i>write</i> call. + * + * @return boolean true just a variable to notify PHP that everything + * is good. + */ + public function close() { $this->_disconnect(); } - function read($id) + /** + * Reads the session data from DB. + * + * @param string $id an id of current session + * @return string + */ + public function read($id) { $dbh = $this->_connect(); $result = $dbh->get($id); @@ -84,14 +126,29 @@ list(, , $packed) = explode(':', $result, 3); $this->_disconnect(); if (strlen($packed) > 4000) { - trigger_error("Overlarge session data!", E_USER_WARNING); + // trigger_error("Overlarge session data!", E_USER_WARNING); $packed = ''; //$res = preg_replace('/s:6:"_cache";O:12:"WikiDB_cache".+}$/',"",$res); } return $packed; } - function write($id, $sess_data) + /** + * Saves the session data into DB. + * + * Just a comment: The "write" handler is not + * executed until after the output stream is closed. Thus, + * output from debugging statements in the "write" handler + * will never be seen in the browser. If debugging output + * is necessary, it is suggested that the debug output be + * written to a file instead. + * + * @param string $id + * @param string $sess_data + * @return boolean true if data saved successfully and false + * otherwise. + */ + public function write($id, $sess_data) { /** * @var WikiRequest $request @@ -120,7 +177,13 @@ return true; } - function gc($maxlifetime) + /** + * Cleans out all expired sessions. + * + * @param int $maxlifetime session's time to live. + * @return boolean true + */ + public function gc($maxlifetime) { $dbh = $this->_connect(); $threshold = time() - $maxlifetime; @@ -134,7 +197,7 @@ return true; } - // WhoIsOnline support. + // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API function currentSessions() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2019-07-30 12:17:43
|
Revision: 10138 http://sourceforge.net/p/phpwiki/code/10138 Author: vargenau Date: 2019-07-30 12:17:41 +0000 (Tue, 30 Jul 2019) Log Message: ----------- ini_set('session.save_handler', 'user') is forbidden in PHP 7.2 Modified Paths: -------------- trunk/lib/DbSession/ADODB.php trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession/dba.php Modified: trunk/lib/DbSession/ADODB.php =================================================================== --- trunk/lib/DbSession/ADODB.php 2019-07-26 14:04:47 UTC (rev 10137) +++ trunk/lib/DbSession/ADODB.php 2019-07-30 12:17:41 UTC (rev 10138) @@ -38,8 +38,6 @@ $this->_dbh = $dbh; $this->_table = $table; - ini_set('session.save_handler', 'user'); - session_module_name('user'); // new style session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2019-07-26 14:04:47 UTC (rev 10137) +++ trunk/lib/DbSession/PDO.php 2019-07-30 12:17:41 UTC (rev 10138) @@ -38,8 +38,6 @@ $this->_dbh = $dbh; $this->_table = $table; - ini_set('session.save_handler', 'user'); - session_module_name('user'); // new style session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2019-07-26 14:04:47 UTC (rev 10137) +++ trunk/lib/DbSession/SQL.php 2019-07-30 12:17:41 UTC (rev 10138) @@ -42,8 +42,6 @@ $this->_dbh = $dbh; $this->_table = $table; - ini_set('session.save_handler', 'user'); - session_module_name('user'); // new style session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), Modified: trunk/lib/DbSession/dba.php =================================================================== --- trunk/lib/DbSession/dba.php 2019-07-26 14:04:47 UTC (rev 10137) +++ trunk/lib/DbSession/dba.php 2019-07-30 12:17:41 UTC (rev 10138) @@ -41,8 +41,6 @@ function __construct($dbh, $table) { $this->_dbh = $dbh; - ini_set('session.save_handler', 'user'); - session_module_name('user'); // new style session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-03-24 13:49:53
|
Revision: 11014 http://sourceforge.net/p/phpwiki/code/11014 Author: vargenau Date: 2022-03-24 13:49:51 +0000 (Thu, 24 Mar 2022) Log Message: ----------- run php-cs-fixer Modified Paths: -------------- trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession/dba.php Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2022-03-24 13:48:01 UTC (rev 11013) +++ trunk/lib/DbSession/PDO.php 2022-03-24 13:49:51 UTC (rev 11014) @@ -28,25 +28,26 @@ * @author: Reini Urban */ -class DbSession_PDO - extends DbSession +class DbSession_PDO extends DbSession { public $_backend_type = "PDO"; - function __construct($dbh, $table) + public function __construct($dbh, $table) { $this->_dbh = $dbh; $this->_table = $table; - session_set_save_handler(array(&$this, 'open'), + session_set_save_handler( + array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), - array(&$this, 'gc')); + array(&$this, 'gc') + ); } - function & _connect() + public function & _connect() { $dbh = &$this->_dbh; global $DBParams; @@ -56,21 +57,22 @@ return $dbh; } - function query($sql) + public function query($sql) { return $this->_backend->query($sql); } // adds surrounding quotes - function quote($string) + public function quote($string) { return $this->_backend->quote($string); } - function _disconnect() + public function _disconnect() { - if (0 and $this->_dbh) + if (0 and $this->_dbh) { unset($this->_dbh); + } } /** @@ -153,7 +155,9 @@ */ global $request; - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) { + return false; + } $dbh = $this->_connect(); $table = $this->_table; @@ -219,7 +223,7 @@ // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API - function currentSessions() + public function currentSessions() { $sessions = array(); $table = $this->_table; @@ -232,10 +236,12 @@ $data = $row[0]; $date = $row[1]; $ip = $row[2]; - if (preg_match('|^[a-zA-Z0-9/+=]+$|', $data)) + if (preg_match('|^[a-zA-Z0-9/+=]+$|', $data)) { $data = base64_decode($data); - if ($date < 908437560 or $date > 1588437560) + } + if ($date < 908437560 or $date > 1588437560) { $date = 0; + } // session_data contains the <variable name> + "|" + <packed string> // we need just the wiki_user object (might be array as well) $user = strstr($data, "wiki_user|"); Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2022-03-24 13:48:01 UTC (rev 11013) +++ trunk/lib/DbSession/SQL.php 2022-03-24 13:49:51 UTC (rev 11014) @@ -32,25 +32,26 @@ * Quasi-major rewrite/decruft/fix by Jeff Dairiki <da...@da...>. */ -class DbSession_SQL - extends DbSession +class DbSession_SQL extends DbSession { public $_backend_type = "SQL"; - function __construct($dbh, $table) + public function __construct($dbh, $table) { $this->_dbh = $dbh; $this->_table = $table; - session_set_save_handler(array(&$this, 'open'), + session_set_save_handler( + array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), - array(&$this, 'gc')); + array(&$this, 'gc') + ); } - function & _connect() + public function & _connect() { $dbh = &$this->_dbh; $this->_connected = is_resource($dbh->connection); @@ -63,21 +64,22 @@ return $dbh; } - function query($sql) + public function query($sql) { return $this->_dbh->query($sql); } // adds surrounding quotes - function quote($string) + public function quote($string) { return $this->_dbh->quote($string); } - function _disconnect() + public function _disconnect() { - if (0 and $this->_connected) + if (0 and $this->_connected) { $this->_dbh->disconnect(); + } } /** @@ -128,8 +130,9 @@ if (DB::isError($res) || empty($res)) { return ''; } - if (is_a($dbh, 'DB_pgsql')) + if (is_a($dbh, 'DB_pgsql')) { $res = base64_decode($res); + } if (strlen($res) > 4000) { // trigger_error("Overlarge session data! ".strlen($res). " gt. 4000", E_USER_WARNING); $res = preg_replace('/s:6:"_cache";O:12:"WikiDB_cache".+}$/', "", $res); @@ -163,7 +166,9 @@ */ global $request; - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) { + return false; + } $dbh = $this->_connect(); $table = $this->_table; @@ -174,8 +179,9 @@ trigger_error("delete empty session $qid", E_USER_WARNING); } // postgres can't handle binary data in a TEXT field. - if (is_a($dbh, 'DB_pgsql')) + if (is_a($dbh, 'DB_pgsql')) { $sess_data = base64_encode($sess_data); + } $qdata = $dbh->quote($sess_data); $dbh->query("DELETE FROM $table WHERE sess_id=$qid"); @@ -226,22 +232,25 @@ // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API - function currentSessions() + public function currentSessions() { $sessions = array(); $dbh = $this->_connect(); $table = $this->_table; $res = $dbh->query("SELECT sess_data,sess_date,sess_ip FROM $table ORDER BY sess_date DESC"); - if (DB::isError($res) || empty($res)) + if (DB::isError($res) || empty($res)) { return $sessions; + } while ($row = $res->fetchRow()) { $data = $row['sess_data']; $date = $row['sess_date']; $ip = $row['sess_ip']; - if (preg_match('|^[a-zA-Z0-9/+=]+$|', $data)) + if (preg_match('|^[a-zA-Z0-9/+=]+$|', $data)) { $data = base64_decode($data); - if ($date < 908437560 or $date > 1588437560) + } + if ($date < 908437560 or $date > 1588437560) { $date = 0; + } // session_data contains the <variable name> + "|" + <packed string> // we need just the wiki_user object (might be array as well) $user = strstr($data, "wiki_user|"); Modified: trunk/lib/DbSession/dba.php =================================================================== --- trunk/lib/DbSession/dba.php 2022-03-24 13:48:01 UTC (rev 11013) +++ trunk/lib/DbSession/dba.php 2022-03-24 13:49:51 UTC (rev 11014) @@ -33,33 +33,34 @@ * @author: Reini Urban. */ -class DbSession_dba - extends DbSession +class DbSession_dba extends DbSession { public $_backend_type = "dba"; - function __construct($dbh, $table) + public function __construct($dbh, $table) { $this->_dbh = $dbh; - session_set_save_handler(array(&$this, 'open'), + session_set_save_handler( + array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), - array(&$this, 'gc')); + array(&$this, 'gc') + ); } - function quote($string) + public function quote($string) { return $string; } - function query($sql) + public function query($sql) { return false; } - function & _connect() + public function & _connect() { global $DBParams; $dbh = &$this->_dbh; @@ -76,7 +77,7 @@ return $dbh; } - function _disconnect() + public function _disconnect() { if (isset($this->_dbh)) { $this->_dbh->close(); @@ -159,7 +160,9 @@ */ global $request; - if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) { + return false; + } $dbh = $this->_connect(); $time = time(); @@ -173,7 +176,7 @@ return true; } - function destroy($id) + public function destroy($id) { $dbh = $this->_connect(); $dbh->delete($id); @@ -193,10 +196,11 @@ $threshold = time() - $maxlifetime; for ($id = $dbh->firstkey(); $id !== false; $id = $nextid) { $result = $dbh->get($id); - list($date, ,) = explode('|', $result, 3); + list($date, , ) = explode('|', $result, 3); $nextid = $dbh->nextkey(); - if ($date < $threshold) + if ($date < $threshold) { $dbh->delete($id); + } } $dbh->optimize(); $this->_disconnect(); @@ -205,7 +209,7 @@ // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API - function currentSessions() + public function currentSessions() { $sessions = array(); $dbh = $this->_connect(); @@ -212,11 +216,14 @@ for ($id = $dbh->firstkey(); $id !== false; $id = $dbh->nextkey()) { $result = $dbh->get($id); list($date, $ip, $packed) = explode('|', $result, 3); - if (!$packed) continue; + if (!$packed) { + continue; + } // session_data contains the <variable name> + "|" + <packed string> // we need just the wiki_user object (might be array as well) - if ($date < 908437560 or $date > 1588437560) + if ($date < 908437560 or $date > 1588437560) { $date = 0; + } $user = strstr($packed, "wiki_user|"); $sessions[] = array('wiki_user' => substr($user, 10), // from "O:" onwards 'date' => $date, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2023-07-14 11:23:16
|
Revision: 11055 http://sourceforge.net/p/phpwiki/code/11055 Author: vargenau Date: 2023-07-14 11:23:14 +0000 (Fri, 14 Jul 2023) Log Message: ----------- lib/DbSession: PHP 7: add types for function arguments and return Modified Paths: -------------- trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession/dba.php Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2023-07-14 11:16:48 UTC (rev 11054) +++ trunk/lib/DbSession/PDO.php 2023-07-14 11:23:14 UTC (rev 11055) @@ -30,7 +30,7 @@ class DbSession_PDO extends DbSession { - public $_backend_type = "PDO"; + public string $_backend_type = "PDO"; public function __construct($dbh, $table) { @@ -84,7 +84,7 @@ * @return boolean true just a variable to notify PHP that everything * is good. */ - public function open($save_path, $session_name) + public function open(string $save_path, string $session_name): bool { //$this->log("_open($save_path, $session_name)"); return true; @@ -98,7 +98,7 @@ * @return boolean true just a variable to notify PHP that everything * is good. */ - public function close() + public function close(): bool { //$this->log("_close()"); return true; @@ -110,7 +110,7 @@ * @param string $id an id of current session * @return string */ - public function read($id) + public function read(string $id): string { $dbh = $this->_connect(); $table = $this->_table; @@ -148,7 +148,7 @@ * @return boolean true if data saved successfully and false * otherwise. */ - public function write($id, $sess_data) + public function write(string $id, string $sess_data): bool { /** * @var WikiRequest $request @@ -192,7 +192,7 @@ * @param string $id * @return boolean true */ - public function destroy($id) + public function destroy(string $id): bool { $table = $this->_table; $dbh = $this->_connect(); @@ -209,7 +209,7 @@ * @param int $maxlifetime session's time to live. * @return boolean true */ - public function gc($maxlifetime) + public function gc(int $maxlifetime): bool { $table = $this->_table; $threshold = time() - $maxlifetime; @@ -223,7 +223,7 @@ // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API - public function currentSessions() + public function currentSessions(): array { $sessions = array(); $table = $this->_table; Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2023-07-14 11:16:48 UTC (rev 11054) +++ trunk/lib/DbSession/SQL.php 2023-07-14 11:23:14 UTC (rev 11055) @@ -34,7 +34,7 @@ class DbSession_SQL extends DbSession { - public $_backend_type = "SQL"; + public string $_backend_type = "SQL"; public function __construct($dbh, $table) { @@ -91,7 +91,7 @@ * @return boolean true just a variable to notify PHP that everything * is good. */ - public function open($save_path, $session_name) + public function open(string $save_path, string $session_name): bool { //$this->log("_open($save_path, $session_name)"); return true; @@ -105,7 +105,7 @@ * @return boolean true just a variable to notify PHP that everything * is good. */ - public function close() + public function close(): bool { //$this->log("_close()"); return true; @@ -117,7 +117,7 @@ * @param string $id an id of current session * @return string */ - public function read($id) + public function read(string $id): string { //$this->log("_read($id)"); $dbh = $this->_connect(); @@ -159,7 +159,7 @@ * @return boolean true if data saved successfully and false * otherwise. */ - public function write($id, $sess_data) + public function write(string $id, string $sess_data): bool { /** * @var WikiRequest $request @@ -200,7 +200,7 @@ * @param string $id * @return boolean true */ - public function destroy($id) + public function destroy(string $id): bool { $dbh = $this->_connect(); $table = $this->_table; @@ -218,7 +218,7 @@ * @param int $maxlifetime session's time to live. * @return boolean true */ - public function gc($maxlifetime) + public function gc(int $maxlifetime): bool { $dbh = $this->_connect(); $table = $this->_table; @@ -232,7 +232,7 @@ // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API - public function currentSessions() + public function currentSessions(): array { $sessions = array(); $dbh = $this->_connect(); Modified: trunk/lib/DbSession/dba.php =================================================================== --- trunk/lib/DbSession/dba.php 2023-07-14 11:16:48 UTC (rev 11054) +++ trunk/lib/DbSession/dba.php 2023-07-14 11:23:14 UTC (rev 11055) @@ -26,7 +26,7 @@ * session: * Index: session_id * Values: date : IP : data - * Already open sessions, e.g. interim xmlrpc requests are + * Already open sessions, e.g. interim xmlrpc requests * are treated specially. see write(). * To avoid deadlocks in the session.db3 access, * the db is opened and closed for each access. @@ -35,7 +35,7 @@ class DbSession_dba extends DbSession { - public $_backend_type = "dba"; + public string $_backend_type = "dba"; public function __construct($dbh, $table) { @@ -55,7 +55,7 @@ return $string; } - public function query($sql) + public function query($sql): bool { return false; } @@ -94,7 +94,7 @@ * @return boolean true just a variable to notify PHP that everything * is good. */ - public function open($save_path, $session_name) + public function open(string $save_path, string $session_name): bool { $dbh = $this->_connect(); $dbh->open(); @@ -109,7 +109,7 @@ * @return boolean true just a variable to notify PHP that everything * is good. */ - public function close() + public function close(): bool { $this->_disconnect(); return true; @@ -121,7 +121,7 @@ * @param string $id an id of current session * @return string */ - public function read($id) + public function read(string $id): string { $dbh = $this->_connect(); $result = $dbh->get($id); @@ -153,7 +153,7 @@ * @return boolean true if data saved successfully and false * otherwise. */ - public function write($id, $sess_data) + public function write(string $id, string $sess_data): bool { /** * @var WikiRequest $request @@ -176,7 +176,7 @@ return true; } - public function destroy($id) + public function destroy($id): bool { $dbh = $this->_connect(); $dbh->delete($id); @@ -190,7 +190,7 @@ * @param int $maxlifetime session's time to live. * @return boolean true */ - public function gc($maxlifetime) + public function gc(int $maxlifetime): bool { $dbh = $this->_connect(); $threshold = time() - $maxlifetime; @@ -209,7 +209,7 @@ // WhoIsOnline support // TODO: ip-accesstime dynamic blocking API - public function currentSessions() + public function currentSessions(): array { $sessions = array(); $dbh = $this->_connect(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |