diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-12-25 14:29:29 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-12-25 14:29:29 +0100 |
commit | 7e36f730ecfe452681f44771b28d1d3c4a5535df (patch) | |
tree | 578e604c170219151239e2da345d332b079ed920 /lib | |
parent | bf05ff351faa693337107ed4a316e36e9aacd296 (diff) | |
parent | 5d59ac07391841677e204958ea20be3fe05cd8ef (diff) | |
download | nextcloud-server-7e36f730ecfe452681f44771b28d1d3c4a5535df.tar.gz nextcloud-server-7e36f730ecfe452681f44771b28d1d3c4a5535df.zip |
merge master into filesystem
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MDB2/Driver/sqlite3.php | 3 | ||||
-rw-r--r-- | lib/files.php | 18 | ||||
-rw-r--r-- | lib/hook.php | 6 | ||||
-rw-r--r-- | lib/l10n/ar.php | 5 | ||||
-rw-r--r-- | lib/l10n/da.php | 7 | ||||
-rw-r--r-- | lib/l10n/mk.php | 28 | ||||
-rw-r--r-- | lib/log/owncloud.php | 15 | ||||
-rw-r--r-- | lib/public/util.php | 36 | ||||
-rwxr-xr-x | lib/util.php | 102 |
9 files changed, 145 insertions, 75 deletions
diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index fa4c91c1269..9839dafbce1 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -98,8 +98,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common if ($this->connection) { $native_code = $this->connection->lastErrorCode(); } - $native_msg = $this->_lasterror - ? html_entity_decode($this->_lasterror) : $this->connection->lastErrorMsg(); + $native_msg = html_entity_decode($this->_lasterror); // PHP 5.2+ prepends the function name to $php_errormsg, so we need // this hack to work around it, per bug #9599. diff --git a/lib/files.php b/lib/files.php index 2d7e335e969..e12797bd610 100644 --- a/lib/files.php +++ b/lib/files.php @@ -100,8 +100,13 @@ class OC_Files { $filename = $dir . '/' . $files; } OC_Util::obEnd(); - if ($zip or \OC\Files\Filesystem::isReadable($filename)) { - header('Content-Disposition: attachment; filename="' . basename($filename) . '"'); + if($zip or \OC\Files\Filesystem::is_readable($filename)) { + if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) { + header( 'Content-Disposition: attachment; filename="' . rawurlencode( basename($filename) ) . '"' ); + } else { + header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode( basename($filename) ) + . '; filename="' . rawurlencode( basename($filename) ) . '"' ); + } header('Content-Transfer-Encoding: binary'); OC_Response::disableCaching(); if ($zip) { @@ -111,7 +116,8 @@ class OC_Files { self::addSendfileHeader($filename); }else{ header('Content-Type: '.\OC\Files\Filesystem::getMimeType($filename)); - list($storage, ) = \OC\Files\Filesystem::resolvePath($filename); + header("Content-Length: ".\OC\Files\Filesystem::filesize($filename)); + $storage = \OC\Files\Filesystem::getStorage($filename); if ($storage instanceof \OC\File\Storage\Local) { self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename)); } @@ -125,10 +131,8 @@ class OC_Files { header("HTTP/1.0 403 Forbidden"); die('403 Forbidden'); } - if ($only_header) { - if (!$zip) - header("Content-Length: " . \OC\Files\Filesystem::filesize($filename)); - return; + if($only_header) { + return ; } if ($zip) { $handle = fopen($filename, 'r'); diff --git a/lib/hook.php b/lib/hook.php index 26a53693748..4da331bb5d8 100644 --- a/lib/hook.php +++ b/lib/hook.php @@ -59,7 +59,11 @@ class OC_Hook{ // Call all slots foreach( self::$registered[$signalclass][$signalname] as $i ) { - call_user_func( array( $i["class"], $i["name"] ), $params ); + try { + call_user_func( array( $i["class"], $i["name"] ), $params ); + } catch (Exception $e){ + OC_Log::write('hook', 'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(), OC_Log::ERROR); + } } // return true diff --git a/lib/l10n/ar.php b/lib/l10n/ar.php index 3ae226f04fd..77e02dd77b1 100644 --- a/lib/l10n/ar.php +++ b/lib/l10n/ar.php @@ -5,5 +5,8 @@ "Users" => "المستخدمين", "Authentication error" => "لم يتم التأكد من الشخصية بنجاح", "Files" => "الملفات", -"Text" => "معلومات إضافية" +"Text" => "معلومات إضافية", +"seconds ago" => "منذ ثواني", +"1 minute ago" => "منذ دقيقة", +"today" => "اليوم" ); diff --git a/lib/l10n/da.php b/lib/l10n/da.php index 7458b329782..a0ab1f17014 100644 --- a/lib/l10n/da.php +++ b/lib/l10n/da.php @@ -14,16 +14,21 @@ "Token expired. Please reload page." => "Adgang er udløbet. Genindlæs siden.", "Files" => "Filer", "Text" => "SMS", +"Images" => "Billeder", "seconds ago" => "sekunder siden", "1 minute ago" => "1 minut siden", "%d minutes ago" => "%d minutter siden", +"1 hour ago" => "1 time siden", +"%d hours ago" => "%d timer siden", "today" => "I dag", "yesterday" => "I går", "%d days ago" => "%d dage siden", "last month" => "Sidste måned", +"%d months ago" => "%d måneder siden", "last year" => "Sidste år", "years ago" => "år siden", "%s is available. Get <a href=\"%s\">more information</a>" => "%s er tilgængelig. Få <a href=\"%s\">mere information</a>", "up to date" => "opdateret", -"updates check is disabled" => "Check for opdateringer er deaktiveret" +"updates check is disabled" => "Check for opdateringer er deaktiveret", +"Could not find category \"%s\"" => "Kunne ikke finde kategorien \"%s\"" ); diff --git a/lib/l10n/mk.php b/lib/l10n/mk.php index a06073e808a..5b3efffb22a 100644 --- a/lib/l10n/mk.php +++ b/lib/l10n/mk.php @@ -3,6 +3,32 @@ "Personal" => "Лично", "Settings" => "Параметри", "Users" => "Корисници", +"Apps" => "Аппликации", +"Admin" => "Админ", +"ZIP download is turned off." => "Преземање во ZIP е исклучено", +"Files need to be downloaded one by one." => "Датотеките треба да се симнат една по една.", +"Back to Files" => "Назад кон датотеки", +"Selected files too large to generate zip file." => "Избраните датотеки се преголеми за да се генерира zip.", +"Application is not enabled" => "Апликацијата не е овозможена", +"Authentication error" => "Грешка во автентикација", +"Token expired. Please reload page." => "Жетонот е истечен. Ве молам превчитајте ја страницата.", "Files" => "Датотеки", -"Text" => "Текст" +"Text" => "Текст", +"Images" => "Слики", +"seconds ago" => "пред секунди", +"1 minute ago" => "пред 1 минута", +"%d minutes ago" => "пред %d минути", +"1 hour ago" => "пред 1 час", +"%d hours ago" => "пред %d часови", +"today" => "денеска", +"yesterday" => "вчера", +"%d days ago" => "пред %d денови", +"last month" => "минатиот месец", +"%d months ago" => "пред %d месеци", +"last year" => "минатата година", +"years ago" => "пред години", +"%s is available. Get <a href=\"%s\">more information</a>" => "%s е достапно. Земи <a href=\"%s\">повеќе информации</a>", +"up to date" => "ажурно", +"updates check is disabled" => "проверката за ажурирања е оневозможена", +"Could not find category \"%s\"" => "Не можам да најдам категорија „%s“" ); diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php index ec43208d833..e53dd5fefcd 100644 --- a/lib/log/owncloud.php +++ b/lib/log/owncloud.php @@ -33,8 +33,11 @@ class OC_Log_Owncloud { * Init class data */ public static function init() { - $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' ); - self::$logFile=OC_Config::getValue( "logfile", $datadir.'/owncloud.log' ); + $defaultLogFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log'; + self::$logFile = OC_Config::getValue("logfile", $defaultLogFile); + if (!file_exists(self::$logFile)) { + self::$logFile = $defaultLogFile; + } } /** @@ -47,9 +50,11 @@ class OC_Log_Owncloud { $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR); if($level>=$minLevel) { $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=>time()); - $fh=fopen(self::$logFile, 'a'); - fwrite($fh, json_encode($entry)."\n"); - fclose($fh); + $handle = @fopen(self::$logFile, 'a'); + if ($handle) { + fwrite($handle, json_encode($entry)."\n"); + fclose($handle); + } } } diff --git a/lib/public/util.php b/lib/public/util.php index 7b5b1abbded..af782b01483 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -173,6 +173,42 @@ class Util { } /** + * @brief returns the server hostname + * @returns the server hostname + * + * Returns the server host name without an eventual port number + */ + public static function getServerHostName() { + $host_name = self::getServerHost(); + // strip away port number (if existing) + $colon_pos = strpos($host_name, ':'); + if ($colon_pos != FALSE) { + $host_name = substr($host_name, 0, $colon_pos); + } + return $host_name; + } + + /** + * @brief Returns the default email address + * @param $user_part the user part of the address + * @returns the default email address + * + * Assembles a default email address (using the server hostname + * and the given user part, and returns it + * Example: when given lostpassword-noreply as $user_part param, + * and is currently accessed via http(s)://example.com/, + * it would return 'lostpassword-noreply@example.com' + */ + public static function getDefaultEmailAddress($user_part) { + $host_name = self::getServerHostName(); + // handle localhost installations + if ($host_name === 'localhost') { + $host_name = "example.com"; + } + return $user_part.'@'.$host_name; + } + + /** * @brief Returns the server protocol * @returns the server protocol * diff --git a/lib/util.php b/lib/util.php index 4411b327310..4ebc2564d1c 100755 --- a/lib/util.php +++ b/lib/util.php @@ -146,7 +146,7 @@ class OC_Util { * @param int timestamp $timestamp * @param bool dateOnly option to omit time from the result */ - public static function formatDate( $timestamp, $dateOnly=false) { + public static function formatDate( $timestamp, $dateOnly=false) { if(isset($_SESSION['timezone'])) {//adjust to clients timezone if we know it $systemTimeZone = intval(date('O')); $systemTimeZone=(round($systemTimeZone/100, 0)*60)+($systemTimeZone%100); @@ -156,37 +156,8 @@ class OC_Util { } $l=OC_L10N::get('lib'); return $l->l($dateOnly ? 'date' : 'datetime', $timestamp); - } - - /** - * Shows a pagenavi widget where you can jump to different pages. - * - * @param int $pagecount - * @param int $page - * @param string $url - * @return OC_Template - */ - public static function getPageNavi($pagecount, $page, $url) { - - $pagelinkcount=8; - if ($pagecount>1) { - $pagestart=$page-$pagelinkcount; - if($pagestart<0) $pagestart=0; - $pagestop=$page+$pagelinkcount; - if($pagestop>$pagecount) $pagestop=$pagecount; - - $tmpl = new OC_Template( '', 'part.pagenavi', '' ); - $tmpl->assign('page', $page); - $tmpl->assign('pagecount', $pagecount); - $tmpl->assign('pagestart', $pagestart); - $tmpl->assign('pagestop', $pagestop); - $tmpl->assign('url', $url); - return $tmpl; - } } - - /** * check if the current server configuration is suitable for ownCloud * @return array arrays with error messages and hints @@ -577,6 +548,18 @@ class OC_Util { /** + * Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server. + */ + public static function issetlocaleworking() { + $result=setlocale(LC_ALL, 'en_US.UTF-8'); + if($result==false) { + return(false); + }else{ + return(true); + } + } + + /** * Check if the ownCloud server can connect to the internet */ public static function isinternetconnectionworking() { @@ -678,34 +661,39 @@ class OC_Util { * If not, file_get_element is used. */ - public static function getUrlContent($url){ + public static function getUrlContent($url){ - if (function_exists('curl_init')) { - - $curl = curl_init(); - - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); - $data = curl_exec($curl); - curl_close($curl); - - } else { - - $ctx = stream_context_create( - array( - 'http' => array( - 'timeout' => 10 - ) - ) - ); - $data=@file_get_contents($url, 0, $ctx); - - } - - return $data; + if (function_exists('curl_init')) { + + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); + if(OC_Config::getValue('proxy','')<>'') { + curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy')); + } + if(OC_Config::getValue('proxyuserpwd','')<>'') { + curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('proxyuserpwd')); + } + $data = curl_exec($curl); + curl_close($curl); + + } else { + + $ctx = stream_context_create( + array( + 'http' => array( + 'timeout' => 10 + ) + ) + ); + $data=@file_get_contents($url, 0, $ctx); + + } + return $data; } } |