summaryrefslogtreecommitdiffstats
path: root/lib/base.php
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-06-14 10:06:13 +0200
committerThomas Mueller <thomas.mueller@tmit.eu>2013-06-14 10:06:13 +0200
commitc8564c07955ead3e85daa67e1871a2c41df3a6d5 (patch)
tree134c228f43e641d34fbf342df2745ece43580fee /lib/base.php
parent0a29d2029a719d42f347edb95bd6486c2ab842a8 (diff)
parent6c534c8165d3c3fba64e3cf5c05993a84733eef7 (diff)
downloadnextcloud-server-c8564c07955ead3e85daa67e1871a2c41df3a6d5.tar.gz
nextcloud-server-c8564c07955ead3e85daa67e1871a2c41df3a6d5.zip
Merge branch 'master' into move-maint-start
Conflicts: lib/util.php
Diffstat (limited to 'lib/base.php')
-rw-r--r--lib/base.php69
1 files changed, 45 insertions, 24 deletions
diff --git a/lib/base.php b/lib/base.php
index edd1860b652..26e9595e869 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -75,6 +75,11 @@ class OC {
protected static $router = null;
/**
+ * @var \OC\Session\Session
+ */
+ public static $session = null;
+
+ /**
* @var \OC\Autoloader $loader
*/
public static $loader = null;
@@ -250,13 +255,16 @@ class OC {
public static function initTemplateEngine() {
// Add the stuff we need always
- OC_Util::addScript("jquery-1.7.2.min");
+ OC_Util::addScript("jquery-1.10.0.min");
+ OC_Util::addScript("jquery-migrate-1.2.1.min");
OC_Util::addScript("jquery-ui-1.10.0.custom");
OC_Util::addScript("jquery-showpassword");
OC_Util::addScript("jquery.infieldlabel");
OC_Util::addScript("jquery-tipsy");
OC_Util::addScript("compatibility");
+ OC_Util::addScript("jquery.ocdialog");
OC_Util::addScript("oc-dialogs");
+ OC_Util::addScript("octemplate");
OC_Util::addScript("js");
OC_Util::addScript("eventsource");
OC_Util::addScript("config");
@@ -268,6 +276,7 @@ class OC {
OC_Util::addStyle("multiselect");
OC_Util::addStyle("jquery-ui-1.10.0.custom");
OC_Util::addStyle("jquery-tipsy");
+ OC_Util::addStyle("jquery.ocdialog");
OC_Util::addScript("oc-requesttoken");
}
@@ -279,14 +288,17 @@ class OC {
$cookie_path = OC::$WEBROOT ?: '/';
ini_set('session.cookie_path', $cookie_path);
- // set the session name to the instance id - which is unique
- session_name(OC_Util::getInstanceId());
+ try{
+ // set the session name to the instance id - which is unique
+ self::$session = new \OC\Session\Internal(OC_Util::getInstanceId());
+ // if session cant be started break with http 500 error
+ }catch (Exception $e){
+ //set the session object to a dummy session so code relying on the session existing still works
+ self::$session = new \OC\Session\Memory('');
- // if session cant be started break with http 500 error
- if (session_start() === false){
- OC_Log::write('core', 'Session could not be initialized',
+ OC_Log::write('core', 'Session could not be initialized',
OC_Log::ERROR);
-
+
header('HTTP/1.1 500 Internal Server Error');
OC_Util::addStyle("styles");
$error = 'Session could not be initialized. Please contact your ';
@@ -300,15 +312,15 @@ class OC {
}
// regenerate session id periodically to avoid session fixation
- if (!isset($_SESSION['SID_CREATED'])) {
- $_SESSION['SID_CREATED'] = time();
- } else if (time() - $_SESSION['SID_CREATED'] > 60*60*12) {
+ if (!self::$session->exists('SID_CREATED')) {
+ self::$session->set('SID_CREATED', time());
+ } else if (time() - self::$session->get('SID_CREATED') > 60*60*12) {
session_regenerate_id(true);
- $_SESSION['SID_CREATED'] = time();
+ self::$session->set('SID_CREATED', time());
}
// session timeout
- if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 60*60*24)) {
+ if (self::$session->exists('LAST_ACTIVITY') && (time() - self::$session->get('LAST_ACTIVITY') > 60*60*24)) {
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 42000, $cookie_path);
}
@@ -316,7 +328,8 @@ class OC {
session_destroy();
session_start();
}
- $_SESSION['LAST_ACTIVITY'] = time();
+
+ self::$session->set('LAST_ACTIVITY', time());
}
public static function getRouter() {
@@ -427,12 +440,14 @@ class OC {
stream_wrapper_register('oc', 'OC\Files\Stream\OC');
self::initTemplateEngine();
- self::checkConfig();
- self::checkInstalled();
- self::checkSSL();
if ( !self::$CLI ) {
self::initSession();
+ } else {
+ self::$session = new \OC\Session\Memory('');
}
+ self::checkConfig();
+ self::checkInstalled();
+ self::checkSSL();
$errors = OC_Util::checkServer();
if (count($errors) > 0) {
@@ -442,14 +457,14 @@ class OC {
// User and Groups
if (!OC_Config::getValue("installed", false)) {
- $_SESSION['user_id'] = '';
+ self::$session->set('user_id','');
}
OC_User::useBackend(new OC_User_Database());
OC_Group::useBackend(new OC_Group_Database());
- if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SESSION['user_id'])
- && $_SERVER['PHP_AUTH_USER'] != $_SESSION['user_id']) {
+ if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('user_id')
+ && $_SERVER['PHP_AUTH_USER'] != self::$session->get('user_id')) {
OC_User::logout();
}
@@ -521,9 +536,15 @@ class OC {
* register hooks for the cache
*/
public static function registerCacheHooks() {
- // register cache cleanup jobs
- OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
- OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
+ if (OC_Config::getValue('installed', false)) { //don't try to do this before we are properly setup
+ // register cache cleanup jobs
+ try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception
+ \OCP\BackgroundJob::registerJob('OC_Cache_FileGlobalGC');
+ } catch (Exception $e) {
+
+ }
+ OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
+ }
}
/**
@@ -594,7 +615,7 @@ class OC {
// Handle redirect URL for logged in users
if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
$location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
-
+
// Deny the redirect if the URL contains a @
// This prevents unvalidated redirects like ?redirect_url=:user@domain.com
if (strpos($location, '@') === false) {
@@ -744,7 +765,7 @@ class OC {
if (OC_User::login($_POST["user"], $_POST["password"])) {
// setting up the time zone
if (isset($_POST['timezone-offset'])) {
- $_SESSION['timezone'] = $_POST['timezone-offset'];
+ self::$session->set('timezone', $_POST['timezone-offset']);
}
self::cleanupLoginTokens($_POST['user']);