summaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-06-02 20:12:44 +0200
committerRobin Appelman <icewind@owncloud.com>2013-06-02 20:12:44 +0200
commit251527c6e65a5f88b56c2dbcfebb7d8dbe38d8fb (patch)
treeedcdac4b814573dad6fb8d47ce4af6f93bd7836d /lib/util.php
parentb7585050b565ac8f42c3afa625037adaf1a8d92c (diff)
parentcf71a54f5d6e08020a1a574d43f7fca6642776c9 (diff)
downloadnextcloud-server-251527c6e65a5f88b56c2dbcfebb7d8dbe38d8fb.tar.gz
nextcloud-server-251527c6e65a5f88b56c2dbcfebb7d8dbe38d8fb.zip
merge master into backgroundjob
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php110
1 files changed, 82 insertions, 28 deletions
diff --git a/lib/util.php b/lib/util.php
index b3fab5041f2..95af22ed0ee 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -1,4 +1,7 @@
<?php
+
+require_once 'Patchwork/PHP/Shim/Normalizer.php';
+
/**
* Class for utility functions
*
@@ -38,6 +41,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 +70,7 @@ class OC_Util {
public static function tearDownFS() {
\OC\Files\Filesystem::tearDown();
self::$fsSetup=false;
+ self::$rootMounted=false;
}
/**
@@ -75,7 +80,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(5, 80, 03);
+ return array(5, 80, 05);
}
/**
@@ -149,10 +154,10 @@ class OC_Util {
* @param bool dateOnly option to omit time from the result
*/
public static function formatDate( $timestamp, $dateOnly=false) {
- if(isset($_SESSION['timezone'])) {//adjust to clients timezone if we know it
+ if(\OC::$session->exists('timezone')) {//adjust to clients timezone if we know it
$systemTimeZone = intval(date('O'));
$systemTimeZone=(round($systemTimeZone/100, 0)*60)+($systemTimeZone%100);
- $clientTimeZone=$_SESSION['timezone']*60;
+ $clientTimeZone=\OC::$session->get('timezone')*60;
$offset=$clientTimeZone-$systemTimeZone;
$timestamp=$timestamp+$offset*60;
}
@@ -171,7 +176,8 @@ class OC_Util {
//check for database drivers
if(!(is_callable('sqlite_open') or class_exists('SQLite3'))
and !is_callable('mysql_connect')
- and !is_callable('pg_connect')) {
+ and !is_callable('pg_connect')
+ and !is_callable('oci_connect')) {
$errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.',
'hint'=>'');//TODO: sane hint
$web_server_restart= true;
@@ -220,63 +226,63 @@ 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 (((strtolower(@ini_get('safe_mode')) == 'on')
|| (strtolower(@ini_get('safe_mode')) == 'yes')
@@ -284,7 +290,12 @@ class OC_Util {
|| (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) {
@@ -450,13 +461,13 @@ class OC_Util {
*/
public static function callRegister() {
// Check if a token exists
- if(!isset($_SESSION['requesttoken'])) {
+ if(!\OC::$session->exists('requesttoken')) {
// No valid token found, generate a new one.
$requestToken = self::generate_random_bytes(20);
- $_SESSION['requesttoken']=$requestToken;
+ \OC::$session->set('requesttoken', $requestToken);
} else {
// Valid token already exists, send it
- $requestToken = $_SESSION['requesttoken'];
+ $requestToken = \OC::$session->get('requesttoken');
}
return($requestToken);
}
@@ -468,7 +479,7 @@ class OC_Util {
* @see OC_Util::callRegister()
*/
public static function isCallRegistered() {
- if(!isset($_SESSION['requesttoken'])) {
+ if(!\OC::$session->exists('requesttoken')) {
return false;
}
@@ -484,7 +495,7 @@ class OC_Util {
}
// Check if the token is valid
- if($token !== $_SESSION['requesttoken']) {
+ if($token !== \OC::$session->get('requesttoken')) {
// Not valid
return false;
} else {
@@ -633,11 +644,10 @@ class OC_Util {
/**
* Check if the ownCloud server can connect to the internet
*/
- 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;
+ public static function isInternetConnectionWorking() {
+ // in case there is no internet connection on purpose return false
+ if (self::isInternetConnectionEnabled() === false) {
+ return false;
}
// try to connect to owncloud.org to see if http connections to the internet are possible.
@@ -659,6 +669,13 @@ class OC_Util {
}
}
+
+ /**
+ * Check if the connection to the internet is disabled on purpose
+ */
+ public static function isInternetConnectionEnabled(){
+ return \OC_Config::getValue("has_internet_connection", true);
+ }
/**
* clear all levels of output buffering
@@ -795,4 +812,41 @@ 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;
+ }
+
+ /**
+ * Normalize a unicode string
+ * @param string $value a not normalized string
+ * @return bool|string
+ */
+ public static function normalizeUnicode($value) {
+ if(class_exists('Patchwork\PHP\Shim\Normalizer')) {
+ $normalizedValue = \Patchwork\PHP\Shim\Normalizer::normalize($value);
+ if($normalizedValue === false) {
+ \OC_Log::write( 'core', 'normalizing failed for "' . $value . '"', \OC_Log::WARN);
+ } else {
+ $value = $normalizedValue;
+ }
+ }
+
+ return $value;
+ }
}