summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-01-09 13:54:58 +0100
committerRobin Appelman <icewind@owncloud.com>2014-01-09 13:54:58 +0100
commit5d456c7cc21f7640435c4638932984a52b4cdbac (patch)
tree0227a865782fab4895f602a7c118d92e21998cbb /lib
parentd50c7391d8e78c9555b073fb9ccc6a91d5da34bc (diff)
parentd8b8abb429d3d66598a16d25cf55f7dc19e3f996 (diff)
downloadnextcloud-server-5d456c7cc21f7640435c4638932984a52b4cdbac.tar.gz
nextcloud-server-5d456c7cc21f7640435c4638932984a52b4cdbac.zip
Merge branch 'master' into memcache-public
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php8
-rw-r--r--lib/l10n/ur.php8
-rw-r--r--lib/private/connector/sabre/file.php2
-rw-r--r--lib/private/files.php7
-rw-r--r--lib/private/files/cache/homecache.php2
-rw-r--r--lib/private/files/view.php13
-rw-r--r--lib/private/helper.php6
-rw-r--r--lib/private/mimetypes.list.php3
-rw-r--r--lib/private/preview/movies.php2
-rw-r--r--lib/private/preview/office.php2
-rwxr-xr-xlib/private/request.php23
-rw-r--r--lib/private/response.php14
-rw-r--r--lib/private/server.php6
-rw-r--r--lib/private/setup.php3
-rw-r--r--lib/private/template/cssresourcelocator.php2
-rw-r--r--lib/private/urlgenerator.php25
-rw-r--r--lib/private/user/backend.php17
-rw-r--r--lib/private/user/database.php15
-rw-r--r--lib/private/user/dummy.php9
-rw-r--r--lib/private/user/manager.php22
-rw-r--r--lib/public/response.php9
21 files changed, 171 insertions, 27 deletions
diff --git a/lib/base.php b/lib/base.php
index d3e483f4948..a8e9e901847 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -410,8 +410,6 @@ class OC {
self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib');
self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing');
self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console');
- self::$loader->registerPrefix('Sabre\\VObject', '3rdparty');
- self::$loader->registerPrefix('Sabre_', '3rdparty');
self::$loader->registerPrefix('Patchwork', '3rdparty');
spl_autoload_register(array(self::$loader, 'load'));
@@ -479,6 +477,12 @@ class OC {
}
OC_Util::isSetLocaleWorking();
+ // setup 3rdparty autoloader
+ $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
+ if (file_exists($vendorAutoLoad)) {
+ require_once $vendorAutoLoad;
+ }
+
// set debug mode if an xdebug session is active
if (!defined('DEBUG') || !DEBUG) {
if (isset($_COOKIE['XDEBUG_SESSION'])) {
diff --git a/lib/l10n/ur.php b/lib/l10n/ur.php
new file mode 100644
index 00000000000..15f78e0bce6
--- /dev/null
+++ b/lib/l10n/ur.php
@@ -0,0 +1,8 @@
+<?php
+$TRANSLATIONS = array(
+"_%n minute ago_::_%n minutes ago_" => array("",""),
+"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("","")
+);
+$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 295575f0af6..53524ec9e54 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -64,7 +64,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
// mark file as partial while uploading (ignored by the scanner)
- $partpath = $this->path . '.part';
+ $partpath = $this->path . '.ocTransferId' . rand() . '.part';
// if file is located in /Shared we write the part file to the users
// root folder because we can't create new files in /shared
diff --git a/lib/private/files.php b/lib/private/files.php
index 6ffa14c0d91..e6c81d58bd2 100644
--- a/lib/private/files.php
+++ b/lib/private/files.php
@@ -115,12 +115,7 @@ class OC_Files {
}
OC_Util::obEnd();
if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
- if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) {
- header( 'Content-Disposition: attachment; filename="' . rawurlencode($name) . '"' );
- } else {
- header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($name)
- . '; filename="' . rawurlencode($name) . '"' );
- }
+ OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary');
OC_Response::disableCaching();
if ($zip) {
diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php
index 18dfbfe3191..71bb944da71 100644
--- a/lib/private/files/cache/homecache.php
+++ b/lib/private/files/cache/homecache.php
@@ -16,7 +16,7 @@ class HomeCache extends Cache {
* @return int
*/
public function calculateFolderSize($path) {
- if ($path !== '/' and $path !== '') {
+ if ($path !== '/' and $path !== '' and $path !== 'files') {
return parent::calculateFolderSize($path);
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index ac45a881331..8893911ed5d 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -336,6 +336,19 @@ class View {
}
public function unlink($path) {
+ if ($path === '' || $path === '/') {
+ // do not allow deleting the root
+ return false;
+ }
+ $postFix = (substr($path, -1, 1) === '/') ? '/' : '';
+ $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
+ list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
+ if (!$internalPath || $internalPath === '' || $internalPath === '/') {
+ // do not allow deleting the storage's root / the mount point
+ // because for some storages it might delete the whole contents
+ // but isn't supposed to work that way
+ return false;
+ }
return $this->basicOperation('unlink', $path, array('delete'));
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 4fe3097af26..1c8d01c141f 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -858,11 +858,13 @@ class OC_Helper {
if (!function_exists($function_name)) {
return false;
}
- $disabled = explode(', ', ini_get('disable_functions'));
+ $disabled = explode(',', ini_get('disable_functions'));
+ $disabled = array_map('trim', $disabled);
if (in_array($function_name, $disabled)) {
return false;
}
- $disabled = explode(', ', ini_get('suhosin.executor.func.blacklist'));
+ $disabled = explode(',', ini_get('suhosin.executor.func.blacklist'));
+ $disabled = array_map('trim', $disabled);
if (in_array($function_name, $disabled)) {
return false;
}
diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php
index 740982910e0..08228336966 100644
--- a/lib/private/mimetypes.list.php
+++ b/lib/private/mimetypes.list.php
@@ -66,6 +66,7 @@ return array(
'xlsx'=>'application/msexcel',
'php'=>'application/x-php',
'exe'=>'application/x-ms-dos-executable',
+ 'msi'=>'application/x-msi',
'pl'=>'application/x-pearl',
'py'=>'application/x-python',
'blend'=>'application/x-blender',
@@ -97,8 +98,6 @@ return array(
'ai' => 'application/illustrator',
'epub' => 'application/epub+zip',
'mobi' => 'application/x-mobipocket-ebook',
- 'exe' => 'application',
- 'msi' => 'application',
'md' => 'text/markdown',
'markdown' => 'text/markdown',
'mdown' => 'text/markdown',
diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php
index ac771deb413..71cd3bae057 100644
--- a/lib/private/preview/movies.php
+++ b/lib/private/preview/movies.php
@@ -18,7 +18,7 @@ function findBinaryPath($program) {
// movie preview is currently not supported on Windows
if (!\OC_Util::runningOnWindows()) {
- $isExecEnabled = !in_array('exec', explode(', ', ini_get('disable_functions')));
+ $isExecEnabled = \OC_Helper::is_function_enabled('exec');
$ffmpegBinary = null;
$avconvBinary = null;
diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php
index 318ab51f851..7a4826c76ec 100644
--- a/lib/private/preview/office.php
+++ b/lib/private/preview/office.php
@@ -7,7 +7,7 @@
*/
//both, libreoffice backend and php fallback, need imagick
if (extension_loaded('imagick')) {
- $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions')));
+ $isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec');
// LibreOffice preview is currently not supported on Windows
if (!\OC_Util::runningOnWindows()) {
diff --git a/lib/private/request.php b/lib/private/request.php
index b2afda35922..d9d5ae08e28 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -7,6 +7,11 @@
*/
class OC_Request {
+
+ const USER_AGENT_IE = '/MSIE/';
+ // Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent
+ const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#';
+
/**
* @brief Check overwrite condition
* @param string $type
@@ -210,4 +215,22 @@ class OC_Request {
return false;
}
}
+
+ /**
+ * Checks whether the user agent matches a given regex
+ * @param string|array $agent agent name or array of agent names
+ * @return boolean true if at least one of the given agent matches,
+ * false otherwise
+ */
+ static public function isUserAgent($agent) {
+ if (!is_array($agent)) {
+ $agent = array($agent);
+ }
+ foreach ($agent as $regex) {
+ if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/lib/private/response.php b/lib/private/response.php
index 674176d078b..04746437347 100644
--- a/lib/private/response.php
+++ b/lib/private/response.php
@@ -148,6 +148,20 @@ class OC_Response {
}
/**
+ * Sets the content disposition header (with possible workarounds)
+ * @param string $filename file name
+ * @param string $type disposition type, either 'attachment' or 'inline'
+ */
+ static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
+ if (OC_Request::isUserAgent(array(OC_Request::USER_AGENT_IE, OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME))) {
+ header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
+ } else {
+ header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )
+ . '; filename="' . rawurlencode( $filename ) . '"' );
+ }
+ }
+
+ /**
* @brief Send file as response, checking and setting caching headers
* @param $filepath of file to send
*/
diff --git a/lib/private/server.php b/lib/private/server.php
index 6b034a5be9f..c9e593ec2ed 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -128,7 +128,9 @@ class Server extends SimpleContainer implements IServerContainer {
return new \OC\L10N\Factory();
});
$this->registerService('URLGenerator', function($c) {
- return new \OC\URLGenerator();
+ /** @var $c SimpleContainer */
+ $config = $c->query('AllConfig');
+ return new \OC\URLGenerator($config);
});
$this->registerService('AppHelper', function($c) {
return new \OC\AppHelper();
@@ -261,7 +263,7 @@ class Server extends SimpleContainer implements IServerContainer {
}
/**
- * @return \OC\Config
+ * @return \OCP\IConfig
*/
function getConfig() {
return $this->query('AllConfig');
diff --git a/lib/private/setup.php b/lib/private/setup.php
index b5c530a091f..5232398d1d7 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -159,6 +159,9 @@ class OC_Setup {
$content.= "</IfModule>\n";
$content.= "AddDefaultCharset utf-8\n";
$content.= "Options -Indexes\n";
+ $content.= "<IfModule pagespeed_module>\n";
+ $content.= "ModPagespeed Off\n";
+ $content.= "</IfModule>\n";
@file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
self::protectDataDirectory();
diff --git a/lib/private/template/cssresourcelocator.php b/lib/private/template/cssresourcelocator.php
index 8e7831ca549..e26daa25827 100644
--- a/lib/private/template/cssresourcelocator.php
+++ b/lib/private/template/cssresourcelocator.php
@@ -22,7 +22,7 @@ class CSSResourceLocator extends ResourceLocator {
$app = substr($style, 0, strpos($style, '/'));
$style = substr($style, strpos($style, '/')+1);
$app_path = \OC_App::getAppPath($app);
- $app_url = $this->webroot . '/index.php/apps/' . $app;
+ $app_url = \OC_App::getAppWebPath($app);
if ($this->appendIfExist($app_path, $style.$this->form_factor.'.css', $app_url)
|| $this->appendIfExist($app_path, $style.'.css', $app_url)
) {
diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php
index 7795011fd06..4e3c1109000 100644
--- a/lib/private/urlgenerator.php
+++ b/lib/private/urlgenerator.php
@@ -15,6 +15,19 @@ use RuntimeException;
* Class to generate URLs
*/
class URLGenerator implements IURLGenerator {
+
+ /**
+ * @var \OCP\IConfig
+ */
+ private $config;
+
+ /**
+ * @param \OCP\IConfig $config
+ */
+ public function __construct($config) {
+ $this->config = $config;
+ }
+
/**
* @brief Creates an url using a defined route
* @param $route
@@ -41,12 +54,18 @@ class URLGenerator implements IURLGenerator {
* Returns a url to the given app and file.
*/
public function linkTo( $app, $file, $args = array() ) {
+ $frontControllerActive=($this->config->getSystemValue('front_controller_active', 'false') == 'true');
+
if( $app != '' ) {
$app_path = \OC_App::getAppPath($app);
// Check if the app is in the app folder
if ($app_path && file_exists($app_path . '/' . $file)) {
if (substr($file, -3) == 'php' || substr($file, -3) == 'css') {
+
$urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app;
+ if ($frontControllerActive) {
+ $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app;
+ }
$urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
} else {
$urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file;
@@ -58,7 +77,11 @@ class URLGenerator implements IURLGenerator {
if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) {
$urlLinkTo = \OC::$WEBROOT . '/core/' . $file;
} else {
- $urlLinkTo = \OC::$WEBROOT . '/' . $file;
+ if ($frontControllerActive && $file === 'index.php') {
+ $urlLinkTo = \OC::$WEBROOT;
+ } else {
+ $urlLinkTo = \OC::$WEBROOT . '/' . $file;
+ }
}
}
diff --git a/lib/private/user/backend.php b/lib/private/user/backend.php
index 02c93d13bdf..f4e5618e04a 100644
--- a/lib/private/user/backend.php
+++ b/lib/private/user/backend.php
@@ -31,13 +31,15 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
/**
* actions that user backends can define
*/
-define('OC_USER_BACKEND_CREATE_USER', 0x0000001);
-define('OC_USER_BACKEND_SET_PASSWORD', 0x0000010);
-define('OC_USER_BACKEND_CHECK_PASSWORD', 0x0000100);
-define('OC_USER_BACKEND_GET_HOME', 0x0001000);
-define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x0010000);
-define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x0100000);
-define('OC_USER_BACKEND_PROVIDE_AVATAR', 0x1000000);
+define('OC_USER_BACKEND_CREATE_USER', 0x00000001);
+define('OC_USER_BACKEND_SET_PASSWORD', 0x00000010);
+define('OC_USER_BACKEND_CHECK_PASSWORD', 0x00000100);
+define('OC_USER_BACKEND_GET_HOME', 0x00001000);
+define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x00010000);
+define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x00100000);
+define('OC_USER_BACKEND_PROVIDE_AVATAR', 0x01000000);
+define('OC_USER_BACKEND_COUNT_USERS', 0x10000000);
+//more actions cannot be defined without breaking 32bit platforms!
/**
* Abstract base class for user management. Provides methods for querying backend
@@ -55,6 +57,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
OC_USER_BACKEND_GET_DISPLAYNAME => 'getDisplayName',
OC_USER_BACKEND_SET_DISPLAYNAME => 'setDisplayName',
OC_USER_BACKEND_PROVIDE_AVATAR => 'canChangeAvatar',
+ OC_USER_BACKEND_COUNT_USERS => 'countUsers',
);
/**
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index c99db3b27ca..1a63755b980 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -253,4 +253,19 @@ class OC_User_Database extends OC_User_Backend {
return true;
}
+ /**
+ * counts the users in the database
+ *
+ * @return int | bool
+ */
+ public function countUsers() {
+ $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
+ $result = $query->execute();
+ if (OC_DB::isError($result)) {
+ OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR);
+ return false;
+ }
+ return $result->fetchOne();
+ }
+
}
diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php
index 52be7edfa75..fc15a630cf3 100644
--- a/lib/private/user/dummy.php
+++ b/lib/private/user/dummy.php
@@ -123,4 +123,13 @@ class OC_User_Dummy extends OC_User_Backend {
public function hasUserListings() {
return true;
}
+
+ /**
+ * counts the users in the database
+ *
+ * @return int | bool
+ */
+ public function countUsers() {
+ return 0;
+ }
}
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index cf83a75ba25..90970ef9963 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -270,4 +270,26 @@ class Manager extends PublicEmitter {
}
return false;
}
+
+ /**
+ * returns how many users per backend exist (if supported by backend)
+ *
+ * @return array with backend class as key and count number as value
+ */
+ public function countUsers() {
+ $userCountStatistics = array();
+ foreach ($this->backends as $backend) {
+ if ($backend->implementsActions(\OC_USER_BACKEND_COUNT_USERS)) {
+ $backendusers = $backend->countUsers();
+ if($backendusers !== false) {
+ if(isset($userCountStatistics[get_class($backend)])) {
+ $userCountStatistics[get_class($backend)] += $backendusers;
+ } else {
+ $userCountStatistics[get_class($backend)] = $backendusers;
+ }
+ }
+ }
+ }
+ return $userCountStatistics;
+ }
}
diff --git a/lib/public/response.php b/lib/public/response.php
index 2ca0a0c9fa4..24d3c81d628 100644
--- a/lib/public/response.php
+++ b/lib/public/response.php
@@ -55,6 +55,15 @@ class Response {
}
/**
+ * Sets the content disposition header (with possible workarounds)
+ * @param string $filename file name
+ * @param string $type disposition type, either 'attachment' or 'inline'
+ */
+ static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
+ \OC_Response::setContentDispositionHeader( $filename, $type );
+ }
+
+ /**
* Disable browser caching
* @see enableCaching with cache_time = 0
*/