summaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php102
1 files changed, 59 insertions, 43 deletions
diff --git a/lib/util.php b/lib/util.php
index ab47e404c97..d8adfd99a47 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -75,7 +75,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, 93, 10);
+ return array(4, 97, 10);
}
/**
@@ -83,7 +83,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '5.0 beta 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" );
@@ -211,80 +211,81 @@ 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));
}
// 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.');
}
@@ -308,7 +309,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);
}
}
@@ -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;
}
@@ -564,13 +569,21 @@ class OC_Util {
if (!function_exists('curl_init')) {
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
@@ -582,6 +595,9 @@ class OC_Util {
$return = false;
}
+ // restore the original timeout
+ ini_set("default_socket_timeout", $old_timeout);
+
return $return;
}