summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2013-02-05 13:44:45 +0000
committerSam Tuke <samtuke@owncloud.com>2013-02-05 13:44:45 +0000
commitfd90b82acd5c553c28998e9a66d6d914c1fb987b (patch)
tree5d67e42f6a00a79ab8e07e25caa3bae26e78dae8 /lib
parent0677d56ee226b0ba884f3e175c86540dbab643a5 (diff)
parent59ed0e6318e447e66429af43a5d3a7fe49ae9d9f (diff)
downloadnextcloud-server-fd90b82acd5c553c28998e9a66d6d914c1fb987b.tar.gz
nextcloud-server-fd90b82acd5c553c28998e9a66d6d914c1fb987b.zip
Merge github.com:owncloud/core
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php7
-rw-r--r--lib/app.php42
-rw-r--r--lib/base.php140
-rw-r--r--lib/connector/sabre/directory.php4
-rw-r--r--lib/connector/sabre/node.php4
-rw-r--r--lib/connector/sabre/request.php50
-rw-r--r--lib/files/cache/cache.php8
-rw-r--r--lib/files/cache/scanner.php2
-rw-r--r--lib/files/filesystem.php12
-rw-r--r--lib/files/storage/local.php4
-rw-r--r--lib/files/view.php16
-rw-r--r--lib/installer.php101
-rw-r--r--lib/l10n.php2
-rw-r--r--lib/l10n/af_ZA.php8
-rw-r--r--lib/l10n/fa.php13
-rw-r--r--lib/l10n/lv.php31
-rw-r--r--lib/l10n/sr.php8
-rw-r--r--lib/ocsclient.php4
-rw-r--r--lib/public/share.php3
-rw-r--r--lib/public/util.php22
-rwxr-xr-xlib/request.php45
-rw-r--r--lib/search.php16
-rw-r--r--lib/template.php2
-rwxr-xr-xlib/util.php71
24 files changed, 464 insertions, 151 deletions
diff --git a/lib/api.php b/lib/api.php
index 545b55757ff..abf1c3b0036 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -188,10 +188,13 @@ class OC_API {
private static function toXML($array, $writer) {
foreach($array as $k => $v) {
- if (is_numeric($k)) {
+ if ($k[0] === '@') {
+ $writer->writeAttribute(substr($k, 1), $v);
+ continue;
+ } else if (is_numeric($k)) {
$k = 'element';
}
- if (is_array($v)) {
+ if(is_array($v)) {
$writer->startElement($k);
self::toXML($v, $writer);
$writer->endElement();
diff --git a/lib/app.php b/lib/app.php
index 73bee11a69c..fa3e14ce4d2 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -142,6 +142,8 @@ class OC_App{
* check if app is shipped
* @param string $appid the id of the app to check
* @return bool
+ *
+ * Check if an app that is installed is a shipped app or installed from the appstore.
*/
public static function isShipped($appid){
$info = self::getAppInfo($appid);
@@ -177,7 +179,7 @@ class OC_App{
* This function checks whether or not an app is enabled.
*/
public static function isEnabled( $app ) {
- if( 'files'==$app or 'yes' == OC_Appconfig::getValue( $app, 'enabled' )) {
+ if( 'files'==$app or ('yes' == OC_Appconfig::getValue( $app, 'enabled' ))) {
return true;
}
@@ -197,9 +199,10 @@ class OC_App{
if(!is_numeric($app)) {
$app = OC_Installer::installShippedApp($app);
}else{
+ $appdata=OC_OCSClient::getApplication($app);
$download=OC_OCSClient::getApplicationDownload($app, 1);
if(isset($download['downloadlink']) and $download['downloadlink']!='') {
- $app=OC_Installer::installApp(array('source'=>'http', 'href'=>$download['downloadlink']));
+ $app=OC_Installer::installApp(array('source'=>'http', 'href'=>$download['downloadlink'],'appdata'=>$appdata));
}
}
}
@@ -212,6 +215,9 @@ class OC_App{
return false;
}else{
OC_Appconfig::setValue( $app, 'enabled', 'yes' );
+ if(isset($appdata['id'])) {
+ OC_Appconfig::setValue( $app, 'ocsid', $appdata['id'] );
+ }
return true;
}
}else{
@@ -227,8 +233,13 @@ class OC_App{
* This function set an app as disabled in appconfig.
*/
public static function disable( $app ) {
- // check if app is a shiped app or not. if not delete
+ // check if app is a shipped app or not. if not delete
OC_Appconfig::setValue( $app, 'enabled', 'no' );
+
+ // check if app is a shipped app or not. if not delete
+ if(!OC_App::isShipped( $app )){
+ OC_Installer::removeApp( $app );
+ }
}
/**
@@ -495,7 +506,7 @@ class OC_App{
* @return string
*/
public static function getCurrentApp() {
- $script=substr($_SERVER["SCRIPT_NAME"], strlen(OC::$WEBROOT)+1);
+ $script=substr(OC_Request::scriptName(), strlen(OC::$WEBROOT)+1);
$topFolder=substr($script, 0, strpos($script, '/'));
if (empty($topFolder)) {
$path_info = OC_Request::getPathInfo();
@@ -621,9 +632,13 @@ class OC_App{
if(isset($info['shipped']) and ($info['shipped']=='true')) {
$info['internal']=true;
$info['internallabel']='Internal App';
+ $info['internalclass']='';
+ $info['update']=false;
} else {
$info['internal']=false;
$info['internallabel']='3rd Party App';
+ $info['internalclass']='externalapp';
+ $info['update']=OC_Installer::isUpdateAvailable($app);
}
$info['preview'] = OC_Helper::imagePath('settings', 'trans.png');
@@ -633,15 +648,15 @@ class OC_App{
}
$remoteApps = OC_App::getAppstoreApps();
if ( $remoteApps ) {
- // Remove duplicates
+ // Remove duplicates
foreach ( $appList as $app ) {
foreach ( $remoteApps AS $key => $remote ) {
if (
$app['name'] == $remote['name']
- // To set duplicate detection to use OCS ID instead of string name,
- // enable this code, remove the line of code above,
- // and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app:
- // OR $app['ocs_id'] == $remote['ocs_id']
+ // To set duplicate detection to use OCS ID instead of string name,
+ // enable this code, remove the line of code above,
+ // and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app:
+ // OR $app['ocs_id'] == $remote['ocs_id']
) {
unset( $remoteApps[$key]);
}
@@ -675,6 +690,15 @@ class OC_App{
$app1[$i]['author'] = $app['personid'];
$app1[$i]['ocs_id'] = $app['id'];
$app1[$i]['internal'] = $app1[$i]['active'] = 0;
+ $app1[$i]['update'] = false;
+ if($app['label']=='recommended'){
+ $app1[$i]['internallabel'] = 'Recommended';
+ $app1[$i]['internalclass'] = 'recommendedapp';
+ }else{
+ $app1[$i]['internallabel'] = '3rd Party';
+ $app1[$i]['internalclass'] = 'externalapp';
+ }
+
// rating img
if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" );
diff --git a/lib/base.php b/lib/base.php
index ea5c939cd80..90e64f13af6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -27,8 +27,7 @@ require_once 'public/constants.php';
* No, we can not put this class in its own file because it is used by
* OC_autoload!
*/
-class OC
-{
+class OC {
/**
* Associative array for autoloading. classname => filename
*/
@@ -78,13 +77,12 @@ class OC
/**
* SPL autoload
*/
- public static function autoload($className)
- {
+ public static function autoload($className) {
if (array_key_exists($className, OC::$CLASSPATH)) {
$path = OC::$CLASSPATH[$className];
/** @TODO: Remove this when necessary
- Remove "apps/" from inclusion path for smooth migration to mutli app dir
- */
+ Remove "apps/" from inclusion path for smooth migration to mutli app dir
+ */
if (strpos($path, 'apps/') === 0) {
OC_Log::write('core', 'include path for class "' . $className . '" starts with "apps/"', OC_Log::DEBUG);
$path = str_replace('apps/', '', $path);
@@ -96,7 +94,7 @@ class OC
} elseif (strpos($className, 'OCP\\') === 0) {
$path = 'public/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
} elseif (strpos($className, 'OCA\\') === 0) {
- foreach(self::$APPSROOTS as $appDir) {
+ foreach (self::$APPSROOTS as $appDir) {
$path = $appDir['path'] . '/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
$fullPath = stream_resolve_include_path($path);
if (file_exists($fullPath)) {
@@ -124,12 +122,18 @@ class OC
return false;
}
- public static function initPaths()
- {
+ public static function initPaths() {
// calculate the root directories
OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
+
+ // ensure we can find OC_Config
+ set_include_path(
+ OC::$SERVERROOT . '/lib' . PATH_SEPARATOR .
+ get_include_path()
+ );
+
OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
- $scriptName = $_SERVER["SCRIPT_NAME"];
+ $scriptName = OC_Request::scriptName();
if (substr($scriptName, -1) == '/') {
$scriptName .= 'index.php';
//make sure suburi follows the same rules as scriptName
@@ -147,12 +151,6 @@ class OC
OC::$WEBROOT = '/' . OC::$WEBROOT;
}
- // ensure we can find OC_Config
- set_include_path(
- OC::$SERVERROOT . '/lib' . PATH_SEPARATOR .
- get_include_path()
- );
-
// search the 3rdparty folder
if (OC_Config::getValue('3rdpartyroot', '') <> '' and OC_Config::getValue('3rdpartyurl', '') <> '') {
OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', '');
@@ -188,17 +186,18 @@ class OC
exit;
}
$paths = array();
- foreach (OC::$APPSROOTS as $path)
+ foreach (OC::$APPSROOTS as $path) {
$paths[] = $path['path'];
+ }
// set the right include path
set_include_path(
OC::$SERVERROOT . '/lib' . PATH_SEPARATOR .
- OC::$SERVERROOT . '/config' . PATH_SEPARATOR .
- OC::$THIRDPARTYROOT . '/3rdparty' . PATH_SEPARATOR .
- implode($paths, PATH_SEPARATOR) . PATH_SEPARATOR .
- get_include_path() . PATH_SEPARATOR .
- OC::$SERVERROOT
+ OC::$SERVERROOT . '/config' . PATH_SEPARATOR .
+ OC::$THIRDPARTYROOT . '/3rdparty' . PATH_SEPARATOR .
+ implode($paths, PATH_SEPARATOR) . PATH_SEPARATOR .
+ get_include_path() . PATH_SEPARATOR .
+ OC::$SERVERROOT
);
}
@@ -211,8 +210,7 @@ class OC
}
}
- public static function checkInstalled()
- {
+ public static function checkInstalled() {
// Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
if (!OC::$CLI) {
@@ -223,14 +221,13 @@ class OC
}
}
- public static function checkSSL()
- {
+ public static function checkSSL() {
// redirect to https site if configured
if (OC_Config::getValue("forcessl", false)) {
header('Strict-Transport-Security: max-age=31536000');
ini_set("session.cookie_secure", "on");
if (OC_Request::serverProtocol() <> 'https' and !OC::$CLI) {
- $url = "https://" . OC_Request::serverHost() . $_SERVER['REQUEST_URI'];
+ $url = "https://" . OC_Request::serverHost() . OC_Request::requestUri();
header("Location: $url");
exit();
}
@@ -274,8 +271,7 @@ class OC
}
}
- public static function initTemplateEngine()
- {
+ public static function initTemplateEngine() {
// Add the stuff we need always
OC_Util::addScript("jquery-1.7.2.min");
OC_Util::addScript("jquery-ui-1.10.0.custom");
@@ -297,8 +293,7 @@ class OC
OC_Util::addScript("oc-requesttoken");
}
- public static function initSession()
- {
+ public static function initSession() {
// prevents javascript from accessing php session cookies
ini_set('session.cookie_httponly', '1;');
@@ -328,8 +323,7 @@ class OC
$_SESSION['LAST_ACTIVITY'] = time();
}
- public static function getRouter()
- {
+ public static function getRouter() {
if (!isset(OC::$router)) {
OC::$router = new OC_Router();
OC::$router->loadRoutes();
@@ -339,19 +333,17 @@ class OC
}
- public static function loadAppClassPaths()
- {
- foreach(OC_APP::getEnabledApps() as $app) {
- $file = OC_App::getAppPath($app).'/appinfo/classpath.php';
- if(file_exists($file)) {
+ public static function loadAppClassPaths() {
+ foreach (OC_APP::getEnabledApps() as $app) {
+ $file = OC_App::getAppPath($app) . '/appinfo/classpath.php';
+ if (file_exists($file)) {
require_once $file;
}
}
}
- public static function init()
- {
+ public static function init() {
// register autoloader
spl_autoload_register(array('OC', 'autoload'));
setlocale(LC_ALL, 'en_US.UTF-8');
@@ -516,8 +508,7 @@ class OC
/**
* register hooks for the cache
*/
- public static function registerCacheHooks()
- {
+ public static function registerCacheHooks() {
// register cache cleanup jobs
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
@@ -526,8 +517,7 @@ class OC
/**
* register hooks for the filesystem
*/
- public static function registerFilesystemHooks()
- {
+ public static function registerFilesystemHooks() {
// Check for blacklisted files
OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted');
OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted');
@@ -536,8 +526,7 @@ class OC
/**
* register hooks for sharing
*/
- public static function registerShareHooks()
- {
+ public static function registerShareHooks() {
OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser');
OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup');
OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup');
@@ -547,12 +536,22 @@ class OC
/**
* @brief Handle the request
*/
- public static function handleRequest()
- {
+ public static function handleRequest() {
// load all the classpaths from the enabled apps so they are available
// in the routing files of each app
OC::loadAppClassPaths();
+ // Check if ownCloud is installed or in maintenance (update) mode
+ if (!OC_Config::getValue('installed', false)) {
+ 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;
@@ -562,6 +561,7 @@ class OC
OC_Response::setStatus(405);
return;
}
+
$app = OC::$REQUESTEDAPP;
$file = OC::$REQUESTEDFILE;
$param = array('app' => $app, 'file' => $file);
@@ -571,14 +571,6 @@ class OC
return;
}
- // Check if ownCloud is installed or in maintenance (update) mode
- if (!OC_Config::getValue('installed', false)) {
- require_once 'core/setup.php';
- exit();
- }
- self::checkMaintenanceMode();
- self::checkUpgrade();
-
// Handle redirect URL for logged in users
if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
$location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
@@ -608,7 +600,7 @@ class OC
$file_ext = substr($param['file'], -3);
if ($file_ext != 'php'
|| !self::loadAppScriptFile($param)
- ) {
+ ) {
header('HTTP/1.0 404 Not Found');
}
}
@@ -618,8 +610,7 @@ class OC
self::handleLogin();
}
- public static function loadAppScriptFile($param)
- {
+ public static function loadAppScriptFile($param) {
OC_App::loadApps();
$app = $param['app'];
$file = $param['file'];
@@ -633,8 +624,7 @@ class OC
return false;
}
- public static function loadCSSFile($param)
- {
+ public static function loadCSSFile($param) {
$app = $param['app'];
$file = $param['file'];
$app_path = OC_App::getAppPath($app);
@@ -647,27 +637,25 @@ class OC
}
}
- protected static function handleLogin()
- {
+ protected static function handleLogin() {
OC_App::loadApps(array('prelogin'));
$error = array();
// remember was checked after last login
if (OC::tryRememberLogin()) {
$error[] = 'invalidcookie';
- // Someone wants to log in :
+ // Someone wants to log in :
} elseif (OC::tryFormLogin()) {
$error[] = 'invalidpassword';
- // The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
+ // The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
} elseif (OC::tryBasicAuthLogin()) {
$error[] = 'invalidpassword';
}
OC_Util::displayLoginPage(array_unique($error));
}
- protected static function cleanupLoginTokens($user)
- {
+ protected static function cleanupLoginTokens($user) {
$cutoff = time() - OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
$tokens = OC_Preferences::getKeys($user, 'login_token');
foreach ($tokens as $token) {
@@ -678,13 +666,12 @@ class OC
}
}
- protected static function tryRememberLogin()
- {
+ protected static function tryRememberLogin() {
if (!isset($_COOKIE["oc_remember_login"])
|| !isset($_COOKIE["oc_token"])
|| !isset($_COOKIE["oc_username"])
|| !$_COOKIE["oc_remember_login"]
- ) {
+ ) {
return false;
}
OC_App::loadApps(array('authentication'));
@@ -719,8 +706,7 @@ class OC
return true;
}
- protected static function tryFormLogin()
- {
+ protected static function tryFormLogin() {
if (!isset($_POST["user"]) || !isset($_POST['password'])) {
return false;
}
@@ -753,18 +739,17 @@ class OC
return true;
}
- protected static function tryBasicAuthLogin()
- {
+ protected static function tryBasicAuthLogin() {
if (!isset($_SERVER["PHP_AUTH_USER"])
|| !isset($_SERVER["PHP_AUTH_PW"])
- ) {
+ ) {
return false;
}
OC_App::loadApps(array('authentication'));
if (OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) {
//OC_Log::write('core',"Logged in with HTTP Authentication", OC_Log::DEBUG);
OC_User::unsetMagicInCookie();
- $_REQUEST['redirect_url'] = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');
+ $_REQUEST['redirect_url'] = OC_Request::requestUri();
OC_Util::redirectToDefaultPage();
}
return true;
@@ -778,8 +763,7 @@ if (!isset($RUNTIME_NOAPPS)) {
}
if (!function_exists('get_temp_dir')) {
- function get_temp_dir()
- {
+ function get_temp_dir() {
if ($temp = ini_get('upload_tmp_dir')) return $temp;
if ($temp = getenv('TMP')) return $temp;
if ($temp = getenv('TEMP')) return $temp;
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index a7201579366..b210602bbf4 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -138,7 +138,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$propertypath = $row['propertypath'];
$propertyname = $row['propertyname'];
$propertyvalue = $row['propertyvalue'];
- $properties[$propertypath][$propertyname] = $propertyvalue;
+ if($propertyname !== self::GETETAG_PROPERTYNAME) {
+ $properties[$propertypath][$propertyname] = $propertyvalue;
+ }
}
}
}
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index b48d3b41f24..52995630211 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -154,7 +154,9 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
}
else {
- if( strcmp( $propertyName, self::LASTMODIFIED_PROPERTYNAME) === 0 ) {
+ if( strcmp( $propertyName, self::GETETAG_PROPERTYNAME) === 0 ) {
+ \OC\Files\Filesystem::putFileInfo($this->path, array('etag'=> $propertyValue));
+ } elseif( strcmp( $propertyName, self::LASTMODIFIED_PROPERTYNAME) === 0 ) {
$this->touch($propertyValue);
} else {
if(!array_key_exists( $propertyName, $existing )) {
diff --git a/lib/connector/sabre/request.php b/lib/connector/sabre/request.php
new file mode 100644
index 00000000000..97a27996bf3
--- /dev/null
+++ b/lib/connector/sabre/request.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @author Stefan Herbrechtsmeier
+ * @copyright 2012 Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+class OC_Connector_Sabre_Request extends Sabre_HTTP_Request {
+ /**
+ * Returns the requested uri
+ *
+ * @return string
+ */
+ public function getUri() {
+ return OC_Request::requestUri();
+ }
+
+ /**
+ * Returns a specific item from the _SERVER array.
+ *
+ * Do not rely on this feature, it is for internal use only.
+ *
+ * @param string $field
+ * @return string
+ */
+ public function getRawServerValue($field) {
+ if($field == 'REQUEST_URI'){
+ return $this->getUri();
+ }
+ else{
+ return isset($this->_SERVER[$field])?$this->_SERVER[$field]:null;
+ }
+ }
+}
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 69cbaea8516..dcb6e8fd39a 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -410,7 +410,13 @@ class Cache {
);
$mimetype = $this->getMimetypeId($mimetype);
$result = $query->execute(array($mimetype, $this->numericId));
- return $result->fetchAll();
+ $files = array();
+ while ($row = $result->fetchRow()) {
+ $row['mimetype'] = $this->getMimetype($row['mimetype']);
+ $row['mimepart'] = $this->getMimetype($row['mimepart']);
+ $files[] = $row;
+ }
+ return $files;
}
/**
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index bf0ef01d6b3..8d504af6163 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -94,7 +94,7 @@ class Scanner {
}
$size = 0;
- if ($dh = $this->storage->opendir($path)) {
+ if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
\OC_DB::beginTransaction();
while ($file = readdir($dh)) {
if ($file !== '.' and $file !== '..') {
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 262fde320a1..65d9ffab485 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -374,7 +374,7 @@ class Filesystem {
* @param array $data from hook
*/
static public function isBlacklisted($data) {
- $blacklist = array('.htaccess');
+ $blacklist = \OC_Config::getValue('blacklisted_files', array('.htaccess'));
if (isset($data['path'])) {
$path = $data['path'];
} else if (isset($data['newpath'])) {
@@ -611,6 +611,16 @@ class Filesystem {
}
/**
+ * Get the owner for a file or folder
+ *
+ * @param string $path
+ * @return string
+ */
+ public static function getOwner($path) {
+ return self::$defaultInstance->getOwner($path);
+ }
+
+ /**
* get the ETag for a file or folder
*
* @param string $path
diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php
index 9fc9d375bb3..a5db4ba9194 100644
--- a/lib/files/storage/local.php
+++ b/lib/files/storage/local.php
@@ -184,7 +184,7 @@ class Local extends \OC\Files\Storage\Common{
// Windows OS: we use COM to access the filesystem
if (strpos($name, 'win') !== false) {
if (class_exists('COM')) {
- $fsobj = new COM("Scripting.FileSystemObject");
+ $fsobj = new \COM("Scripting.FileSystemObject");
$f = $fsobj->GetFile($fullPath);
return $f->Size;
}
@@ -197,7 +197,7 @@ class Local extends \OC\Files\Storage\Common{
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);
+ \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR);
}
return 0;
diff --git a/lib/files/view.php b/lib/files/view.php
index 302232b5134..dfcb770328b 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -670,6 +670,9 @@ class View {
*/
public function getFileInfo($path) {
$data = array();
+ if (!Filesystem::isValidPath($path)) {
+ return $data;
+ }
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
/**
* @var \OC\Files\Storage\Storage $storage
@@ -724,6 +727,9 @@ class View {
*/
public function getDirectoryContent($directory, $mimetype_filter = '') {
$result = array();
+ if (!Filesystem::isValidPath($directory)) {
+ return $result;
+ }
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $directory);
/**
* @var \OC\Files\Storage\Storage $storage
@@ -915,6 +921,16 @@ class View {
}
/**
+ * Get the owner for a file or folder
+ *
+ * @param string $path
+ * @return string
+ */
+ public function getOwner($path) {
+ return $this->basicOperation('getOwner', $path);
+ }
+
+ /**
* get the ETag for a file or folder
*
* @param string $path
diff --git a/lib/installer.php b/lib/installer.php
index 7dc8b0cef8d..c86f801b5fc 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -141,13 +141,17 @@ class OC_Installer{
return false;
}
- //check if an app with the same id is already installed
- if(self::isInstalled( $info['id'] )) {
- OC_Log::write('core', 'App already installed', OC_Log::WARN);
+ // check if shipped tag is set which is only allowed for apps that are shipped with ownCloud
+ if(isset($info['shipped']) and ($info['shipped']=='true')) {
+ OC_Log::write('core', 'App can\'t be installed because it contains the <shipped>true</shippe> tag which is not allowed for non shipped apps', OC_Log::ERROR);
+ OC_Helper::rmdirr($extractDir);
+ return false;
+ }
+
+ // check if the ocs version is the same as the version in info.xml/version
+ if(!isset($info['version']) or ($info['version']<>$data['appdata']['version'])) {
+ OC_Log::write('core', 'App can\'t be installed because the version in info.xml/version is not the same as the version reported from the app store', OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
- if($data['source']=='http') {
- unlink($path);
- }
return false;
}
@@ -226,7 +230,6 @@ class OC_Installer{
/**
* @brief Update an application
* @param $data array with all information
- * @returns integer
*
* This function installs an app. All information needed are passed in the
* associative array $data.
@@ -250,9 +253,55 @@ class OC_Installer{
*
* upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid, 'installed_version')"
*/
- public static function upgradeApp( $data = array()) {
- // TODO: write function
- return true;
+ public static function updateApp( $app ) {
+ $ocsid=OC_Appconfig::getValue( $app, 'ocsid');
+ OC_App::disable($app);
+ OC_App::enable($ocsid);
+ return(true);
+ }
+
+ /**
+ * @brief Check if an update for the app is available
+ * @param $name name of the application
+ * @returns empty string is no update available or the version number of the update
+ *
+ * The function will check if an update for a version is available
+ */
+ public static function isUpdateAvailable( $app ) {
+ $ocsid=OC_Appconfig::getValue( $app, 'ocsid', '');
+
+ if($ocsid<>''){
+
+ $ocsdata=OC_OCSClient::getApplication($ocsid);
+ $ocsversion= (string) $ocsdata['version'];
+ $currentversion=OC_App::getAppVersion($app);
+ if($ocsversion<>$currentversion){
+ return($ocsversion);
+
+ }else{
+ return('');
+ }
+
+ }else{
+ return('');
+ }
+
+ }
+
+ /**
+ * @brief Check if app is already downloaded
+ * @param $name name of the application to remove
+ * @returns true/false
+ *
+ * The function will check if the app is already downloaded in the apps repository
+ */
+ public static function isDownloaded( $name ) {
+
+ $downloaded=false;
+ foreach(OC::$APPSROOTS as $dir) {
+ if(is_dir($dir['path'].'/'.$name)) $downloaded=true;
+ }
+ return($downloaded);
}
/**
@@ -276,8 +325,36 @@ class OC_Installer{
* this has to be done by the function oc_app_uninstall().
*/
public static function removeApp( $name, $options = array()) {
- // TODO: write function
- return true;
+
+ if(isset($options['keeppreferences']) and $options['keeppreferences']==false ){
+ // todo
+ // remove preferences
+ }
+
+ if(isset($options['keepappconfig']) and $options['keepappconfig']==false ){
+ // todo
+ // remove app config
+ }
+
+ if(isset($options['keeptables']) and $options['keeptables']==false ){
+ // todo
+ // remove app database tables
+ }
+
+ if(isset($options['keepfiles']) and $options['keepfiles']==false ){
+ // todo
+ // remove user files
+ }
+
+ if(OC_Installer::isDownloaded( $name )) {
+ $appdir=OC_App::getInstallPath().'/'.$name;
+ OC_Helper::rmdirr($appdir);
+
+ }else{
+ OC_Log::write('core', 'can\'t remove app '.$name.'. It is not installed.', OC_Log::ERROR);
+
+ }
+
}
/**
diff --git a/lib/l10n.php b/lib/l10n.php
index ca53b3cf65c..ee879009265 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -287,7 +287,7 @@ class OC_L10N{
}
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
- $accepted_languages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+ $accepted_languages = preg_split('/,\s*/', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
if(is_array($app)) {
$available = $app;
}
diff --git a/lib/l10n/af_ZA.php b/lib/l10n/af_ZA.php
new file mode 100644
index 00000000000..38e91288fbe
--- /dev/null
+++ b/lib/l10n/af_ZA.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Hulp",
+"Personal" => "Persoonlik",
+"Settings" => "Instellings",
+"Users" => "Gebruikers",
+"Apps" => "Toepassings",
+"Admin" => "Admin"
+);
diff --git a/lib/l10n/fa.php b/lib/l10n/fa.php
index 8cbdcb03b3b..bbb04290a5c 100644
--- a/lib/l10n/fa.php
+++ b/lib/l10n/fa.php
@@ -3,17 +3,28 @@
"Personal" => "شخصی",
"Settings" => "تنظیمات",
"Users" => "کاربران",
+"Apps" => " برنامه ها",
"Admin" => "مدیر",
+"ZIP download is turned off." => "دانلود به صورت فشرده غیر فعال است",
+"Files need to be downloaded one by one." => "فایل ها باید به صورت یکی یکی دانلود شوند",
+"Back to Files" => "بازگشت به فایل ها",
+"Selected files too large to generate zip file." => "فایل های انتخاب شده بزرگتر از آن هستند که بتوان یک فایل فشرده تولید کرد",
+"Application is not enabled" => "برنامه فعال نشده است",
"Authentication error" => "خطا در اعتبار سنجی",
"Files" => "پرونده‌ها",
"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" => "سال‌های قبل"
+"years ago" => "سال‌های قبل",
+"Could not find category \"%s\"" => "دسته بندی %s یافت نشد"
);
diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php
index 3330d0e6b70..9f2a0dea749 100644
--- a/lib/l10n/lv.php
+++ b/lib/l10n/lv.php
@@ -3,6 +3,33 @@
"Personal" => "Personīgi",
"Settings" => "Iestatījumi",
"Users" => "Lietotāji",
-"Authentication error" => "Ielogošanās kļūme",
-"Files" => "Faili"
+"Apps" => "Lietotnes",
+"Admin" => "Administratori",
+"ZIP download is turned off." => "ZIP lejupielādēšana ir izslēgta.",
+"Files need to be downloaded one by one." => "Datnes var lejupielādēt tikai katru atsevišķi.",
+"Back to Files" => "Atpakaļ pie datnēm",
+"Selected files too large to generate zip file." => "Izvēlētās datnes ir pārāk lielas, lai izveidotu zip datni.",
+"couldn't be determined" => "nevarēja noteikt",
+"Application is not enabled" => "Lietotne nav aktivēta",
+"Authentication error" => "Autentifikācijas kļūda",
+"Token expired. Please reload page." => "Pilnvarai ir beidzies termiņš. Lūdzu, pārlādējiet lapu.",
+"Files" => "Datnes",
+"Text" => "Teksts",
+"Images" => "Attēli",
+"seconds ago" => "sekundes atpakaļ",
+"1 minute ago" => "pirms 1 minūtes",
+"%d minutes ago" => "pirms %d minūtēm",
+"1 hour ago" => "pirms 1 stundas",
+"%d hours ago" => "pirms %d stundām",
+"today" => "šodien",
+"yesterday" => "vakar",
+"%d days ago" => "pirms %d dienām",
+"last month" => "pagājušajā mēnesī",
+"%d months ago" => "pirms %d mēnešiem",
+"last year" => "gājušajā gadā",
+"years ago" => "gadus atpakaļ",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s ir pieejams. Iegūt <a href=\"%s\">vairāk informācijas</a>",
+"up to date" => "ir aktuāls",
+"updates check is disabled" => "atjauninājumu pārbaude ir deaktivēta",
+"Could not find category \"%s\"" => "Nevarēja atrast kategoriju “%s”"
);
diff --git a/lib/l10n/sr.php b/lib/l10n/sr.php
index 34ae89a6219..1161b0a44b7 100644
--- a/lib/l10n/sr.php
+++ b/lib/l10n/sr.php
@@ -1,10 +1,10 @@
<?php $TRANSLATIONS = array(
"Help" => "Помоћ",
"Personal" => "Лично",
-"Settings" => "Подешавања",
+"Settings" => "Поставке",
"Users" => "Корисници",
"Apps" => "Апликације",
-"Admin" => "Администрација",
+"Admin" => "Администратор",
"ZIP download is turned off." => "Преузимање ZIP-а је искључено.",
"Files need to be downloaded one by one." => "Датотеке морате преузимати једну по једну.",
"Back to Files" => "Назад на датотеке",
@@ -29,7 +29,7 @@
"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" => "провера ажурирања је онемогућена.",
+"up to date" => "је ажурна",
+"updates check is disabled" => "провера ажурирања је онемогућена",
"Could not find category \"%s\"" => "Не могу да пронађем категорију „%s“."
);
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index ca0665da436..30163c1e403 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -123,6 +123,8 @@ class OC_OCSClient{
$app=array();
$app['id']=(string)$tmp[$i]->id;
$app['name']=(string)$tmp[$i]->name;
+ $app['label']=(string)$tmp[$i]->label;
+ $app['version']=(string)$tmp[$i]->version;
$app['type']=(string)$tmp[$i]->typeid;
$app['typename']=(string)$tmp[$i]->typename;
$app['personid']=(string)$tmp[$i]->personid;
@@ -162,7 +164,9 @@ class OC_OCSClient{
$app=array();
$app['id']=$tmp->id;
$app['name']=$tmp->name;
+ $app['version']=$tmp->version;
$app['type']=$tmp->typeid;
+ $app['label']=$tmp->label;
$app['typename']=$tmp->typename;
$app['personid']=$tmp->personid;
$app['detailpage']=$tmp->detailpage;
diff --git a/lib/public/share.php b/lib/public/share.php
index 9894f1550a8..9aacf5e3449 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -529,7 +529,8 @@ class Share {
$collectionTypes[] = $type;
}
}
- if (!self::getBackend($itemType) instanceof Share_Backend_Collection) {
+ // TODO Add option for collections to be collection of themselves, only 'folder' does it now...
+ if (!self::getBackend($itemType) instanceof Share_Backend_Collection || $itemType != 'folder') {
unset($collectionTypes[0]);
}
// Return array if collections were found or the item type is a collection itself - collections can be inside collections
diff --git a/lib/public/util.php b/lib/public/util.php
index 413dbcccd28..a78a52f326e 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -219,6 +219,28 @@ class Util {
}
/**
+ * @brief Returns the request uri
+ * @returns the request uri
+ *
+ * Returns the request uri, even if the website uses one or more
+ * reverse proxies
+ */
+ public static function getRequestUri() {
+ return(\OC_Request::requestUri());
+ }
+
+ /**
+ * @brief Returns the script name
+ * @returns the script name
+ *
+ * Returns the script name, even if the website uses one or more
+ * reverse proxies
+ */
+ public static function getScriptName() {
+ return(\OC_Request::scriptName());
+ }
+
+ /**
* @brief Creates path to an image
* @param string $app app
* @param string $image image name
diff --git a/lib/request.php b/lib/request.php
index f2f15c21103..1661a1406ca 100755
--- a/lib/request.php
+++ b/lib/request.php
@@ -8,6 +8,15 @@
class OC_Request {
/**
+ * @brief Check overwrite condition
+ * @returns true/false
+ */
+ private static function isOverwriteCondition() {
+ $regex = '/' . OC_Config::getValue('overwritecondaddr', '') . '/';
+ return $regex === '//' or preg_match($regex, $_SERVER['REMOTE_ADDR']) === 1;
+ }
+
+ /**
* @brief Returns the server host
* @returns the server host
*
@@ -18,7 +27,7 @@ class OC_Request {
if(OC::$CLI) {
return 'localhost';
}
- if(OC_Config::getValue('overwritehost', '')<>'') {
+ if(OC_Config::getValue('overwritehost', '')<>'' and self::isOverwriteCondition()) {
return OC_Config::getValue('overwritehost');
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
@@ -43,7 +52,7 @@ class OC_Request {
* Returns the server protocol. It respects reverse proxy servers and load balancers
*/
public static function serverProtocol() {
- if(OC_Config::getValue('overwriteprotocol', '')<>'') {
+ if(OC_Config::getValue('overwriteprotocol', '')<>'' and self::isOverwriteCondition()) {
return OC_Config::getValue('overwriteprotocol');
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
@@ -59,6 +68,38 @@ class OC_Request {
}
/**
+ * @brief Returns the request uri
+ * @returns the request uri
+ *
+ * Returns the request uri, even if the website uses one or more
+ * reverse proxies
+ */
+ public static function requestUri() {
+ $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
+ if (OC_Config::getValue('overwritewebroot', '') <> '' and self::isOverwriteCondition()) {
+ $uri = self::scriptName() . substr($uri, strlen($_SERVER['SCRIPT_NAME']));
+ }
+ return $uri;
+ }
+
+ /**
+ * @brief Returns the script name
+ * @returns the script name
+ *
+ * Returns the script name, even if the website uses one or more
+ * reverse proxies
+ */
+ public static function scriptName() {
+ $name = $_SERVER['SCRIPT_NAME'];
+ if (OC_Config::getValue('overwritewebroot', '') <> '' and self::isOverwriteCondition()) {
+ $serverroot = str_replace("\\", '/', substr(__DIR__, 0, -4));
+ $suburi = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen($serverroot)));
+ $name = OC_Config::getValue('overwritewebroot', '') . $suburi;
+ }
+ return $name;
+ }
+
+ /**
* @brief get Path info from request
* @returns string Path info or false when not found
*/
diff --git a/lib/search.php b/lib/search.php
index 3c3378ad13c..e5a65f7157d 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -57,6 +57,22 @@ class OC_Search{
}
return $results;
}
+
+ /**
+ * remove an existing search provider
+ * @param string $provider class name of a OC_Search_Provider
+ */
+ public static function removeProvider($provider) {
+ self::$registeredProviders = array_filter(
+ self::$registeredProviders,
+ function ($element) use ($provider) {
+ return ($element['class'] != $provider);
+ }
+ );
+ // force regeneration of providers on next search
+ self::$providers=array();
+ }
+
/**
* create instances of all the registered search providers
diff --git a/lib/template.php b/lib/template.php
index 238d8a8ad0f..fb9f7ad62d9 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -192,7 +192,7 @@ class OC_Template{
// Content Security Policy
// If you change the standard policy, please also change it in config.sample.php
- $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; frame-src *; img-src *');
+ $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; frame-src *; img-src *; font-src \'self\' data:');
header('Content-Security-Policy:'.$policy); // Standard
header('X-WebKit-CSP:'.$policy); // Older webkit browsers
diff --git a/lib/util.php b/lib/util.php
index e8057abe9ae..363e3f105c0 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -186,45 +186,20 @@ class OC_Util {
in owncloud or disabling the appstore in the config file.");
}
}
-
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
- //check for correct file permissions
- if(!stristr(PHP_OS, 'WIN')) {
- $permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users.";
- $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
- if(substr($prems, -1)!='0') {
- OC_Helper::chmodr($CONFIG_DATADIRECTORY, 0770);
- clearstatcache();
- $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3);
- if(substr($prems, 2, 1)!='0') {
- $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint);
- }
- }
- if( OC_Config::getValue( "enablebackup", false )) {
- $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" );
- $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
- if(substr($prems, -1)!='0') {
- OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770);
- clearstatcache();
- $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3);
- if(substr($prems, 2, 1)!='0') {
- $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint);
- }
- }
- }
- }else{
- //TODO: permissions checks for windows hosts
- }
// Create root dir.
if(!is_dir($CONFIG_DATADIRECTORY)) {
$success=@mkdir($CONFIG_DATADIRECTORY);
- if(!$success) {
+ if ($success) {
+ $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
+ } else {
$errors[]=array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY.")", 'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' ");
}
} else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
$errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud<br/>', 'hint'=>$permissionsHint);
+ } else {
+ $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
}
-
// check if all required php modules are present
if(!class_exists('ZipArchive')) {
$errors[]=array('error'=>'PHP module zip not installed.<br/>', 'hint'=>'Please ask your server administrator to install the module.');
@@ -268,6 +243,17 @@ class OC_Util {
$web_server_restart= false;
}
+ $handler = ini_get("session.save_handler");
+ if($handler == "files") {
+ $tmpDir = session_save_path();
+ if($tmpDir != ""){
+ if(!@is_writable($tmpDir)){
+ $errors[]=array('error' => 'The temporary folder used by PHP to save the session data is either incorrect or not writable! Please check : '.session_save_path().'<br/>',
+ 'hint'=>'Please ask your server administrator to grant write access or define another temporary folder.');
+ }
+ }
+ }
+
if($web_server_restart) {
$errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?<br/>', 'hint'=>'Please ask your server administrator to restart the web server.');
}
@@ -275,6 +261,29 @@ class OC_Util {
return $errors;
}
+ /**
+ * Check for correct file permissions of data directory
+ * @return array arrays with error messages and hints
+ */
+ public static function checkDataDirectoryPermissions($dataDirectory) {
+ $errors = array();
+ if (stristr(PHP_OS, 'WIN')) {
+ //TODO: permissions checks for windows hosts
+ } else {
+ $permissionsModHint = 'Please change the permissions to 0770 so that the directory cannot be listed by other users.';
+ $prems = substr(decoct(@fileperms($dataDirectory)), -3);
+ if (substr($prems, -1) != '0') {
+ OC_Helper::chmodr($dataDirectory, 0770);
+ clearstatcache();
+ $prems = substr(decoct(@fileperms($dataDirectory)), -3);
+ if (substr($prems, 2, 1) != '0') {
+ $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users<br/>', 'hint' => $permissionsModHint);
+ }
+ }
+ }
+ return $errors;
+ }
+
public static function displayLoginPage($errors = array()) {
$parameters = array();
foreach( $errors as $key => $value ) {
@@ -312,7 +321,7 @@ class OC_Util {
public static function checkLoggedIn() {
// Check if we are a user
if( !OC_User::isLoggedIn()) {
- header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', array('redirect_url' => $_SERVER["REQUEST_URI"])));
+ header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', array('redirect_url' => OC_Request::requestUri())));
exit();
}
}