summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2013-01-30 14:36:17 +0100
committerFrank Karlitschek <frank@owncloud.org>2013-01-30 14:36:17 +0100
commit66cab77b6d83980d260cd35556d2759089d2971b (patch)
treeccf3767afba89f90ea82bd0805f23eb189956b53 /lib
parent389c4e84153893a04310876ef70943cad53ee3e7 (diff)
parent5761bd771f4142394a00083712b63e77f8976946 (diff)
downloadnextcloud-server-66cab77b6d83980d260cd35556d2759089d2971b.tar.gz
nextcloud-server-66cab77b6d83980d260cd35556d2759089d2971b.zip
merge master
Merge branch 'master' into improved_appsmanagement Conflicts: settings/apps.php settings/templates/apps.php
Diffstat (limited to 'lib')
-rw-r--r--lib/MDB2/Driver/sqlite3.php2
-rw-r--r--lib/api.php32
-rw-r--r--lib/app.php110
-rw-r--r--lib/backgroundjob.php2
-rw-r--r--lib/base.php1387
-rw-r--r--lib/cache/apc.php2
-rw-r--r--lib/connector/sabre/node.php6
-rw-r--r--lib/db.php36
-rw-r--r--lib/filecache.php15
-rw-r--r--lib/fileproxy/quota.php2
-rw-r--r--lib/files.php2
-rw-r--r--lib/filestorage/local.php2
-rw-r--r--lib/filesystem.php14
-rw-r--r--lib/filesystemview.php44
-rw-r--r--lib/group.php29
-rw-r--r--lib/group/backend.php18
-rw-r--r--lib/group/database.php28
-rw-r--r--lib/helper.php84
-rw-r--r--lib/image.php2
-rw-r--r--lib/installer.php1
-rw-r--r--lib/json.php21
-rw-r--r--lib/l10n.php18
-rw-r--r--lib/l10n/ca.php1
-rw-r--r--lib/l10n/cs_CZ.php1
-rw-r--r--lib/l10n/da.php1
-rw-r--r--lib/l10n/de.php1
-rw-r--r--lib/l10n/de_DE.php1
-rw-r--r--lib/l10n/el.php1
-rw-r--r--lib/l10n/es.php1
-rw-r--r--lib/l10n/es_AR.php1
-rw-r--r--lib/l10n/eu.php1
-rw-r--r--lib/l10n/fa.php1
-rw-r--r--lib/l10n/fi_FI.php1
-rw-r--r--lib/l10n/fr.php1
-rw-r--r--lib/l10n/gl.php1
-rw-r--r--lib/l10n/hu_HU.php5
-rw-r--r--lib/l10n/it.php1
-rw-r--r--lib/l10n/ja_JP.php1
-rw-r--r--lib/l10n/lb.php8
-rw-r--r--lib/l10n/ms_MY.php1
-rw-r--r--lib/l10n/nl.php1
-rw-r--r--lib/l10n/pl.php1
-rw-r--r--lib/l10n/pt_PT.php1
-rw-r--r--lib/l10n/ro.php1
-rw-r--r--lib/l10n/ru_RU.php1
-rw-r--r--lib/l10n/sk_SK.php1
-rw-r--r--lib/l10n/sr.php1
-rw-r--r--lib/l10n/sv.php1
-rw-r--r--lib/l10n/th_TH.php1
-rw-r--r--lib/l10n/tr.php1
-rw-r--r--lib/l10n/uk.php1
-rw-r--r--lib/l10n/zh_TW.php13
-rw-r--r--lib/log.php4
-rw-r--r--lib/mail.php12
-rw-r--r--lib/migrate.php4
-rw-r--r--lib/migration/content.php2
-rw-r--r--lib/mimetypes.list.php2
-rw-r--r--lib/ocs/cloud.php14
-rw-r--r--lib/ocs/config.php4
-rw-r--r--lib/ocs/person.php2
-rw-r--r--lib/ocs/privatedata.php4
-rw-r--r--lib/ocs/result.php14
-rw-r--r--lib/ocsclient.php14
-rw-r--r--lib/public/api.php4
-rw-r--r--lib/public/app.php7
-rw-r--r--lib/public/constants.php1
-rw-r--r--lib/public/db.php6
-rw-r--r--lib/public/files.php3
-rw-r--r--lib/public/response.php14
-rw-r--r--lib/public/share.php19
-rw-r--r--lib/public/user.php26
-rw-r--r--lib/public/util.php14
-rwxr-xr-xlib/request.php4
-rw-r--r--lib/router.php22
-rw-r--r--lib/setup.php46
-rw-r--r--lib/subadmin.php7
-rw-r--r--lib/template.php34
-rw-r--r--lib/templatelayout.php12
-rw-r--r--lib/user.php98
-rw-r--r--lib/user/backend.php28
-rw-r--r--lib/user/database.php54
-rw-r--r--lib/user/interface.php15
-rwxr-xr-xlib/util.php54
-rw-r--r--lib/vcategories.php1
84 files changed, 1462 insertions, 993 deletions
diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php
index 9839dafbce1..8f057cfb6e8 100644
--- a/lib/MDB2/Driver/sqlite3.php
+++ b/lib/MDB2/Driver/sqlite3.php
@@ -98,7 +98,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common
if ($this->connection) {
$native_code = $this->connection->lastErrorCode();
}
- $native_msg = html_entity_decode($this->_lasterror);
+ $native_msg = html_entity_decode($this->_lasterror);
// PHP 5.2+ prepends the function name to $php_errormsg, so we need
// this hack to work around it, per bug #9599.
diff --git a/lib/api.php b/lib/api.php
index cb67e0c2a89..545b55757ff 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -42,12 +42,12 @@ class OC_API {
private static function init() {
self::$server = new OC_OAuth_Server(new OC_OAuth_Store());
}
-
+
/**
* api actions
*/
protected static $actions = array();
-
+
/**
* registers an api call
* @param string $method the http method
@@ -58,7 +58,7 @@ class OC_API {
* @param array $defaults
* @param array $requirements
*/
- public static function register($method, $url, $action, $app,
+ public static function register($method, $url, $action, $app,
$authLevel = OC_API::USER_AUTH,
$defaults = array(),
$requirements = array()) {
@@ -73,7 +73,7 @@ class OC_API {
}
self::$actions[$name] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel);
}
-
+
/**
* handles an api call
* @param array $parameters
@@ -90,10 +90,15 @@ class OC_API {
if(self::isAuthorised(self::$actions[$name])) {
if(is_callable(self::$actions[$name]['action'])) {
$response = call_user_func(self::$actions[$name]['action'], $parameters);
+ if(!($response instanceof OC_OCS_Result)) {
+ $response = new OC_OCS_Result(null, 996, 'Internal Server Error');
+ }
} else {
$response = new OC_OCS_Result(null, 998, 'Api method not found');
- }
+ }
} else {
+ header('WWW-Authenticate: Basic realm="Authorization Required"');
+ header('HTTP/1.0 401 Unauthorized');
$response = new OC_OCS_Result(null, 997, 'Unauthorised');
}
// Send the response
@@ -103,7 +108,7 @@ class OC_API {
// logout the user to be stateless
OC_User::logout();
}
-
+
/**
* authenticate the api call
* @param array $action the action details as supplied to OC_API::register()
@@ -127,8 +132,7 @@ class OC_API {
return false;
} else {
$subAdmin = OC_SubAdmin::isSubAdmin($user);
- $admin = OC_Group::inGroup($user, 'admin');
- if($subAdmin || $admin) {
+ if($subAdmin) {
return true;
} else {
return false;
@@ -141,7 +145,7 @@ class OC_API {
if(!$user) {
return false;
} else {
- return OC_Group::inGroup($user, 'admin');
+ return OC_User::isAdminUser($user);
}
break;
default:
@@ -149,18 +153,18 @@ class OC_API {
return false;
break;
}
- }
-
+ }
+
/**
* http basic auth
* @return string|false (username, or false on failure)
*/
- private static function loginUser(){
+ private static function loginUser(){
$authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '';
$authPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '';
return OC_User::login($authUser, $authPw) ? $authUser : false;
}
-
+
/**
* respond to a call
* @param int|array $result the result from the api method
@@ -196,5 +200,5 @@ class OC_API {
}
}
}
-
+
}
diff --git a/lib/app.php b/lib/app.php
index fcf5a65458d..f851d802dc3 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -63,17 +63,17 @@ class OC_App{
if (!defined('DEBUG') || !DEBUG) {
if (is_null($types)
- && empty(OC_Util::$core_scripts)
- && empty(OC_Util::$core_styles)) {
+ && empty(OC_Util::$core_scripts)
+ && empty(OC_Util::$core_styles)) {
OC_Util::$core_scripts = OC_Util::$scripts;
- OC_Util::$scripts = array();
- OC_Util::$core_styles = OC_Util::$styles;
- OC_Util::$styles = array();
- }
+ OC_Util::$scripts = array();
+ OC_Util::$core_styles = OC_Util::$styles;
+ OC_Util::$styles = array();
}
- // return
- return true;
}
+ // return
+ return true;
+}
/**
* load a single app
@@ -137,7 +137,7 @@ class OC_App{
OC_Appconfig::setValue($app, 'types', $appTypes);
}
-
+
/**
* check if app is shipped
* @param string $appid the id of the app to check
@@ -309,7 +309,7 @@ class OC_App{
if(OC_Config::getValue('knowledgebaseenabled', true)==true) {
$settings = array(
array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_help" ), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath( "settings", "help.svg" ))
- );
+ );
}
// if the user is logged-in
@@ -323,14 +323,14 @@ class OC_App{
$settings[]=array( "id" => "settings", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_settings" ), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath( "settings", "settings.svg" ));
//SubAdmins are also allowed to access user management
- if(OC_SubAdmin::isSubAdmin($_SESSION["user_id"]) || OC_Group::inGroup( $_SESSION["user_id"], "admin" )) {
+ if(OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
// admin users menu
$settings[] = array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkToRoute( "settings_users" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "settings", "users.svg" ));
}
// if the user is an admin
- if(OC_Group::inGroup( $_SESSION["user_id"], "admin" )) {
+ if(OC_User::isAdminUser(OC_User::getUser())) {
// admin apps menu
$settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkToRoute( "settings_apps" ).'?installed', "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" ));
@@ -529,16 +529,16 @@ class OC_App{
$forms=array();
switch($type) {
case 'settings':
- $source=self::$settingsForms;
- break;
+ $source=self::$settingsForms;
+ break;
case 'admin':
- $source=self::$adminForms;
- break;
+ $source=self::$adminForms;
+ break;
case 'personal':
- $source=self::$personalForms;
- break;
+ $source=self::$personalForms;
+ break;
default:
- return array();
+ return array();
}
foreach($source as $form) {
$forms[]=include $form;
@@ -599,6 +599,76 @@ class OC_App{
}
/**
+ * @brief: Lists all apps, this is used in apps.php
+ * @return array
+ */
+ public static function listAllApps() {
+ $installedApps = OC_App::getAllApps();
+
+ //TODO which apps do we want to blacklist and how do we integrate blacklisting with the multi apps folder feature?
+
+ $blacklist = array('files');//we dont want to show configuration for these
+ $appList = array();
+
+ foreach ( $installedApps as $app ) {
+ if ( array_search( $app, $blacklist ) === false ) {
+
+ $info=OC_App::getAppInfo($app);
+
+ if (!isset($info['name'])) {
+ OC_Log::write('core', 'App id "'.$app.'" has no name in appinfo', OC_Log::ERROR);
+ continue;
+ }
+
+ if ( OC_Appconfig::getValue( $app, 'enabled', 'no') == 'yes' ) {
+ $active = true;
+ } else {
+ $active = false;
+ }
+
+ $info['active'] = $active;
+
+ 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');
+ $info['version'] = OC_App::getAppVersion($app);
+ $appList[] = $info;
+ }
+ }
+ $remoteApps = OC_App::getAppstoreApps();
+ if ( $remoteApps ) {
+ // 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']
+ ) {
+ unset( $remoteApps[$key]);
+ }
+ }
+ }
+ $combinedApps = array_merge( $appList, $remoteApps );
+ } else {
+ $combinedApps = $appList;
+ }
+ return $combinedApps;
+}
+
+ /**
* @brief: get a list of all apps on apps.owncloud.com
* @return array, multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
*/
@@ -767,7 +837,7 @@ class OC_App{
}
return new OC_FilesystemView('/'.OC_User::getUser().'/'.$appid);
}else{
- OC_Log::write('core', 'Can\'t get app storage, app, user not logged in', OC_Log::ERROR);
+ OC_Log::write('core', 'Can\'t get app storage, app '.$appid.', user not logged in', OC_Log::ERROR);
return false;
}
}else{
diff --git a/lib/backgroundjob.php b/lib/backgroundjob.php
index 28b5ce3af20..9619dcb732c 100644
--- a/lib/backgroundjob.php
+++ b/lib/backgroundjob.php
@@ -34,7 +34,7 @@ class OC_BackgroundJob{
public static function getExecutionType() {
return OC_Appconfig::getValue( 'core', 'backgroundjobs_mode', 'ajax' );
}
-
+
/**
* @brief sets the background jobs execution type
* @param $type execution type
diff --git a/lib/base.php b/lib/base.php
index 3d3e7d59f90..f9818d3514e 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -29,169 +29,176 @@ require_once 'public/constants.php';
*/
class OC
{
- /**
- * Assoziative array for autoloading. classname => filename
- */
- public static $CLASSPATH = array();
- /**
- * The installation path for owncloud on the server (e.g. /srv/http/owncloud)
- */
- public static $SERVERROOT = '';
- /**
- * the current request path relative to the owncloud root (e.g. files/index.php)
- */
- private static $SUBURI = '';
- /**
- * the owncloud root path for http requests (e.g. owncloud/)
- */
- public static $WEBROOT = '';
- /**
- * The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty)
- */
- public static $THIRDPARTYROOT = '';
- /**
- * the root path of the 3rdparty folder for http requests (e.g. owncloud/3rdparty)
- */
- public static $THIRDPARTYWEBROOT = '';
- /**
- * The installation path array of the apps folder on the server (e.g. /srv/http/owncloud) 'path' and
- * web path in 'url'
- */
- public static $APPSROOTS = array();
- /*
- * requested app
- */
- public static $REQUESTEDAPP = '';
- /*
- * requested file of app
- */
- public static $REQUESTEDFILE = '';
- /**
- * check if owncloud runs in cli mode
- */
- public static $CLI = false;
- /*
- * OC router
- */
- protected static $router = null;
-
- /**
- * SPL autoload
- */
- 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
- */
- 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);
- }
- } elseif (strpos($className, 'OC_') === 0) {
- $path = strtolower(str_replace('_', '/', substr($className, 3)) . '.php');
- } elseif (strpos($className, 'OC\\') === 0) {
- $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
- } elseif (strpos($className, 'OCP\\') === 0) {
- $path = 'public/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
- } elseif (strpos($className, 'OCA\\') === 0) {
- $path = 'apps/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
- } elseif (strpos($className, 'Sabre_') === 0) {
- $path = str_replace('_', '/', $className) . '.php';
- } elseif (strpos($className, 'Symfony\\Component\\Routing\\') === 0) {
- $path = 'symfony/routing/' . str_replace('\\', '/', $className) . '.php';
- } elseif (strpos($className, 'Sabre\\VObject') === 0) {
- $path = str_replace('\\', '/', $className) . '.php';
- } elseif (strpos($className, 'Test_') === 0) {
- $path = 'tests/lib/' . strtolower(str_replace('_', '/', substr($className, 5)) . '.php');
- } else {
- return false;
- }
-
- if ($fullPath = stream_resolve_include_path($path)) {
- require_once $fullPath;
- }
- return false;
- }
-
- public static function initPaths()
- {
- // calculate the root directories
- OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
- OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
- $scriptName = $_SERVER["SCRIPT_NAME"];
- if (substr($scriptName, -1) == '/') {
- $scriptName .= 'index.php';
- //make sure suburi follows the same rules as scriptName
- if (substr(OC::$SUBURI, -9) != 'index.php') {
- if (substr(OC::$SUBURI, -1) != '/') {
- OC::$SUBURI = OC::$SUBURI . '/';
- }
- OC::$SUBURI = OC::$SUBURI . 'index.php';
- }
- }
-
- OC::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(OC::$SUBURI));
-
- if (OC::$WEBROOT != '' and OC::$WEBROOT[0] !== '/') {
- 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', '');
- OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', '');
- } elseif (file_exists(OC::$SERVERROOT . '/3rdparty')) {
- OC::$THIRDPARTYROOT = OC::$SERVERROOT;
- OC::$THIRDPARTYWEBROOT = OC::$WEBROOT;
- } elseif (file_exists(OC::$SERVERROOT . '/../3rdparty')) {
- OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
- OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
- } else {
- echo("3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
- exit;
- }
- // search the apps folder
- $config_paths = OC_Config::getValue('apps_paths', array());
- if (!empty($config_paths)) {
- foreach ($config_paths as $paths) {
- if (isset($paths['url']) && isset($paths['path'])) {
- $paths['url'] = rtrim($paths['url'], '/');
- $paths['path'] = rtrim($paths['path'], '/');
- OC::$APPSROOTS[] = $paths;
- }
- }
- } elseif (file_exists(OC::$SERVERROOT . '/apps')) {
- OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true);
- } elseif (file_exists(OC::$SERVERROOT . '/../apps')) {
- OC::$APPSROOTS[] = array('path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', 'url' => '/apps', 'writable' => true);
- }
-
- if (empty(OC::$APPSROOTS)) {
- echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
- exit;
- }
- $paths = array();
- 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
- );
- }
+ /**
+ * Associative array for autoloading. classname => filename
+ */
+ public static $CLASSPATH = array();
+ /**
+ * The installation path for owncloud on the server (e.g. /srv/http/owncloud)
+ */
+ public static $SERVERROOT = '';
+ /**
+ * the current request path relative to the owncloud root (e.g. files/index.php)
+ */
+ private static $SUBURI = '';
+ /**
+ * the owncloud root path for http requests (e.g. owncloud/)
+ */
+ public static $WEBROOT = '';
+ /**
+ * The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty)
+ */
+ public static $THIRDPARTYROOT = '';
+ /**
+ * the root path of the 3rdparty folder for http requests (e.g. owncloud/3rdparty)
+ */
+ public static $THIRDPARTYWEBROOT = '';
+ /**
+ * The installation path array of the apps folder on the server (e.g. /srv/http/owncloud) 'path' and
+ * web path in 'url'
+ */
+ public static $APPSROOTS = array();
+ /*
+ * requested app
+ */
+ public static $REQUESTEDAPP = '';
+ /*
+ * requested file of app
+ */
+ public static $REQUESTEDFILE = '';
+ /**
+ * check if owncloud runs in cli mode
+ */
+ public static $CLI = false;
+ /*
+ * OC router
+ */
+ protected static $router = null;
+
+ /**
+ * SPL autoload
+ */
+ 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
+ */
+ 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);
+ }
+ } elseif (strpos($className, 'OC_') === 0) {
+ $path = strtolower(str_replace('_', '/', substr($className, 3)) . '.php');
+ } elseif (strpos($className, 'OC\\') === 0) {
+ $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ } elseif (strpos($className, 'OCP\\') === 0) {
+ $path = 'public/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ } elseif (strpos($className, 'OCA\\') === 0) {
+ 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)) {
+ require_once $fullPath;
+ return false;
+ }
+ }
+ } elseif (strpos($className, 'Sabre_') === 0) {
+ $path = str_replace('_', '/', $className) . '.php';
+ } elseif (strpos($className, 'Symfony\\Component\\Routing\\') === 0) {
+ $path = 'symfony/routing/' . str_replace('\\', '/', $className) . '.php';
+ } elseif (strpos($className, 'Sabre\\VObject') === 0) {
+ $path = str_replace('\\', '/', $className) . '.php';
+ } elseif (strpos($className, 'Test_') === 0) {
+ $path = 'tests/lib/' . strtolower(str_replace('_', '/', substr($className, 5)) . '.php');
+ } else {
+ return false;
+ }
+
+ if ($fullPath = stream_resolve_include_path($path)) {
+ require_once $fullPath;
+ }
+ return false;
+ }
+
+ public static function initPaths()
+ {
+ // calculate the root directories
+ OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
+ OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
+ $scriptName = $_SERVER["SCRIPT_NAME"];
+ if (substr($scriptName, -1) == '/') {
+ $scriptName .= 'index.php';
+ //make sure suburi follows the same rules as scriptName
+ if (substr(OC::$SUBURI, -9) != 'index.php') {
+ if (substr(OC::$SUBURI, -1) != '/') {
+ OC::$SUBURI = OC::$SUBURI . '/';
+ }
+ OC::$SUBURI = OC::$SUBURI . 'index.php';
+ }
+ }
+
+ OC::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(OC::$SUBURI));
+
+ if (OC::$WEBROOT != '' and OC::$WEBROOT[0] !== '/') {
+ 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', '');
+ OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', '');
+ } elseif (file_exists(OC::$SERVERROOT . '/3rdparty')) {
+ OC::$THIRDPARTYROOT = OC::$SERVERROOT;
+ OC::$THIRDPARTYWEBROOT = OC::$WEBROOT;
+ } elseif (file_exists(OC::$SERVERROOT . '/../3rdparty')) {
+ OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
+ OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
+ } else {
+ echo("3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
+ exit;
+ }
+ // search the apps folder
+ $config_paths = OC_Config::getValue('apps_paths', array());
+ if (!empty($config_paths)) {
+ foreach ($config_paths as $paths) {
+ if (isset($paths['url']) && isset($paths['path'])) {
+ $paths['url'] = rtrim($paths['url'], '/');
+ $paths['path'] = rtrim($paths['path'], '/');
+ OC::$APPSROOTS[] = $paths;
+ }
+ }
+ } elseif (file_exists(OC::$SERVERROOT . '/apps')) {
+ OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true);
+ } elseif (file_exists(OC::$SERVERROOT . '/../apps')) {
+ OC::$APPSROOTS[] = array('path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', 'url' => '/apps', 'writable' => true);
+ }
+
+ if (empty(OC::$APPSROOTS)) {
+ echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
+ exit;
+ }
+ $paths = array();
+ 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
+ );
+ }
public static function checkConfig() {
if (file_exists(OC::$SERVERROOT . "/config/config.php") and !is_writable(OC::$SERVERROOT . "/config/config.php")) {
@@ -202,35 +209,41 @@ class OC
}
}
- public static function checkInstalled()
- {
- // Redirect to installer if not installed
- if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
- if (!OC::$CLI) {
- $url = 'http://' . $_SERVER['SERVER_NAME'] . OC::$WEBROOT . '/index.php';
- header("Location: $url");
- }
- exit();
- }
- }
-
- 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'];
- header("Location: $url");
- exit();
- }
- }
- }
+ public static function checkInstalled()
+ {
+ // Redirect to installer if not installed
+ if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
+ if (!OC::$CLI) {
+ $url = 'http://' . $_SERVER['SERVER_NAME'] . OC::$WEBROOT . '/index.php';
+ header("Location: $url");
+ }
+ exit();
+ }
+ }
+
+ 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'];
+ header("Location: $url");
+ exit();
+ }
+ }
+ }
public static function checkMaintenanceMode() {
// Allow ajax update script to execute without being stopped
if (OC_Config::getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') {
+ // send http status 503
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ header('Retry-After: 120');
+
+ // render error page
$tmpl = new OC_Template('', 'error', 'guest');
$tmpl->assign('errors', array(1 => array('error' => 'ownCloud is in maintenance mode')));
$tmpl->printPage();
@@ -246,6 +259,7 @@ class OC
if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
OC_Config::setValue('maintenance', true);
OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
+ OC_Util::addscript('update');
$tmpl = new OC_Template('', 'update', 'guest');
$tmpl->assign('version', OC_Util::getVersionString());
$tmpl->printPage();
@@ -258,504 +272,525 @@ class OC
}
}
- public static function initTemplateEngine()
- {
- // Add the stuff we need always
- OC_Util::addScript("jquery-1.7.2.min");
- OC_Util::addScript("jquery-ui-1.8.16.custom.min");
- OC_Util::addScript("jquery-showpassword");
- OC_Util::addScript("jquery.infieldlabel");
- OC_Util::addScript("jquery-tipsy");
- OC_Util::addScript("oc-dialogs");
- OC_Util::addScript("js");
- OC_Util::addScript("eventsource");
- OC_Util::addScript("config");
- //OC_Util::addScript( "multiselect" );
- OC_Util::addScript('search', 'result');
- OC_Util::addScript('router');
-
- OC_Util::addStyle("styles");
- OC_Util::addStyle("multiselect");
- OC_Util::addStyle("jquery-ui-1.8.16.custom");
- OC_Util::addStyle("jquery-tipsy");
- }
-
- public static function initSession()
- {
- // prevents javascript from accessing php session cookies
- ini_set('session.cookie_httponly', '1;');
-
- // set the session name to the instance id - which is unique
- session_name(OC_Util::getInstanceId());
-
- // (re)-initialize session
- session_start();
-
- // regenerate session id periodically to avoid session fixation
- if (!isset($_SESSION['SID_CREATED'])) {
- $_SESSION['SID_CREATED'] = time();
- } else if (time() - $_SESSION['SID_CREATED'] > 900) {
- session_regenerate_id(true);
- $_SESSION['SID_CREATED'] = time();
- }
-
- // session timeout
- if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 3600)) {
- if (isset($_COOKIE[session_name()])) {
- setcookie(session_name(), '', time() - 42000, '/');
- }
- session_unset();
- session_destroy();
- session_start();
- }
- $_SESSION['LAST_ACTIVITY'] = time();
- }
-
- public static function getRouter()
- {
- if (!isset(OC::$router)) {
- OC::$router = new OC_Router();
- OC::$router->loadRoutes();
- }
-
- return OC::$router;
- }
-
- public static function init()
- {
- // register autoloader
- spl_autoload_register(array('OC', 'autoload'));
- setlocale(LC_ALL, 'en_US.UTF-8');
-
- // set some stuff
- //ob_start();
- error_reporting(E_ALL | E_STRICT);
- if (defined('DEBUG') && DEBUG) {
- ini_set('display_errors', 1);
- }
- self::$CLI = (php_sapi_name() == 'cli');
-
- date_default_timezone_set('UTC');
- ini_set('arg_separator.output', '&amp;');
-
- // try to switch magic quotes off.
- if (get_magic_quotes_gpc()) {
- @set_magic_quotes_runtime(false);
- }
-
- //try to configure php to enable big file uploads.
- //this doesn´t work always depending on the webserver and php configuration.
- //Let´s try to overwrite some defaults anyways
-
- //try to set the maximum execution time to 60min
- @set_time_limit(3600);
- @ini_set('max_execution_time', 3600);
- @ini_set('max_input_time', 3600);
-
- //try to set the maximum filesize to 10G
- @ini_set('upload_max_filesize', '10G');
- @ini_set('post_max_size', '10G');
- @ini_set('file_uploads', '50');
-
- //try to set the session lifetime to 60min
- @ini_set('gc_maxlifetime', '3600');
-
- //copy http auth headers for apache+php-fcgid work around
- if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) {
- $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION'];
- }
-
- //set http auth headers for apache+php-cgi work around
- if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) {
- list($name, $password) = explode(':', base64_decode($matches[1]), 2);
- $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
- $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
- }
-
- //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
- if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) {
- list($name, $password) = explode(':', base64_decode($matches[1]), 2);
- $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
- $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
- }
-
- self::initPaths();
-
- register_shutdown_function(array('OC_Log', 'onShutdown'));
- set_error_handler(array('OC_Log', 'onError'));
- set_exception_handler(array('OC_Log', 'onException'));
-
- // set debug mode if an xdebug session is active
- if (!defined('DEBUG') || !DEBUG) {
- if (isset($_COOKIE['XDEBUG_SESSION'])) {
- define('DEBUG', true);
- }
- }
-
- // register the stream wrappers
- require_once 'streamwrappers.php';
- stream_wrapper_register("fakedir", "OC_FakeDirStream");
- stream_wrapper_register('static', 'OC_StaticStreamWrapper');
- stream_wrapper_register('close', 'OC_CloseStreamWrapper');
-
- self::checkConfig();
- self::checkInstalled();
- self::checkSSL();
- self::initSession();
- self::initTemplateEngine();
- self::checkMaintenanceMode();
- self::checkUpgrade();
-
- $errors = OC_Util::checkServer();
- if (count($errors) > 0) {
- OC_Template::printGuestPage('', 'error', array('errors' => $errors));
- exit;
- }
-
- // User and Groups
- if (!OC_Config::getValue("installed", false)) {
- $_SESSION['user_id'] = '';
- }
-
- OC_User::useBackend(new OC_User_Database());
- OC_Group::useBackend(new OC_Group_Database());
-
- if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SESSION['user_id']) && $_SERVER['PHP_AUTH_USER'] != $_SESSION['user_id']) {
- OC_User::logout();
- }
-
- // Load Apps
- // This includes plugins for users and filesystems as well
- global $RUNTIME_NOAPPS;
- global $RUNTIME_APPTYPES;
- if (!$RUNTIME_NOAPPS) {
- if ($RUNTIME_APPTYPES) {
- OC_App::loadApps($RUNTIME_APPTYPES);
- } else {
- OC_App::loadApps();
- }
- }
-
- //setup extra user backends
- OC_User::setupBackends();
-
- self::registerCacheHooks();
- self::registerFilesystemHooks();
- self::registerShareHooks();
-
- //make sure temporary files are cleaned up
- 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'));
- if (substr_count(self::$REQUESTEDAPP, '?') != 0) {
- $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?'));
- $param = substr($_GET['app'], strpos($_GET['app'], '?') + 1);
- parse_str($param, $get);
- $_GET = array_merge($_GET, $get);
- self::$REQUESTEDAPP = $app;
- $_GET['app'] = $app;
- }
- self::$REQUESTEDFILE = (isset($_GET['getfile']) ? $_GET['getfile'] : null);
- if (substr_count(self::$REQUESTEDFILE, '?') != 0) {
- $file = substr(self::$REQUESTEDFILE, 0, strpos(self::$REQUESTEDFILE, '?'));
- $param = substr(self::$REQUESTEDFILE, strpos(self::$REQUESTEDFILE, '?') + 1);
- parse_str($param, $get);
- $_GET = array_merge($_GET, $get);
- self::$REQUESTEDFILE = $file;
- $_GET['getfile'] = $file;
- }
- if (!is_null(self::$REQUESTEDFILE)) {
- $subdir = OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . self::$REQUESTEDFILE;
- $parent = OC_App::getAppPath(OC::$REQUESTEDAPP);
- if (!OC_Helper::issubdirectory($subdir, $parent)) {
- self::$REQUESTEDFILE = null;
- header('HTTP/1.0 404 Not Found');
- exit;
- }
- }
-
- // write error into log if locale can't be set
- if (OC_Util::issetlocaleworking() == false) {
- OC_Log::write('core', 'setting locate to en_US.UTF-8 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') {
- OC_Util::addScript('backgroundjobs');
+ 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");
+ OC_Util::addScript("jquery-showpassword");
+ OC_Util::addScript("jquery.infieldlabel");
+ OC_Util::addScript("jquery-tipsy");
+ OC_Util::addScript("oc-dialogs");
+ OC_Util::addScript("js");
+ OC_Util::addScript("eventsource");
+ OC_Util::addScript("config");
+ //OC_Util::addScript( "multiselect" );
+ OC_Util::addScript('search', 'result');
+ OC_Util::addScript('router');
+
+ OC_Util::addStyle("styles");
+ OC_Util::addStyle("multiselect");
+ OC_Util::addStyle("jquery-ui-1.10.0.custom");
+ OC_Util::addStyle("jquery-tipsy");
+ OC_Util::addScript("oc-requesttoken");
+ }
+
+ public static function initSession()
+ {
+ // prevents javascript from accessing php session cookies
+ ini_set('session.cookie_httponly', '1;');
+
+ // set the session name to the instance id - which is unique
+ session_name(OC_Util::getInstanceId());
+
+ // (re)-initialize session
+ session_start();
+
+ // regenerate session id periodically to avoid session fixation
+ if (!isset($_SESSION['SID_CREATED'])) {
+ $_SESSION['SID_CREATED'] = time();
+ } else if (time() - $_SESSION['SID_CREATED'] > 900) {
+ session_regenerate_id(true);
+ $_SESSION['SID_CREATED'] = time();
+ }
+
+ // session timeout
+ if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 3600)) {
+ if (isset($_COOKIE[session_name()])) {
+ setcookie(session_name(), '', time() - 42000, '/');
+ }
+ session_unset();
+ session_destroy();
+ session_start();
+ }
+ $_SESSION['LAST_ACTIVITY'] = time();
+ }
+
+ public static function getRouter()
+ {
+ if (!isset(OC::$router)) {
+ OC::$router = new OC_Router();
+ OC::$router->loadRoutes();
+ }
+
+ return OC::$router;
+ }
+
+
+ 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()
+ {
+ // register autoloader
+ spl_autoload_register(array('OC', 'autoload'));
+ setlocale(LC_ALL, 'en_US.UTF-8');
+
+ // set some stuff
+ //ob_start();
+ error_reporting(E_ALL | E_STRICT);
+ if (defined('DEBUG') && DEBUG) {
+ ini_set('display_errors', 1);
+ }
+ self::$CLI = (php_sapi_name() == 'cli');
+
+ date_default_timezone_set('UTC');
+ ini_set('arg_separator.output', '&amp;');
+
+ // try to switch magic quotes off.
+ if (get_magic_quotes_gpc()) {
+ @set_magic_quotes_runtime(false);
+ }
+
+ //try to configure php to enable big file uploads.
+ //this doesn´t work always depending on the webserver and php configuration.
+ //Let´s try to overwrite some defaults anyways
+
+ //try to set the maximum execution time to 60min
+ @set_time_limit(3600);
+ @ini_set('max_execution_time', 3600);
+ @ini_set('max_input_time', 3600);
+
+ //try to set the maximum filesize to 10G
+ @ini_set('upload_max_filesize', '10G');
+ @ini_set('post_max_size', '10G');
+ @ini_set('file_uploads', '50');
+
+ //try to set the session lifetime to 60min
+ @ini_set('gc_maxlifetime', '3600');
+
+ //copy http auth headers for apache+php-fcgid work around
+ if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION'];
+ }
+
+ //set http auth headers for apache+php-cgi work around
+ if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) {
+ list($name, $password) = explode(':', base64_decode($matches[1]), 2);
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
+ //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
+ if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) {
+ list($name, $password) = explode(':', base64_decode($matches[1]), 2);
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
+ self::initPaths();
+
+ register_shutdown_function(array('OC_Log', 'onShutdown'));
+ set_error_handler(array('OC_Log', 'onError'));
+ set_exception_handler(array('OC_Log', 'onException'));
+
+ // set debug mode if an xdebug session is active
+ if (!defined('DEBUG') || !DEBUG) {
+ if (isset($_COOKIE['XDEBUG_SESSION'])) {
+ define('DEBUG', true);
+ }
+ }
+
+ // register the stream wrappers
+ require_once 'streamwrappers.php';
+ stream_wrapper_register("fakedir", "OC_FakeDirStream");
+ stream_wrapper_register('static', 'OC_StaticStreamWrapper');
+ stream_wrapper_register('close', 'OC_CloseStreamWrapper');
+
+ self::checkConfig();
+ self::checkInstalled();
+ self::checkSSL();
+ self::initSession();
+ self::initTemplateEngine();
+
+ $errors = OC_Util::checkServer();
+ if (count($errors) > 0) {
+ OC_Template::printGuestPage('', 'error', array('errors' => $errors));
+ exit;
+ }
+
+ // User and Groups
+ if (!OC_Config::getValue("installed", false)) {
+ $_SESSION['user_id'] = '';
+ }
+
+ OC_User::useBackend(new OC_User_Database());
+ OC_Group::useBackend(new OC_Group_Database());
+
+ if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SESSION['user_id']) && $_SERVER['PHP_AUTH_USER'] != $_SESSION['user_id']) {
+ OC_User::logout();
+ }
+
+ // Load Apps
+ // This includes plugins for users and filesystems as well
+ global $RUNTIME_NOAPPS;
+ global $RUNTIME_APPTYPES;
+ if (!$RUNTIME_NOAPPS) {
+ if ($RUNTIME_APPTYPES) {
+ OC_App::loadApps($RUNTIME_APPTYPES);
+ } else {
+ OC_App::loadApps();
+ }
+ }
+
+ //setup extra user backends
+ OC_User::setupBackends();
+
+ self::registerCacheHooks();
+ self::registerFilesystemHooks();
+ self::registerShareHooks();
+
+ //make sure temporary files are cleaned up
+ 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'));
+ if (substr_count(self::$REQUESTEDAPP, '?') != 0) {
+ $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?'));
+ $param = substr($_GET['app'], strpos($_GET['app'], '?') + 1);
+ parse_str($param, $get);
+ $_GET = array_merge($_GET, $get);
+ self::$REQUESTEDAPP = $app;
+ $_GET['app'] = $app;
+ }
+ self::$REQUESTEDFILE = (isset($_GET['getfile']) ? $_GET['getfile'] : null);
+ if (substr_count(self::$REQUESTEDFILE, '?') != 0) {
+ $file = substr(self::$REQUESTEDFILE, 0, strpos(self::$REQUESTEDFILE, '?'));
+ $param = substr(self::$REQUESTEDFILE, strpos(self::$REQUESTEDFILE, '?') + 1);
+ parse_str($param, $get);
+ $_GET = array_merge($_GET, $get);
+ self::$REQUESTEDFILE = $file;
+ $_GET['getfile'] = $file;
+ }
+ if (!is_null(self::$REQUESTEDFILE)) {
+ $subdir = OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . self::$REQUESTEDFILE;
+ $parent = OC_App::getAppPath(OC::$REQUESTEDAPP);
+ if (!OC_Helper::issubdirectory($subdir, $parent)) {
+ self::$REQUESTEDFILE = null;
+ header('HTTP/1.0 404 Not Found');
+ exit;
+ }
+ }
+
+ // write error into log if locale can't be set
+ if (OC_Util::issetlocaleworking() == false) {
+ OC_Log::write('core', 'setting locate to en_US.UTF-8 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') {
+ OC_Util::addScript('backgroundjobs');
+ }
+ }
+ }
+
+ /**
+ * register hooks for the cache
+ */
+ 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');
+ }
+
+ /**
+ * register hooks for the filesystem
+ */
+ 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');
+ }
+
+ /**
+ * register hooks for sharing
+ */
+ 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');
+ OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup');
+ }
+
+ /**
+ * @brief Handle the request
+ */
+ 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();
+
+ 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;
+ }
+ $app = OC::$REQUESTEDAPP;
+ $file = OC::$REQUESTEDFILE;
+ $param = array('app' => $app, 'file' => $file);
+ // Handle app css files
+ if (substr($file, -3) == 'css') {
+ self::loadCSSFile($param);
+ 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']));
+ header('Location: ' . $location);
+ return;
+ }
+ // Handle WebDAV
+ if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
+ header('location: ' . OC_Helper::linkToRemote('webdav'));
+ return;
+ }
+
+ // Someone is logged in :
+ if (OC_User::isLoggedIn()) {
+ OC_App::loadApps();
+ OC_User::setupBackends();
+ if (isset($_GET["logout"]) and ($_GET["logout"])) {
+ if (isset($_COOKIE['oc_token'])) {
+ OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
+ }
+ OC_User::logout();
+ header("Location: " . OC::$WEBROOT . '/');
+ } else {
+ if (is_null($file)) {
+ $param['file'] = 'index.php';
+ }
+ $file_ext = substr($param['file'], -3);
+ if ($file_ext != 'php'
+ || !self::loadAppScriptFile($param)
+ ) {
+ header('HTTP/1.0 404 Not Found');
+ }
+ }
+ return;
+ }
+ // Not handled and not logged in
+ self::handleLogin();
+ }
+
+ public static function loadAppScriptFile($param)
+ {
+ OC_App::loadApps();
+ $app = $param['app'];
+ $file = $param['file'];
+ $app_path = OC_App::getAppPath($app);
+ $file = $app_path . '/' . $file;
+ unset($app, $app_path);
+ if (file_exists($file)) {
+ require_once $file;
+ return true;
+ }
+ return false;
+ }
+
+ public static function loadCSSFile($param)
+ {
+ $app = $param['app'];
+ $file = $param['file'];
+ $app_path = OC_App::getAppPath($app);
+ if (file_exists($app_path . '/' . $file)) {
+ $app_web_path = OC_App::getAppWebPath($app);
+ $filepath = $app_web_path . '/' . $file;
+ $minimizer = new OC_Minimizer_CSS();
+ $info = array($app_path, $app_web_path, $file);
+ $minimizer->output(array($info), $filepath);
+ }
+ }
+
+ 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 :
+ } elseif (OC::tryFormLogin()) {
+ $error[] = 'invalidpassword';
+
+ // 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)
+ {
+ $cutoff = time() - OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
+ $tokens = OC_Preferences::getKeys($user, 'login_token');
+ foreach ($tokens as $token) {
+ $time = OC_Preferences::getValue($user, 'login_token', $token);
+ if ($time < $cutoff) {
+ OC_Preferences::deleteKey($user, 'login_token', $token);
+ }
+ }
+ }
+
+ 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'));
+ if (defined("DEBUG") && DEBUG) {
+ OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
+ }
+ // confirm credentials in cookie
+ if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username'])) {
+ // delete outdated cookies
+ self::cleanupLoginTokens($_COOKIE['oc_username']);
+ // get stored tokens
+ $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token');
+ // test cookies token against stored tokens
+ if (in_array($_COOKIE['oc_token'], $tokens, true)) {
+ // replace successfully used token with a new one
+ OC_Preferences::deleteKey($_COOKIE['oc_username'], 'login_token', $_COOKIE['oc_token']);
+ $token = OC_Util::generate_random_bytes(32);
+ OC_Preferences::setValue($_COOKIE['oc_username'], 'login_token', $token, time());
+ OC_User::setMagicInCookie($_COOKIE['oc_username'], $token);
+ // login
+ OC_User::setUserId($_COOKIE['oc_username']);
+ OC_Util::redirectToDefaultPage();
+ // doesn't return
+ }
+ // if you reach this point you have changed your password
+ // or you are an attacker
+ // we can not delete tokens here because users may reach
+ // this point multiple times after a password change
+ OC_Log::write('core', 'Authentication cookie rejected for user ' . $_COOKIE['oc_username'], OC_Log::WARN);
+ }
+ OC_User::unsetMagicInCookie();
+ return true;
+ }
+
+ protected static function tryFormLogin()
+ {
+ if (!isset($_POST["user"]) || !isset($_POST['password'])) {
+ return false;
+ }
+
+ OC_App::loadApps();
+
+ //setup extra user backends
+ OC_User::setupBackends();
+
+ if (OC_User::login($_POST["user"], $_POST["password"])) {
+ // setting up the time zone
+ if (isset($_POST['timezone-offset'])) {
+ $_SESSION['timezone'] = $_POST['timezone-offset'];
+ }
+
+ self::cleanupLoginTokens($_POST['user']);
+ if (!empty($_POST["remember_login"])) {
+ if (defined("DEBUG") && DEBUG) {
+ OC_Log::write('core', 'Setting remember login to cookie', OC_Log::DEBUG);
+ }
+ $token = OC_Util::generate_random_bytes(32);
+ OC_Preferences::setValue($_POST['user'], 'login_token', $token, time());
+ OC_User::setMagicInCookie($_POST["user"], $token);
+ } else {
+ OC_User::unsetMagicInCookie();
+ }
+ OC_Util::redirectToDefaultPage();
+ exit();
+ }
+ return true;
+ }
+
+ 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'] : '');
+ OC_Util::redirectToDefaultPage();
+ }
+ return true;
}
- }
-
- /**
- * register hooks for the cache
- */
- 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');
- }
-
- /**
- * register hooks for the filesystem
- */
- 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');
- }
-
- /**
- * register hooks for sharing
- */
- 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');
- OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup');
- }
-
- /**
- * @brief Handle the request
- */
- public static function handleRequest()
- {
- if (!OC_Config::getValue('installed', false)) {
- require_once 'core/setup.php';
- exit();
- }
- // Handle redirect URL for logged in users
- if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
- $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
- header('Location: ' . $location);
- return;
- }
- // Handle WebDAV
- if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
- header('location: ' . OC_Helper::linkToRemote('webdav'));
- return;
- }
- 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;
- }
- $app = OC::$REQUESTEDAPP;
- $file = OC::$REQUESTEDFILE;
- $param = array('app' => $app, 'file' => $file);
- // Handle app css files
- if (substr($file, -3) == 'css') {
- self::loadCSSFile($param);
- return;
- }
- // Someone is logged in :
- if (OC_User::isLoggedIn()) {
- OC_App::loadApps();
- OC_User::setupBackends();
- if (isset($_GET["logout"]) and ($_GET["logout"])) {
- if (isset($_COOKIE['oc_token'])) {
- OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
- }
- OC_User::logout();
- header("Location: " . OC::$WEBROOT . '/');
- } else {
- if (is_null($file)) {
- $param['file'] = 'index.php';
- }
- $file_ext = substr($param['file'], -3);
- if ($file_ext != 'php'
- || !self::loadAppScriptFile($param)
- ) {
- header('HTTP/1.0 404 Not Found');
- }
- }
- return;
- }
- // Not handled and not logged in
- self::handleLogin();
- }
-
- public static function loadAppScriptFile($param)
- {
- OC_App::loadApps();
- $app = $param['app'];
- $file = $param['file'];
- $app_path = OC_App::getAppPath($app);
- $file = $app_path . '/' . $file;
- unset($app, $app_path);
- if (file_exists($file)) {
- require_once $file;
- return true;
- }
- return false;
- }
-
- public static function loadCSSFile($param)
- {
- $app = $param['app'];
- $file = $param['file'];
- $app_path = OC_App::getAppPath($app);
- if (file_exists($app_path . '/' . $file)) {
- $app_web_path = OC_App::getAppWebPath($app);
- $filepath = $app_web_path . '/' . $file;
- $minimizer = new OC_Minimizer_CSS();
- $info = array($app_path, $app_web_path, $file);
- $minimizer->output(array($info), $filepath);
- }
- }
-
- 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 :
- } elseif (OC::tryFormLogin()) {
- $error[] = 'invalidpassword';
-
- // 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)
- {
- $cutoff = time() - OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
- $tokens = OC_Preferences::getKeys($user, 'login_token');
- foreach ($tokens as $token) {
- $time = OC_Preferences::getValue($user, 'login_token', $token);
- if ($time < $cutoff) {
- OC_Preferences::deleteKey($user, 'login_token', $token);
- }
- }
- }
-
- 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'));
- if (defined("DEBUG") && DEBUG) {
- OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
- }
- // confirm credentials in cookie
- if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username'])) {
- // delete outdated cookies
- self::cleanupLoginTokens($_COOKIE['oc_username']);
- // get stored tokens
- $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token');
- // test cookies token against stored tokens
- if (in_array($_COOKIE['oc_token'], $tokens, true)) {
- // replace successfully used token with a new one
- OC_Preferences::deleteKey($_COOKIE['oc_username'], 'login_token', $_COOKIE['oc_token']);
- $token = OC_Util::generate_random_bytes(32);
- OC_Preferences::setValue($_COOKIE['oc_username'], 'login_token', $token, time());
- OC_User::setMagicInCookie($_COOKIE['oc_username'], $token);
- // login
- OC_User::setUserId($_COOKIE['oc_username']);
- OC_Util::redirectToDefaultPage();
- // doesn't return
- }
- // if you reach this point you have changed your password
- // or you are an attacker
- // we can not delete tokens here because users may reach
- // this point multiple times after a password change
- OC_Log::write('core', 'Authentication cookie rejected for user ' . $_COOKIE['oc_username'], OC_Log::WARN);
- }
- OC_User::unsetMagicInCookie();
- return true;
- }
-
- protected static function tryFormLogin()
- {
- if (!isset($_POST["user"]) || !isset($_POST['password'])) {
- return false;
- }
-
- OC_App::loadApps();
-
- //setup extra user backends
- OC_User::setupBackends();
-
- if (OC_User::login($_POST["user"], $_POST["password"])) {
- // setting up the time zone
- if (isset($_POST['timezone-offset'])) {
- $_SESSION['timezone'] = $_POST['timezone-offset'];
- }
-
- self::cleanupLoginTokens($_POST['user']);
- if (!empty($_POST["remember_login"])) {
- if (defined("DEBUG") && DEBUG) {
- OC_Log::write('core', 'Setting remember login to cookie', OC_Log::DEBUG);
- }
- $token = OC_Util::generate_random_bytes(32);
- OC_Preferences::setValue($_POST['user'], 'login_token', $token, time());
- OC_User::setMagicInCookie($_POST["user"], $token);
- } else {
- OC_User::unsetMagicInCookie();
- }
- OC_Util::redirectToDefaultPage();
- exit();
- }
- return true;
- }
-
- 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'] : '');
- OC_Util::redirectToDefaultPage();
- }
- return true;
- }
}
// define runtime variables - unless this already has been done
if (!isset($RUNTIME_NOAPPS)) {
- $RUNTIME_NOAPPS = false;
+ $RUNTIME_NOAPPS = false;
}
if (!function_exists('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;
- if ($temp = getenv('TMPDIR')) return $temp;
- $temp = tempnam(__FILE__, '');
- if (file_exists($temp)) {
- unlink($temp);
- return dirname($temp);
- }
- if ($temp = sys_get_temp_dir()) return $temp;
-
- return null;
- }
+ 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;
+ if ($temp = getenv('TMPDIR')) return $temp;
+ $temp = tempnam(__FILE__, '');
+ if (file_exists($temp)) {
+ unlink($temp);
+ return dirname($temp);
+ }
+ if ($temp = sys_get_temp_dir()) return $temp;
+
+ return null;
+ }
}
OC::init();
diff --git a/lib/cache/apc.php b/lib/cache/apc.php
index 6dda0a0ff8c..895d307ea26 100644
--- a/lib/cache/apc.php
+++ b/lib/cache/apc.php
@@ -57,7 +57,7 @@ class OC_Cache_APC {
if(!function_exists('apc_exists')) {
function apc_exists($keys)
{
- $result;
+ $result=false;
apc_fetch($keys, $result);
return $result;
}
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index 52350072fb2..026ec9f7ec5 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -176,9 +176,9 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @brief Returns a list of properties for this nodes.;
* @param array $properties
* @return array
- * @note The properties list is a list of propertynames the client
- * requested, encoded as xmlnamespace#tagName, for example:
- * http://www.example.org/namespace#author If the array is empty, all
+ * @note The properties list is a list of propertynames the client
+ * requested, encoded as xmlnamespace#tagName, for example:
+ * http://www.example.org/namespace#author If the array is empty, all
* properties should be returned
*/
public function getProperties($properties) {
diff --git a/lib/db.php b/lib/db.php
index 74e7ca5b0e0..51f7c7679d4 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -41,6 +41,8 @@ class OC_DB {
const BACKEND_PDO=0;
const BACKEND_MDB2=1;
+ static private $preparedQueries = array();
+
/**
* @var MDB2_Driver_Common
*/
@@ -121,6 +123,7 @@ class OC_DB {
return true;
}
}
+ self::$preparedQueries = array();
// The global data we need
$name = OC_Config::getValue( "dbname", "owncloud" );
$host = OC_Config::getValue( "dbhost", "" );
@@ -181,7 +184,14 @@ class OC_DB {
try{
self::$PDO=new PDO($dsn, $user, $pass, $opts);
}catch(PDOException $e) {
- OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.$e->getMessage().')' );
+ OC_Log::write('core', $e->getMessage(), OC_Log::FATAL);
+ OC_User::setUserId(null);
+
+ // send http status 503
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ OC_Template::printErrorPage('Failed to connect to database');
+ die();
}
// We always, really always want associative arrays
self::$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
@@ -201,6 +211,7 @@ class OC_DB {
return true;
}
}
+ self::$preparedQueries = array();
// The global data we need
$name = OC_Config::getValue( "dbname", "owncloud" );
$host = OC_Config::getValue( "dbhost", "" );
@@ -277,7 +288,13 @@ class OC_DB {
if( PEAR::isError( self::$MDB2 )) {
OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL);
OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL);
- OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')' );
+ OC_User::setUserId(null);
+
+ // send http status 503
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ OC_Template::printErrorPage('Failed to connect to database');
+ die();
}
// We always, really always want associative arrays
@@ -321,7 +338,12 @@ class OC_DB {
$query.=$limitsql;
}
}
+ } else {
+ if (isset(self::$preparedQueries[$query])) {
+ return self::$preparedQueries[$query];
+ }
}
+ $rawQuery = $query;
// Optimize the query
$query = self::processQuery( $query );
@@ -343,6 +365,9 @@ class OC_DB {
}
$result=new PDOStatementWrapper($result);
}
+ if (is_null($limit) || $limit == -1) {
+ self::$preparedQueries[$rawQuery] = $result;
+ }
return $result;
}
@@ -428,6 +453,9 @@ class OC_DB {
$CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
+ // cleanup the cached queries
+ self::$preparedQueries = array();
+
self::connectScheme();
// read file
@@ -588,7 +616,7 @@ class OC_DB {
error_log('DB error: '.$entry);
OC_Template::printErrorPage( $entry );
}
-
+
if($result->numRows() == 0) {
$query = 'INSERT INTO "' . $table . '" ("'
. implode('","', array_keys($input)) . '") VALUES("'
@@ -623,7 +651,7 @@ class OC_DB {
return $result->execute();
}
-
+
/**
* @brief does minor changes to query
* @param string $query Query string
diff --git a/lib/filecache.php b/lib/filecache.php
index c3256c783e6..7764890ef1a 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -23,9 +23,14 @@
* provide caching for filesystem info in the database
*
* not used by OC_Filesystem for reading filesystem info,
- * instread apps should use OC_FileCache::get where possible
+ * instead apps should use OC_FileCache::get where possible
+ *
+ * It will try to keep the data up to date but changes from outside
+ * ownCloud can invalidate the cache
+ *
+ * Methods that take $path and $root params expect $path to be relative, like
+ * /admin/files/file.txt, if $root is false
*
- * It will try to keep the data up to date but changes from outside ownCloud can invalidate the cache
*/
class OC_FileCache{
@@ -59,7 +64,7 @@ class OC_FileCache{
* @param string $path
* @param array data
* @param string root (optional)
- * @note $data is an associative array in the same format as returned
+ * @note $data is an associative array in the same format as returned
* by get
*/
public static function put($path, $data, $root=false) {
@@ -206,7 +211,7 @@ class OC_FileCache{
OC_Cache::remove('fileid/'.$root.$path);
}
-
+
/**
* return array of filenames matching the querty
* @param string $query
@@ -354,7 +359,7 @@ class OC_FileCache{
public static function increaseSize($path, $sizeDiff, $root=false) {
if($sizeDiff==0) return;
$item = OC_FileCache_Cached::get($path);
- //stop walking up the filetree if we hit a non-folder or reached to root folder
+ //stop walking up the filetree if we hit a non-folder or reached the root folder
if($path == '/' || $path=='' || $item['mimetype'] !== 'httpd/unix-directory') {
return;
}
diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php
index 742e02d471b..503288142aa 100644
--- a/lib/fileproxy/quota.php
+++ b/lib/fileproxy/quota.php
@@ -76,7 +76,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{
$usedSpace=isset($sharedInfo['size'])?$usedSpace-$sharedInfo['size']:$usedSpace;
return $totalSpace-$usedSpace;
}
-
+
public function postFree_space($path, $space) {
$free=$this->getFreeSpace($path);
if($free==-1) {
diff --git a/lib/files.php b/lib/files.php
index 69097e41074..f4e0f140a44 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -141,7 +141,7 @@ class OC_Files {
*/
public static function get($dir, $files, $only_header = false) {
$xsendfile = false;
- if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) ||
+ if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) ||
isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
$xsendfile = true;
}
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 910b3fa039d..4a4019a3224 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -92,7 +92,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
public function file_get_contents($path) {
return file_get_contents($this->datadir.$path);
}
- public function file_put_contents($path, $data) {
+ public function file_put_contents($path, $data) {//trigger_error("$path = ".var_export($path, 1));
return file_put_contents($this->datadir.$path, $data);
}
public function unlink($path) {
diff --git a/lib/filesystem.php b/lib/filesystem.php
index aa03593908d..f185d777def 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -179,11 +179,11 @@ class OC_Filesystem{
$internalPath=substr($path, strlen($mountPoint));
return $internalPath;
}
-
+
static private function mountPointsLoaded($user) {
return in_array($user, self::$loadedUsers);
}
-
+
/**
* get the storage object for a path
* @param string path
@@ -216,7 +216,7 @@ class OC_Filesystem{
self::mount($options['class'], $options['options'], $mountPoint);
}
}
-
+
if(isset($mountConfig['group'])) {
foreach($mountConfig['group'] as $group=>$mounts) {
if(OC_Group::inGroup($user, $group)) {
@@ -230,7 +230,7 @@ class OC_Filesystem{
}
}
}
-
+
if(isset($mountConfig['user'])) {
foreach($mountConfig['user'] as $mountUser=>$mounts) {
if($user==='all' or strtolower($mountUser)===strtolower($user)) {
@@ -244,16 +244,16 @@ class OC_Filesystem{
}
}
}
-
+
$mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
$previousMTime=OC_Appconfig::getValue('files', 'mountconfigmtime', 0);
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
OC_FileCache::triggerUpdate();
OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime);
}
- }
+ }
}
-
+
static public function init($root, $user = '') {
if(self::$defaultInstance) {
return false;
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index e944ae5045d..1fc8e83d68f 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -36,8 +36,12 @@
*
* Filesystem functions are not called directly; they are passed to the correct
* OC_Filestorage object
+ *
+ * @note default root (if $root is empty or '/') is /data/[user]/
+ * @note If you don't include a leading slash, you may encounter problems.
+ * e.g. use $v = new \OC_FilesystemView( '/' . $params['uid'] ); not
+ * $v = new \OC_FilesystemView( $params['uid'] );
*/
-
class OC_FilesystemView {
private $fakeRoot='';
private $internal_path_cache=array();
@@ -430,10 +434,10 @@ class OC_FilesystemView {
$target = $this->fopen($path2.$postFix2, 'w');
$result = OC_Helper::streamCopy($source, $target);
}
- if( $this->fakeRoot==OC_Filesystem::getRoot() ) {
- // If the file to be copied originates within
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ) {
+ // If the file to be copied originates within
// the user's data directory
-
+
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_post_copy,
@@ -454,33 +458,33 @@ class OC_FilesystemView {
OC_Filesystem::signal_post_write,
array( OC_Filesystem::signal_param_path => $path2)
);
-
- } else {
- // If this is not a normal file copy operation
- // and the file originates somewhere else
- // (e.g. a version rollback operation), do not
+
+ } else {
+ // If this is not a normal file copy operation
+ // and the file originates somewhere else
+ // (e.g. a version rollback operation), do not
// perform all the other post_write actions
-
+
// Update webdav properties
OC_Filesystem::removeETagHook(array("path" => $path2), $this->fakeRoot);
-
+
$splitPath2 = explode( '/', $path2 );
-
- // Only cache information about files
- // that are being copied from within
- // the user files directory. Caching
+
+ // Only cache information about files
+ // that are being copied from within
+ // the user files directory. Caching
// other files, like VCS backup files,
// serves no purpose
if ( $splitPath2[1] == 'files' ) {
-
+
OC_FileCache_Update::update($path2, $this->fakeRoot);
-
+
}
-
+
}
-
+
return $result;
-
+
}
}
}
diff --git a/lib/group.php b/lib/group.php
index ed9482418bd..5afef769361 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -286,4 +286,33 @@ class OC_Group {
}
return $users;
}
+
+ /**
+ * @brief get a list of all display names in a group
+ * @returns array with display names (value) and user ids(key)
+ */
+ public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames=array();
+ foreach(self::$_usedBackends as $backend) {
+ $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames);
+ }
+ return $displayNames;
+ }
+
+ /**
+ * @brief get a list of all display names in several groups
+ * @param array $gids
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (Key) user ids (value)
+ */
+ public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
+ $displayNames = array();
+ foreach ($gids as $gid) {
+ // TODO Need to apply limits to groups as total
+ $displayNames = array_merge(array_diff(self::displayNamesInGroup($gid, $search, $limit, $offset), $displayNames), $displayNames);
+ }
+ return $displayNames;
+ }
}
diff --git a/lib/group/backend.php b/lib/group/backend.php
index 9ff432d0663..4f6570c3be3 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -133,5 +133,23 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
return array();
}
+
+ /**
+ * @brief get a list of all display names in a group
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (value) and user ids (key)
+ */
+ public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames = '';
+ $users = $this->usersInGroup($gid, $search, $limit, $offset);
+ foreach ( $users as $user ) {
+ $DisplayNames[$user] = $user;
+ }
+
+ return $DisplayNames;
+ }
}
diff --git a/lib/group/database.php b/lib/group/database.php
index 6eca98ba019..c5dd402b212 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -208,4 +208,32 @@ class OC_Group_Database extends OC_Group_Backend {
}
return $users;
}
+
+ /**
+ * @brief get a list of all display names in a group
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (value) and user ids (key)
+ */
+ public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames = '';
+ /*
+
+ SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
+ FROM Persons
+ INNER JOIN Orders
+ ON Persons.P_Id=Orders.P_Id
+ ORDER BY Persons.LastName
+ */
+ $stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname` FROM `*PREFIX*users` INNER JOIN `*PREFIX*group_user` ON `*PREFIX*group_user`.`uid` = `*PREFIX*users`.`uid` WHERE `gid` = ? AND `*PREFIX*group_user.uid` LIKE ?', $limit, $offset);
+ $result = $stmt->execute(array($gid, $search.'%'));
+ $users = array();
+ while ($row = $result->fetchRow()) {
+ $displayName = trim($row['displayname'], ' ');
+ $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
+ }
+ return $displayNames;
+ }
}
diff --git a/lib/helper.php b/lib/helper.php
index 1aba2a38100..425dc138c5a 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -78,11 +78,8 @@ class OC_Helper {
}
}
- if (!empty($args)) {
- $urlLinkTo .= '?';
- foreach($args as $k => $v) {
- $urlLinkTo .= '&'.$k.'='.urlencode($v);
- }
+ if ($args && $query = http_build_query($args, '', '&')) {
+ $urlLinkTo .= '?'.$query;
}
return $urlLinkTo;
@@ -193,8 +190,9 @@ class OC_Helper {
if(isset($alias[$mimetype])) {
$mimetype=$alias[$mimetype];
}
- // Replace slash with a minus
+ // Replace slash and backslash with a minus
$mimetype = str_replace( "/", "-", $mimetype );
+ $mimetype = str_replace( "\\", "-", $mimetype );
// Is it a dir?
if( $mimetype == "dir" ) {
@@ -223,6 +221,10 @@ class OC_Helper {
* Makes 2048 to 2 kB.
*/
public static function humanFileSize( $bytes ) {
+ if( $bytes < 0 ) {
+ $l = OC_L10N::get('lib');
+ return $l->t("couldn't be determined");
+ }
if( $bytes < 1024 ) {
return "$bytes B";
}
@@ -549,7 +551,7 @@ class OC_Helper {
fclose($fh);
return $file;
}
-
+
/**
* create a temporary folder with an unique filename
* @return string
@@ -625,37 +627,17 @@ class OC_Helper {
return $newpath;
}
- /*
- * checks if $sub is a subdirectory of $parent
+ /**
+ * @brief Checks if $sub is a subdirectory of $parent
*
* @param string $sub
* @param string $parent
* @return bool
*/
public static function issubdirectory($sub, $parent) {
- if($sub == null || $sub == '' || $parent == null || $parent == '') {
- return false;
- }
- $realpath_sub = realpath($sub);
- $realpath_parent = realpath($parent);
- if(($realpath_sub == false && substr_count($realpath_sub, './') != 0) || ($realpath_parent == false && substr_count($realpath_parent, './') != 0)) { //it checks for both ./ and ../
- return false;
- }
- if($realpath_sub && $realpath_sub != '' && $realpath_parent && $realpath_parent != '') {
- if(substr($realpath_sub, 0, strlen($realpath_parent)) == $realpath_parent) {
- return true;
- }
- }else{
- if(substr($sub, 0, strlen($parent)) == $parent) {
- return true;
- }
+ if (strpos(realpath($sub), realpath($parent)) === 0) {
+ return true;
}
- /*echo 'SUB: ' . $sub . "\n";
- echo 'PAR: ' . $parent . "\n";
- echo 'REALSUB: ' . $realpath_sub . "\n";
- echo 'REALPAR: ' . $realpath_parent . "\n";
- echo substr($realpath_sub, 0, strlen($realpath_parent));
- exit;*/
return false;
}
@@ -695,8 +677,8 @@ class OC_Helper {
$start = intval($start);
$length = intval($length);
$string = mb_substr($string, 0, $start, $encoding) .
- $replacement .
- mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
+ $replacement .
+ mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
return $string;
}
@@ -765,6 +747,23 @@ class OC_Helper {
}
/**
+ * @brief calculates the maximum upload size respecting system settings, free space and user quota
+ *
+ * @param $dir the current folder where the user currently operates
+ * @return number of bytes representing
+ */
+ public static function maxUploadFilesize($dir) {
+ $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+ $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
+ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+
+ $freeSpace = OC_Filesystem::free_space($dir);
+ $freeSpace = max($freeSpace, 0);
+
+ return min($maxUploadFilesize, $freeSpace);
+ }
+
+ /**
* Checks if a function is available
* @param string $function_name
* @return bool
@@ -783,4 +782,23 @@ class OC_Helper {
}
return true;
}
+
+ /**
+ * Calculate the disc space
+ */
+ public static function getStorageInfo() {
+ $rootInfo = OC_FileCache::get('');
+ $used = $rootInfo['size'];
+ if ($used < 0) {
+ $used = 0;
+ }
+ $free = OC_Filesystem::free_space();
+ $total = $free + $used;
+ if ($total == 0) {
+ $total = 1; // prevent division by zero
+ }
+ $relative = round(($used / $total) * 10000) / 100;
+
+ return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative);
+ }
}
diff --git a/lib/image.php b/lib/image.php
index 2043a452541..cfc6d477395 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -646,7 +646,7 @@ class OC_Image {
fclose($fh);
return $im;
}
-
+
/**
* @brief Resizes the image preserving ratio.
* @param $maxsize The maximum size of either the width or height.
diff --git a/lib/installer.php b/lib/installer.php
index 8cffe5f06c7..bf81cbdadaf 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -267,7 +267,6 @@ class OC_Installer{
* 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<>''){
diff --git a/lib/json.php b/lib/json.php
index 204430411c0..f929e958957 100644
--- a/lib/json.php
+++ b/lib/json.php
@@ -57,9 +57,7 @@ class OC_JSON{
* Check if the user is a admin, send json error msg if not
*/
public static function checkAdminUser() {
- self::checkLoggedIn();
- self::verifyUser();
- if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) {
+ if( !OC_User::isAdminUser(OC_User::getUser())) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();
@@ -70,9 +68,7 @@ class OC_JSON{
* Check if the user is a subadmin, send json error msg if not
*/
public static function checkSubAdminUser() {
- self::checkLoggedIn();
- self::verifyUser();
- if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
+ if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();
@@ -80,19 +76,6 @@ class OC_JSON{
}
/**
- * Check if the user verified the login with his password
- */
- public static function verifyUser() {
- if(OC_Config::getValue('enhancedauth', false) === true) {
- if(!isset($_SESSION['verifiedLogin']) OR $_SESSION['verifiedLogin'] < time()) {
- $l = OC_L10N::get('lib');
- self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
- exit();
- }
- }
- }
-
- /**
* Send json error msg
*/
public static function error($data = array()) {
diff --git a/lib/l10n.php b/lib/l10n.php
index f70dfa5e34e..ca53b3cf65c 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -141,15 +141,15 @@ class OC_L10N{
}
}
- /**
- * @brief Translating
- * @param $text String The text we need a translation for
- * @param array $parameters default:array() Parameters for sprintf
- * @return \OC_L10N_String Translation or the same text
- *
- * Returns the translation. If no translation is found, $text will be
- * returned.
- */
+ /**
+ * @brief Translating
+ * @param $text String The text we need a translation for
+ * @param array $parameters default:array() Parameters for sprintf
+ * @return \OC_L10N_String Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $text will be
+ * returned.
+ */
public function t($text, $parameters = array()) {
return new OC_L10N_String($this, $text, $parameters);
}
diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php
index b3321ef82e1..f6401fa39b6 100644
--- a/lib/l10n/ca.php
+++ b/lib/l10n/ca.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Els fitxers s'han de baixar d'un en un.",
"Back to Files" => "Torna a Fitxers",
"Selected files too large to generate zip file." => "Els fitxers seleccionats son massa grans per generar un fitxer zip.",
+"couldn't be determined" => "no s'ha pogut determinar",
"Application is not enabled" => "L'aplicació no està habilitada",
"Authentication error" => "Error d'autenticació",
"Token expired. Please reload page." => "El testimoni ha expirat. Torneu a carregar la pàgina.",
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php
index fa11e886774..2c823194b96 100644
--- a/lib/l10n/cs_CZ.php
+++ b/lib/l10n/cs_CZ.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Soubory musí být stahovány jednotlivě.",
"Back to Files" => "Zpět k souborům",
"Selected files too large to generate zip file." => "Vybrané soubory jsou příliš velké pro vytvoření zip souboru.",
+"couldn't be determined" => "nelze zjistit",
"Application is not enabled" => "Aplikace není povolena",
"Authentication error" => "Chyba ověření",
"Token expired. Please reload page." => "Token vypršel. Obnovte prosím stránku.",
diff --git a/lib/l10n/da.php b/lib/l10n/da.php
index a0ab1f17014..8f22be5e823 100644
--- a/lib/l10n/da.php
+++ b/lib/l10n/da.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Filer skal downloades en for en.",
"Back to Files" => "Tilbage til Filer",
"Selected files too large to generate zip file." => "De markerede filer er for store til at generere en ZIP-fil.",
+"couldn't be determined" => "kunne ikke fastslås",
"Application is not enabled" => "Programmet er ikke aktiveret",
"Authentication error" => "Adgangsfejl",
"Token expired. Please reload page." => "Adgang er udløbet. Genindlæs siden.",
diff --git a/lib/l10n/de.php b/lib/l10n/de.php
index 4b77bf7210d..c285a07f63a 100644
--- a/lib/l10n/de.php
+++ b/lib/l10n/de.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Die Dateien müssen einzeln heruntergeladen werden.",
"Back to Files" => "Zurück zu \"Dateien\"",
"Selected files too large to generate zip file." => "Die gewählten Dateien sind zu groß, um eine ZIP-Datei zu erstellen.",
+"couldn't be determined" => "Konnte nicht festgestellt werden",
"Application is not enabled" => "Die Anwendung ist nicht aktiviert",
"Authentication error" => "Authentifizierungs-Fehler",
"Token expired. Please reload page." => "Token abgelaufen. Bitte lade die Seite neu.",
diff --git a/lib/l10n/de_DE.php b/lib/l10n/de_DE.php
index e9f0f34a0e1..625ba2ecf20 100644
--- a/lib/l10n/de_DE.php
+++ b/lib/l10n/de_DE.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Die Dateien müssen einzeln heruntergeladen werden.",
"Back to Files" => "Zurück zu \"Dateien\"",
"Selected files too large to generate zip file." => "Die gewählten Dateien sind zu groß, um eine ZIP-Datei zu erstellen.",
+"couldn't be determined" => "konnte nicht ermittelt werden",
"Application is not enabled" => "Die Anwendung ist nicht aktiviert",
"Authentication error" => "Authentifizierungs-Fehler",
"Token expired. Please reload page." => "Token abgelaufen. Bitte laden Sie die Seite neu.",
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index 315b995ecc9..cf0be24b432 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.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/es.php b/lib/l10n/es.php
index f843c42dfd3..8bbc8a8f7b4 100644
--- a/lib/l10n/es.php
+++ b/lib/l10n/es.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Los archivos deben ser descargados uno por uno.",
"Back to Files" => "Volver a Archivos",
"Selected files too large to generate zip file." => "Los archivos seleccionados son demasiado grandes para generar el archivo zip.",
+"couldn't be determined" => "no pudo ser determinado",
"Application is not enabled" => "La aplicación no está habilitada",
"Authentication error" => "Error de autenticación",
"Token expired. Please reload page." => "Token expirado. Por favor, recarga la página.",
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
index 2bbffd39e9e..c32017a10f8 100644
--- a/lib/l10n/es_AR.php
+++ b/lib/l10n/es_AR.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Los archivos deben ser descargados de a uno.",
"Back to Files" => "Volver a archivos",
"Selected files too large to generate zip file." => "Los archivos seleccionados son demasiado grandes para generar el archivo zip.",
+"couldn't be determined" => "no pudo ser determinado",
"Application is not enabled" => "La aplicación no está habilitada",
"Authentication error" => "Error de autenticación",
"Token expired. Please reload page." => "Token expirado. Por favor, recargá la página.",
diff --git a/lib/l10n/eu.php b/lib/l10n/eu.php
index 5d47ecbda23..1941551b176 100644
--- a/lib/l10n/eu.php
+++ b/lib/l10n/eu.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Fitxategiak banan-banan deskargatu behar dira.",
"Back to Files" => "Itzuli fitxategietara",
"Selected files too large to generate zip file." => "Hautatuko fitxategiak oso handiak dira zip fitxategia sortzeko.",
+"couldn't be determined" => "ezin izan da zehaztu",
"Application is not enabled" => "Aplikazioa ez dago gaituta",
"Authentication error" => "Autentikazio errorea",
"Token expired. Please reload page." => "Tokena iraungitu da. Mesedez birkargatu orria.",
diff --git a/lib/l10n/fa.php b/lib/l10n/fa.php
index ce7c7c6e970..8cbdcb03b3b 100644
--- a/lib/l10n/fa.php
+++ b/lib/l10n/fa.php
@@ -10,6 +10,7 @@
"seconds ago" => "ثانیه‌ها پیش",
"1 minute ago" => "1 دقیقه پیش",
"%d minutes ago" => "%d دقیقه پیش",
+"1 hour ago" => "1 ساعت پیش",
"today" => "امروز",
"yesterday" => "دیروز",
"last month" => "ماه قبل",
diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php
index 6a5734e978d..b8d4b137431 100644
--- a/lib/l10n/fi_FI.php
+++ b/lib/l10n/fi_FI.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Tiedostot on ladattava yksittäin.",
"Back to Files" => "Takaisin tiedostoihin",
"Selected files too large to generate zip file." => "Valitut tiedostot ovat liian suurikokoisia mahtuakseen zip-tiedostoon.",
+"couldn't be determined" => "ei voitu määrittää",
"Application is not enabled" => "Sovellusta ei ole otettu käyttöön",
"Authentication error" => "Todennusvirhe",
"Token expired. Please reload page." => "Valtuutus vanheni. Lataa sivu uudelleen.",
diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php
index 218c22c1d53..c6bf8f7f9c3 100644
--- a/lib/l10n/fr.php
+++ b/lib/l10n/fr.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Les fichiers nécessitent d'être téléchargés un par un.",
"Back to Files" => "Retour aux Fichiers",
"Selected files too large to generate zip file." => "Les fichiers sélectionnés sont trop volumineux pour être compressés.",
+"couldn't be determined" => "impossible à déterminer",
"Application is not enabled" => "L'application n'est pas activée",
"Authentication error" => "Erreur d'authentification",
"Token expired. Please reload page." => "La session a expiré. Veuillez recharger la page.",
diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php
index 1e897959e41..532b3443b44 100644
--- a/lib/l10n/gl.php
+++ b/lib/l10n/gl.php
@@ -9,6 +9,7 @@
"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",
"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.",
diff --git a/lib/l10n/hu_HU.php b/lib/l10n/hu_HU.php
index 3dcf0646d06..e25de3e1ed6 100644
--- a/lib/l10n/hu_HU.php
+++ b/lib/l10n/hu_HU.php
@@ -5,10 +5,11 @@
"Users" => "Felhasználók",
"Apps" => "Alkalmazások",
"Admin" => "Admin",
-"ZIP download is turned off." => "A ZIP-letöltés nem engedélyezett.",
+"ZIP download is turned off." => "A ZIP-letöltés nincs engedélyezve.",
"Files need to be downloaded one by one." => "A fájlokat egyenként kell letölteni",
"Back to Files" => "Vissza a Fájlokhoz",
-"Selected files too large to generate zip file." => "A kiválasztott fájlok túl nagy a zip tömörítéshez.",
+"Selected files too large to generate zip file." => "A kiválasztott fájlok túl nagyok a zip tömörítéshez.",
+"couldn't be determined" => "nem határozható meg",
"Application is not enabled" => "Az alkalmazás nincs engedélyezve",
"Authentication error" => "Hitelesítési hiba",
"Token expired. Please reload page." => "A token lejárt. Frissítse az oldalt.",
diff --git a/lib/l10n/it.php b/lib/l10n/it.php
index c0fb0babfb3..eb404db7fb5 100644
--- a/lib/l10n/it.php
+++ b/lib/l10n/it.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "I file devono essere scaricati uno alla volta.",
"Back to Files" => "Torna ai file",
"Selected files too large to generate zip file." => "I file selezionati sono troppo grandi per generare un file zip.",
+"couldn't be determined" => "non può essere determinato",
"Application is not enabled" => "L'applicazione non è abilitata",
"Authentication error" => "Errore di autenticazione",
"Token expired. Please reload page." => "Token scaduto. Ricarica la pagina.",
diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php
index 854734c9764..11cefe900c2 100644
--- a/lib/l10n/ja_JP.php
+++ b/lib/l10n/ja_JP.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "ファイルは1つずつダウンロードする必要があります。",
"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/lb.php b/lib/l10n/lb.php
index baee630e897..06e8b2ca094 100644
--- a/lib/l10n/lb.php
+++ b/lib/l10n/lb.php
@@ -1,6 +1,12 @@
<?php $TRANSLATIONS = array(
+"Help" => "Hëllef",
"Personal" => "Perséinlech",
"Settings" => "Astellungen",
"Authentication error" => "Authentifikatioun's Fehler",
-"Text" => "SMS"
+"Files" => "Dateien",
+"Text" => "SMS",
+"1 hour ago" => "vrun 1 Stonn",
+"last month" => "Läschte Mount",
+"last year" => "Läscht Joer",
+"years ago" => "Joren hier"
);
diff --git a/lib/l10n/ms_MY.php b/lib/l10n/ms_MY.php
index 86c7e51b486..5afee1cb5a8 100644
--- a/lib/l10n/ms_MY.php
+++ b/lib/l10n/ms_MY.php
@@ -1,4 +1,5 @@
<?php $TRANSLATIONS = array(
+"Help" => "Bantuan",
"Personal" => "Peribadi",
"Settings" => "Tetapan",
"Users" => "Pengguna",
diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php
index 087cf23a627..7ce134e3621 100644
--- a/lib/l10n/nl.php
+++ b/lib/l10n/nl.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Bestanden moeten één voor één worden gedownload.",
"Back to Files" => "Terug naar bestanden",
"Selected files too large to generate zip file." => "De geselecteerde bestanden zijn te groot om een zip bestand te maken.",
+"couldn't be determined" => "kon niet worden vastgesteld",
"Application is not enabled" => "De applicatie is niet actief",
"Authentication error" => "Authenticatie fout",
"Token expired. Please reload page." => "Token verlopen. Herlaad de pagina.",
diff --git a/lib/l10n/pl.php b/lib/l10n/pl.php
index 6f84a328ed9..6ec35445bc2 100644
--- a/lib/l10n/pl.php
+++ b/lib/l10n/pl.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Pliki muszą zostać pobrane pojedynczo.",
"Back to Files" => "Wróć do plików",
"Selected files too large to generate zip file." => "Wybrane pliki są zbyt duże, aby wygenerować plik zip.",
+"couldn't be determined" => "nie może zostać znaleziony",
"Application is not enabled" => "Aplikacja nie jest włączona",
"Authentication error" => "Błąd uwierzytelniania",
"Token expired. Please reload page." => "Token wygasł. Proszę ponownie załadować stronę.",
diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php
index 84867c4c37c..e35bb489c49 100644
--- a/lib/l10n/pt_PT.php
+++ b/lib/l10n/pt_PT.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Os ficheiros precisam de ser descarregados um por um.",
"Back to Files" => "Voltar a Ficheiros",
"Selected files too large to generate zip file." => "Os ficheiros seleccionados são grandes demais para gerar um ficheiro zip.",
+"couldn't be determined" => "Não foi possível determinar",
"Application is not enabled" => "A aplicação não está activada",
"Authentication error" => "Erro na autenticação",
"Token expired. Please reload page." => "O token expirou. Por favor recarregue a página.",
diff --git a/lib/l10n/ro.php b/lib/l10n/ro.php
index d3ce066c8c1..3f8e59cdac2 100644
--- a/lib/l10n/ro.php
+++ b/lib/l10n/ro.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Fișierele trebuie descărcate unul câte unul.",
"Back to Files" => "Înapoi la fișiere",
"Selected files too large to generate zip file." => "Fișierele selectate sunt prea mari pentru a genera un fișier zip.",
+"couldn't be determined" => "nu poate fi determinat",
"Application is not enabled" => "Aplicația nu este activată",
"Authentication error" => "Eroare la autentificare",
"Token expired. Please reload page." => "Token expirat. Te rugăm să reîncarci pagina.",
diff --git a/lib/l10n/ru_RU.php b/lib/l10n/ru_RU.php
index ba7d39f9eb0..03da09236ea 100644
--- a/lib/l10n/ru_RU.php
+++ b/lib/l10n/ru_RU.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/sk_SK.php b/lib/l10n/sk_SK.php
index 98a5b5ca677..81f23ffdc50 100644
--- a/lib/l10n/sk_SK.php
+++ b/lib/l10n/sk_SK.php
@@ -9,6 +9,7 @@
"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.",
+"couldn't be determined" => "nedá sa zistiť",
"Application is not enabled" => "Aplikácia nie je zapnutá",
"Authentication error" => "Chyba autentifikácie",
"Token expired. Please reload page." => "Token vypršal. Obnovte, prosím, stránku.",
diff --git a/lib/l10n/sr.php b/lib/l10n/sr.php
index 2ae7400ba79..34ae89a6219 100644
--- a/lib/l10n/sr.php
+++ b/lib/l10n/sr.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/sv.php b/lib/l10n/sv.php
index 5799e2dd1a8..36f00636b2b 100644
--- a/lib/l10n/sv.php
+++ b/lib/l10n/sv.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Filer laddas ner en åt gången.",
"Back to Files" => "Tillbaka till Filer",
"Selected files too large to generate zip file." => "Valda filer är för stora för att skapa zip-fil.",
+"couldn't be determined" => "kunde inte bestämmas",
"Application is not enabled" => "Applikationen är inte aktiverad",
"Authentication error" => "Fel vid autentisering",
"Token expired. Please reload page." => "Ogiltig token. Ladda om sidan.",
diff --git a/lib/l10n/th_TH.php b/lib/l10n/th_TH.php
index 75fa02f84b0..0da607a0589 100644
--- a/lib/l10n/th_TH.php
+++ b/lib/l10n/th_TH.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/tr.php b/lib/l10n/tr.php
index 9b7f1815fa3..e55caa15972 100644
--- a/lib/l10n/tr.php
+++ b/lib/l10n/tr.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Dosyaların birer birer indirilmesi gerekmektedir.",
"Back to Files" => "Dosyalara dön",
"Selected files too large to generate zip file." => "Seçilen dosyalar bir zip dosyası oluşturmak için fazla büyüktür.",
+"couldn't be determined" => "tespit edilemedi",
"Application is not enabled" => "Uygulama etkinleştirilmedi",
"Authentication error" => "Kimlik doğrulama hatası",
"Token expired. Please reload page." => "Jetonun süresi geçti. Lütfen sayfayı yenileyin.",
diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php
index f5d52f8682d..053644ddede 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.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/zh_TW.php b/lib/l10n/zh_TW.php
index 4dbf89c2e0e..62ab8fedd52 100644
--- a/lib/l10n/zh_TW.php
+++ b/lib/l10n/zh_TW.php
@@ -9,26 +9,27 @@
"Files need to be downloaded one by one." => "檔案需要逐一下載",
"Back to Files" => "回到檔案列表",
"Selected files too large to generate zip file." => "選擇的檔案太大以致於無法產生壓縮檔",
+"couldn't be determined" => "無法判斷",
"Application is not enabled" => "應用程式未啟用",
"Authentication error" => "認證錯誤",
-"Token expired. Please reload page." => "Token 過期. 請重新整理頁面",
+"Token expired. Please reload page." => "Token 過期,請重新整理頁面。",
"Files" => "檔案",
"Text" => "文字",
"Images" => "圖片",
"seconds ago" => "幾秒前",
"1 minute ago" => "1 分鐘前",
"%d minutes ago" => "%d 分鐘前",
-"1 hour ago" => "1小時之前",
-"%d hours ago" => "%d小時之前",
+"1 hour ago" => "1 小時之前",
+"%d hours ago" => "%d 小時之前",
"today" => "今天",
"yesterday" => "昨天",
"%d days ago" => "%d 天前",
"last month" => "上個月",
-"%d months ago" => "%d個月之前",
+"%d months ago" => "%d 個月之前",
"last year" => "去年",
"years ago" => "幾年前",
-"%s is available. Get <a href=\"%s\">more information</a>" => "%s 已經可用. 取得 <a href=\"%s\">更多資訊</a>",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s 已經可用。取得 <a href=\"%s\">更多資訊</a>",
"up to date" => "最新的",
"updates check is disabled" => "檢查更新已停用",
-"Could not find category \"%s\"" => "找不到分類-\"%s\""
+"Could not find category \"%s\"" => "找不到分類:\"%s\""
);
diff --git a/lib/log.php b/lib/log.php
index e9cededa5c0..e869282e88c 100644
--- a/lib/log.php
+++ b/lib/log.php
@@ -39,7 +39,7 @@ class OC_Log {
$log_class::write($app, $message, $level);
}
}
-
+
//Fatal errors handler
public static function onShutdown() {
$error = error_get_last();
@@ -50,7 +50,7 @@ class OC_Log {
return true;
}
}
-
+
// Uncaught exception handler
public static function onException($exception) {
self::write('PHP', $exception->getMessage() . ' at ' . $exception->getFile() . '#' . $exception->getLine(), self::FATAL);
diff --git a/lib/mail.php b/lib/mail.php
index 4683a1b4eee..1bb202ac977 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -38,8 +38,12 @@ class OC_Mail {
$SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' );
$SMTPPORT = OC_Config::getValue( 'mail_smtpport', 25 );
$SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', false );
+ $SMTPAUTHTYPE = OC_Config::getValue( 'mail_smtpauthtype', 'LOGIN' );
$SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' );
$SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' );
+ $SMTPDEBUG = OC_Config::getValue( 'mail_smtpdebug', false );
+ $SMTPTIMEOUT = OC_Config::getValue( 'mail_smtptimeout', 10 );
+ $SMTPSECURE = OC_Config::getValue( 'mail_smtpsecure', '' );
$mailo = new PHPMailer(true);
@@ -57,12 +61,16 @@ class OC_Mail {
$mailo->Host = $SMTPHOST;
$mailo->Port = $SMTPPORT;
$mailo->SMTPAuth = $SMTPAUTH;
+ $mailo->SMTPDebug = $SMTPDEBUG;
+ $mailo->SMTPSecure = $SMTPSECURE;
+ $mailo->AuthType = $SMTPAUTHTYPE;
$mailo->Username = $SMTPUSERNAME;
$mailo->Password = $SMTPPASSWORD;
+ $mailo->Timeout = $SMTPTIMEOUT;
- $mailo->From =$fromaddress;
+ $mailo->From = $fromaddress;
$mailo->FromName = $fromname;;
- $mailo->Sender =$fromaddress;
+ $mailo->Sender = $fromaddress;
$a=explode(' ', $toaddress);
try {
foreach($a as $ad) {
diff --git a/lib/migrate.php b/lib/migrate.php
index 5ff8e338a44..87bdd016fe4 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -219,7 +219,7 @@ class OC_Migrate{
// We need to be an admin if we are not importing our own data
if(($type == 'user' && self::$uid != $currentuser) || $type != 'user' ) {
- if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) {
+ if( !OC_User::isAdminUser($currentuser)) {
// Naughty.
OC_Log::write( 'migration', 'Import not permitted.', OC_Log::ERROR );
return json_encode( array( 'success' => false ) );
@@ -655,7 +655,7 @@ class OC_Migrate{
$query = OC_DB::prepare( "INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )" );
$result = $query->execute( array( $uid, $hash));
if( !$result ) {
- OC_Log::write('migration', 'Failed to create the new user "'.$uid."");
+ OC_Log::write('migration', 'Failed to create the new user "'.$uid."", OC_Log::ERROR);
}
return $result ? true : false;
diff --git a/lib/migration/content.php b/lib/migration/content.php
index 00df62f0c7f..e81c8f217ff 100644
--- a/lib/migration/content.php
+++ b/lib/migration/content.php
@@ -66,7 +66,7 @@ class OC_Migration_Content{
// Die if we have an error (error means: bad query, not 0 results!)
if( PEAR::isError( $query ) ) {
- $entry = 'DB Error: "'.$result->getMessage().'"<br />';
+ $entry = 'DB Error: "'.$query->getMessage().'"<br />';
$entry .= 'Offending command was: '.$query.'<br />';
OC_Log::write( 'migration', $entry, OC_Log::FATAL );
return false;
diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php
index 77b97917583..fc87d011ecd 100644
--- a/lib/mimetypes.list.php
+++ b/lib/mimetypes.list.php
@@ -95,4 +95,6 @@ return array(
'cdr' => 'application/coreldraw',
'impress' => 'text/impress',
'ai' => 'application/illustrator',
+ 'epub' => 'application/epub+zip',
+ 'mobi' => 'application/x-mobipocket-ebook',
);
diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php
index 21095ec91e9..2d18b1db3f2 100644
--- a/lib/ocs/cloud.php
+++ b/lib/ocs/cloud.php
@@ -24,7 +24,7 @@
class OC_OCS_Cloud {
- public static function getSystemWebApps($parameters) {
+ public static function getSystemWebApps() {
OC_Util::checkLoggedIn();
$apps = OC_App::getEnabledApps();
$values = array();
@@ -37,15 +37,15 @@ class OC_OCS_Cloud {
}
return new OC_OCS_Result($values);
}
-
+
public static function getUserQuota($parameters) {
$user = OC_User::getUser();
- if(OC_Group::inGroup($user, 'admin') or ($user==$parameters['user'])) {
+ if(OC_User::isAdminUser($user) or ($user==$parameters['user'])) {
if(OC_User::userExists($parameters['user'])) {
// calculate the disc space
$userDir = '/'.$parameters['user'].'/files';
- OC_Filesystem::init($useDir);
+ OC_Filesystem::init($userDir);
$rootInfo = OC_FileCache::get('');
$sharedInfo = OC_FileCache::get('/Shared');
$used = $rootInfo['size'] - $sharedInfo['size'];
@@ -68,7 +68,7 @@ class OC_OCS_Cloud {
return new OC_OCS_Result(null, 300);
}
}
-
+
public static function getUserPublickey($parameters) {
if(OC_User::userExists($parameters['user'])) {
@@ -79,10 +79,10 @@ class OC_OCS_Cloud {
return new OC_OCS_Result(null, 300);
}
}
-
+
public static function getUserPrivatekey($parameters) {
$user = OC_User::getUser();
- if(OC_Group::inGroup($user, 'admin') or ($user==$parameters['user'])) {
+ if(OC_User::isAdminUser($user) or ($user==$parameters['user'])) {
if(OC_User::userExists($user)) {
// calculate the disc space
diff --git a/lib/ocs/config.php b/lib/ocs/config.php
index 03c54aa2314..f19121f4b2b 100644
--- a/lib/ocs/config.php
+++ b/lib/ocs/config.php
@@ -23,7 +23,7 @@
*/
class OC_OCS_Config {
-
+
public static function apiConfig($parameters) {
$xml['version'] = '1.7';
$xml['website'] = 'ownCloud';
@@ -32,5 +32,5 @@ class OC_OCS_Config {
$xml['ssl'] = 'false';
return new OC_OCS_Result($xml);
}
-
+
}
diff --git a/lib/ocs/person.php b/lib/ocs/person.php
index 169cc8211db..1c8210d0825 100644
--- a/lib/ocs/person.php
+++ b/lib/ocs/person.php
@@ -38,5 +38,5 @@ class OC_OCS_Person {
return new OC_OCS_Result(null, 101);
}
}
-
+
}
diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php
index e01ed5e8b07..311b24269dd 100644
--- a/lib/ocs/privatedata.php
+++ b/lib/ocs/privatedata.php
@@ -39,7 +39,7 @@ class OC_OCS_Privatedata {
return new OC_OCS_Result($xml);
//TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it
}
-
+
public static function set($parameters) {
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
@@ -50,7 +50,7 @@ class OC_OCS_Privatedata {
return new OC_OCS_Result(null, 100);
}
}
-
+
public static function delete($parameters) {
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
diff --git a/lib/ocs/result.php b/lib/ocs/result.php
index b08d911f785..65b2067fc3f 100644
--- a/lib/ocs/result.php
+++ b/lib/ocs/result.php
@@ -21,9 +21,9 @@
*/
class OC_OCS_Result{
-
+
private $data, $message, $statusCode, $items, $perPage;
-
+
/**
* create the OCS_Result object
* @param $data mixed the data to return
@@ -33,7 +33,7 @@ class OC_OCS_Result{
$this->statusCode = $code;
$this->message = $message;
}
-
+
/**
* optionally set the total number of items available
* @param $items int
@@ -41,7 +41,7 @@ class OC_OCS_Result{
public function setTotalItems(int $items) {
$this->items = $items;
}
-
+
/**
* optionally set the the number of items per page
* @param $items int
@@ -49,7 +49,7 @@ class OC_OCS_Result{
public function setItemsPerPage(int $items) {
$this->perPage = $items;
}
-
+
/**
* returns the data associated with the api result
* @return array
@@ -70,6 +70,6 @@ class OC_OCS_Result{
// Return the result data.
return $return;
}
-
-
+
+
} \ No newline at end of file
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 09ccb2be159..30163c1e403 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -39,11 +39,11 @@ class OC_OCSClient{
return($url);
}
- /**
- * @brief Get the url of the OCS KB server.
- * @returns string of the KB server
- * This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default
- */
+ /**
+ * @brief Get the url of the OCS KB server.
+ * @returns string of the KB server
+ * This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default
+ */
private static function getKBURL() {
$url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1');
return($url);
@@ -59,7 +59,7 @@ class OC_OCSClient{
return($data);
}
- /**
+ /**
* @brief Get all the categories from the OCS server
* @returns array with category ids
* @note returns NULL if config value appstoreenabled is set to false
@@ -246,7 +246,7 @@ class OC_OCSClient{
}
$kbe['totalitems'] = $data->meta->totalitems;
}
- return $kbe;
+ return $kbe;
}
diff --git a/lib/public/api.php b/lib/public/api.php
index a85daa1935c..95d333f2165 100644
--- a/lib/public/api.php
+++ b/lib/public/api.php
@@ -26,7 +26,7 @@ namespace OCP;
* This class provides functions to manage apps in ownCloud
*/
class API {
-
+
/**
* registers an api call
* @param string $method the http method
@@ -40,5 +40,5 @@ class API {
public static function register($method, $url, $action, $app, $authLevel = OC_API::USER_AUTH, $defaults = array(), $requirements = array()){
\OC_API::register($method, $url, $action, $app, $authLevel, $defaults, $requirements);
}
-
+
}
diff --git a/lib/public/app.php b/lib/public/app.php
index 809a656f17f..a1ecf524cc8 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -89,7 +89,7 @@ class App {
* @param $page string page to be included
*/
public static function registerPersonal( $app, $page ) {
- return \OC_App::registerPersonal( $app, $page );
+ \OC_App::registerPersonal( $app, $page );
}
/**
@@ -98,7 +98,7 @@ class App {
* @param $page string page to be included
*/
public static function registerAdmin( $app, $page ) {
- return \OC_App::registerAdmin( $app, $page );
+ \OC_App::registerAdmin( $app, $page );
}
/**
@@ -125,10 +125,9 @@ class App {
/**
* @brief Check if the app is enabled, redirects to home if not
* @param $app app
- * @returns true/false
*/
public static function checkAppEnabled( $app ) {
- return \OC_Util::checkAppEnabled( $app );
+ \OC_Util::checkAppEnabled( $app );
}
/**
diff --git a/lib/public/constants.php b/lib/public/constants.php
index bc979c9031f..1495c620dc9 100644
--- a/lib/public/constants.php
+++ b/lib/public/constants.php
@@ -35,4 +35,3 @@ const PERMISSION_UPDATE = 2;
const PERMISSION_DELETE = 8;
const PERMISSION_SHARE = 16;
const PERMISSION_ALL = 31;
-
diff --git a/lib/public/db.php b/lib/public/db.php
index 5d4aadd22ae..932e79d9ef1 100644
--- a/lib/public/db.php
+++ b/lib/public/db.php
@@ -49,9 +49,9 @@ class DB {
* @brief Insert a row if a matching row doesn't exists.
* @param $table string The table name (will replace *PREFIX*) to perform the replace on.
* @param $input array
- *
+ *
* The input array if in the form:
- *
+ *
* array ( 'id' => array ( 'value' => 6,
* 'key' => true
* ),
@@ -65,7 +65,7 @@ class DB {
public static function insertIfNotExist($table, $input) {
return(\OC_DB::insertIfNotExist($table, $input));
}
-
+
/**
* @brief gets last value of autoincrement
* @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
diff --git a/lib/public/files.php b/lib/public/files.php
index 90889c59ad8..75e1d2fbbc1 100644
--- a/lib/public/files.php
+++ b/lib/public/files.php
@@ -38,9 +38,10 @@ class Files {
* @brief Recusive deletion of folders
* @param string $dir path to the folder
*
+ * @return bool
*/
static function rmdirr( $dir ) {
- \OC_Helper::rmdirr( $dir );
+ return \OC_Helper::rmdirr( $dir );
}
/**
diff --git a/lib/public/response.php b/lib/public/response.php
index bfb84eda5d1..de0c3f25347 100644
--- a/lib/public/response.php
+++ b/lib/public/response.php
@@ -42,7 +42,7 @@ class Response {
* null cache indefinitly
*/
static public function enableCaching( $cache_time = null ) {
- return(\OC_Response::enableCaching( $cache_time ));
+ \OC_Response::enableCaching( $cache_time );
}
/**
@@ -51,7 +51,7 @@ class Response {
* @param string $lastModified time when the reponse was last modified
*/
static public function setLastModifiedHeader( $lastModified ) {
- return(\OC_Response::setLastModifiedHeader( $lastModified ));
+ \OC_Response::setLastModifiedHeader( $lastModified );
}
/**
@@ -59,7 +59,7 @@ class Response {
* @see enableCaching with cache_time = 0
*/
static public function disableCaching() {
- return(\OC_Response::disableCaching());
+ \OC_Response::disableCaching();
}
/**
@@ -68,7 +68,7 @@ class Response {
* @param string $etag token to use for modification check
*/
static public function setETagHeader( $etag ) {
- return(\OC_Response::setETagHeader( $etag ));
+ \OC_Response::setETagHeader( $etag );
}
/**
@@ -76,7 +76,7 @@ class Response {
* @param string $filepath of file to send
*/
static public function sendFile( $filepath ) {
- return(\OC_Response::sendFile( $filepath ));
+ \OC_Response::sendFile( $filepath );
}
/**
@@ -86,7 +86,7 @@ class Response {
* DateTime object when to expire response
*/
static public function setExpiresHeader( $expires ) {
- return(\OC_Response::setExpiresHeader( $expires ));
+ \OC_Response::setExpiresHeader( $expires );
}
/**
@@ -94,6 +94,6 @@ class Response {
* @param string $location to redirect to
*/
static public function redirect( $location ) {
- return(\OC_Response::redirect( $location ));
+ \OC_Response::redirect( $location );
}
}
diff --git a/lib/public/share.php b/lib/public/share.php
index 8c0cfc16b4e..e1d77e652d5 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -351,14 +351,14 @@ class Share {
//delete the old share
self::delete($checkExists['id']);
}
-
+
// Generate hash of password - same method as user passwords
if (isset($shareWith)) {
$forcePortable = (CRYPT_BLOWFISH != 1);
$hasher = new \PasswordHash(8, $forcePortable);
$shareWith = $hasher->HashPassword($shareWith.\OC_Config::getValue('passwordsalt', ''));
}
-
+
// Generate token
if (isset($oldToken)) {
$token = $oldToken;
@@ -415,7 +415,7 @@ class Share {
if ($parentFolder && $files = \OC_Files::getDirectoryContent($itemSource)) {
for ($i = 0; $i < count($files); $i++) {
$name = substr($files[$i]['name'], strpos($files[$i]['name'], $itemSource) - strlen($itemSource));
- if ($files[$i]['mimetype'] == 'httpd/unix-directory'
+ if ($files[$i]['mimetype'] == 'httpd/unix-directory'
&& $children = \OC_Files::getDirectoryContent($name, '/')
) {
// Continue scanning into child folders
@@ -748,7 +748,7 @@ class Share {
$itemTypes = $collectionTypes;
}
$placeholders = join(',', array_fill(0, count($itemTypes), '?'));
- $where .= ' WHERE `item_type` IN ('.$placeholders.'))';
+ $where = ' WHERE `item_type` IN ('.$placeholders.'))';
$queryArgs = $itemTypes;
} else {
$where = ' WHERE `item_type` = ?';
@@ -864,7 +864,7 @@ class Share {
}
} else {
if ($fileDependent) {
- if (($itemType == 'file' || $itemType == 'folder')
+ if (($itemType == 'file' || $itemType == 'folder')
&& $format == \OC_Share_Backend_File::FORMAT_FILE_APP
|| $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT
) {
@@ -946,6 +946,15 @@ class Share {
continue;
}
}
+
+ // Add display names to result
+ if ( isset($row['share_with']) && $row['share_with'] != '') {
+ $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']);
+ }
+ if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
+ $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
+ }
+
$items[$row['id']] = $row;
}
if (!empty($items)) {
diff --git a/lib/public/user.php b/lib/public/user.php
index 9e50115ab70..de52055a4c5 100644
--- a/lib/public/user.php
+++ b/lib/public/user.php
@@ -51,7 +51,25 @@ class User {
public static function getUsers($search = '', $limit = null, $offset = null) {
return \OC_USER::getUsers();
}
-
+
+ /**
+ * @brief get the user display name of the user currently logged in.
+ * @return string display name
+ */
+ public static function getDisplayName($user=null) {
+ return \OC_USER::getDisplayName($user);
+ }
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all display names (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public static function getDisplayNames($search = '', $limit = null, $offset = null) {
+ return \OC_USER::getDisplayNames($search, $limit, $offset);
+ }
+
/**
* @brief Check if the user is logged in
* @returns true/false
@@ -65,7 +83,7 @@ class User {
/**
* @brief check if a user exists
* @param string $uid the username
- * @param string $excludingBackend (default none)
+ * @param string $excludingBackend (default none)
* @return boolean
*/
public static function userExists( $uid, $excludingBackend = null ) {
@@ -73,12 +91,10 @@ class User {
}
/**
* @brief Loggs the user out including all the session data
- * @returns true
- *
* Logout, destroys session
*/
public static function logout() {
- return \OC_USER::logout();
+ \OC_USER::logout();
}
/**
diff --git a/lib/public/util.php b/lib/public/util.php
index df09ea81ae1..413dbcccd28 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -203,7 +203,7 @@ class Util {
$host_name = self::getServerHostName();
// handle localhost installations
if ($host_name === 'localhost') {
- $host_name = "example.com";
+ $host_name = "example.com";
}
return $user_part.'@'.$host_name;
}
@@ -298,7 +298,7 @@ class Util {
* Todo: Write howto
*/
public static function callCheck() {
- return(\OC_Util::callCheck());
+ \OC_Util::callCheck();
}
/**
@@ -367,4 +367,14 @@ class Util {
public static function recursiveArraySearch($haystack, $needle, $index = null) {
return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
}
+
+ /**
+ * @brief calculates the maximum upload size respecting system settings, free space and user quota
+ *
+ * @param $dir the current folder where the user currently operates
+ * @return number of bytes representing
+ */
+ public static function maxUploadFilesize($dir) {
+ return \OC_Helper::maxUploadFilesize($dir);
+ }
}
diff --git a/lib/request.php b/lib/request.php
index 99a77e1b59e..f2f15c21103 100755
--- a/lib/request.php
+++ b/lib/request.php
@@ -19,7 +19,7 @@ class OC_Request {
return 'localhost';
}
if(OC_Config::getValue('overwritehost', '')<>'') {
- return OC_Config::getValue('overwritehost');
+ return OC_Config::getValue('overwritehost');
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) {
@@ -44,7 +44,7 @@ class OC_Request {
*/
public static function serverProtocol() {
if(OC_Config::getValue('overwriteprotocol', '')<>'') {
- return OC_Config::getValue('overwriteprotocol');
+ return OC_Config::getValue('overwriteprotocol');
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$proto = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']);
diff --git a/lib/router.php b/lib/router.php
index 27e14c38abf..746b68c2c0c 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -49,6 +49,7 @@ class OC_Router {
$files = $this->getRoutingFiles();
$files[] = 'settings/routes.php';
$files[] = 'core/routes.php';
+ $files[] = 'ocs/routes.php';
$this->cache_key = OC_Cache::generateCacheKeyFromFiles($files);
}
return $this->cache_key;
@@ -58,23 +59,6 @@ class OC_Router {
* loads the api routes
*/
public function loadRoutes() {
-
- // TODO cache
- $this->root = $this->getCollection('root');
- foreach(OC_APP::getEnabledApps() as $app){
- $file = OC_App::getAppPath($app).'/appinfo/routes.php';
- if(file_exists($file)){
- $this->useCollection($app);
- require_once($file);
- $collection = $this->getCollection($app);
- $this->root->addCollection($collection, '/apps/'.$app);
- }
- }
- // include ocs routes
- require_once(OC::$SERVERROOT.'/ocs/routes.php');
- $collection = $this->getCollection('ocs');
- $this->root->addCollection($collection, '/ocs');
-
foreach($this->getRoutingFiles() as $app => $file) {
$this->useCollection($app);
require_once $file;
@@ -85,6 +69,10 @@ class OC_Router {
require_once 'settings/routes.php';
require_once 'core/routes.php';
+ // include ocs routes
+ require_once 'ocs/routes.php';
+ $collection = $this->getCollection('ocs');
+ $this->root->addCollection($collection, '/ocs');
}
protected function getCollection($name) {
diff --git a/lib/setup.php b/lib/setup.php
index fdd10be6824..4dd190b99fb 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -1,5 +1,23 @@
<?php
+class DatabaseSetupException extends Exception
+{
+ private $hint;
+
+ public function __construct($message, $hint, $code = 0, Exception $previous = null) {
+ $this->hint = $hint;
+ parent::__construct($message, $code, $previous);
+ }
+
+ public function __toString() {
+ return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
+ }
+
+ public function getHint() {
+ return $this->hint;
+ }
+}
+
class OC_Setup {
public static function install($options) {
$error = array();
@@ -19,9 +37,9 @@ class OC_Setup {
if($dbtype=='mysql')
$dbprettyname = 'MySQL';
else if($dbtype=='pgsql')
- $dbprettyname = 'PostgreSQL';
+ $dbprettyname = 'PostgreSQL';
else
- $dbprettyname = 'Oracle';
+ $dbprettyname = 'Oracle';
if(empty($options['dbuser'])) {
@@ -69,10 +87,16 @@ class OC_Setup {
try {
self::setupMySQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username);
+ } catch (DatabaseSetupException $e) {
+ $error[] = array(
+ 'error' => $e->getMessage(),
+ 'hint' => $e->getHint()
+ );
+ return($error);
} catch (Exception $e) {
$error[] = array(
- 'error' => 'MySQL username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
+ 'error' => $e->getMessage(),
+ 'hint' => ''
);
return($error);
}
@@ -141,7 +165,9 @@ class OC_Setup {
if(count($error) == 0) {
OC_Appconfig::setValue('core', 'installedat', microtime(true));
OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
-
+ OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
+ OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
+
OC_Group::createGroup('admin');
OC_Group::addToGroup($username, 'admin');
OC_User::login($username, $password);
@@ -153,7 +179,7 @@ class OC_Setup {
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
self::createHtaccess();
}
-
+
//and we are done
OC_Config::setValue('installed', true);
}
@@ -166,7 +192,7 @@ class OC_Setup {
//check if the database user has admin right
$connection = @mysql_connect($dbhost, $dbuser, $dbpass);
if(!$connection) {
- throw new Exception('MySQL username and/or password not valid');
+ throw new DatabaseSetupException('MySQL username and/or password not valid','You need to enter either an existing account or the administrator.');
}
$oldUser=OC_Config::getValue('dbuser', false);
@@ -229,8 +255,14 @@ class OC_Setup {
// the anonymous user would take precedence when there is one.
$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.");
+ }
$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.");
+ }
}
private static function setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username) {
diff --git a/lib/subadmin.php b/lib/subadmin.php
index 9e83e6da430..8cda7240ac9 100644
--- a/lib/subadmin.php
+++ b/lib/subadmin.php
@@ -122,6 +122,11 @@ class OC_SubAdmin{
* @return bool
*/
public static function isSubAdmin($uid) {
+ // Check if the user is already an admin
+ if(OC_Group::inGroup($uid, 'admin' )) {
+ return true;
+ }
+
$stmt = OC_DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*group_admin` WHERE `uid` = ?');
$result = $stmt->execute(array($uid));
$result = $result->fetchRow();
@@ -141,7 +146,7 @@ class OC_SubAdmin{
if(!self::isSubAdmin($subadmin)) {
return false;
}
- if(OC_Group::inGroup($user, 'admin')) {
+ if(OC_User::isAdminUser($user)) {
return false;
}
$accessiblegroups = self::getSubAdminsGroups($subadmin);
diff --git a/lib/template.php b/lib/template.php
index 04667d73a2c..238d8a8ad0f 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -85,15 +85,25 @@ function human_file_size( $bytes ) {
}
function simple_file_size($bytes) {
- $mbytes = round($bytes/(1024*1024), 1);
- if($bytes == 0) { return '0'; }
- else if($mbytes < 0.1) { return '&lt; 0.1'; }
- else if($mbytes > 1000) { return '&gt; 1000'; }
- else { return number_format($mbytes, 1); }
+ if ($bytes < 0) {
+ return '?';
+ }
+ $mbytes = round($bytes / (1024 * 1024), 1);
+ if ($bytes == 0) {
+ return '0';
+ }
+ if ($mbytes < 0.1) {
+ return '&lt; 0.1';
+ }
+ if ($mbytes > 1000) {
+ return '&gt; 1000';
+ } else {
+ return number_format($mbytes, 1);
+ }
}
function relative_modified_date($timestamp) {
- $l=OC_L10N::get('lib');
+ $l=OC_L10N::get('lib');
$timediff = time() - $timestamp;
$diffminutes = round($timediff/60);
$diffhours = round($diffminutes/60);
@@ -176,9 +186,15 @@ class OC_Template{
$this->l10n = OC_L10N::get($parts[0]);
// Some headers to enhance security
- header('X-Frame-Options: Sameorigin');
- header('X-XSS-Protection: 1; mode=block');
- header('X-Content-Type-Options: nosniff');
+ header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains
+ header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
+ header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
+
+ // 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 *');
+ header('Content-Security-Policy:'.$policy); // Standard
+ header('X-WebKit-CSP:'.$policy); // Older webkit browsers
$this->findTemplate($name);
}
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 4173e008ba7..37ece91047f 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -33,18 +33,6 @@ class OC_TemplateLayout extends OC_Template {
} else {
parent::__construct('core', 'layout.base');
}
-
- $apps_paths = array();
- foreach(OC_App::getEnabledApps() as $app) {
- $apps_paths[$app] = OC_App::getAppWebPath($app);
- }
- $this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes waiting for better solution
-
- if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) {
- OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
- OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
- }
-
// Add the js files
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
$this->assign('jsfiles', array(), false);
diff --git a/lib/user.php b/lib/user.php
index 80f88ca7052..38259bceea5 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -251,6 +251,7 @@ class OC_User {
if($uid && $enabled) {
session_regenerate_id(true);
self::setUserId($uid);
+ self::setDisplayName($uid);
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>$password ));
return true;
}
@@ -260,17 +261,55 @@ class OC_User {
/**
* @brief Sets user id for session and triggers emit
- * @returns true
- *
*/
public static function setUserId($uid) {
$_SESSION['user_id'] = $uid;
- return true;
+ }
+
+ /**
+ * @brief Sets user display name for session
+ */
+ public static function setDisplayName($uid, $displayName = null) {
+ $result = false;
+ if ($displayName ) {
+ foreach(self::$_usedBackends as $backend) {
+ if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) {
+ if($backend->userExists($uid)) {
+ $success |= $backend->setDisplayName($uid, $displayName);
+ }
+ }
+ }
+ } else {
+ $displayName = self::determineDisplayName($uid);
+ $result = true;
+ }
+ if (OC_User::getUser() === $uid) {
+ $_SESSION['display_name'] = $displayName;
+ }
+ return $result;
+ }
+
+
+ /**
+ * @brief get display name
+ * @param $uid The username
+ * @returns string display name or uid if no display name is defined
+ *
+ */
+ private static function determineDisplayName( $uid ) {
+ foreach(self::$_usedBackends as $backend) {
+ if($backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) {
+ $result=$backend->getDisplayName( $uid );
+ if($result) {
+ return $result;
+ }
+ }
+ }
+ return $uid;
}
/**
* @brief Logs the current user out and kills all the session data
- * @returns true
*
* Logout, destroys session
*/
@@ -279,7 +318,6 @@ class OC_User {
session_unset();
session_destroy();
OC_User::unsetMagicInCookie();
- return true;
}
/**
@@ -300,6 +338,19 @@ class OC_User {
}
/**
+ * @brief Check if the user is an admin user
+ * @param $uid uid of the admin
+ * @returns bool
+ */
+ public static function isAdminUser($uid) {
+ if(OC_Group::inGroup($uid, 'admin' )) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
* @brief get the user id of the user currently logged in.
* @return string uid or false
*/
@@ -313,6 +364,21 @@ class OC_User {
}
/**
+ * @brief get the display name of the user currently logged in.
+ * @return string uid or false
+ */
+ public static function getDisplayName($user=null) {
+ if ( $user ) {
+ return self::determineDisplayName($user);
+ } else if( isset($_SESSION['display_name']) AND $_SESSION['display_name'] ) {
+ return $_SESSION['display_name'];
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
* @brief Autogenerate a password
* @returns string
*
@@ -375,8 +441,8 @@ class OC_User {
/**
* @brief Check if the password is correct
- * @param $uid The username
- * @param $password The password
+ * @param string $uid The username
+ * @param string $password The password
* @returns string
*
* returns the path to the users home directory
@@ -412,6 +478,24 @@ class OC_User {
}
/**
+ * @brief Get a list of all users display name
+ * @returns associative array with all display names (value) and corresponding uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public static function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array();
+ foreach (self::$_usedBackends as $backend) {
+ $backendDisplayNames = $backend->getDisplayNames($search, $limit, $offset);
+ if (is_array($backendDisplayNames)) {
+ $displayNames = array_merge($displayNames, $backendDisplayNames);
+ }
+ }
+ ksort($displayNames);
+ return $displayNames;
+ }
+
+ /**
* @brief check if a user exists
* @param string $uid the username
* @param string $excludingBackend (default none)
diff --git a/lib/user/backend.php b/lib/user/backend.php
index 2a95db93690..56fa3195978 100644
--- a/lib/user/backend.php
+++ b/lib/user/backend.php
@@ -35,6 +35,8 @@ define('OC_USER_BACKEND_CREATE_USER', 0x000001);
define('OC_USER_BACKEND_SET_PASSWORD', 0x000010);
define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100);
define('OC_USER_BACKEND_GET_HOME', 0x001000);
+define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x010000);
+define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x010000);
/**
@@ -50,6 +52,8 @@ abstract class OC_User_Backend implements OC_User_Interface {
OC_USER_BACKEND_SET_PASSWORD => 'setPassword',
OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword',
OC_USER_BACKEND_GET_HOME => 'getHome',
+ OC_USER_BACKEND_GET_DISPLAYNAME => 'getDisplayName',
+ OC_USER_BACKEND_SET_DISPLAYNAME => 'setDisplayName',
);
/**
@@ -120,4 +124,28 @@ abstract class OC_User_Backend implements OC_User_Interface {
public function getHome($uid) {
return false;
}
+
+ /**
+ * @brief get display name of the user
+ * @param $uid user ID of the user
+ * @return display name
+ */
+ public function getDisplayName($uid) {
+ return $uid;
+ }
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all displayNames (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array();
+ $users = $this->getUsers($search, $limit, $offset);
+ foreach ( $users as $user) {
+ $displayNames[$user] = $user;
+ }
+ return $displayNames;
+ }
}
diff --git a/lib/user/database.php b/lib/user/database.php
index f33e338e2e4..7deeb0c4697 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -110,7 +110,61 @@ class OC_User_Database extends OC_User_Backend {
return false;
}
}
+
+ /**
+ * @brief Set display name
+ * @param $uid The username
+ * @param $displayName The new display name
+ * @returns true/false
+ *
+ * Change the display name of a user
+ */
+ public function setDisplayName( $uid, $displayName ) {
+ if( $this->userExists($uid) ) {
+ $query = OC_DB::prepare( 'UPDATE `*PREFIX*users` SET `displayname` = ? WHERE `uid` = ?' );
+ $query->execute( array( $displayName, $uid ));
+ return true;
+ }else{
+ return false;
+ }
+ }
+ /**
+ * @brief get display name of the user
+ * @param $uid user ID of the user
+ * @return display name
+ */
+ public function getDisplayName($uid) {
+ if( $this->userExists($uid) ) {
+ $query = OC_DB::prepare( 'SELECT displayname FROM `*PREFIX*users` WHERE `uid` = ?' );
+ $result = $query->execute( array( $uid ))->fetchAll();
+ $displayName = trim($result[0]['displayname'], ' ');
+ if ( !empty($displayName) ) {
+ return $displayName;
+ } else {
+ return $uid;
+ }
+ }
+ }
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all displayNames (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array();
+ $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset);
+ $result = $query->execute(array($search.'%'));
+ $users = array();
+ while ($row = $result->fetchRow()) {
+ $displayName = trim($row['displayname'], ' ');
+ $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
+ }
+ return $displayNames;
+ }
+
/**
* @brief Check if the password is correct
* @param $uid The username
diff --git a/lib/user/interface.php b/lib/user/interface.php
index 3d9f4691f24..b4667633b50 100644
--- a/lib/user/interface.php
+++ b/lib/user/interface.php
@@ -57,4 +57,19 @@ interface OC_User_Interface {
*/
public function userExists($uid);
+ /**
+ * @brief get display name of the user
+ * @param $uid user ID of the user
+ * @return display name
+ */
+ public function getDisplayName($uid);
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all displayNames (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null);
+
} \ No newline at end of file
diff --git a/lib/util.php b/lib/util.php
index 7b1de094ead..0543df979d3 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -95,7 +95,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, 02);
+ return array(4, 91, 03);
}
/**
@@ -342,10 +342,7 @@ class OC_Util {
* Check if the user is a admin, redirects to home if not
*/
public static function checkAdminUser() {
- // Check if we are a user
- self::checkLoggedIn();
- self::verifyUser();
- if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) {
+ if( !OC_User::isAdminUser(OC_User::getUser())) {
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ));
exit();
}
@@ -356,12 +353,6 @@ class OC_Util {
* @return array $groups where the current user is subadmin
*/
public static function checkSubAdminUser() {
- // Check if we are a user
- self::checkLoggedIn();
- self::verifyUser();
- if(OC_Group::inGroup(OC_User::getUser(), 'admin')) {
- return true;
- }
if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ));
exit();
@@ -370,40 +361,6 @@ class OC_Util {
}
/**
- * Check if the user verified the login with his password in the last 15 minutes
- * If not, the user will be shown a password verification page
- */
- public static function verifyUser() {
- if(OC_Config::getValue('enhancedauth', false) === true) {
- // Check password to set session
- if(isset($_POST['password'])) {
- if (OC_User::login(OC_User::getUser(), $_POST["password"] ) === true) {
- $_SESSION['verifiedLogin']=time() + OC_Config::getValue('enhancedauthtime', 15 * 60);
- }
- }
-
- // Check if the user verified his password
- if(!isset($_SESSION['verifiedLogin']) OR $_SESSION['verifiedLogin'] < time()) {
- OC_Template::printGuestPage("", "verify", array('username' => OC_User::getUser()));
- exit();
- }
- }
- }
-
- /**
- * Check if the user verified the login with his password
- * @return bool
- */
- public static function isUserVerified() {
- if(OC_Config::getValue('enhancedauth', false) === true) {
- if(!isset($_SESSION['verifiedLogin']) OR $_SESSION['verifiedLogin'] < time()) {
- return false;
- }
- }
- return true;
- }
-
- /**
* Redirect to the user default page
*/
public static function redirectToDefaultPage() {
@@ -510,8 +467,11 @@ class OC_Util {
* @return array with sanitized strings or a single sanitized string, depends on the input parameter.
*/
public static function sanitizeHTML( &$value ) {
- if (is_array($value) || is_object($value)) array_walk_recursive($value, 'OC_Util::sanitizeHTML');
- else $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4
+ if (is_array($value) || is_object($value)) {
+ array_walk_recursive($value, 'OC_Util::sanitizeHTML');
+ } else {
+ $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4
+ }
return $value;
}
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 406a4eb1074..1700870f91f 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -763,4 +763,3 @@ class OC_VCategories {
return array_search(strtolower($needle), array_map('strtolower', $haystack));
}
}
-