|
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.
|