Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-03-28 03:42:39 +0400
committermattab <matthieu.aubry@gmail.com>2013-03-28 03:42:40 +0400
commitae4b03163792f0b6e933933e5d37df87dc3fd566 (patch)
treed1d7510a9728f587d3d63ebd03e4ecf3d904838b /core/Session
parent158c2150f5f2e13ece459b8d131244c11b763997 (diff)
Mass conversion of all files to the newly agreed coding standard: PSR 1/2
Converting Piwik core source files, PHP, JS, TPL, CSS More info: http://piwik.org/participate/coding-standards/
Diffstat (limited to 'core/Session')
-rw-r--r--core/Session/Namespace.php31
-rw-r--r--core/Session/SaveHandler/DbTable.php246
2 files changed, 138 insertions, 139 deletions
diff --git a/core/Session/Namespace.php b/core/Session/Namespace.php
index 582363de4c..3c18aa06db 100644
--- a/core/Session/Namespace.php
+++ b/core/Session/Namespace.php
@@ -1,34 +1,33 @@
<?php
/**
* Piwik - Open source web analytics
- *
+ *
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
+ *
* @category Piwik
* @package Piwik
*/
/**
* Session namespace.
- *
+ *
* @package Piwik
* @subpackage Piwik_Session
*/
class Piwik_Session_Namespace extends Zend_Session_Namespace
{
- /**
- * @param string $namespace
- * @param bool $singleInstance
- */
- public function __construct($namespace = 'Default', $singleInstance = false)
- {
- if(Piwik_Common::isPhpCliMode())
- {
- self::$_readable = true;
- return;
- }
+ /**
+ * @param string $namespace
+ * @param bool $singleInstance
+ */
+ public function __construct($namespace = 'Default', $singleInstance = false)
+ {
+ if (Piwik_Common::isPhpCliMode()) {
+ self::$_readable = true;
+ return;
+ }
- parent::__construct($namespace, $singleInstance);
- }
+ parent::__construct($namespace, $singleInstance);
+ }
}
diff --git a/core/Session/SaveHandler/DbTable.php b/core/Session/SaveHandler/DbTable.php
index 7582d0ef19..df00a920ea 100644
--- a/core/Session/SaveHandler/DbTable.php
+++ b/core/Session/SaveHandler/DbTable.php
@@ -17,127 +17,127 @@
*/
class Piwik_Session_SaveHandler_DbTable implements Zend_Session_SaveHandler_Interface
{
- protected $config;
- protected $maxLifetime;
-
- /**
- * @param array $config
- */
- function __construct($config)
- {
- $this->config = $config;
- $this->maxLifetime = ini_get('session.gc_maxlifetime');
- }
-
- /**
- * Destructor
- *
- * @return void
- */
- public function __destruct()
- {
- Zend_Session::writeClose();
- }
-
- /**
- * Open Session - retrieve resources
- *
- * @param string $save_path
- * @param string $name
- * @return boolean
- */
- public function open($save_path, $name)
- {
- $this->config['db']->getConnection();
-
- return true;
- }
-
- /**
- * Close Session - free resources
- *
- * @return boolean
- */
- public function close()
- {
- return true;
- }
-
- /**
- * Read session data
- *
- * @param string $id
- * @return string
- */
- public function read($id)
- {
- $sql = 'SELECT '.$this->config['dataColumn'].' FROM '.$this->config['name']
- .' WHERE '.$this->config['primary'].' = ?'
- .' AND '.$this->config['modifiedColumn'].' + '.$this->config['lifetimeColumn'].' >= ?';
-
- $result = $this->config['db']->fetchOne($sql, array($id, time()));
- if(!$result)
- $result = '';
-
- return $result;
- }
-
- /**
- * Write Session - commit data to resource
- *
- * @param string $id
- * @param mixed $data
- * @return boolean
- */
- public function write($id, $data)
- {
- $sql = 'INSERT INTO '.$this->config['name']
- .' ('.$this->config['primary'].','
- .$this->config['modifiedColumn'].','
- .$this->config['lifetimeColumn'].','
- .$this->config['dataColumn'].')'
- .' VALUES (?,?,?,?)'
- .' ON DUPLICATE KEY UPDATE '
- .$this->config['modifiedColumn'].' = ?,'
- .$this->config['lifetimeColumn'].' = ?,'
- .$this->config['dataColumn'].' = ?';
-
- $this->config['db']->query($sql, array($id, time(), $this->maxLifetime, $data, time(), $this->maxLifetime, $data));
-
- return true;
- }
-
- /**
- * Destroy Session - remove data from resource for
- * given session id
- *
- * @param string $id
- * @return boolean
- */
- public function destroy($id)
- {
- $sql = 'DELETE FROM '.$this->config['name']
- .' WHERE '.$this->config['primary'].' = ?';
-
- $this->config['db']->query($sql, array($id));
-
- return true;
- }
-
- /**
- * Garbage Collection - remove old session data older
- * than $maxlifetime (in seconds)
- *
- * @param int $maxlifetime timestamp in seconds
- * @return true
- */
- public function gc($maxlifetime)
- {
- $sql = 'DELETE FROM '.$this->config['name']
- .' WHERE '.$this->config['modifiedColumn'].' + '.$this->config['lifetimeColumn'].' < ?';
-
- $this->config['db']->query($sql, array(time()));
-
- return true;
- }
+ protected $config;
+ protected $maxLifetime;
+
+ /**
+ * @param array $config
+ */
+ function __construct($config)
+ {
+ $this->config = $config;
+ $this->maxLifetime = ini_get('session.gc_maxlifetime');
+ }
+
+ /**
+ * Destructor
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ Zend_Session::writeClose();
+ }
+
+ /**
+ * Open Session - retrieve resources
+ *
+ * @param string $save_path
+ * @param string $name
+ * @return boolean
+ */
+ public function open($save_path, $name)
+ {
+ $this->config['db']->getConnection();
+
+ return true;
+ }
+
+ /**
+ * Close Session - free resources
+ *
+ * @return boolean
+ */
+ public function close()
+ {
+ return true;
+ }
+
+ /**
+ * Read session data
+ *
+ * @param string $id
+ * @return string
+ */
+ public function read($id)
+ {
+ $sql = 'SELECT ' . $this->config['dataColumn'] . ' FROM ' . $this->config['name']
+ . ' WHERE ' . $this->config['primary'] . ' = ?'
+ . ' AND ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' >= ?';
+
+ $result = $this->config['db']->fetchOne($sql, array($id, time()));
+ if (!$result)
+ $result = '';
+
+ return $result;
+ }
+
+ /**
+ * Write Session - commit data to resource
+ *
+ * @param string $id
+ * @param mixed $data
+ * @return boolean
+ */
+ public function write($id, $data)
+ {
+ $sql = 'INSERT INTO ' . $this->config['name']
+ . ' (' . $this->config['primary'] . ','
+ . $this->config['modifiedColumn'] . ','
+ . $this->config['lifetimeColumn'] . ','
+ . $this->config['dataColumn'] . ')'
+ . ' VALUES (?,?,?,?)'
+ . ' ON DUPLICATE KEY UPDATE '
+ . $this->config['modifiedColumn'] . ' = ?,'
+ . $this->config['lifetimeColumn'] . ' = ?,'
+ . $this->config['dataColumn'] . ' = ?';
+
+ $this->config['db']->query($sql, array($id, time(), $this->maxLifetime, $data, time(), $this->maxLifetime, $data));
+
+ return true;
+ }
+
+ /**
+ * Destroy Session - remove data from resource for
+ * given session id
+ *
+ * @param string $id
+ * @return boolean
+ */
+ public function destroy($id)
+ {
+ $sql = 'DELETE FROM ' . $this->config['name']
+ . ' WHERE ' . $this->config['primary'] . ' = ?';
+
+ $this->config['db']->query($sql, array($id));
+
+ return true;
+ }
+
+ /**
+ * Garbage Collection - remove old session data older
+ * than $maxlifetime (in seconds)
+ *
+ * @param int $maxlifetime timestamp in seconds
+ * @return true
+ */
+ public function gc($maxlifetime)
+ {
+ $sql = 'DELETE FROM ' . $this->config['name']
+ . ' WHERE ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' < ?';
+
+ $this->config['db']->query($sql, array(time()));
+
+ return true;
+ }
}