diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-12 00:32:38 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-12 00:32:38 +0100 |
commit | 76b31f870cf78aa8882761d954554fecb92e6211 (patch) | |
tree | 9c89430fe00983e94cc8864a12cd05242741d4c3 /lib | |
parent | 0c31c3cc3a928e8ca9272d32d68163c0700697ea (diff) | |
parent | fb23ac3ce2e0b3f002f036e55e516b672f088dc0 (diff) | |
download | nextcloud-server-76b31f870cf78aa8882761d954554fecb92e6211.tar.gz nextcloud-server-76b31f870cf78aa8882761d954554fecb92e6211.zip |
Merge branch 'master' into master-sqlserver
Diffstat (limited to 'lib')
44 files changed, 1051 insertions, 111 deletions
diff --git a/lib/app.php b/lib/app.php index 3a4e21e8cd1..bf7eeef0181 100644 --- a/lib/app.php +++ b/lib/app.php @@ -39,6 +39,15 @@ class OC_App{ static private $altLogin = array(); /** + * @brief clean the appid + * @param $app Appid that needs to be cleaned + * @return string + */ + public static function cleanAppId($app) { + return str_replace(array('\0', '/', '\\', '..'), '', $app); + } + + /** * @brief loads all apps * @param array $types * @return bool @@ -286,6 +295,23 @@ class OC_App{ } /** + * @brief Get the navigation entries for the $app + * @param string $app app + * @return array of the $data added with addNavigationEntry + */ + public static function getAppNavigationEntries($app) { + if(is_file(self::getAppPath($app).'/appinfo/app.php')) { + $save = self::$navigation; + self::$navigation = array(); + require $app.'/appinfo/app.php'; + $app_entries = self::$navigation; + self::$navigation = $save; + return $app_entries; + } + return array(); + } + + /** * @brief gets the active Menu entry * @return string id or empty string * @@ -645,7 +671,7 @@ class OC_App{ $info['update']=false; } else { $info['internal']=false; - $info['internallabel']='3rd Party App'; + $info['internallabel']='3rd Party'; $info['internalclass']='externalapp'; $info['update']=OC_Installer::isUpdateAvailable($app); } @@ -683,10 +709,10 @@ class OC_App{ * @return array, multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ public static function getAppstoreApps( $filter = 'approved' ) { - $catagoryNames = OC_OCSClient::getCategories(); - if ( is_array( $catagoryNames ) ) { + $categoryNames = OC_OCSClient::getCategories(); + if ( is_array( $categoryNames ) ) { // Check that categories of apps were retrieved correctly - if ( ! $categories = array_keys( $catagoryNames ) ) { + if ( ! $categories = array_keys( $categoryNames ) ) { return false; } diff --git a/lib/archive/tar.php b/lib/archive/tar.php index 117d88e5f42..e7c81389619 100644 --- a/lib/archive/tar.php +++ b/lib/archive/tar.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -require_once 'Archive/Tar.php'; +require_once OC::$THIRDPARTYROOT . '/3rdparty/Archive/Tar.php'; class OC_Archive_TAR extends OC_Archive{ const PLAIN=0; diff --git a/lib/base.php b/lib/base.php index b432f282aaf..c60a97100f4 100644 --- a/lib/base.php +++ b/lib/base.php @@ -346,7 +346,7 @@ class OC { public static function init() { // register autoloader spl_autoload_register(array('OC', 'autoload')); - setlocale(LC_ALL, 'en_US.UTF-8'); + OC_Util::issetlocaleworking(); // set some stuff //ob_start(); @@ -468,7 +468,7 @@ class OC { register_shutdown_function(array('OC_Helper', 'cleanTmp')); //parse the given parameters - self::$REQUESTEDAPP = (isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? str_replace(array('\0', '/', '\\', '..'), '', strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files')); + self::$REQUESTEDAPP = (isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? OC_App::cleanAppId(strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files')); if (substr_count(self::$REQUESTEDAPP, '?') != 0) { $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?')); $param = substr($_GET['app'], strpos($_GET['app'], '?') + 1); @@ -498,7 +498,7 @@ class OC { // write error into log if locale can't be set if (OC_Util::issetlocaleworking() == false) { - OC_Log::write('core', 'setting locale to en_US.UTF-8 failed. Support is probably not installed on your system', OC_Log::ERROR); + OC_Log::write('core', 'setting locale to en_US.UTF-8/en_US.UTF8 failed. Support is probably not installed on your system', OC_Log::ERROR); } if (OC_Config::getValue('installed', false)) { if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { @@ -548,20 +548,24 @@ class OC { require_once 'core/setup.php'; exit(); } + $request = OC_Request::getPathInfo(); if(substr($request, -3) !== '.js'){// we need these files during the upgrade self::checkMaintenanceMode(); self::checkUpgrade(); } - try { - OC::getRouter()->match(OC_Request::getPathInfo()); - return; - } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { - //header('HTTP/1.0 404 Not Found'); - } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { - OC_Response::setStatus(405); - return; + if (!self::$CLI) { + try { + OC_App::loadApps(); + OC::getRouter()->match(OC_Request::getPathInfo()); + return; + } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { + //header('HTTP/1.0 404 Not Found'); + } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { + OC_Response::setStatus(405); + return; + } } $app = OC::$REQUESTEDAPP; diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index b210602bbf4..e29059d0395 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -62,7 +62,36 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa } } else { $newPath = $this->path . '/' . $name; - \OC\Files\Filesystem::file_put_contents($newPath, $data); + + // mark file as partial while uploading (ignored by the scanner) + $partpath = $newPath . '.part'; + + \OC\Files\Filesystem::file_put_contents($partpath, $data); + + //detect aborted upload + if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) { + if (isset($_SERVER['CONTENT_LENGTH'])) { + $expected = $_SERVER['CONTENT_LENGTH']; + $actual = \OC\Files\Filesystem::filesize($partpath); + if ($actual != $expected) { + \OC\Files\Filesystem::unlink($partpath); + throw new Sabre_DAV_Exception_BadRequest( + 'expected filesize ' . $expected . ' got ' . $actual); + } + } + } + + // rename to correct path + \OC\Files\Filesystem::rename($partpath, $newPath); + + // allow sync clients to send the mtime along in a header + $mtime = OC_Request::hasModificationTime(); + if ($mtime !== false) { + if(\OC\Files\Filesystem::touch($newPath, $mtime)) { + header('X-OC-MTime: accepted'); + } + } + return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath); } @@ -121,7 +150,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $paths = array(); foreach($folder_content as $info) { $paths[] = $this->path.'/'.$info['name']; - $properties[$this->path.'/'.$info['name']][self::GETETAG_PROPERTYNAME] = $info['etag']; + $properties[$this->path.'/'.$info['name']][self::GETETAG_PROPERTYNAME] = '"' . $info['etag'] . '"'; } if(count($paths)>0) { // diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 1c18a391742..61165d9956d 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -45,7 +45,34 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D */ public function put($data) { - \OC\Files\Filesystem::file_put_contents($this->path,$data); + // mark file as partial while uploading (ignored by the scanner) + $partpath = $this->path . '.part'; + + \OC\Files\Filesystem::file_put_contents($partpath, $data); + + //detect aborted upload + if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) { + if (isset($_SERVER['CONTENT_LENGTH'])) { + $expected = $_SERVER['CONTENT_LENGTH']; + $actual = \OC\Files\Filesystem::filesize($partpath); + if ($actual != $expected) { + \OC\Files\Filesystem::unlink($partpath); + throw new Sabre_DAV_Exception_BadRequest( + 'expected filesize ' . $expected . ' got ' . $actual); + } + } + } + + // rename to correct path + \OC\Files\Filesystem::rename($partpath, $this->path); + + //allow sync clients to send the mtime along in a header + $mtime = OC_Request::hasModificationTime(); + if ($mtime !== false) { + if(\OC\Files\Filesystem::touch($this->path, $mtime)) { + header('X-OC-MTime: accepted'); + } + } return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path); } diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index 8d504af6163..5a9a119458e 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -97,7 +97,7 @@ class Scanner { if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) { \OC_DB::beginTransaction(); while ($file = readdir($dh)) { - if ($file !== '.' and $file !== '..') { + if (!$this->isIgnoredFile($file)) { $child = ($path) ? $path . '/' . $file : $file; $data = $this->scanFile($child); if ($data) { @@ -133,12 +133,28 @@ class Scanner { } return $size; } + + /** + * @brief check if the file should be ignored when scanning + * NOTE: files with a '.part' extension are ignored as well! + * prevents unfinished put requests to be scanned + * @param String $file + * @return boolean + */ + private function isIgnoredFile($file) { + if ($file === '.' || $file === '..' + || pathinfo($file,PATHINFO_EXTENSION) === 'part') + { + return true; + } + return false; + } /** * walk over any folders that are not fully scanned yet and scan them */ public function backgroundScan() { - while ($path = $this->cache->getIncomplete()) { + while (($path = $this->cache->getIncomplete()) !== false) { $this->scan($path); $this->cache->correctFolderSize($path); } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index 71bf3d8708d..a0c3c4b9b75 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -190,14 +190,14 @@ class Filesystem { } } - static public function init($root) { + static public function init($user, $root) { if (self::$defaultInstance) { return false; } self::$defaultInstance = new View($root); //load custom mount config - self::initMountPoints(); + self::initMountPoints($user); self::$loaded = true; diff --git a/lib/files/mapper.php b/lib/files/mapper.php new file mode 100644 index 00000000000..71b665e49bb --- /dev/null +++ b/lib/files/mapper.php @@ -0,0 +1,216 @@ +<?php + +namespace OC\Files; + +/** + * class Mapper is responsible to translate logical paths to physical paths and reverse + */ +class Mapper +{ + /** + * @param string $logicPath + * @param bool $create indicates if the generated physical name shall be stored in the database or not + * @return string the physical path + */ + public function logicToPhysical($logicPath, $create) { + $physicalPath = $this->resolveLogicPath($logicPath); + if ($physicalPath !== null) { + return $physicalPath; + } + + return $this->create($logicPath, $create); + } + + /** + * @param string $physicalPath + * @return string|null + */ + public function physicalToLogic($physicalPath) { + $logicPath = $this->resolvePhysicalPath($physicalPath); + if ($logicPath !== null) { + return $logicPath; + } + + $this->insert($physicalPath, $physicalPath); + return $physicalPath; + } + + /** + * @param string $path + * @param bool $isLogicPath indicates if $path is logical or physical + * @param $recursive + */ + public function removePath($path, $isLogicPath, $recursive) { + if ($recursive) { + $path=$path.'%'; + } + + if ($isLogicPath) { + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*file_map` WHERE `logic_path` LIKE ?'); + $query->execute(array($path)); + } else { + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*file_map` WHERE `physic_path` LIKE ?'); + $query->execute(array($path)); + } + } + + /** + * @param $path1 + * @param $path2 + * @throws \Exception + */ + public function copy($path1, $path2) + { + $path1 = $this->stripLast($path1); + $path2 = $this->stripLast($path2); + $physicPath1 = $this->logicToPhysical($path1, true); + $physicPath2 = $this->logicToPhysical($path2, true); + + $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*file_map` WHERE `logic_path` LIKE ?'); + $result = $query->execute(array($path1.'%')); + $updateQuery = \OC_DB::prepare('UPDATE `*PREFIX*file_map`' + .' SET `logic_path` = ?' + .' AND `physic_path` = ?' + .' WHERE `logic_path` = ?'); + while( $row = $result->fetchRow()) { + $currentLogic = $row['logic_path']; + $currentPhysic = $row['physic_path']; + $newLogic = $path2.$this->stripRootFolder($currentLogic, $path1); + $newPhysic = $physicPath2.$this->stripRootFolder($currentPhysic, $physicPath1); + if ($path1 !== $currentLogic) { + try { + $updateQuery->execute(array($newLogic, $newPhysic, $currentLogic)); + } catch (\Exception $e) { + error_log('Mapper::Copy failed '.$currentLogic.' -> '.$newLogic.'\n'.$e); + throw $e; + } + } + } + } + + /** + * @param $path + * @param $root + * @return bool|string + */ + public function stripRootFolder($path, $root) { + if (strpos($path, $root) !== 0) { + // throw exception ??? + return false; + } + if (strlen($path) > strlen($root)) { + return substr($path, strlen($root)); + } + + return ''; + } + + private function stripLast($path) { + if (substr($path, -1) == '/') { + $path = substr_replace($path ,'',-1); + } + return $path; + } + + private function resolveLogicPath($logicPath) { + $logicPath = $this->stripLast($logicPath); + $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*file_map` WHERE `logic_path_hash` = ?'); + $result = $query->execute(array(md5($logicPath))); + $result = $result->fetchRow(); + + return $result['physic_path']; + } + + private function resolvePhysicalPath($physicalPath) { + $physicalPath = $this->stripLast($physicalPath); + $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*file_map` WHERE `physic_path_hash` = ?'); + $result = $query->execute(array(md5($physicalPath))); + $result = $result->fetchRow(); + + return $result['logic_path']; + } + + private function create($logicPath, $store) { + $logicPath = $this->stripLast($logicPath); + $index = 0; + + // create the slugified path + $physicalPath = $this->slugifyPath($logicPath); + + // detect duplicates + while ($this->resolvePhysicalPath($physicalPath) !== null) { + $physicalPath = $this->slugifyPath($physicalPath, $index++); + } + + // insert the new path mapping if requested + if ($store) { + $this->insert($logicPath, $physicalPath); + } + + return $physicalPath; + } + + private function insert($logicPath, $physicalPath) { + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*file_map`(`logic_path`, `physic_path`, `logic_path_hash`, `physic_path_hash`) VALUES(?, ?, ?, ?)'); + $query->execute(array($logicPath, $physicalPath, md5($logicPath), md5($physicalPath))); + } + + private function slugifyPath($path, $index=null) { + $pathElements = explode('/', $path); + $sluggedElements = array(); + + // skip slugging the drive letter on windows - TODO: test if local path + if (strpos(strtolower(php_uname('s')), 'win') !== false) { + $sluggedElements[]= $pathElements[0]; + array_shift($pathElements); + } + foreach ($pathElements as $pathElement) { + // TODO: remove file ext before slugify on last element + $sluggedElements[] = self::slugify($pathElement); + } + + // + // TODO: add the index before the file extension + // + if ($index !== null) { + $last= end($sluggedElements); + array_pop($sluggedElements); + array_push($sluggedElements, $last.'-'.$index); + } + return implode(DIRECTORY_SEPARATOR, $sluggedElements); + } + + /** + * Modifies a string to remove all non ASCII characters and spaces. + * + * @param string $text + * @return string + */ + private function slugify($text) + { + // replace non letter or digits by - + $text = preg_replace('~[^\\pL\d]+~u', '-', $text); + + // trim + $text = trim($text, '-'); + + // transliterate + if (function_exists('iconv')) { + $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); + } + + // lowercase + $text = strtolower($text); + + // remove unwanted characters + $text = preg_replace('~[^-\w]+~', '', $text); + + if (empty($text)) + { + // TODO: we better generate a guid in this case + return 'n-a'; + } + + return $text; + } +} diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 591803f0440..ce9e7ead6d1 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -277,4 +277,27 @@ abstract class Common implements \OC\Files\Storage\Storage { return uniqid(); } } + + /** + * clean a path, i.e. remove all redundant '.' and '..' + * making sure that it can't point to higher than '/' + * @param $path The path to clean + * @return string cleaned path + */ + public function cleanPath($path) { + if (strlen($path) == 0 or $path[0] != '/') { + $path = '/' . $path; + } + + $output = array(); + foreach (explode('/', $path) as $chunk) { + if ($chunk == '..') { + array_pop($output); + } else if ($chunk == '.') { + } else { + $output[] = $chunk; + } + } + return implode('/', $output); + } } diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index a5db4ba9194..9fe01135866 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -8,6 +8,10 @@ namespace OC\Files\Storage; +if (\OC_Util::runningOnWindows()) { + require_once 'mappedlocal.php'; +} else { + /** * for local filestore, we only have to map the paths */ @@ -19,6 +23,8 @@ class Local extends \OC\Files\Storage\Common{ $this->datadir.='/'; } } + public function __destruct() { + } public function getId(){ return 'local::'.$this->datadir; } @@ -245,3 +251,4 @@ class Local extends \OC\Files\Storage\Common{ return $this->filemtime($path)>$time; } } +} diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php new file mode 100644 index 00000000000..80dd79bc41f --- /dev/null +++ b/lib/files/storage/mappedlocal.php @@ -0,0 +1,335 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +namespace OC\Files\Storage; + +/** + * for local filestore, we only have to map the paths + */ +class Local extends \OC\Files\Storage\Common{ + protected $datadir; + private $mapper; + + public function __construct($arguments) { + $this->datadir=$arguments['datadir']; + if(substr($this->datadir, -1)!=='/') { + $this->datadir.='/'; + } + + $this->mapper= new \OC\Files\Mapper(); + } + public function __destruct() { + if (defined('PHPUNIT_RUN')) { + $this->mapper->removePath($this->datadir, true, true); + } + } + public function getId(){ + return 'local::'.$this->datadir; + } + public function mkdir($path) { + return @mkdir($this->buildPath($path)); + } + public function rmdir($path) { + if ($result = @rmdir($this->buildPath($path))) { + $this->cleanMapper($path); + } + return $result; + } + public function opendir($path) { + $files = array('.', '..'); + $physicalPath= $this->buildPath($path); + + $logicalPath = $this->mapper->physicalToLogic($physicalPath); + $dh = opendir($physicalPath); + while ($file = readdir($dh)) { + if ($file === '.' or $file === '..') { + continue; + } + + $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.DIRECTORY_SEPARATOR.$file); + + $file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath); + $file = $this->stripLeading($file); + $files[]= $file; + } + + \OC\Files\Stream\Dir::register('local-win32'.$path, $files); + return opendir('fakedir://local-win32'.$path); + } + public function is_dir($path) { + if(substr($path,-1)=='/') { + $path=substr($path, 0, -1); + } + return is_dir($this->buildPath($path)); + } + public function is_file($path) { + return is_file($this->buildPath($path)); + } + public function stat($path) { + $fullPath = $this->buildPath($path); + $statResult = stat($fullPath); + + if ($statResult['size'] < 0) { + $size = self::getFileSizeFromOS($fullPath); + $statResult['size'] = $size; + $statResult[7] = $size; + } + return $statResult; + } + public function filetype($path) { + $filetype=filetype($this->buildPath($path)); + if($filetype=='link') { + $filetype=filetype(realpath($this->buildPath($path))); + } + return $filetype; + } + public function filesize($path) { + if($this->is_dir($path)) { + return 0; + }else{ + $fullPath = $this->buildPath($path); + $fileSize = filesize($fullPath); + if ($fileSize < 0) { + return self::getFileSizeFromOS($fullPath); + } + + return $fileSize; + } + } + public function isReadable($path) { + return is_readable($this->buildPath($path)); + } + public function isUpdatable($path) { + return is_writable($this->buildPath($path)); + } + public function file_exists($path) { + return file_exists($this->buildPath($path)); + } + public function filemtime($path) { + return filemtime($this->buildPath($path)); + } + public function touch($path, $mtime=null) { + // sets the modification time of the file to the given value. + // If mtime is nil the current time is set. + // note that the access time of the file always changes to the current time. + if(!is_null($mtime)) { + $result=touch( $this->buildPath($path), $mtime ); + }else{ + $result=touch( $this->buildPath($path)); + } + if( $result ) { + clearstatcache( true, $this->buildPath($path) ); + } + + return $result; + } + public function file_get_contents($path) { + return file_get_contents($this->buildPath($path)); + } + public function file_put_contents($path, $data) {//trigger_error("$path = ".var_export($path, 1)); + return file_put_contents($this->buildPath($path), $data); + } + public function unlink($path) { + return $this->delTree($path); + } + public function rename($path1, $path2) { + if (!$this->isUpdatable($path1)) { + \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR); + return false; + } + if(! $this->file_exists($path1)) { + \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR); + return false; + } + + $physicPath1 = $this->buildPath($path1); + $physicPath2 = $this->buildPath($path2); + if($return=rename($physicPath1, $physicPath2)) { + // mapper needs to create copies or all children + $this->copyMapping($path1, $path2); + $this->cleanMapper($physicPath1, false, true); + } + return $return; + } + public function copy($path1, $path2) { + if($this->is_dir($path2)) { + if(!$this->file_exists($path2)) { + $this->mkdir($path2); + } + $source=substr($path1, strrpos($path1, '/')+1); + $path2.=$source; + } + if($return=copy($this->buildPath($path1), $this->buildPath($path2))) { + // mapper needs to create copies or all children + $this->copyMapping($path1, $path2); + } + return $return; + } + public function fopen($path, $mode) { + if($return=fopen($this->buildPath($path), $mode)) { + switch($mode) { + case 'r': + break; + case 'r+': + case 'w+': + case 'x+': + case 'a+': + break; + case 'w': + case 'x': + case 'a': + break; + } + } + return $return; + } + + public function getMimeType($path) { + if($this->isReadable($path)) { + return \OC_Helper::getMimeType($this->buildPath($path)); + }else{ + return false; + } + } + + private function delTree($dir, $isLogicPath=true) { + $dirRelative=$dir; + if ($isLogicPath) { + $dir=$this->buildPath($dir); + } + if (!file_exists($dir)) { + return true; + } + if (!is_dir($dir) || is_link($dir)) { + if($return=unlink($dir)) { + $this->cleanMapper($dir, false); + return $return; + } + } + foreach (scandir($dir) as $item) { + if ($item == '.' || $item == '..') { + continue; + } + if(is_file($dir.'/'.$item)) { + if(unlink($dir.'/'.$item)) { + $this->cleanMapper($dir.'/'.$item, false); + } + }elseif(is_dir($dir.'/'.$item)) { + if (!$this->delTree($dir. "/" . $item, false)) { + return false; + }; + } + } + if($return=rmdir($dir)) { + $this->cleanMapper($dir, false); + } + return $return; + } + + private static function getFileSizeFromOS($fullPath) { + $name = strtolower(php_uname('s')); + // Windows OS: we use COM to access the filesystem + if (strpos($name, 'win') !== false) { + if (class_exists('COM')) { + $fsobj = new \COM("Scripting.FileSystemObject"); + $f = $fsobj->GetFile($fullPath); + return $f->Size; + } + } else if (strpos($name, 'bsd') !== false) { + if (\OC_Helper::is_function_enabled('exec')) { + return (float)exec('stat -f %z ' . escapeshellarg($fullPath)); + } + } else if (strpos($name, 'linux') !== false) { + if (\OC_Helper::is_function_enabled('exec')) { + return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); + } + } else { + \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); + } + + return 0; + } + + public function hash($path, $type, $raw=false) { + return hash_file($type, $this->buildPath($path), $raw); + } + + public function free_space($path) { + return @disk_free_space($this->buildPath($path)); + } + + public function search($query) { + return $this->searchInDir($query); + } + public function getLocalFile($path) { + return $this->buildPath($path); + } + public function getLocalFolder($path) { + return $this->buildPath($path); + } + + protected function searchInDir($query, $dir='', $isLogicPath=true) { + $files=array(); + $physicalDir = $this->buildPath($dir); + foreach (scandir($physicalDir) as $item) { + if ($item == '.' || $item == '..') + continue; + $physicalItem = $this->mapper->physicalToLogic($physicalDir.DIRECTORY_SEPARATOR.$item); + $item = substr($physicalItem, strlen($physicalDir)+1); + + if(strstr(strtolower($item), strtolower($query)) !== false) { + $files[]=$dir.'/'.$item; + } + if(is_dir($physicalItem)) { + $files=array_merge($files, $this->searchInDir($query, $physicalItem, false)); + } + } + return $files; + } + + /** + * check if a file or folder has been updated since $time + * @param string $path + * @param int $time + * @return bool + */ + public function hasUpdated($path, $time) { + return $this->filemtime($path)>$time; + } + + private function buildPath($path, $create=true) { + $path = $this->stripLeading($path); + $fullPath = $this->datadir.$path; + return $this->mapper->logicToPhysical($fullPath, $create); + } + + private function cleanMapper($path, $isLogicPath=true, $recursive=true) { + $fullPath = $path; + if ($isLogicPath) { + $fullPath = $this->datadir.$path; + } + $this->mapper->removePath($fullPath, $isLogicPath, $recursive); + } + + private function copyMapping($path1, $path2) { + $path1 = $this->stripLeading($path1); + $path2 = $this->stripLeading($path2); + + $fullPath1 = $this->datadir.$path1; + $fullPath2 = $this->datadir.$path2; + + $this->mapper->copy($fullPath1, $fullPath2); + } + + private function stripLeading($path) { + if(strpos($path, '/') === 0) { + $path = substr($path, 1); + } + + return $path; + } +} diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php index 542d2cd9f48..d84dbda2e39 100644 --- a/lib/files/storage/temporary.php +++ b/lib/files/storage/temporary.php @@ -21,6 +21,7 @@ class Temporary extends Local{ } public function __destruct() { + parent::__destruct(); $this->cleanUp(); } } diff --git a/lib/files/view.php b/lib/files/view.php index dfcb770328b..1a234228eab 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -509,11 +509,7 @@ class View { if (Filesystem::isValidPath($path)) { $source = $this->fopen($path, 'r'); if ($source) { - $extension = ''; - $extOffset = strpos($path, '.'); - if ($extOffset !== false) { - $extension = substr($path, strrpos($path, '.')); - } + $extension = pathinfo($path, PATHINFO_EXTENSION); $tmpFile = \OC_Helper::tmpFile($extension); file_put_contents($tmpFile, $source); return $tmpFile; diff --git a/lib/filesystem.php b/lib/filesystem.php index 57cca902303..e86bea6bff9 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -58,8 +58,8 @@ class OC_Filesystem { /** * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem */ - static public function init($root) { - return \OC\Files\Filesystem::init($root); + static public function init($user, $root) { + return \OC\Files\Filesystem::init($user, $root); } /** diff --git a/lib/helper.php b/lib/helper.php index 0e549d006a1..2713ffed451 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -394,13 +394,12 @@ class OC_Helper { // it looks like we have a 'file' command, // lets see if it does have mime support $path=escapeshellarg($path); - $fp = popen("file -i -b $path 2>/dev/null", "r"); + $fp = popen("file -b --mime-type $path 2>/dev/null", "r"); $reply = fgets($fp); pclose($fp); - // we have smth like 'text/x-c++; charset=us-ascii\n' - // and need to eliminate everything starting with semicolon including trailing LF - $mimeType = preg_replace('/;.*/ms', '', trim($reply)); + //trim the newline + $mimeType = trim($reply); } return $mimeType; @@ -437,8 +436,9 @@ class OC_Helper { //FIXME: should also check for value validation (i.e. the email is an email). public static function init_var($s, $d="") { $r = $d; - if(isset($_REQUEST[$s]) && !empty($_REQUEST[$s])) - $r = stripslashes(htmlspecialchars($_REQUEST[$s])); + if(isset($_REQUEST[$s]) && !empty($_REQUEST[$s])) { + $r = OC_Util::sanitizeHTML($_REQUEST[$s]); + } return $r; } diff --git a/lib/l10n.php b/lib/l10n.php index ee879009265..e272bcd79f3 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -97,7 +97,7 @@ class OC_L10N{ if ($this->app === true) { return; } - $app = $this->app; + $app = OC_App::cleanAppId($this->app); $lang = $this->lang; $this->app = true; // Find the right language diff --git a/lib/l10n/bg_BG.php b/lib/l10n/bg_BG.php index 31f37458b81..fed7f29cbb2 100644 --- a/lib/l10n/bg_BG.php +++ b/lib/l10n/bg_BG.php @@ -9,6 +9,7 @@ "Files need to be downloaded one by one." => "Файловете трябва да се изтеглят един по един.", "Back to Files" => "Назад към файловете", "Selected files too large to generate zip file." => "Избраните файлове са прекалено големи за генерирането на ZIP архив.", +"couldn't be determined" => "не може да се определи", "Application is not enabled" => "Приложението не е включено.", "Authentication error" => "Възникна проблем с идентификацията", "Token expired. Please reload page." => "Ключът е изтекъл, моля презаредете страницата", diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php index f6401fa39b6..3e3938aa6cb 100644 --- a/lib/l10n/ca.php +++ b/lib/l10n/ca.php @@ -16,6 +16,26 @@ "Files" => "Fitxers", "Text" => "Text", "Images" => "Imatges", +"Set an admin username." => "Establiu un nom d'usuari per l'administrador.", +"Set an admin password." => "Establiu una contrasenya per l'administrador.", +"Specify a data folder." => "Especifiqueu una carpeta de dades.", +"%s enter the database username." => "%s escriviu el nom d'usuari de la base de dades.", +"%s enter the database name." => "%s escriviu el nom de la base de dades.", +"%s you may not use dots in the database name" => "%s no podeu usar punts en el nom de la base de dades", +"%s set the database host." => "%s establiu l'ordinador central de la base de dades.", +"PostgreSQL username and/or password not valid" => "Nom d'usuari i/o contrasenya PostgreSQL no vàlids", +"You need to enter either an existing account or the administrator." => "Heu d'escriure un compte existent o el d'administrador.", +"Oracle username and/or password not valid" => "Nom d'usuari i/o contrasenya Oracle no vàlids", +"MySQL username and/or password not valid" => "Nom d'usuari i/o contrasenya MySQL no vàlids", +"DB Error: \"%s\"" => "Error DB: \"%s\"", +"Offending command was: \"%s\"" => "L'ordre en conflicte és: \"%s\"", +"MySQL user '%s'@'localhost' exists already." => "L'usuari MySQL '%s'@'localhost' ja existeix.", +"Drop this user from MySQL" => "Elimina aquest usuari de MySQL", +"MySQL user '%s'@'%%' already exists" => "L'usuari MySQL '%s'@'%%' ja existeix", +"Drop this user from MySQL." => "Elimina aquest usuari de MySQL.", +"Offending command was: \"%s\", name: %s, password: %s" => "L'ordre en conflicte és: \"%s\", nom: %s, contrasenya: %s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "El servidor web no està configurat correctament per permetre la sincronització de fitxers perquè la interfície WebDAV sembla no funcionar correctament.", +"Please double check the <a href='%s'>installation guides</a>." => "Comproveu les <a href='%s'>guies d'instal·lació</a>.", "seconds ago" => "segons enrere", "1 minute ago" => "fa 1 minut", "%d minutes ago" => "fa %d minuts", diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php index 2c823194b96..d99f259cb0f 100644 --- a/lib/l10n/cs_CZ.php +++ b/lib/l10n/cs_CZ.php @@ -16,6 +16,26 @@ "Files" => "Soubory", "Text" => "Text", "Images" => "Obrázky", +"Set an admin username." => "Zadejte uživatelské jméno správce.", +"Set an admin password." => "Zadejte heslo správce.", +"Specify a data folder." => "Určete složku dat.", +"%s enter the database username." => "Zadejte uživatelské jméno %s databáze.", +"%s enter the database name." => "Zadejte název databáze pro %s databáze.", +"%s you may not use dots in the database name" => "V názvu databáze %s nesmíte používat tečky.", +"%s set the database host." => "Zadejte název počítače s databází %s.", +"PostgreSQL username and/or password not valid" => "Uživatelské jméno, či heslo PostgreSQL není platné", +"You need to enter either an existing account or the administrator." => "Musíte zadat existující účet, či správce.", +"Oracle username and/or password not valid" => "Uživatelské jméno, či heslo Oracle není platné", +"MySQL username and/or password not valid" => "Uživatelské jméno, či heslo MySQL není platné", +"DB Error: \"%s\"" => "Chyba DB: \"%s\"", +"Offending command was: \"%s\"" => "Podezřelý příkaz byl: \"%s\"", +"MySQL user '%s'@'localhost' exists already." => "Uživatel '%s'@'localhost' již v MySQL existuje.", +"Drop this user from MySQL" => "Zahodit uživatele z MySQL", +"MySQL user '%s'@'%%' already exists" => "Uživatel '%s'@'%%' již v MySQL existuje", +"Drop this user from MySQL." => "Zahodit uživatele z MySQL.", +"Offending command was: \"%s\", name: %s, password: %s" => "Podezřelý příkaz byl: \"%s\", jméno: %s, heslo: %s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Váš webový server není správně nastaven pro umožnění synchronizace, protože rozhraní WebDAV je rozbité.", +"Please double check the <a href='%s'>installation guides</a>." => "Zkonzultujte, prosím, <a href='%s'>průvodce instalací</a>.", "seconds ago" => "před vteřinami", "1 minute ago" => "před 1 minutou", "%d minutes ago" => "před %d minutami", diff --git a/lib/l10n/da.php b/lib/l10n/da.php index 8f22be5e823..e61fba30ff3 100644 --- a/lib/l10n/da.php +++ b/lib/l10n/da.php @@ -16,6 +16,26 @@ "Files" => "Filer", "Text" => "SMS", "Images" => "Billeder", +"Set an admin username." => "Angiv et admin brugernavn.", +"Set an admin password." => "Angiv et admin kodeord.", +"Specify a data folder." => "Specificer en data mappe.", +"%s enter the database username." => "%s indtast database brugernavnet.", +"%s enter the database name." => "%s indtast database navnet.", +"%s you may not use dots in the database name" => "%s du må ikke bruge punktummer i databasenavnet.", +"%s set the database host." => "%s sæt database værten.", +"PostgreSQL username and/or password not valid" => "PostgreSQL brugernavn og/eller kodeord er ikke gyldigt.", +"You need to enter either an existing account or the administrator." => "Du bliver nødt til at indtaste en eksisterende bruger eller en administrator.", +"Oracle username and/or password not valid" => "Oracle brugernavn og/eller kodeord er ikke gyldigt.", +"MySQL username and/or password not valid" => "MySQL brugernavn og/eller kodeord er ikke gyldigt.", +"DB Error: \"%s\"" => "Databasefejl: \"%s\"", +"Offending command was: \"%s\"" => "Fejlende kommando var: \"%s\"", +"MySQL user '%s'@'localhost' exists already." => "MySQL brugeren '%s'@'localhost' eksisterer allerede.", +"Drop this user from MySQL" => "Slet denne bruger fra MySQL", +"MySQL user '%s'@'%%' already exists" => "MySQL brugeren '%s'@'%%' eksisterer allerede.", +"Drop this user from MySQL." => "Slet denne bruger fra MySQL", +"Offending command was: \"%s\", name: %s, password: %s" => "Fejlende kommando var: \"%s\", navn: %s, password: %s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Din webserver er endnu ikke sat op til at tillade fil synkronisering fordi WebDAV grænsefladen virker ødelagt.", +"Please double check the <a href='%s'>installation guides</a>." => "Dobbelttjek venligst <a href='%s'>installations vejledningerne</a>.", "seconds ago" => "sekunder siden", "1 minute ago" => "1 minut siden", "%d minutes ago" => "%d minutter siden", diff --git a/lib/l10n/es.php b/lib/l10n/es.php index 8bbc8a8f7b4..f3b03b56652 100644 --- a/lib/l10n/es.php +++ b/lib/l10n/es.php @@ -16,6 +16,8 @@ "Files" => "Archivos", "Text" => "Texto", "Images" => "Imágenes", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Su servidor web aún no está configurado adecuadamente para permitir sincronización de archivos ya que la interfaz WebDAV parece no estar funcionando.", +"Please double check the <a href='%s'>installation guides</a>." => "Por favor, vuelva a comprobar las <a href='%s'>guías de instalación</a>.", "seconds ago" => "hace segundos", "1 minute ago" => "hace 1 minuto", "%d minutes ago" => "hace %d minutos", diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php index c32017a10f8..8e3f3d5e903 100644 --- a/lib/l10n/es_AR.php +++ b/lib/l10n/es_AR.php @@ -16,6 +16,11 @@ "Files" => "Archivos", "Text" => "Texto", "Images" => "Imágenes", +"Set an admin username." => "Configurar un nombre de administrador", +"Set an admin password." => "Configurar una palabra clave de administrador", +"Specify a data folder." => "Especificar un directorio de datos", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Tu servidor web no está configurado todavía para permitir sincronización de archivos porque la interfaz WebDAV parece no funcionar.", +"Please double check the <a href='%s'>installation guides</a>." => "Por favor, comprobá nuevamente la <a href='%s'>guía de instalación</a>.", "seconds ago" => "hace unos segundos", "1 minute ago" => "hace 1 minuto", "%d minutes ago" => "hace %d minutos", diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php index b8d4b137431..fb94dd8404c 100644 --- a/lib/l10n/fi_FI.php +++ b/lib/l10n/fi_FI.php @@ -16,6 +16,7 @@ "Files" => "Tiedostot", "Text" => "Teksti", "Images" => "Kuvat", +"Please double check the <a href='%s'>installation guides</a>." => "Lue tarkasti <a href='%s'>asennusohjeet</a>.", "seconds ago" => "sekuntia sitten", "1 minute ago" => "1 minuutti sitten", "%d minutes ago" => "%d minuuttia sitten", diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php index c6bf8f7f9c3..852fe1ddc4a 100644 --- a/lib/l10n/fr.php +++ b/lib/l10n/fr.php @@ -16,6 +16,8 @@ "Files" => "Fichiers", "Text" => "Texte", "Images" => "Images", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Votre serveur web, n'est pas correctement configuré pour permettre la synchronisation des fichiers, car l'interface WebDav ne fonctionne pas comme il faut.", +"Please double check the <a href='%s'>installation guides</a>." => "Veuillez vous référer au <a href='%s'>guide d'installation</a>.", "seconds ago" => "à l'instant", "1 minute ago" => "il y a 1 minute", "%d minutes ago" => "il y a %d minutes", diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php index 532b3443b44..c49e8134af1 100644 --- a/lib/l10n/gl.php +++ b/lib/l10n/gl.php @@ -5,18 +5,20 @@ "Users" => "Usuarios", "Apps" => "Aplicativos", "Admin" => "Administración", -"ZIP download is turned off." => "As descargas ZIP están desactivadas", +"ZIP download is turned off." => "As descargas ZIP están desactivadas.", "Files need to be downloaded one by one." => "Os ficheiros necesitan seren descargados de un en un.", "Back to Files" => "Volver aos ficheiros", "Selected files too large to generate zip file." => "Os ficheiros seleccionados son demasiado grandes como para xerar un ficheiro zip.", -"couldn't be determined" => "non puido ser determinado", +"couldn't be determined" => "non foi posíbel determinalo", "Application is not enabled" => "O aplicativo non está activado", "Authentication error" => "Produciuse un erro na autenticación", "Token expired. Please reload page." => "Testemuña caducada. Recargue a páxina.", "Files" => "Ficheiros", "Text" => "Texto", "Images" => "Imaxes", -"seconds ago" => "hai segundos", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "O seu servidor web non está aínda configurado adecuadamente para permitir a sincronización de ficheiros xa que semella que a interface WebDAV non está a funcionar.", +"Please double check the <a href='%s'>installation guides</a>." => "Volva comprobar as <a href='%s'>guías de instalación</a>", +"seconds ago" => "segundos atrás", "1 minute ago" => "hai 1 minuto", "%d minutes ago" => "hai %d minutos", "1 hour ago" => "Vai 1 hora", diff --git a/lib/l10n/it.php b/lib/l10n/it.php index eb404db7fb5..fa4bac8ec46 100644 --- a/lib/l10n/it.php +++ b/lib/l10n/it.php @@ -16,6 +16,26 @@ "Files" => "File", "Text" => "Testo", "Images" => "Immagini", +"Set an admin username." => "Imposta un nome utente di amministrazione.", +"Set an admin password." => "Imposta una password di amministrazione.", +"Specify a data folder." => "Specifica una cartella dei dati.", +"%s enter the database username." => "%s digita il nome utente del database.", +"%s enter the database name." => "%s digita il nome del database.", +"%s you may not use dots in the database name" => "%s non dovresti utilizzare punti nel nome del database", +"%s set the database host." => "%s imposta l'host del database.", +"PostgreSQL username and/or password not valid" => "Nome utente e/o password di PostgreSQL non validi", +"You need to enter either an existing account or the administrator." => "È necessario inserire un account esistente o l'amministratore.", +"Oracle username and/or password not valid" => "Nome utente e/o password di Oracle non validi", +"MySQL username and/or password not valid" => "Nome utente e/o password di MySQL non validi", +"DB Error: \"%s\"" => "Errore DB: \"%s\"", +"Offending command was: \"%s\"" => "Il comando non consentito era: \"%s\"", +"MySQL user '%s'@'localhost' exists already." => "L'utente MySQL '%s'@'localhost' esiste già.", +"Drop this user from MySQL" => "Elimina questo utente da MySQL", +"MySQL user '%s'@'%%' already exists" => "L'utente MySQL '%s'@'%%' esiste già", +"Drop this user from MySQL." => "Elimina questo utente da MySQL.", +"Offending command was: \"%s\", name: %s, password: %s" => "Il comando non consentito era: \"%s\", nome: %s, password: %s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Il tuo server web non è configurato correttamente per consentire la sincronizzazione dei file poiché l'interfaccia WebDAV sembra essere danneggiata.", +"Please double check the <a href='%s'>installation guides</a>." => "Leggi attentamente le <a href='%s'>guide d'installazione</a>.", "seconds ago" => "secondi fa", "1 minute ago" => "1 minuto fa", "%d minutes ago" => "%d minuti fa", diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php index 9f2a0dea749..5ec9ddd9693 100644 --- a/lib/l10n/lv.php +++ b/lib/l10n/lv.php @@ -16,6 +16,26 @@ "Files" => "Datnes", "Text" => "Teksts", "Images" => "Attēli", +"Set an admin username." => "Iestatiet administratora lietotājvārdu.", +"Set an admin password." => "Iestatiet administratora paroli.", +"Specify a data folder." => "Norādiet datu mapi.", +"%s enter the database username." => "%s ievadiet datubāzes lietotājvārdu.", +"%s enter the database name." => "%s ievadiet datubāzes nosaukumu.", +"%s you may not use dots in the database name" => "%s datubāžu nosaukumos nedrīkst izmantot punktus", +"%s set the database host." => "%s iestatiet datubāžu serveri.", +"PostgreSQL username and/or password not valid" => "Nav derīga PostgreSQL parole un/vai lietotājvārds", +"You need to enter either an existing account or the administrator." => "Jums jāievada vai nu esošs vai administratora konts.", +"Oracle username and/or password not valid" => "Nav derīga Oracle parole un/vai lietotājvārds", +"MySQL username and/or password not valid" => "Nav derīga MySQL parole un/vai lietotājvārds", +"DB Error: \"%s\"" => "DB kļūda — “%s”", +"Offending command was: \"%s\"" => "Vainīgā komanda bija “%s”", +"MySQL user '%s'@'localhost' exists already." => "MySQL lietotājs %s'@'localhost' jau eksistē.", +"Drop this user from MySQL" => "Izmest šo lietotāju no MySQL", +"MySQL user '%s'@'%%' already exists" => "MySQL lietotājs '%s'@'%%' jau eksistē", +"Drop this user from MySQL." => "Izmest šo lietotāju no MySQL.", +"Offending command was: \"%s\", name: %s, password: %s" => "Vainīgā komanda bija \"%s\", vārds: %s, parole: %s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Jūsu serveris vēl nav pareizi iestatīts, lai ļautu sinhronizēt datnes, jo izskatās, ka WebDAV saskarne ir salauzta.", +"Please double check the <a href='%s'>installation guides</a>." => "Lūdzu, vēlreiz pārbaudiet <a href='%s'>instalēšanas palīdzību</a>.", "seconds ago" => "sekundes atpakaļ", "1 minute ago" => "pirms 1 minūtes", "%d minutes ago" => "pirms %d minūtēm", diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php index 7ce134e3621..4a357889fdc 100644 --- a/lib/l10n/nl.php +++ b/lib/l10n/nl.php @@ -16,6 +16,26 @@ "Files" => "Bestanden", "Text" => "Tekst", "Images" => "Afbeeldingen", +"Set an admin username." => "Stel de gebruikersnaam van de beheerder in.", +"Set an admin password." => "Stel een beheerderswachtwoord in.", +"Specify a data folder." => "Geef een datamap op.", +"%s enter the database username." => "%s opgeven database gebruikersnaam.", +"%s enter the database name." => "%s opgeven databasenaam.", +"%s you may not use dots in the database name" => "%s er mogen geen puntjes in de databasenaam voorkomen", +"%s set the database host." => "%s instellen databaseservernaam.", +"PostgreSQL username and/or password not valid" => "PostgreSQL gebruikersnaam en/of wachtwoord ongeldig", +"You need to enter either an existing account or the administrator." => "Geef of een bestaand account op of het beheerdersaccount.", +"Oracle username and/or password not valid" => "Oracle gebruikersnaam en/of wachtwoord ongeldig", +"MySQL username and/or password not valid" => "MySQL gebruikersnaam en/of wachtwoord ongeldig", +"DB Error: \"%s\"" => "DB Fout: \"%s\"", +"Offending command was: \"%s\"" => "Onjuiste commande was: \"%s\"", +"MySQL user '%s'@'localhost' exists already." => "MySQL gebruiker '%s'@'localhost' bestaat al.", +"Drop this user from MySQL" => "Verwijder deze gebruiker uit MySQL", +"MySQL user '%s'@'%%' already exists" => "MySQL gebruiker '%s'@'%%' bestaat al", +"Drop this user from MySQL." => "Verwijder deze gebruiker uit MySQL.", +"Offending command was: \"%s\", name: %s, password: %s" => "Onjuiste commando was: \"%s\", naam: %s, wachtwoord: %s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Uw webserver is nog niet goed ingesteld voor bestandssynchronisatie omdat de WebDAV interface verbroken lijkt.", +"Please double check the <a href='%s'>installation guides</a>." => "Conntroleer de <a href='%s'>installatie handleiding</a> goed.", "seconds ago" => "seconden geleden", "1 minute ago" => "1 minuut geleden", "%d minutes ago" => "%d minuten geleden", diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php index e35bb489c49..67b8078ddfa 100644 --- a/lib/l10n/pt_PT.php +++ b/lib/l10n/pt_PT.php @@ -16,6 +16,8 @@ "Files" => "Ficheiros", "Text" => "Texto", "Images" => "Imagens", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "O seu servidor web não está configurado correctamente para autorizar sincronização de ficheiros, pois o interface WebDAV parece estar com problemas.", +"Please double check the <a href='%s'>installation guides</a>." => "Por favor verifique <a href='%s'>installation guides</a>.", "seconds ago" => "há alguns segundos", "1 minute ago" => "há 1 minuto", "%d minutes ago" => "há %d minutos", diff --git a/lib/l10n/ru_RU.php b/lib/l10n/ru_RU.php index 03da09236ea..de770563662 100644 --- a/lib/l10n/ru_RU.php +++ b/lib/l10n/ru_RU.php @@ -16,6 +16,8 @@ "Files" => "Файлы", "Text" => "Текст", "Images" => "Изображения", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ваш веб сервер ещё не достаточно точно настроен для возможности синхронизации, т.к. похоже, что интерфейс WebDAV сломан.", +"Please double check the <a href='%s'>installation guides</a>." => "Пожалуйста проверте дважды <a href='%s'>гиды по установке</a>.", "seconds ago" => "секунд назад", "1 minute ago" => "1 минуту назад", "%d minutes ago" => "%d минут назад", diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php index 81f23ffdc50..16df7f2e199 100644 --- a/lib/l10n/sk_SK.php +++ b/lib/l10n/sk_SK.php @@ -2,13 +2,13 @@ "Help" => "Pomoc", "Personal" => "Osobné", "Settings" => "Nastavenia", -"Users" => "Užívatelia", +"Users" => "Používatelia", "Apps" => "Aplikácie", -"Admin" => "Správca", +"Admin" => "Administrátor", "ZIP download is turned off." => "Sťahovanie súborov ZIP je vypnuté.", "Files need to be downloaded one by one." => "Súbory musia byť nahrávané jeden za druhým.", "Back to Files" => "Späť na súbory", -"Selected files too large to generate zip file." => "Zvolené súbory sú príliž veľké na vygenerovanie zip súboru.", +"Selected files too large to generate zip file." => "Zvolené súbory sú príliš veľké na vygenerovanie zip súboru.", "couldn't be determined" => "nedá sa zistiť", "Application is not enabled" => "Aplikácia nie je zapnutá", "Authentication error" => "Chyba autentifikácie", @@ -16,6 +16,8 @@ "Files" => "Súbory", "Text" => "Text", "Images" => "Obrázky", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Váš webový server nie je správne nastavený na synchronizáciu, pretože rozhranie WebDAV je poškodené.", +"Please double check the <a href='%s'>installation guides</a>." => "Prosím skontrolujte <a href='%s'>inštalačnú príručku</a>.", "seconds ago" => "pred sekundami", "1 minute ago" => "pred 1 minútou", "%d minutes ago" => "pred %d minútami", @@ -28,7 +30,7 @@ "%d months ago" => "Pred %d mesiacmi.", "last year" => "minulý rok", "years ago" => "pred rokmi", -"%s is available. Get <a href=\"%s\">more information</a>" => "%s je dostupné. Získať <a href=\"%s\">viac informácií</a>", +"%s is available. Get <a href=\"%s\">more information</a>" => "%s je dostupné. Získať <a href=\"%s\">pre viac informácií</a>", "up to date" => "aktuálny", "updates check is disabled" => "sledovanie aktualizácií je vypnuté", "Could not find category \"%s\"" => "Nemožno nájsť danú kategóriu \"%s\"" diff --git a/lib/l10n/sv.php b/lib/l10n/sv.php index 36f00636b2b..63ca60e89cd 100644 --- a/lib/l10n/sv.php +++ b/lib/l10n/sv.php @@ -16,6 +16,8 @@ "Files" => "Filer", "Text" => "Text", "Images" => "Bilder", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Din webbserver är inte korrekt konfigurerad för att tillåta filsynkronisering eftersom WebDAV inte verkar fungera.", +"Please double check the <a href='%s'>installation guides</a>." => "Var god kontrollera <a href='%s'>installationsguiden</a>.", "seconds ago" => "sekunder sedan", "1 minute ago" => "1 minut sedan", "%d minutes ago" => "%d minuter sedan", diff --git a/lib/l10n/vi.php b/lib/l10n/vi.php index 8b7242ae611..ea9660093ae 100644 --- a/lib/l10n/vi.php +++ b/lib/l10n/vi.php @@ -9,6 +9,7 @@ "Files need to be downloaded one by one." => "Tập tin cần phải được tải về từng người một.", "Back to Files" => "Trở lại tập tin", "Selected files too large to generate zip file." => "Tập tin được chọn quá lớn để tạo tập tin ZIP.", +"couldn't be determined" => "không thể phát hiện được", "Application is not enabled" => "Ứng dụng không được BẬT", "Authentication error" => "Lỗi xác thực", "Token expired. Please reload page." => "Mã Token đã hết hạn. Hãy tải lại trang.", diff --git a/lib/l10n/zh_TW.php b/lib/l10n/zh_TW.php index 62ab8fedd52..91b0329e246 100644 --- a/lib/l10n/zh_TW.php +++ b/lib/l10n/zh_TW.php @@ -16,6 +16,8 @@ "Files" => "檔案", "Text" => "文字", "Images" => "圖片", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "您的網頁伺服器尚未被正確設定來進行檔案同步,因為您的 WebDAV 界面似乎無法使用。", +"Please double check the <a href='%s'>installation guides</a>." => "請參考<a href='%s'>安裝指南</a>。", "seconds ago" => "幾秒前", "1 minute ago" => "1 分鐘前", "%d minutes ago" => "%d 分鐘前", diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php index fc87d011ecd..86ce9c6c237 100644 --- a/lib/mimetypes.list.php +++ b/lib/mimetypes.list.php @@ -97,4 +97,6 @@ return array( 'ai' => 'application/illustrator', 'epub' => 'application/epub+zip', 'mobi' => 'application/x-mobipocket-ebook', + 'exe' => 'application', + 'msi' => 'application' ); diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php index 179ed8f3107..820d24a8e0c 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -45,7 +45,7 @@ class OC_OCS_Cloud { if(OC_User::userExists($parameters['user'])) { // calculate the disc space $userDir = '/'.$parameters['user'].'/files'; - \OC\Files\Filesystem::init($useDir); + \OC\Files\Filesystem::init($parameters['user'], $userDir); $rootInfo = \OC\Files\Filesystem::getFileInfo(''); $sharedInfo = \OC\Files\Filesystem::getFileInfo('/Shared'); $used = $rootInfo['size'] - $sharedInfo['size']; diff --git a/lib/public/share.php b/lib/public/share.php index d46bee26dd4..af2a538e252 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -704,7 +704,7 @@ class Share { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, ' .'`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' .'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' - .'`name` `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; + .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; } else { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`'; } diff --git a/lib/public/util.php b/lib/public/util.php index 968ca891b4c..5f6ede4460e 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -148,6 +148,20 @@ class Util { } /** + * @brief Creates an url using a defined route + * @param $route + * @param array $parameters + * @return + * @internal param array $args with param=>value, will be appended to the returned url + * @returns the url + * + * Returns a url to the given app and file. + */ + public static function linkToRoute( $route, $parameters = array() ) { + return \OC_Helper::linkToRoute($route, $parameters); + } + + /** * @brief Creates an url * @param string $app app * @param string $file file diff --git a/lib/request.php b/lib/request.php index 1661a1406ca..3c668b02c5f 100755 --- a/lib/request.php +++ b/lib/request.php @@ -149,4 +149,16 @@ class OC_Request { return 'gzip'; return false; } + + /** + * @brief Check if the requester sent along an mtime + * @returns false or an mtime + */ + static public function hasModificationTime () { + if (isset($_SERVER['HTTP_X_OC_MTIME'])) { + return $_SERVER['HTTP_X_OC_MTIME']; + } else { + return false; + } + } } diff --git a/lib/router.php b/lib/router.php index 746b68c2c0c..dbaca9e0d5d 100644 --- a/lib/router.php +++ b/lib/router.php @@ -23,7 +23,11 @@ class OC_Router { public function __construct() { $baseUrl = OC_Helper::linkTo('', 'index.php'); - $method = $_SERVER['REQUEST_METHOD']; + if ( !OC::$CLI) { + $method = $_SERVER['REQUEST_METHOD']; + }else{ + $method = 'GET'; + } $host = OC_Request::serverHost(); $schema = OC_Request::serverProtocol(); $this->context = new RequestContext($baseUrl, $method, $host, $schema); diff --git a/lib/setup.php b/lib/setup.php index 3efad79cfad..893e0121ffa 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -19,18 +19,25 @@ class DatabaseSetupException extends Exception } class OC_Setup { + + public static function getTrans(){ + return OC_L10N::get('lib'); + } + public static function install($options) { + $l = self::getTrans(); + $error = array(); $dbtype = $options['dbtype']; if(empty($options['adminlogin'])) { - $error[] = 'Set an admin username.'; + $error[] = $l->t('Set an admin username.'); } if(empty($options['adminpass'])) { - $error[] = 'Set an admin password.'; + $error[] = $l->t('Set an admin password.'); } if(empty($options['directory'])) { - $error[] = 'Specify a data folder.'; + $error[] = $l->t('Specify a data folder.'); } if($dbtype == 'mysql' or $dbtype == 'pgsql' or $dbtype == 'oci' or $dbtype == 'mssql') { //mysql and postgresql needs more config options @@ -45,16 +52,16 @@ class OC_Setup { if(empty($options['dbuser'])) { - $error[] = "$dbprettyname enter the database username."; + $error[] = $l->t("%s enter the database username.", array($dbprettyname)); } if(empty($options['dbname'])) { - $error[] = "$dbprettyname enter the database name."; + $error[] = $l->t("%s enter the database name.", array($dbprettyname)); } if(substr_count($options['dbname'], '.') >= 1) { - $error[] = "$dbprettyname you may not use dots in the database name"; + $error[] = $l->t("%s you may not use dots in the database name", array($dbprettyname)); } if($dbtype != 'oci' && empty($options['dbhost'])) { - $error[] = "$dbprettyname set the database host."; + $error[] = $l->t("%s set the database host.", array($dbprettyname)); } } @@ -118,8 +125,8 @@ class OC_Setup { self::setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username); } catch (Exception $e) { $error[] = array( - 'error' => 'PostgreSQL username and/or password not valid', - 'hint' => 'You need to enter either an existing account or the administrator.' + 'error' => $l->t('PostgreSQL username and/or password not valid'), + 'hint' => $l->t('You need to enter either an existing account or the administrator.') ); return $error; } @@ -141,8 +148,8 @@ class OC_Setup { self::setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username); } catch (Exception $e) { $error[] = array( - 'error' => 'Oracle username and/or password not valid', - 'hint' => 'You need to enter either an existing account or the administrator.' + 'error' => $l->t('Oracle username and/or password not valid'), + 'hint' => $l->t('You need to enter either an existing account or the administrator.') ); return $error; } @@ -215,9 +222,11 @@ class OC_Setup { private static function setupMySQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username) { //check if the database user has admin right + $l = self::getTrans(); $connection = @mysql_connect($dbhost, $dbuser, $dbpass); if(!$connection) { - throw new DatabaseSetupException('MySQL username and/or password not valid','You need to enter either an existing account or the administrator.'); + throw new DatabaseSetupException($l->t('MySQL username and/or password not valid'), + $l->t('You need to enter either an existing account or the administrator.')); } $oldUser=OC_Config::getValue('dbuser', false); @@ -264,11 +273,12 @@ class OC_Setup { private static function createMySQLDatabase($name, $user, $connection) { //we cant use OC_BD functions here because we need to connect as the administrative user. + $l = self::getTrans(); $query = "CREATE DATABASE IF NOT EXISTS `$name`"; $result = mysql_query($query, $connection); if(!$result) { - $entry='DB Error: "'.mysql_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(mysql_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; @@ -278,15 +288,18 @@ class OC_Setup { private static function createDBUser($name, $password, $connection) { // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one, // the anonymous user would take precedence when there is one. + $l = self::getTrans(); $query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'"; $result = mysql_query($query, $connection); if (!$result) { - throw new DatabaseSetupException("MySQL user '" . "$name" . "'@'localhost' already exists","Delete this user from MySQL."); + throw new DatabaseSetupException($l->t("MySQL user '%s'@'localhost' exists already.", + array($name)), $l->t("Drop this user from MySQL", array($name))); } $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; $result = mysql_query($query, $connection); if (!$result) { - throw new DatabaseSetupException("MySQL user '" . "$name" . "'@'%' already exists","Delete this user from MySQL."); + throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)), + $l->t("Drop this user from MySQL.")); } } @@ -294,12 +307,13 @@ class OC_Setup { $e_host = addslashes($dbhost); $e_user = addslashes($dbuser); $e_password = addslashes($dbpass); + $l = self::getTrans(); //check if the database user has admin rights $connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'"; $connection = @pg_connect($connection_string); if(!$connection) { - throw new Exception('PostgreSQL username and/or password not valid'); + throw new Exception($l->t('PostgreSQL username and/or password not valid')); } $e_user = pg_escape_string($dbuser); //check for roles creation rights in postgresql @@ -344,7 +358,7 @@ class OC_Setup { $connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' password='$e_password'"; $connection = @pg_connect($connection_string); if(!$connection) { - throw new Exception('PostgreSQL username and/or password not valid'); + throw new Exception($l->t('PostgreSQL username and/or password not valid')); } $query = "select count(*) FROM pg_class WHERE relname='{$dbtableprefix}users' limit 1"; $result = pg_query($connection, $query); @@ -357,14 +371,16 @@ class OC_Setup { } private static function pg_createDatabase($name, $user, $connection) { + //we cant use OC_BD functions here because we need to connect as the administrative user. + $l = self::getTrans(); $e_name = pg_escape_string($name); $e_user = pg_escape_string($user); $query = "select datname from pg_database where datname = '$e_name'"; $result = pg_query($connection, $query); if(!$result) { - $entry='DB Error: "'.pg_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } if(! pg_fetch_row($result)) { @@ -372,8 +388,8 @@ class OC_Setup { $query = "CREATE DATABASE \"$e_name\" OWNER \"$e_user\""; $result = pg_query($connection, $query); if(!$result) { - $entry='DB Error: "'.pg_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } else { @@ -384,13 +400,14 @@ class OC_Setup { } private static function pg_createDBUser($name, $password, $connection) { + $l = self::getTrans(); $e_name = pg_escape_string($name); $e_password = pg_escape_string($password); $query = "select * from pg_roles where rolname='$e_name';"; $result = pg_query($connection, $query); if(!$result) { - $entry='DB Error: "'.pg_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } @@ -399,8 +416,8 @@ class OC_Setup { $query = "CREATE USER \"$e_name\" CREATEDB PASSWORD '$e_password';"; $result = pg_query($connection, $query); if(!$result) { - $entry='DB Error: "'.pg_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } } @@ -408,14 +425,15 @@ class OC_Setup { $query = "ALTER ROLE \"$e_name\" WITH PASSWORD '$e_password';"; $result = pg_query($connection, $query); if(!$result) { - $entry='DB Error: "'.pg_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } } } private static function setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username) { + $l = self::getTrans(); $e_host = addslashes($dbhost); $e_dbname = addslashes($dbname); //check if the database user has admin right @@ -427,15 +445,15 @@ class OC_Setup { $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string); if(!$connection) { $e = oci_error(); - throw new Exception('Oracle username and/or password not valid'); + throw new Exception($l->t('Oracle username and/or password not valid')); } //check for roles creation rights in oracle $query="SELECT count(*) FROM user_role_privs, role_sys_privs WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'"; $stmt = oci_parse($connection, $query); if (!$stmt) { - $entry='DB Error: "'.oci_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } $result = oci_execute($stmt); @@ -493,15 +511,15 @@ class OC_Setup { } $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string); if(!$connection) { - throw new Exception('Oracle username and/or password not valid'); + throw new Exception($l->t('Oracle username and/or password not valid')); } $query = "SELECT count(*) FROM user_tables WHERE table_name = :un"; $stmt = oci_parse($connection, $query); $un = $dbtableprefix.'users'; oci_bind_by_name($stmt, ':un', $un); if (!$stmt) { - $entry='DB Error: "'.oci_last_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_last_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } $result = oci_execute($stmt); @@ -522,19 +540,19 @@ class OC_Setup { * @param resource $connection */ private static function oci_createDBUser($name, $password, $tablespace, $connection) { - + $l = self::getTrans(); $query = "SELECT * FROM all_users WHERE USERNAME = :un"; $stmt = oci_parse($connection, $query); if (!$stmt) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } oci_bind_by_name($stmt, ':un', $name); $result = oci_execute($stmt); if(!$result) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } @@ -544,31 +562,32 @@ class OC_Setup { $query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$tablespace; //TODO set default tablespace $stmt = oci_parse($connection, $query); if (!$stmt) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } //oci_bind_by_name($stmt, ':un', $name); $result = oci_execute($stmt); if(!$result) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.', name:'.$name.', password:'.$password.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s", name: %s, password: %s', + array($query, $name, $password)) . '<br />'; echo($entry); } } else { // change password of the existing role $query = "ALTER USER :un IDENTIFIED BY :pw"; $stmt = oci_parse($connection, $query); if (!$stmt) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } oci_bind_by_name($stmt, ':un', $name); oci_bind_by_name($stmt, ':pw', $password); $result = oci_execute($stmt); if(!$result) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } } @@ -576,14 +595,15 @@ class OC_Setup { $query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name; $stmt = oci_parse($connection, $query); if (!$stmt) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />'; echo($entry); } $result = oci_execute($stmt); if(!$result) { - $entry='DB Error: "'.oci_error($connection).'"<br />'; - $entry.='Offending command was: '.$query.', name:'.$name.', password:'.$password.'<br />'; + $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />'; + $entry .= $l->t('Offending command was: "%s", name: %s, password: %s', + array($query, $name, $password)) . '<br />'; echo($entry); } } @@ -807,4 +827,24 @@ class OC_Setup { file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content); file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/index.html', ''); } + + /** + * @brief Post installation checks + */ + public static function postSetupCheck($params) { + // setup was successful -> webdav testing now + $l = self::getTrans(); + if (OC_Util::isWebDAVWorking()) { + header("Location: ".OC::$WEBROOT.'/'); + } else { + + $error = $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); + $hint = $l->t('Please double check the <a href=\'%s\'>installation guides</a>.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); + + $tmpl = new OC_Template('', 'error', 'guest'); + $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false); + $tmpl->printPage(); + exit(); + } + } } diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 37ece91047f..345f540af04 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -19,6 +19,7 @@ class OC_TemplateLayout extends OC_Template { } // Add navigation entry + $this->assign( 'application', '', false ); $navigation = OC_App::getNavigation(); $this->assign( 'navigation', $navigation, false); $this->assign( 'settingsnavigation', OC_App::getSettingsNavigation(), false); @@ -28,6 +29,8 @@ class OC_TemplateLayout extends OC_Template { break; } } + $user_displayname = OC_User::getDisplayName(); + $this->assign( 'user_displayname', $user_displayname ); } else if ($renderas == 'guest') { parent::__construct('core', 'layout.guest'); } else { @@ -36,6 +39,9 @@ class OC_TemplateLayout extends OC_Template { // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); + if (OC_Config::getValue('installed', false)) { + $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config')); + } if (!empty(OC_Util::$core_scripts)) { $this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false)); } diff --git a/lib/user.php b/lib/user.php index 9dc8cca97a6..f58b6673f7f 100644 --- a/lib/user.php +++ b/lib/user.php @@ -445,10 +445,12 @@ class OC_User { * Check whether a specified user can change his display name */ public static function canUserChangeDisplayName($uid) { - foreach(self::$_usedBackends as $backend) { - if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) { - if($backend->userExists($uid)) { - return true; + if (OC_Config::getValue('allow_user_to_change_display_name', true)) { + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) { + if($backend->userExists($uid)) { + return true; + } } } } @@ -485,7 +487,7 @@ class OC_User { */ public static function getHome($uid) { foreach(self::$_usedBackends as $backend) { - if($backend->implementsActions(OC_USER_BACKEND_GET_HOME)) { + if($backend->implementsActions(OC_USER_BACKEND_GET_HOME) && $backend->userExists($uid)) { $result=$backend->getHome($uid); if($result) { return $result; diff --git a/lib/util.php b/lib/util.php index faa1a549e64..81ad2df3ac6 100755 --- a/lib/util.php +++ b/lib/util.php @@ -51,7 +51,7 @@ class OC_Util { mkdir( $userdirectory, 0755, true ); } //jail the user into his "home" directory - \OC\Files\Filesystem::init($user_dir); + \OC\Files\Filesystem::init($user, $user_dir); $quotaProxy=new OC_FileProxy_Quota(); $fileOperationProxy = new OC_FileProxy_FileOperations(); @@ -74,7 +74,7 @@ class OC_Util { */ public static function getVersion() { // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user - return array(4, 91, 9); + return array(4, 91, 10); } /** @@ -516,6 +516,40 @@ class OC_Util { } } + /** + * we test if webDAV is working properly + * + * The basic assumption is that if the server returns 401/Not Authenticated for an unauthenticated PROPFIND + * the web server it self is setup properly. + * + * Why not an authenticated PROFIND and other verbs? + * - We don't have the password available + * - We have no idea about other auth methods implemented (e.g. OAuth with Bearer header) + * + */ + public static function isWebDAVWorking() { + if (!function_exists('curl_init')) { + return; + } + + $settings = array( + 'baseUri' => OC_Helper::linkToRemote('webdav'), + ); + + $client = new \Sabre_DAV_Client($settings); + + $return = true; + try { + // test PROPFIND + $client->propfind('', array('{DAV:}resourcetype')); + } catch(\Sabre_DAV_Exception_NotAuthenticated $e) { + $return = true; + } catch(\Exception $e) { + $return = false; + } + + return $return; + } /** * Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server. @@ -526,12 +560,11 @@ class OC_Util { return true; } - $result=setlocale(LC_ALL, 'en_US.UTF-8'); - if($result==false) { - return(false); - }else{ - return(true); - } + $result = setlocale(LC_ALL, 'en_US.UTF-8', 'en_US.UTF8'); + if($result == false) { + return false; + } + return true; } /** @@ -654,6 +687,9 @@ class OC_Util { curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_MAXREDIRS, 10); + curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); if(OC_Config::getValue('proxy','')<>'') { curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy')); |