diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-05-21 23:35:19 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-05-21 23:35:19 +0200 |
commit | 81fd1badc3feb72c3a4e597c670e8adcdca525da (patch) | |
tree | dda3deee50551ebdffa8a9021b528ac29fdbf369 /lib/util.php | |
parent | d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2 (diff) | |
parent | fb4d8ddf0a76da7e9f806b837f9cf23699671f75 (diff) | |
download | nextcloud-server-81fd1badc3feb72c3a4e597c670e8adcdca525da.tar.gz nextcloud-server-81fd1badc3feb72c3a4e597c670e8adcdca525da.zip |
merge master into filecache_mtime
Diffstat (limited to 'lib/util.php')
-rwxr-xr-x | lib/util.php | 105 |
1 files changed, 71 insertions, 34 deletions
diff --git a/lib/util.php b/lib/util.php index 6ed3b8b942f..48c224a3034 100755 --- a/lib/util.php +++ b/lib/util.php @@ -38,6 +38,7 @@ class OC_Util { $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); //first set up the local "root" storage + \OC\Files\Filesystem::initMounts(); if(!self::$rootMounted) { \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', array('datadir'=>$CONFIG_DATADIRECTORY), '/'); self::$rootMounted=true; @@ -66,6 +67,7 @@ class OC_Util { public static function tearDownFS() { \OC\Files\Filesystem::tearDown(); self::$fsSetup=false; + self::$rootMounted=false; } /** @@ -75,7 +77,7 @@ class OC_Util { public static function getVersion() { // hint: We only can count up. Reset minor/patchlevel when // updating major/minor version number. - return array(4, 97, 11); + return array(5, 80, 03); } /** @@ -83,7 +85,7 @@ class OC_Util { * @return string */ public static function getVersionString() { - return '5.0 RC 3'; + return '6.0 pre alpha'; } /** @@ -211,7 +213,7 @@ class OC_Util { ."'chown -R www-data:www-data /path/to/your/owncloud/install/data' "); } } else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { - $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud<br/>', + $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud', 'hint'=>$permissionsHint); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); @@ -220,68 +222,76 @@ class OC_Util { if(!class_exists('ZipArchive')) { $errors[]=array('error'=>'PHP module zip not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(!class_exists('DOMDocument')) { $errors[] = array('error' => 'PHP module dom not installed.', 'hint' => 'Please ask your server administrator to install the module.'); - $web_server_restart = false; + $web_server_restart =true; } if(!function_exists('xml_parser_create')) { $errors[] = array('error' => 'PHP module libxml not installed.', 'hint' => 'Please ask your server administrator to install the module.'); - $web_server_restart = false; + $web_server_restart =true; } if(!function_exists('mb_detect_encoding')) { $errors[]=array('error'=>'PHP module mb multibyte not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(!function_exists('ctype_digit')) { $errors[]=array('error'=>'PHP module ctype is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(!function_exists('json_encode')) { $errors[]=array('error'=>'PHP module JSON is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } - if(!function_exists('imagepng')) { + if(!extension_loaded('gd') || !function_exists('gd_info')) { $errors[]=array('error'=>'PHP module GD is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(!function_exists('gzencode')) { $errors[]=array('error'=>'PHP module zlib is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(!function_exists('iconv')) { $errors[]=array('error'=>'PHP module iconv is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(!function_exists('simplexml_load_string')) { $errors[]=array('error'=>'PHP module SimpleXML is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } if(floatval(phpversion())<5.3) { $errors[]=array('error'=>'PHP 5.3 is required.', 'hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher.' .' PHP 5.2 is no longer supported by ownCloud and the PHP community.'); - $web_server_restart= false; + $web_server_restart=true; } if(!defined('PDO::ATTR_DRIVER_NAME')) { $errors[]=array('error'=>'PHP PDO module is not installed.', 'hint'=>'Please ask your server administrator to install the module.'); - $web_server_restart= false; + $web_server_restart=true; } - if(ini_get('safe_mode')) { + if (((strtolower(@ini_get('safe_mode')) == 'on') + || (strtolower(@ini_get('safe_mode')) == 'yes') + || (strtolower(@ini_get('safe_mode')) == 'true') + || (ini_get("safe_mode") == 1 ))) { $errors[]=array('error'=>'PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.', 'hint'=>'PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. Please ask your server administrator to disable it in php.ini or in your webserver config.'); - $web_server_restart= false; + $web_server_restart=true; + } + if (get_magic_quotes_gpc() == 1 ) { + $errors[]=array('error'=>'Magic Quotes is enabled. ownCloud requires that it is disabled to work properly.', + 'hint'=>'Magic Quotes is a deprecated and mostly useless setting that should be disabled. Please ask your server administrator to disable it in php.ini or in your webserver config.'); + $web_server_restart=true; } if($web_server_restart) { @@ -309,7 +319,7 @@ class OC_Util { clearstatcache(); $prems = substr(decoct(@fileperms($dataDirectory)), -3); if (substr($prems, 2, 1) != '0') { - $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users<br/>', + $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users', 'hint' => $permissionsModHint); } } @@ -408,18 +418,19 @@ class OC_Util { exit(); } - /** - * get an id unqiue for this instance - * @return string - */ - public static function getInstanceId() { - $id=OC_Config::getValue('instanceid', null); - if(is_null($id)) { - $id=uniqid(); - OC_Config::setValue('instanceid', $id); - } - return $id; - } + /** + * get an id unique for this instance + * @return string + */ + public static function getInstanceId() { + $id = OC_Config::getValue('instanceid', null); + if(is_null($id)) { + // We need to guarantee at least one letter in instanceid so it can be used as the session_name + $id = 'oc' . OC_Util::generate_random_bytes(10); + OC_Config::setValue('instanceid', $id); + } + return $id; + } /** * @brief Static lifespan (in seconds) when a request token expires. @@ -591,7 +602,7 @@ class OC_Util { } catch(\Sabre_DAV_Exception_NotAuthenticated $e) { $return = true; } catch(\Exception $e) { - OC_Log::write('core', 'isWebDAVWorking: NO - Reason: '.$e, OC_Log::WARN); + OC_Log::write('core', 'isWebDAVWorking: NO - Reason: '.$e->getMessage(). ' ('.get_class($e).')', OC_Log::WARN); $return = false; } @@ -614,8 +625,8 @@ class OC_Util { $result = setlocale(LC_ALL, 'en_US.UTF-8', 'en_US.UTF8'); if($result == false) { return false; - } - return true; + } + return true; } /** @@ -631,6 +642,11 @@ class OC_Util { */ public static function isinternetconnectionworking() { + // in case there is no internet connection on purpose there is no need to display a warning + if (!\OC_Config::getValue("has_internet_connection", true)) { + return true; + } + // try to connect to owncloud.org to see if http connections to the internet are possible. $connected = @fsockopen("www.owncloud.org", 80); if ($connected) { @@ -786,4 +802,25 @@ class OC_Util { return (substr(PHP_OS, 0, 3) === "WIN"); } + + /** + * Handles the case that there may not be a theme, then check if a "default" + * theme exists and take that one + * @return string the theme + */ + public static function getTheme() { + $theme = OC_Config::getValue("theme"); + + if(is_null($theme)) { + + if(is_dir(OC::$SERVERROOT . '/themes/default')) { + $theme = 'default'; + } + + } + + return $theme; + } + + } |