summaryrefslogtreecommitdiffstats
path: root/lib/base.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-05-22 20:22:53 +0200
committerRobin Appelman <icewind@owncloud.com>2012-05-22 20:22:53 +0200
commit60fdc13ae60a4d1bb62cbf29a8ab4b5ac1159709 (patch)
treeffa7d3e4e133da17c08106048088bf8c1e147d89 /lib/base.php
parent27f7dae9325a00ca19a25d56370729b475c5946e (diff)
downloadnextcloud-server-60fdc13ae60a4d1bb62cbf29a8ab4b5ac1159709.tar.gz
nextcloud-server-60fdc13ae60a4d1bb62cbf29a8ab4b5ac1159709.zip
enable running unit tests from cli
Diffstat (limited to 'lib/base.php')
-rw-r--r--lib/base.php25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/base.php b/lib/base.php
index fb2d978f449..f3d6689fa2e 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -79,6 +79,10 @@ class OC{
*/
public static $REQUESTEDFILE = '';
/**
+ * check if owncloud runs in cli mode
+ */
+ public static $CLI = false;
+ /**
* SPL autoload
*/
public static function autoload($className){
@@ -320,6 +324,7 @@ class OC{
if (defined('DEBUG') && DEBUG){
ini_set('display_errors', 1);
}
+ self::$CLI=(php_sapi_name() == 'cli');
date_default_timezone_set('Europe/Berlin');
ini_set('arg_separator.output','&amp;');
@@ -369,15 +374,17 @@ class OC{
self::checkInstalled();
self::checkSSL();
- // CSRF protection
- if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer='';
- if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']<>'') $protocol='https://'; else $protocol='http://';
- $server=$protocol.$_SERVER['SERVER_NAME'];
- if(($_SERVER['REQUEST_METHOD']=='POST') and (substr($referer,0,strlen($server))<>$server)) {
- $url = $protocol.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
- header("Location: $url");
- exit();
- }
+ // CSRF protection
+ if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer='';
+ if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']<>'') $protocol='https://'; else $protocol='http://';
+ if(!self::$CLI){
+ $server=$protocol.$_SERVER['SERVER_NAME'];
+ if(($_SERVER['REQUEST_METHOD']=='POST') and (substr($referer,0,strlen($server))<>$server)) {
+ $url = $protocol.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
+ header("Location: $url");
+ exit();
+ }
+ }
self::initSession();
self::initTemplateEngine();