aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php7
-rw-r--r--lib/base.php134
-rw-r--r--lib/connector/sabre/directory.php4
-rw-r--r--lib/connector/sabre/node.php4
-rw-r--r--lib/files/cache/scanner.php2
-rw-r--r--lib/files/filesystem.php2
-rw-r--r--lib/l10n/fa.php13
-rw-r--r--lib/l10n/sr.php8
-rw-r--r--lib/search.php16
-rwxr-xr-xlib/util.php58
10 files changed, 132 insertions, 116 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/base.php b/lib/base.php
index 232350b59e2..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,10 +122,16 @@ 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 = OC_Request::scriptName();
if (substr($scriptName, -1) == '/') {
@@ -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,8 +221,7 @@ 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');
@@ -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,11 +739,10 @@ 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'));
@@ -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/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..47c09acf294 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'])) {
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/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/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/util.php b/lib/util.php
index 809f6a88be7..91970ab2b96 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.');
@@ -275,6 +250,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 ) {