diff options
author | kondou <kondou@ts.unde.re> | 2013-09-02 07:58:06 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2013-09-02 07:58:06 +0200 |
commit | e5fc7b9dbeb01ac116bb132903c562c8f7d3c5b3 (patch) | |
tree | b7d8d913cdf7f4d1ce42f3027918ad0f5fbe5c3b /lib/base.php | |
parent | 8dd93c8c0288a11f04816bea2a58aee661ef9e97 (diff) | |
parent | f038cb9aea7c9a1513ab14d0df002773b17d5333 (diff) | |
download | nextcloud-server-e5fc7b9dbeb01ac116bb132903c562c8f7d3c5b3.tar.gz nextcloud-server-e5fc7b9dbeb01ac116bb132903c562c8f7d3c5b3.zip |
Merge branch 'master' into clean_up_util
Conflicts:
lib/base.php
Diffstat (limited to 'lib/base.php')
-rw-r--r-- | lib/base.php | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/lib/base.php b/lib/base.php index a59fe8b7a48..fe160f73652 100644 --- a/lib/base.php +++ b/lib/base.php @@ -257,20 +257,22 @@ class OC { 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("octemplate"); OC_Util::addScript("eventsource"); OC_Util::addScript("config"); //OC_Util::addScript( "multiselect" ); OC_Util::addScript('search', 'result'); OC_Util::addScript('router'); + OC_Util::addScript("oc-requesttoken"); OC_Util::addStyle("styles"); + OC_Util::addStyle("apps"); + OC_Util::addStyle("fixes"); 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"); } public static function initSession() { @@ -490,7 +492,9 @@ class OC { self::registerCacheHooks(); self::registerFilesystemHooks(); + self::registerPreviewHooks(); self::registerShareHooks(); + self::registerLogRotate(); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper', 'cleanTmp')); @@ -553,6 +557,21 @@ class OC { } /** + * register hooks for the cache + */ + public static function registerLogRotate() { + if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', 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\Log\Rotate', OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log'); + } catch (Exception $e) { + + } + } + } + + /** * register hooks for the filesystem */ public static function registerFilesystemHooks() { @@ -562,6 +581,14 @@ class OC { } /** + * register hooks for previews + */ + public static function registerPreviewHooks() { + OC_Hook::connect('OC_Filesystem', 'post_write', 'OC\Preview', 'post_write'); + OC_Hook::connect('OC_Filesystem', 'delete', 'OC\Preview', 'post_delete'); + } + + /** * register hooks for sharing */ public static function registerShareHooks() { @@ -669,12 +696,15 @@ class OC { $app = $param['app']; $file = $param['file']; $app_path = OC_App::getAppPath($app); - $file = $app_path . '/' . $file; - unset($app, $app_path); - if (file_exists($file)) { - require_once $file; - return true; + if (OC_App::isEnabled($app) && $app_path !== false) { + $file = $app_path . '/' . $file; + unset($app, $app_path); + if (file_exists($file)) { + require_once $file; + return true; + } } + header('HTTP/1.0 404 Not Found'); return false; } @@ -772,14 +802,15 @@ class OC { self::$session->set('timezone', $_POST['timezone-offset']); } - self::cleanupLoginTokens($_POST['user']); + $userid = OC_User::getUser(); + self::cleanupLoginTokens($userid); if (!empty($_POST["remember_login"])) { if (defined("DEBUG") && DEBUG) { OC_Log::write('core', 'Setting remember login to cookie', OC_Log::DEBUG); } $token = OC_Util::generateRandomBytes(32); - OC_Preferences::setValue($_POST['user'], 'login_token', $token, time()); - OC_User::setMagicInCookie($_POST["user"], $token); + OC_Preferences::setValue($userid, 'login_token', $token, time()); + OC_User::setMagicInCookie($userid, $token); } else { OC_User::unsetMagicInCookie(); } @@ -795,11 +826,16 @@ class OC { ) { return false; } - OC_App::loadApps(array('authentication')); - if (OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) { - //OC_Log::write('core',"Logged in with HTTP Authentication", OC_Log::DEBUG); - OC_User::unsetMagicInCookie(); - $_SERVER['HTTP_REQUESTTOKEN'] = OC_Util::callRegister(); + // don't redo authentication if user is already logged in + // otherwise session would be invalidated in OC_User::login with + // session_regenerate_id at every page load + if (!OC_User::isLoggedIn()) { + OC_App::loadApps(array('authentication')); + if (OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) { + //OC_Log::write('core',"Logged in with HTTP Authentication", OC_Log::DEBUG); + OC_User::unsetMagicInCookie(); + $_SERVER['HTTP_REQUESTTOKEN'] = OC_Util::callRegister(); + } } return true; } |