Merge branch 'master' into move-maint-start

Conflicts:
	lib/util.php
This commit is contained in:
Thomas Mueller
2013-06-14 10:06:13 +02:00
1477 changed files with 40812 additions and 46934 deletions

View File

@@ -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;
}
}