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:
Diffstat (limited to 'core/Session.php')
-rw-r--r--core/Session.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/core/Session.php b/core/Session.php
new file mode 100644
index 0000000000..d4f11e9ef9
--- /dev/null
+++ b/core/Session.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
+ * @version $Id$
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+
+/**
+ * Session initialization.
+ *
+ * @package Piwik
+ */
+class Piwik_Session extends Zend_Session
+{
+ public static function start($options = false)
+ {
+ // don't use the default: PHPSESSID
+ $sessionName = defined('PIWIK_SESSION_NAME') ? PIWIK_SESSION_NAME : 'PIWIK_SESSID';
+ @ini_set('session.name', $sessionName);
+
+ // we consider this a misconfiguration (i.e., Piwik doesn't implement user-defined session handler functions)
+ if(ini_get('session.save_handler') == 'user')
+ {
+ @ini_set('session.save_handler', 'files');
+ @ini_set('session.save_path', '');
+ }
+
+ // for "files", we want a writeable folder
+ if(ini_get('session.save_handler') == 'files')
+ {
+ $sessionPath = ini_get('session.save_path');
+ if(preg_match('/^[0-9]+;(.*)/', $sessionPath, $matches))
+ {
+ $sessionPath = $matches[1];
+ }
+ if(ini_get('safe_mode') || ini_get('open_basedir') || empty($sessionPath) || !@is_writable($sessionPath))
+ {
+ $sessionPath = PIWIK_USER_PATH . '/tmp/sessions';
+
+ if(!is_dir($sessionPath))
+ {
+ @mkdir($sessionPath, 0755, true);
+ if(!is_dir($sessionPath))
+ {
+ die("Error: Unable to mkdir $sessionPath");
+ }
+ }
+ else if(!@is_writable($sessionPath))
+ {
+ die("Error: $sessionPath is not writable");
+ }
+
+ @ini_set('session.save_path', $sessionPath);
+ }
+ }
+
+ Zend_Session::start();
+ }
+}