summaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-06-14 10:06:13 +0200
committerThomas Mueller <thomas.mueller@tmit.eu>2013-06-14 10:06:13 +0200
commitc8564c07955ead3e85daa67e1871a2c41df3a6d5 (patch)
tree134c228f43e641d34fbf342df2745ece43580fee /lib/util.php
parent0a29d2029a719d42f347edb95bd6486c2ab842a8 (diff)
parent6c534c8165d3c3fba64e3cf5c05993a84733eef7 (diff)
downloadnextcloud-server-c8564c07955ead3e85daa67e1871a2c41df3a6d5.tar.gz
nextcloud-server-c8564c07955ead3e85daa67e1871a2c41df3a6d5.zip
Merge branch 'master' into move-maint-start
Conflicts: lib/util.php
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php55
1 files changed, 41 insertions, 14 deletions
diff --git a/lib/util.php b/lib/util.php
index a7ed0379294..ddef0c63c55 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
*
@@ -77,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, 02);
+ return array(5, 80, 05);
}
/**
@@ -151,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;
}
@@ -173,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;
@@ -457,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);
}
@@ -475,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;
}
@@ -491,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 {
@@ -640,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.
@@ -666,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
@@ -842,4 +852,21 @@ class OC_Util {
}
}
+ /**
+ * 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;
+ }
}