summaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-03-08 15:28:45 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2013-03-08 15:28:45 -0500
commitd7beac6d6f3ad588cee6c5ba8a2145b42fa184a2 (patch)
tree613f576938ee8ef88a5a93304a824f60fbb85a7a /lib/util.php
parent2ed850e05b46d820528813c2f2415dad60c1c570 (diff)
parent546fb72b25fb8ebdc70aa75ccc7a095d7d83b174 (diff)
downloadnextcloud-server-d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2.tar.gz
nextcloud-server-d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2.zip
Merge branch 'master' into filecache_mtime
Conflicts: lib/files/view.php lib/util.php tests/lib/files/cache/cache.php
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php105
1 files changed, 61 insertions, 44 deletions
diff --git a/lib/util.php b/lib/util.php
index e739f76034c..6ed3b8b942f 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -73,9 +73,9 @@ class OC_Util {
* @return array
*/
public static function getVersion() {
- // hint: We only can count up. So the internal version number
- // of ownCloud 4.5 will be 4.90.0. This is not visible to the user
- return array(4, 92, 11);
+ // hint: We only can count up. Reset minor/patchlevel when
+ // updating major/minor version number.
+ return array(4, 97, 11);
}
/**
@@ -83,7 +83,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '5.0 alpha 1';
+ return '5.0 RC 3';
}
/**
@@ -172,20 +172,20 @@ class OC_Util {
if(!(is_callable('sqlite_open') or class_exists('SQLite3'))
and !is_callable('mysql_connect')
and !is_callable('pg_connect')) {
- $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.<br/>',
+ $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.',
'hint'=>'');//TODO: sane hint
$web_server_restart= true;
}
//common hint for all file permissons error messages
- $permissionsHint="Permissions can usually be fixed by giving the webserver write access'
- .' to the ownCloud directory";
+ $permissionsHint='Permissions can usually be fixed by giving the webserver write access'
+ .' to the ownCloud directory';
// Check if config folder is writable.
if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) {
$errors[]=array('error'=>"Can't write into config directory 'config'",
- 'hint'=>"You can usually fix this by giving the webserver user write access'
- .' to the config directory in owncloud");
+ 'hint'=>'You can usually fix this by giving the webserver user write access'
+ .' to the config directory in owncloud');
}
// Check if there is a writable install folder.
@@ -194,8 +194,8 @@ class OC_Util {
|| !is_writable(OC_App::getInstallPath())
|| !is_readable(OC_App::getInstallPath()) ) {
$errors[]=array('error'=>"Can't write into apps directory",
- 'hint'=>"You can usually fix this by giving the webserver user write access'
- .' to the apps directory in owncloud or disabling the appstore in the config file.");
+ 'hint'=>'You can usually fix this by giving the webserver user write access'
+ .' to the apps directory in owncloud or disabling the appstore in the config file.');
}
}
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
@@ -218,73 +218,74 @@ class OC_Util {
}
// check if all required php modules are present
if(!class_exists('ZipArchive')) {
- $errors[]=array('error'=>'PHP module zip not installed.<br/>',
+ $errors[]=array('error'=>'PHP module zip not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
-
+ 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;
+ }
+ 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;
+ }
if(!function_exists('mb_detect_encoding')) {
- $errors[]=array('error'=>'PHP module mb multibyte not installed.<br/>',
+ $errors[]=array('error'=>'PHP module mb multibyte not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('ctype_digit')) {
- $errors[]=array('error'=>'PHP module ctype is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module ctype is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('json_encode')) {
- $errors[]=array('error'=>'PHP module JSON is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module JSON is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('imagepng')) {
- $errors[]=array('error'=>'PHP module GD is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module GD is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('gzencode')) {
- $errors[]=array('error'=>'PHP module zlib is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module zlib is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('iconv')) {
- $errors[]=array('error'=>'PHP module iconv is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module iconv is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('simplexml_load_string')) {
- $errors[]=array('error'=>'PHP module SimpleXML is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module SimpleXML is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(floatval(phpversion())<5.3) {
- $errors[]=array('error'=>'PHP 5.3 is required.<br/>',
+ $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;
}
if(!defined('PDO::ATTR_DRIVER_NAME')) {
- $errors[]=array('error'=>'PHP PDO module is not installed.<br/>',
+ $errors[]=array('error'=>'PHP PDO module is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
-
- $handler = ini_get("session.save_handler");
- if($handler == "files") {
- $tmpDir = session_save_path();
- if($tmpDir != "") {
- if(!@is_writable($tmpDir)) {
- $errors[]=array('error' => 'The temporary folder used by PHP to save the session data'
- .' is either incorrect or not writable! Please check : '.session_save_path().'<br/>',
- 'hint'=>'Please ask your server administrator to grant write access'
- .' or define another temporary folder.');
- }
- }
+ if(ini_get('safe_mode')) {
+ $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;
}
if($web_server_restart) {
- $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?<br/>',
+ $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?',
'hint'=>'Please ask your server administrator to restart the web server.');
}
@@ -322,14 +323,14 @@ class OC_Util {
$parameters[$value] = true;
}
if (!empty($_POST['user'])) {
- $parameters["username"] = OC_Util::sanitizeHTML($_POST['user']).'"';
+ $parameters["username"] = $_POST['user'];
$parameters['user_autofocus'] = false;
} else {
$parameters["username"] = '';
$parameters['user_autofocus'] = true;
}
if (isset($_REQUEST['redirect_url'])) {
- $redirect_url = OC_Util::sanitizeHTML($_REQUEST['redirect_url']);
+ $redirect_url = $_REQUEST['redirect_url'];
$parameters['redirect_url'] = urlencode($redirect_url);
}
@@ -463,13 +464,17 @@ class OC_Util {
* @see OC_Util::callRegister()
*/
public static function isCallRegistered() {
+ if(!isset($_SESSION['requesttoken'])) {
+ return false;
+ }
+
if(isset($_GET['requesttoken'])) {
$token=$_GET['requesttoken'];
- }elseif(isset($_POST['requesttoken'])) {
+ } elseif(isset($_POST['requesttoken'])) {
$token=$_POST['requesttoken'];
- }elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])) {
+ } elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])) {
$token=$_SERVER['HTTP_REQUESTTOKEN'];
- }else{
+ } else {
//no token found.
return false;
}
@@ -504,10 +509,10 @@ class OC_Util {
* @return array with sanitized strings or a single sanitized string, depends on the input parameter.
*/
public static function sanitizeHTML( &$value ) {
- if (is_array($value) || is_object($value)) {
+ if (is_array($value)) {
array_walk_recursive($value, 'OC_Util::sanitizeHTML');
} else {
- $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4
+ $value = htmlentities((string)$value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4
}
return $value;
}
@@ -562,15 +567,23 @@ class OC_Util {
*/
public static function isWebDAVWorking() {
if (!function_exists('curl_init')) {
- return;
+ return true;
}
-
$settings = array(
'baseUri' => OC_Helper::linkToRemote('webdav'),
);
+ // save the old timeout so that we can restore it later
+ $old_timeout=ini_get("default_socket_timeout");
+
+ // use a 5 sec timeout for the check. Should be enough for local requests.
+ ini_set("default_socket_timeout", 5);
+
$client = new \Sabre_DAV_Client($settings);
+ // for this self test we don't care if the ssl certificate is self signed and the peer cannot be verified.
+ $client->setVerifyPeer(false);
+
$return = true;
try {
// test PROPFIND
@@ -578,9 +591,13 @@ 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);
$return = false;
}
+ // restore the original timeout
+ ini_set("default_socket_timeout", $old_timeout);
+
return $return;
}