summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-10-28 11:16:04 +0000
committerTom Needham <needham.thomas@gmail.com>2012-10-28 11:16:04 +0000
commitbcdf3a23db6867332232f8c1b69ba3fa394e191a (patch)
tree20be51b4a2e5f1c7f8bc3a50ca3fb9571e972af3 /lib
parentb07944798848bc5196dc75e8d8caea5ca71b0f15 (diff)
parent22dcd3b6a691c7a245e4d1de30f09bb17efdfceb (diff)
downloadnextcloud-server-bcdf3a23db6867332232f8c1b69ba3fa394e191a.tar.gz
nextcloud-server-bcdf3a23db6867332232f8c1b69ba3fa394e191a.zip
Merge master into ocs_api
Diffstat (limited to 'lib')
-rw-r--r--lib/MDB2/Driver/Function/sqlite3.php2
-rw-r--r--lib/app.php164
-rw-r--r--lib/appconfig.php36
-rw-r--r--lib/archive.php8
-rw-r--r--lib/archive/tar.php25
-rw-r--r--lib/archive/zip.php7
-rw-r--r--lib/backgroundjob.php52
-rw-r--r--lib/base.php119
-rw-r--r--lib/cache/xcache.php6
-rw-r--r--lib/config.php22
-rw-r--r--lib/connector/sabre/auth.php2
-rw-r--r--lib/connector/sabre/directory.php16
-rw-r--r--lib/connector/sabre/locks.php2
-rw-r--r--lib/connector/sabre/node.php6
-rw-r--r--lib/connector/sabre/principal.php4
-rw-r--r--lib/db.php120
-rw-r--r--lib/eventsource.php6
-rw-r--r--lib/filecache.php116
-rw-r--r--lib/filecache/update.php25
-rw-r--r--lib/filechunking.php58
-rw-r--r--lib/fileproxy.php4
-rw-r--r--lib/fileproxy/fileoperations.php37
-rw-r--r--lib/fileproxy/quota.php60
-rw-r--r--lib/files.php98
-rw-r--r--lib/filestorage.php1
-rw-r--r--lib/filestorage/common.php11
-rw-r--r--lib/filestorage/local.php4
-rw-r--r--lib/filesystem.php131
-rw-r--r--lib/filesystemview.php164
-rw-r--r--lib/group.php59
-rw-r--r--lib/group/backend.php27
-rw-r--r--lib/group/database.php47
-rw-r--r--lib/group/interface.php27
-rw-r--r--lib/helper.php203
-rw-r--r--lib/hook.php24
-rw-r--r--lib/image.php2
-rw-r--r--lib/installer.php6
-rw-r--r--lib/json.php15
-rw-r--r--lib/l10n.php29
-rw-r--r--lib/l10n/ar.php8
-rw-r--r--lib/l10n/bg_BG.php4
-rw-r--r--lib/l10n/ca.php3
-rw-r--r--lib/l10n/cs_CZ.php3
-rw-r--r--lib/l10n/da.php5
-rw-r--r--lib/l10n/de.php11
-rw-r--r--lib/l10n/de_DE.php31
-rw-r--r--lib/l10n/el.php9
-rw-r--r--lib/l10n/eo.php2
-rw-r--r--lib/l10n/es.php2
-rw-r--r--lib/l10n/es_AR.php31
-rw-r--r--lib/l10n/et_EE.php2
-rw-r--r--lib/l10n/eu.php2
-rw-r--r--lib/l10n/fa.php2
-rw-r--r--lib/l10n/fi_FI.php2
-rw-r--r--lib/l10n/fr.php3
-rw-r--r--lib/l10n/gl.php29
-rw-r--r--lib/l10n/he.php1
-rw-r--r--lib/l10n/hr.php16
-rw-r--r--lib/l10n/hu_HU.php2
-rw-r--r--lib/l10n/ia.php7
-rw-r--r--lib/l10n/id.php29
-rw-r--r--lib/l10n/it.php3
-rw-r--r--lib/l10n/ja_JP.php3
-rw-r--r--lib/l10n/ka_GE.php20
-rw-r--r--lib/l10n/ko.php8
-rw-r--r--lib/l10n/ku_IQ.php5
-rw-r--r--lib/l10n/lb.php6
-rw-r--r--lib/l10n/lt_LT.php11
-rw-r--r--lib/l10n/lv.php7
-rw-r--r--lib/l10n/mk.php7
-rw-r--r--lib/l10n/ms_MY.php8
-rw-r--r--lib/l10n/nb_NO.php7
-rw-r--r--lib/l10n/nl.php7
-rw-r--r--lib/l10n/nn_NO.php8
-rw-r--r--lib/l10n/oc.php25
-rw-r--r--lib/l10n/pl.php3
-rw-r--r--lib/l10n/pl_PL.php3
-rw-r--r--lib/l10n/pt_BR.php30
-rw-r--r--lib/l10n/pt_PT.php31
-rw-r--r--lib/l10n/ro.php30
-rw-r--r--lib/l10n/ru.php2
-rw-r--r--lib/l10n/ru_RU.php30
-rw-r--r--lib/l10n/si_LK.php31
-rw-r--r--lib/l10n/sk_SK.php31
-rw-r--r--lib/l10n/sl.php20
-rw-r--r--lib/l10n/sr.php8
-rw-r--r--lib/l10n/sr@latin.php8
-rw-r--r--lib/l10n/sv.php3
-rw-r--r--lib/l10n/ta_LK.php31
-rw-r--r--lib/l10n/th_TH.php2
-rw-r--r--lib/l10n/tr.php9
-rw-r--r--lib/l10n/uk.php2
-rw-r--r--lib/l10n/vi.php3
-rw-r--r--lib/l10n/zh_CN.GB2312.php30
-rw-r--r--lib/l10n/zh_CN.php3
-rw-r--r--lib/l10n/zh_TW.php2
-rw-r--r--lib/log.php35
-rw-r--r--lib/migrate.php20
-rw-r--r--lib/migration/content.php17
-rw-r--r--lib/mimetypes.list.php1
-rw-r--r--lib/ocsclient.php61
-rw-r--r--lib/preferences.php66
-rw-r--r--lib/public/backgroundjob.php23
-rw-r--r--lib/public/config.php56
-rw-r--r--lib/public/share.php104
-rw-r--r--lib/public/util.php2
-rw-r--r--lib/search/provider/file.php29
-rw-r--r--lib/setup.php478
-rw-r--r--lib/streamwrappers.php8
-rw-r--r--lib/subadmin.php2
-rw-r--r--lib/template.php112
-rw-r--r--lib/templatelayout.php9
-rw-r--r--lib/updater.php19
-rw-r--r--lib/user.php23
-rwxr-xr-xlib/util.php213
-rw-r--r--lib/vcategories.php2
-rw-r--r--lib/vobject.php14
117 files changed, 2590 insertions, 1090 deletions
diff --git a/lib/MDB2/Driver/Function/sqlite3.php b/lib/MDB2/Driver/Function/sqlite3.php
index 235a106e183..0bddde5bf3f 100644
--- a/lib/MDB2/Driver/Function/sqlite3.php
+++ b/lib/MDB2/Driver/Function/sqlite3.php
@@ -94,7 +94,7 @@ class MDB2_Driver_Function_sqlite3 extends MDB2_Driver_Function_Common
if (!is_null($length)) {
return "substr($value,$position,$length)";
}
- return "substr($value,$position,length($value))";
+ return "substr($value, $position, length($value))";
}
// }}}
diff --git a/lib/app.php b/lib/app.php
index 620732f6006..3d2ceb1729f 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -40,7 +40,7 @@ class OC_App{
/**
* @brief loads all apps
* @param array $types
- * @returns true/false
+ * @return bool
*
* This function walks through the owncloud directory and loads all apps
* it can find. A directory contains an app if the file /appinfo/app.php
@@ -63,7 +63,7 @@ class OC_App{
if (!defined('DEBUG') || !DEBUG) {
if (is_null($types)
- && empty(OC_Util::$core_scripts)
+ && empty(OC_Util::$core_scripts)
&& empty(OC_Util::$core_styles)) {
OC_Util::$core_scripts = OC_Util::$scripts;
OC_Util::$scripts = array();
@@ -77,7 +77,7 @@ class OC_App{
/**
* load a single app
- * @param string app
+ * @param string $app
*/
public static function loadApp($app) {
if(is_file(self::getAppPath($app).'/appinfo/app.php')) {
@@ -90,6 +90,7 @@ class OC_App{
* check if an app is of a specific type
* @param string $app
* @param string/array $types
+ * @return bool
*/
public static function isType($app,$types) {
if(is_string($types)) {
@@ -170,8 +171,8 @@ class OC_App{
/**
* @brief checks whether or not an app is enabled
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* This function checks whether or not an app is enabled.
*/
@@ -185,8 +186,8 @@ class OC_App{
/**
* @brief enables an app
- * @param $app app
- * @returns true/false
+ * @param mixed $app app
+ * @return bool
*
* This function set an app as enabled in appconfig.
*/
@@ -216,13 +217,12 @@ class OC_App{
}else{
return false;
}
- return $app;
}
/**
* @brief disables an app
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* This function set an app as disabled in appconfig.
*/
@@ -233,8 +233,8 @@ class OC_App{
/**
* @brief adds an entry to the navigation
- * @param $data array containing the data
- * @returns true/false
+ * @param string $data array containing the data
+ * @return bool
*
* This function adds a new entry to the navigation visible to users. $data
* is an associative array.
@@ -259,8 +259,8 @@ class OC_App{
/**
* @brief marks a navigation entry as active
- * @param $id id of the entry
- * @returns true/false
+ * @param string $id id of the entry
+ * @return bool
*
* This function sets a navigation entry as active and removes the 'active'
* property from all other entries. The templates can use this for
@@ -273,7 +273,7 @@ class OC_App{
/**
* @brief gets the active Menu entry
- * @returns id or empty string
+ * @return string id or empty string
*
* This function returns the id of the active navigation entry (set by
* setActiveNavigationEntry
@@ -284,7 +284,7 @@ class OC_App{
/**
* @brief Returns the Settings Navigation
- * @returns associative array
+ * @return array
*
* This function returns an array containing all settings pages added. The
* entries are sorted by the key 'order' ascending.
@@ -305,7 +305,7 @@ class OC_App{
// personal menu
$settings[] = array( "id" => "personal", "order" => 1, "href" => OC_Helper::linkTo( "settings", "personal.php" ), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath( "settings", "personal.svg" ));
- // if there're some settings forms
+ // if there are some settings forms
if(!empty(self::$settingsForms))
// settings menu
$settings[]=array( "id" => "settings", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "settings.php" ), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath( "settings", "settings.svg" ));
@@ -375,6 +375,7 @@ class OC_App{
return $app_dir[$appid]=$dir;
}
}
+ return false;
}
/**
* Get the directory for the given app.
@@ -384,6 +385,7 @@ class OC_App{
if( ($dir = self::findAppInDirectories($appid)) != false) {
return $dir['path'].'/'.$appid;
}
+ return false;
}
/**
@@ -394,6 +396,7 @@ class OC_App{
if( ($dir = self::findAppInDirectories($appid)) != false) {
return OC::$WEBROOT.$dir['url'].'/'.$appid;
}
+ return false;
}
/**
@@ -401,9 +404,8 @@ class OC_App{
*/
public static function getAppVersion($appid) {
$file= self::getAppPath($appid).'/appinfo/version';
- $version=@file_get_contents($file);
- if($version) {
- return trim($version);
+ if(is_file($file) && $version = trim(file_get_contents($file))) {
+ return $version;
}else{
$appData=self::getAppInfo($appid);
return isset($appData['version'])? $appData['version'] : '';
@@ -411,10 +413,11 @@ class OC_App{
}
/**
- * @brief Read app metadata from the info.xml file
+ * @brief Read all app metadata from the info.xml file
* @param string $appid id of the app or the path of the info.xml file
- * @param boolean path (optional)
- * @returns array
+ * @param boolean $path (optional)
+ * @return array
+ * @note all data is read from info.xml, not just pre-defined fields
*/
public static function getAppInfo($appid,$path=false) {
if($path) {
@@ -428,24 +431,36 @@ class OC_App{
$data=array();
$content=@file_get_contents($file);
if(!$content) {
- return;
+ return null;
}
$xml = new SimpleXMLElement($content);
$data['info']=array();
$data['remote']=array();
$data['public']=array();
foreach($xml->children() as $child) {
+ /**
+ * @var $child SimpleXMLElement
+ */
if($child->getName()=='remote') {
foreach($child->children() as $remote) {
+ /**
+ * @var $remote SimpleXMLElement
+ */
$data['remote'][$remote->getName()]=(string)$remote;
}
}elseif($child->getName()=='public') {
foreach($child->children() as $public) {
+ /**
+ * @var $public SimpleXMLElement
+ */
$data['public'][$public->getName()]=(string)$public;
}
}elseif($child->getName()=='types') {
$data['types']=array();
foreach($child->children() as $type) {
+ /**
+ * @var $type SimpleXMLElement
+ */
$data['types'][]=$type->getName();
}
}elseif($child->getName()=='description') {
@@ -456,12 +471,13 @@ class OC_App{
}
}
self::$appInfo[$appid]=$data;
+
return $data;
}
/**
* @brief Returns the navigation
- * @returns associative array
+ * @return array
*
* This function returns an array containing all entries added. The
* entries are sorted by the key 'order' ascending. Additional to the keys
@@ -506,6 +522,8 @@ class OC_App{
case 'personal':
$source=self::$personalForms;
break;
+ default:
+ return array();
}
foreach($source as $form) {
$forms[]=include $form;
@@ -535,22 +553,84 @@ class OC_App{
}
/**
- * get a list of all apps in the apps folder
+ * @brief: get a list of all apps in the apps folder
+ * @return array or app names (string IDs)
+ * @todo: change the name of this method to getInstalledApps, which is more accurate
*/
public static function getAllApps() {
+
$apps=array();
- foreach(OC::$APPSROOTS as $apps_dir) {
- $dh=opendir($apps_dir['path']);
- while($file=readdir($dh)) {
- if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
- $apps[]=$file;
+
+ foreach ( OC::$APPSROOTS as $apps_dir ) {
+ if(! is_readable($apps_dir['path'])) {
+ OC_Log::write('core', 'unable to read app folder : ' .$apps_dir['path'], OC_Log::WARN);
+ continue;
+ }
+ $dh = opendir( $apps_dir['path'] );
+
+ while( $file = readdir( $dh ) ) {
+
+ if ($file[0] != '.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
+
+ $apps[] = $file;
+
}
+
}
+
}
+
return $apps;
}
/**
+ * @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
+ */
+ public static function getAppstoreApps( $filter = 'approved' ) {
+ $catagoryNames = OC_OCSClient::getCategories();
+ if ( is_array( $catagoryNames ) ) {
+ // Check that categories of apps were retrieved correctly
+ if ( ! $categories = array_keys( $catagoryNames ) ) {
+ return false;
+ }
+
+ $page = 0;
+ $remoteApps = OC_OCSClient::getApplications( $categories, $page, $filter );
+ $app1 = array();
+ $i = 0;
+ foreach ( $remoteApps as $app ) {
+ $app1[$i] = $app;
+ $app1[$i]['author'] = $app['personid'];
+ $app1[$i]['ocs_id'] = $app['id'];
+ $app1[$i]['internal'] = $app1[$i]['active'] = 0;
+
+ // rating img
+ if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" );
+ elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" );
+ elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" );
+ elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" );
+ elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" );
+ elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" );
+ elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" );
+ elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" );
+ elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" );
+ elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" );
+ elseif($app['score']>=95 and $app['score']<100) $img=OC_Helper::imagePath( "core", "rating/s11.png" );
+
+ $app1[$i]['score'] = '<img src="'.$img.'"> Score: '.$app['score'].'%';
+ $i++;
+ }
+ }
+
+ if ( empty( $app1 ) ) {
+ return false;
+ } else {
+ return $app1;
+ }
+ }
+
+ /**
* check if the app need updating and update when needed
*/
public static function checkUpgrade($app) {
@@ -564,7 +644,13 @@ class OC_App{
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) {
OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG);
- OC_App::updateApp($app);
+ try {
+ OC_App::updateApp($app);
+ }
+ catch (Exception $e) {
+ echo 'Failed to upgrade "'.$app.'". Exception="'.$e->getMessage().'"';
+ die;
+ }
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
@@ -584,7 +670,7 @@ class OC_App{
foreach($apps as $app) {
// check if the app is compatible with this version of ownCloud
$info = OC_App::getAppInfo($app);
- if(!isset($info['require']) or ($version[0]>$info['require'])) {
+ if(!isset($info['require']) or (($version[0].'.'.$version[1])>$info['require'])) {
OC_Log::write('core', 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is not compatible with this version of ownCloud', OC_Log::ERROR);
OC_App::disable( $app );
}
@@ -610,9 +696,13 @@ class OC_App{
/**
* update the database for the app and call the update script
- * @param string appid
+ * @param string $appid
*/
public static function updateApp($appid) {
+ if(file_exists(self::getAppPath($appid).'/appinfo/preupdate.php')) {
+ self::loadApp($appid);
+ include self::getAppPath($appid).'/appinfo/preupdate.php';
+ }
if(file_exists(self::getAppPath($appid).'/appinfo/database.xml')) {
OC_DB::updateDbFromStructure(self::getAppPath($appid).'/appinfo/database.xml');
}
@@ -624,7 +714,7 @@ class OC_App{
include self::getAppPath($appid).'/appinfo/update.php';
}
- //set remote/public handelers
+ //set remote/public handlers
$appData=self::getAppInfo($appid);
foreach($appData['remote'] as $name=>$path) {
OCP\CONFIG::setAppValue('core', 'remote_'.$name, $appid.'/'.$path);
@@ -637,7 +727,7 @@ class OC_App{
}
/**
- * @param string appid
+ * @param string $appid
* @return OC_FilesystemView
*/
public static function getStorage($appid) {
@@ -654,7 +744,7 @@ class OC_App{
}
}else{
OC_Log::write('core', 'Can\'t get app storage, app '.$appid.' not enabled', OC_Log::ERROR);
- false;
+ return false;
}
}
}
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 7f58b878504..ed0e8f1d0bd 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -40,7 +40,7 @@
class OC_Appconfig{
/**
* @brief Get all apps using the config
- * @returns array with app ids
+ * @return array with app ids
*
* This function returns a list of all apps that have at least one
* entry in the appconfig table.
@@ -60,8 +60,8 @@ class OC_Appconfig{
/**
* @brief Get the available keys for an app
- * @param $app the app we are looking for
- * @returns array with key names
+ * @param string $app the app we are looking for
+ * @return array with key names
*
* This function gets all keys of an app. Please note that the values are
* not returned.
@@ -81,13 +81,13 @@ class OC_Appconfig{
/**
* @brief Gets the config value
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
*
* This function gets a value from the appconfig table. If the key does
- * not exist the default value will be returnes
+ * not exist the default value will be returned
*/
public static function getValue( $app, $key, $default = null ) {
// At least some magic in here :-)
@@ -114,16 +114,16 @@ class OC_Appconfig{
/**
* @brief sets a value in the appconfig
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* Sets a value. If the key did not exist before it will be created.
*/
public static function setValue( $app, $key, $value ) {
// Does the key exist? yes: update. No: insert
- if(! self::hasKey($app,$key)) {
+ if(! self::hasKey($app, $key)) {
$query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ? )' );
$query->execute( array( $app, $key, $value ));
}
@@ -135,9 +135,9 @@ class OC_Appconfig{
/**
* @brief Deletes a key
- * @param $app app
- * @param $key key
- * @returns true/false
+ * @param string $app app
+ * @param string $key key
+ * @return bool
*
* Deletes a key.
*/
@@ -151,8 +151,8 @@ class OC_Appconfig{
/**
* @brief Remove app from appconfig
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* Removes all keys in appconfig belonging to the app.
*/
diff --git a/lib/archive.php b/lib/archive.php
index b4459c2b6ce..a9c245eaf43 100644
--- a/lib/archive.php
+++ b/lib/archive.php
@@ -13,14 +13,14 @@ abstract class OC_Archive{
* @return OC_Archive
*/
public static function open($path) {
- $ext=substr($path,strrpos($path,'.'));
+ $ext=substr($path, strrpos($path, '.'));
switch($ext) {
case '.zip':
return new OC_Archive_ZIP($path);
case '.gz':
case '.bz':
case '.bz2':
- if(strpos($path,'.tar.')) {
+ if(strpos($path, '.tar.')) {
return new OC_Archive_TAR($path);
}
break;
@@ -126,9 +126,9 @@ abstract class OC_Archive{
continue;
}
if(is_dir($source.'/'.$file)) {
- $this->addRecursive($path.'/'.$file,$source.'/'.$file);
+ $this->addRecursive($path.'/'.$file, $source.'/'.$file);
}else{
- $this->addFile($path.'/'.$file,$source.'/'.$file);
+ $this->addFile($path.'/'.$file, $source.'/'.$file);
}
}
}
diff --git a/lib/archive/tar.php b/lib/archive/tar.php
index 639d2392b63..86d39b88968 100644
--- a/lib/archive/tar.php
+++ b/lib/archive/tar.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once 'Archive/Tar.php';
+require_once '3rdparty/Archive/Tar.php';
class OC_Archive_TAR extends OC_Archive{
const PLAIN=0;
@@ -14,6 +14,7 @@ class OC_Archive_TAR extends OC_Archive{
const BZIP=2;
private $fileList;
+ private $cachedHeaders;
/**
* @var Archive_Tar tar
@@ -74,6 +75,7 @@ class OC_Archive_TAR extends OC_Archive{
$result=$this->tar->addModify(array($tmpBase.$path), '', $tmpBase);
rmdir($tmpBase.$path);
$this->fileList=false;
+ $this->cachedHeaders=false;
return $result;
}
/**
@@ -95,6 +97,7 @@ class OC_Archive_TAR extends OC_Archive{
$result=$this->tar->addString($path, $source);
}
$this->fileList=false;
+ $this->cachedHeaders=false;
return $result;
}
@@ -115,13 +118,20 @@ class OC_Archive_TAR extends OC_Archive{
$this->tar=new Archive_Tar($this->path, $types[self::getTarType($this->path)]);
$this->tar->createModify(array($tmp), '', $tmp.'/');
$this->fileList=false;
+ $this->cachedHeaders=false;
return true;
}
private function getHeader($file) {
- $headers=$this->tar->listContent();
- foreach($headers as $header) {
- if($file==$header['filename'] or $file.'/'==$header['filename'] or '/'.$file.'/'==$header['filename'] or '/'.$file==$header['filename']) {
+ if ( ! $this->cachedHeaders ) {
+ $this->cachedHeaders = $this->tar->listContent();
+ }
+ foreach($this->cachedHeaders as $header) {
+ if( $file == $header['filename']
+ or $file.'/' == $header['filename']
+ or '/'.$file.'/' == $header['filename']
+ or '/'.$file == $header['filename'])
+ {
return $header;
}
}
@@ -180,9 +190,11 @@ class OC_Archive_TAR extends OC_Archive{
if($this->fileList) {
return $this->fileList;
}
- $headers=$this->tar->listContent();
+ if ( ! $this->cachedHeaders ) {
+ $this->cachedHeaders = $this->tar->listContent();
+ }
$files=array();
- foreach($headers as $header) {
+ foreach($this->cachedHeaders as $header) {
$files[]=$header['filename'];
}
$this->fileList=$files;
@@ -265,6 +277,7 @@ class OC_Archive_TAR extends OC_Archive{
return false;
}
$this->fileList=false;
+ $this->cachedHeaders=false;
//no proper way to delete, extract entire archive, delete file and remake archive
$tmp=OCP\Files::tmpFolder();
$this->tar->extract($tmp);
diff --git a/lib/archive/zip.php b/lib/archive/zip.php
index a2b07f1a35d..d016c692e35 100644
--- a/lib/archive/zip.php
+++ b/lib/archive/zip.php
@@ -86,7 +86,7 @@ class OC_Archive_ZIP extends OC_Archive{
$pathLength=strlen($path);
foreach($files as $file) {
if(substr($file, 0, $pathLength)==$path and $file!=$path) {
- if(strrpos(substr($file, 0, -1),'/')<=$pathLength) {
+ if(strrpos(substr($file, 0, -1), '/')<=$pathLength) {
$folderContent[]=substr($file, $pathLength);
}
}
@@ -161,7 +161,10 @@ class OC_Archive_ZIP extends OC_Archive{
function getStream($path,$mode) {
if($mode=='r' or $mode=='rb') {
return $this->zip->getStream($path);
- }else{//since we cant directly get a writable stream, make a temp copy of the file and put it back in the archive when the stream is closed
+ } else {
+ //since we cant directly get a writable stream,
+ //make a temp copy of the file and put it back
+ //in the archive when the stream is closed
if(strrpos($path, '.')!==false) {
$ext=substr($path, strrpos($path, '.'));
}else{
diff --git a/lib/backgroundjob.php b/lib/backgroundjob.php
new file mode 100644
index 00000000000..6415f5b84aa
--- /dev/null
+++ b/lib/backgroundjob.php
@@ -0,0 +1,52 @@
+<?php
+/**
+* ownCloud
+*
+* @author Jakob Sack
+* @copyright 2012 Jakob Sack owncloud@jakobsack.de
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * This class does the dirty work.
+ */
+class OC_BackgroundJob{
+ /**
+ * @brief get the execution type of background jobs
+ * @return string
+ *
+ * This method returns the type how background jobs are executed. If the user
+ * did not select something, the type is ajax.
+ */
+ public static function getExecutionType() {
+ return OC_Appconfig::getValue( 'core', 'backgroundjobs_mode', 'ajax' );
+ }
+
+ /**
+ * @brief sets the background jobs execution type
+ * @param $type execution type
+ * @return boolean
+ *
+ * This method sets the execution type of the background jobs. Possible types
+ * are "none", "ajax", "webcron", "cron"
+ */
+ public static function setExecutionType( $type ) {
+ if( !in_array( $type, array('none', 'ajax', 'webcron', 'cron'))){
+ return false;
+ }
+ return OC_Appconfig::setValue( 'core', 'backgroundjobs_mode', $type );
+ }
+}
diff --git a/lib/base.php b/lib/base.php
index 2b05fd7f9ea..d47c1d30dd0 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -76,11 +76,14 @@ class OC{
*/
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
*/
- $path = str_replace('apps/', '', OC::$CLASSPATH[$className]);
- require_once $path;
+ 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');
@@ -105,14 +108,14 @@ class OC{
}
if($fullPath = stream_resolve_include_path($path)) {
- require_once $path;
+ require_once $fullPath;
}
return false;
}
public static function initPaths() {
// calculate the root directories
- OC::$SERVERROOT=str_replace("\\", '/', substr(__FILE__, 0, -13));
+ 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)=='/') {
@@ -181,7 +184,7 @@ class OC{
OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.
OC::$SERVERROOT.'/config'.PATH_SEPARATOR.
OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.
- implode($paths,PATH_SEPARATOR).PATH_SEPARATOR.
+ implode($paths, PATH_SEPARATOR).PATH_SEPARATOR.
get_include_path().PATH_SEPARATOR.
OC::$SERVERROOT
);
@@ -201,6 +204,7 @@ class OC{
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'];
@@ -248,6 +252,8 @@ class OC{
OC_Util::addScript( "jquery-tipsy" );
OC_Util::addScript( "oc-dialogs" );
OC_Util::addScript( "js" );
+ // request protection token MUST be defined after the jquery library but before any $('document').ready()
+ OC_Util::addScript( "requesttoken" );
OC_Util::addScript( "eventsource" );
OC_Util::addScript( "config" );
//OC_Util::addScript( "multiselect" );
@@ -266,8 +272,30 @@ class OC{
}
public static function initSession() {
+ // prevents javascript from accessing php session cookies
ini_set('session.cookie_httponly', '1;');
+
+ // (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 loadapp(){
@@ -322,7 +350,7 @@ class OC{
ini_set('arg_separator.output', '&amp;');
// try to switch magic quotes off.
- if(function_exists('set_magic_quotes_runtime')) {
+ if(get_magic_quotes_gpc()) {
@set_magic_quotes_runtime(false);
}
@@ -346,20 +374,24 @@ class OC{
//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]));
+ 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]));
+ 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'])) {
@@ -393,6 +425,10 @@ class OC{
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;
@@ -482,6 +518,7 @@ class OC{
OC_App::loadApps();
OC_User::setupBackends();
if(isset($_GET["logout"]) and ($_GET["logout"])) {
+ OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
OC_User::logout();
header("Location: ".OC::$WEBROOT.'/');
}else{
@@ -527,20 +564,31 @@ class OC{
protected static function handleLogin() {
OC_App::loadApps(array('prelogin'));
- $error = false;
+ $error = array();
// remember was checked after last login
if (OC::tryRememberLogin()) {
- // nothing more to do
+ $error[] = 'invalidcookie';
// Someone wants to log in :
} elseif (OC::tryFormLogin()) {
- $error = true;
+ $error[] = 'invalidpassword';
// The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
} elseif (OC::tryBasicAuthLogin()) {
- $error = true;
+ $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);
+ }
}
- OC_Util::displayLoginPage($error);
}
protected static function tryRememberLogin() {
@@ -556,24 +604,35 @@ class OC{
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']) &&
- OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") === $_COOKIE['oc_token'])
- {
- OC_User::setUserId($_COOKIE['oc_username']);
- OC_Util::redirectToDefaultPage();
- }
- else {
- OC_User::unsetMagicInCookie();
+ 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'])
- || !isset($_SESSION['sectoken'])
- || !isset($_POST['sectoken'])
- || ($_SESSION['sectoken']!=$_POST['sectoken']) ) {
+ if(!isset($_POST["user"]) || !isset($_POST['password'])) {
return false;
}
@@ -583,18 +642,20 @@ class OC{
OC_User::setupBackends();
if(OC_User::login($_POST["user"], $_POST["password"])) {
+ 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 = md5($_POST["user"].time().$_POST['password']);
- OC_Preferences::setValue($_POST['user'], 'login', 'token', $token);
+ $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();
+ header( 'Location: '.$_SERVER['REQUEST_URI'] );
+ exit();
}
return true;
}
diff --git a/lib/cache/xcache.php b/lib/cache/xcache.php
index cecdf46351c..9f380f870b9 100644
--- a/lib/cache/xcache.php
+++ b/lib/cache/xcache.php
@@ -44,6 +44,12 @@ class OC_Cache_XCache {
}
public function clear($prefix='') {
+ if(!function_exists('xcache_unset_by_prefix')) {
+ function xcache_unset_by_prefix($prefix) {
+ // Since we can't clear targetted cache, we'll clear all. :(
+ xcache_clear_cache(XC_TYPE_VAR, 0);
+ }
+ }
xcache_unset_by_prefix($this->getNamespace().$prefix);
return true;
}
diff --git a/lib/config.php b/lib/config.php
index 032d401264c..cbea9199320 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -47,7 +47,7 @@ class OC_Config{
/**
* @brief Lists all available config keys
- * @returns array with key names
+ * @return array with key names
*
* This function returns all keys saved in config.php. Please note that it
* does not return the values.
@@ -60,9 +60,9 @@ class OC_Config{
/**
* @brief Gets a value from config.php
- * @param $key key
- * @param $default = null default value
- * @returns the value or $default
+ * @param string $key key
+ * @param string $default = null default value
+ * @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
@@ -79,9 +79,9 @@ class OC_Config{
/**
* @brief Sets a value
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
@@ -99,8 +99,8 @@ class OC_Config{
/**
* @brief Removes a key from the config
- * @param $key key
- * @returns true/false
+ * @param string $key key
+ * @return bool
*
* This function removes a key from the config.php. If owncloud has no
* write access to config.php, the function will return false.
@@ -121,7 +121,7 @@ class OC_Config{
/**
* @brief Loads the config file
- * @returns true/false
+ * @return bool
*
* Reads the config file and saves it to the cache
*/
@@ -148,7 +148,7 @@ class OC_Config{
/**
* @brief Writes the config file
- * @returns true/false
+ * @return bool
*
* Saves the config to the config file.
*
diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php
index 0c34c7ea29f..db8f005745a 100644
--- a/lib/connector/sabre/auth.php
+++ b/lib/connector/sabre/auth.php
@@ -37,7 +37,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
} else {
OC_Util::setUpFS();//login hooks may need early access to the filesystem
if(OC_User::login($username, $password)) {
- OC_Util::setUpFS($username);
+ OC_Util::setUpFS(OC_User::getUser());
return true;
}
else{
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 39606577f6d..b6e02569d2a 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -50,12 +50,14 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public function createFile($name, $data = null) {
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
$info = OC_FileChunking::decodeName($name);
+ if (empty($info)) {
+ throw new Sabre_DAV_Exception_NotImplemented();
+ }
$chunk_handler = new OC_FileChunking($info);
$chunk_handler->store($info['index'], $data);
if ($chunk_handler->isComplete()) {
$newPath = $this->path . '/' . $info['name'];
- $f = OC_Filesystem::fopen($newPath, 'w');
- $chunk_handler->assemble($f);
+ $chunk_handler->file_assemble($newPath);
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
}
} else {
@@ -91,10 +93,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$path = $this->path . '/' . $name;
if (is_null($info)) {
- $info = OC_FileCache::get($path);
+ $info = OC_Files::getFileInfo($path);
}
- if (!$info) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+ if (!$info) {
+ throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+ }
if ($info['mimetype'] == 'httpd/unix-directory') {
$node = new OC_Connector_Sabre_Directory($path);
@@ -113,7 +117,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function getChildren() {
- $folder_content = OC_FileCache::getFolderContent($this->path);
+ $folder_content = OC_Files::getDirectoryContent($this->path);
$paths = array();
foreach($folder_content as $info) {
$paths[] = $this->path.'/'.$info['name'];
@@ -196,7 +200,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public function getProperties($properties) {
$props = parent::getProperties($properties);
if (in_array(self::GETETAG_PROPERTYNAME, $properties) && !isset($props[self::GETETAG_PROPERTYNAME])) {
- $props[self::GETETAG_PROPERTYNAME]
+ $props[self::GETETAG_PROPERTYNAME]
= OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
}
return $props;
diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php
index dbcc57558e0..8ebe324602c 100644
--- a/lib/connector/sabre/locks.php
+++ b/lib/connector/sabre/locks.php
@@ -109,7 +109,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
$lockInfo->created = time();
$lockInfo->uri = $uri;
- $locks = $this->getLocks($uri,false);
+ $locks = $this->getLocks($uri, false);
$exists = false;
foreach($locks as $lock) {
if ($lock->token == $lockInfo->token) $exists = true;
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index ecbbef81292..72de9723774 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -23,6 +23,7 @@
abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IProperties {
const GETETAG_PROPERTYNAME = '{DAV:}getetag';
+ const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
/**
* The path to the current node
@@ -142,7 +143,6 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
public function updateProperties($properties) {
$existing = $this->getProperties(array());
foreach($properties as $propertyName => $propertyValue) {
- $propertyName = preg_replace("/^{.*}/", "", $propertyName); // remove leading namespace from property name
// If it was null, we need to delete the property
if (is_null($propertyValue)) {
if(array_key_exists( $propertyName, $existing )) {
@@ -151,7 +151,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
}
else {
- if( strcmp( $propertyName, "lastmodified") === 0) {
+ if( strcmp( $propertyName, self::LASTMODIFIED_PROPERTYNAME) === 0 ) {
$this->touch($propertyValue);
} else {
if(!array_key_exists( $propertyName, $existing )) {
@@ -235,7 +235,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
static public function removeETagPropertyForPath($path) {
// remove tags from this and parent paths
$paths = array();
- while ($path != '/' && $path != '.' && $path != '') {
+ while ($path != '/' && $path != '.' && $path != '' && $path != '\\') {
$paths[] = $path;
$path = dirname($path);
}
diff --git a/lib/connector/sabre/principal.php b/lib/connector/sabre/principal.php
index ee95ae63306..763503721f8 100644
--- a/lib/connector/sabre/principal.php
+++ b/lib/connector/sabre/principal.php
@@ -115,11 +115,11 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
public function setGroupMemberSet($principal, array $members) {
throw new Sabre_DAV_Exception('Setting members of the group is not supported yet');
}
-
+
function updatePrincipal($path, $mutations) {
return 0;
}
-
+
function searchPrincipals($prefixPath, array $searchProperties) {
return 0;
}
diff --git a/lib/db.php b/lib/db.php
index 4d8e5a1a868..a43f2ad20b2 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -28,18 +28,30 @@ class OC_DB {
const BACKEND_PDO=0;
const BACKEND_MDB2=1;
+ /**
+ * @var MDB2_Driver_Common
+ */
static private $connection; //the prefered connection to use, either PDO or MDB2
static private $backend=null;
- static private $MDB2=false;
- static private $PDO=false;
- static private $schema=false;
+ /**
+ * @var MDB2_Driver_Common
+ */
+ static private $MDB2=null;
+ /**
+ * @var PDO
+ */
+ static private $PDO=null;
+ /**
+ * @var MDB2_Schema
+ */
+ static private $schema=null;
static private $inTransaction=false;
static private $prefix=null;
static private $type=null;
/**
* check which backend we should use
- * @return BACKEND_MDB2 or BACKEND_PDO
+ * @return int BACKEND_MDB2 or BACKEND_PDO
*/
private static function getDBBackend() {
//check if we can use PDO, else use MDB2 (installation always needs to be done my mdb2)
@@ -59,37 +71,41 @@ class OC_DB {
/**
* @brief connects to the database
- * @returns true if connection can be established or nothing (die())
+ * @param int $backend
+ * @return bool true if connection can be established or false on error
*
* Connects to the database as specified in config.php
*/
public static function connect($backend=null) {
if(self::$connection) {
- return;
+ return true;
}
if(is_null($backend)) {
$backend=self::getDBBackend();
}
if($backend==self::BACKEND_PDO) {
- self::connectPDO();
+ $success = self::connectPDO();
self::$connection=self::$PDO;
self::$backend=self::BACKEND_PDO;
}else{
- self::connectMDB2();
+ $success = self::connectMDB2();
self::$connection=self::$MDB2;
self::$backend=self::BACKEND_MDB2;
}
+ return $success;
}
/**
* connect to the database using pdo
+ *
+ * @return bool
*/
public static function connectPDO() {
if(self::$connection) {
if(self::$backend==self::BACKEND_MDB2) {
self::disconnect();
}else{
- return;
+ return true;
}
}
// The global data we need
@@ -146,6 +162,8 @@ class OC_DB {
$dsn = 'oci:dbname=//' . $host . '/' . $name;
}
break;
+ default:
+ return false;
}
try{
self::$PDO=new PDO($dsn, $user, $pass, $opts);
@@ -168,7 +186,7 @@ class OC_DB {
if(self::$backend==self::BACKEND_PDO) {
self::disconnect();
}else{
- return;
+ return true;
}
}
// The global data we need
@@ -226,14 +244,18 @@ class OC_DB {
'phptype' => 'oci8',
'username' => $user,
'password' => $pass,
+ 'charset' => 'AL32UTF8',
);
if ($host != '') {
$dsn['hostspec'] = $host;
$dsn['database'] = $name;
} else { // use dbname for hostspec
$dsn['hostspec'] = $name;
+ $dsn['database'] = $user;
}
break;
+ default:
+ return false;
}
// Try to establish connection
@@ -244,7 +266,7 @@ class OC_DB {
echo( '<b>can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')</center>');
OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL);
OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL);
- die( $error );
+ die();
}
// We always, really always want associative arrays
@@ -257,8 +279,10 @@ class OC_DB {
/**
* @brief Prepare a SQL query
- * @param $query Query string
- * @returns prepared SQL query
+ * @param string $query Query string
+ * @param int $limit
+ * @param int $offset
+ * @return MDB2_Statement_Common prepared SQL query
*
* SQL query via MDB2 prepare(), needs to be execute()'d!
*/
@@ -273,8 +297,10 @@ class OC_DB {
//FIXME: check limit notation for other dbs
//the following sql thus might needs to take into account db ways of representing it
//(oracle has no LIMIT / OFFSET)
- $limitsql = ' LIMIT ' . $limit;
+ $limit = (int)$limit;
+ $limitsql = ' LIMIT ' . $limit;
if (!is_null($offset)) {
+ $offset = (int)$offset;
$limitsql .= ' OFFSET ' . $offset;
}
//insert limitsql
@@ -297,7 +323,7 @@ class OC_DB {
// Die if we have an error (error means: bad query, not 0 results!)
if( PEAR::isError($result)) {
$entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$query.'<br />';
+ $entry .= 'Offending command was: '.htmlentities($query).'<br />';
OC_Log::write('core', $entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
die( $entry );
@@ -307,7 +333,7 @@ class OC_DB {
$result=self::$connection->prepare($query);
}catch(PDOException $e) {
$entry = 'DB Error: "'.$e->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$query.'<br />';
+ $entry .= 'Offending command was: '.htmlentities($query).'<br />';
OC_Log::write('core', $entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
die( $entry );
@@ -319,8 +345,8 @@ class OC_DB {
/**
* @brief gets last value of autoincrement
- * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
- * @returns id
+ * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix
+ * @return int id
*
* MDB2 lastInsertID()
*
@@ -332,14 +358,14 @@ class OC_DB {
if($table !== null) {
$prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
$suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" );
- $table = str_replace( '*PREFIX*', $prefix, $table );
+ $table = str_replace( '*PREFIX*', $prefix, $table ).$suffix;
}
- return self::$connection->lastInsertId($table.$suffix);
+ return self::$connection->lastInsertId($table);
}
/**
* @brief Disconnect
- * @returns true/false
+ * @return bool
*
* This is good bye, good bye, yeah!
*/
@@ -359,12 +385,13 @@ class OC_DB {
/**
* @brief saves database scheme to xml file
- * @param $file name of file
- * @returns true/false
+ * @param string $file name of file
+ * @param int $mode
+ * @return bool
*
* TODO: write more documentation
*/
- public static function getDbStructure( $file ,$mode=MDB2_SCHEMA_DUMP_STRUCTURE) {
+ public static function getDbStructure( $file, $mode=MDB2_SCHEMA_DUMP_STRUCTURE) {
self::connectScheme();
// write the scheme
@@ -381,8 +408,8 @@ class OC_DB {
/**
* @brief Creates tables from XML file
- * @param $file file to read structure from
- * @returns true/false
+ * @param string $file file to read structure from
+ * @return bool
*
* TODO: write more documentation
*/
@@ -400,14 +427,14 @@ class OC_DB {
$file2 = 'static://db_scheme';
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
- /* FIXME: REMOVE this commented code
- * actually mysql, postgresql, sqlite and oracle support CURRENT_TIMESTAMP
+ /* FIXME: use CURRENT_TIMESTAMP for all databases. mysql supports it as a default for DATETIME since 5.6.5 [1]
+ * as a fallback we could use <default>0000-01-01 00:00:00</default> everywhere
+ * [1] http://bugs.mysql.com/bug.php?id=27645
* http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html
* http://www.postgresql.org/docs/8.1/static/functions-datetime.html
* http://www.sqlite.org/lang_createtable.html
* http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm
*/
-
if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't
$content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content );
}
@@ -443,7 +470,8 @@ class OC_DB {
/**
* @brief update the database scheme
- * @param $file file to read structure from
+ * @param string $file file to read structure from
+ * @return bool
*/
public static function updateDbFromStructure($file) {
$CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
@@ -466,16 +494,17 @@ class OC_DB {
$file2 = 'static://db_scheme';
$content = str_replace( '*dbname*', $previousSchema['name'], $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
- /* FIXME: REMOVE this commented code
- * actually mysql, postgresql, sqlite and oracle support CUURENT_TIMESTAMP
+ /* FIXME: use CURRENT_TIMESTAMP for all databases. mysql supports it as a default for DATETIME since 5.6.5 [1]
+ * as a fallback we could use <default>0000-01-01 00:00:00</default> everywhere
+ * [1] http://bugs.mysql.com/bug.php?id=27645
* http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html
* http://www.postgresql.org/docs/8.1/static/functions-datetime.html
* http://www.sqlite.org/lang_createtable.html
* http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm
+ */
if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't
$content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content );
}
- */
file_put_contents( $file2, $content );
$op = self::$schema->updateDatabase($file2, $previousSchema, array(), false);
@@ -493,7 +522,7 @@ class OC_DB {
/**
* @brief connects to a MDB2 database scheme
- * @returns true/false
+ * @returns bool
*
* Connects to a MDB2 database scheme
*/
@@ -513,12 +542,12 @@ class OC_DB {
}
/**
- * @brief does minor chages to query
- * @param $query Query string
- * @returns corrected query string
+ * @brief does minor changes to query
+ * @param string $query Query string
+ * @return string corrected query string
*
* This function replaces *PREFIX* with the value of $CONFIG_DBTABLEPREFIX
- * and replaces the ` woth ' or " according to the database driver.
+ * and replaces the ` with ' or " according to the database driver.
*/
private static function processQuery( $query ) {
self::connect();
@@ -553,7 +582,7 @@ class OC_DB {
/**
* @brief drop a table
- * @param string $tableNamme the table to drop
+ * @param string $tableName the table to drop
*/
public static function dropTable($tableName) {
self::connectMDB2();
@@ -614,6 +643,7 @@ class OC_DB {
/**
* Start a transaction
+ * @return bool
*/
public static function beginTransaction() {
self::connect();
@@ -622,10 +652,12 @@ class OC_DB {
}
self::$connection->beginTransaction();
self::$inTransaction=true;
+ return true;
}
/**
* Commit the database changes done during a transaction that is in progress
+ * @return bool
*/
public static function commit() {
self::connect();
@@ -634,6 +666,7 @@ class OC_DB {
}
self::$connection->commit();
self::$inTransaction=false;
+ return true;
}
/**
@@ -650,7 +683,7 @@ class OC_DB {
return false;
}
}
-
+
/**
* returns the error code and message as a string for logging
* works with MDB2 and PDOException
@@ -670,7 +703,11 @@ class OC_DB {
$msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
$msg .= 'Driver Code = '.$errorInfo[1] . ', ';
$msg .= 'Driver Message = '.$errorInfo[2];
+ }else{
+ $msg = '';
}
+ }else{
+ $msg = '';
}
return $msg;
}
@@ -680,6 +717,9 @@ class OC_DB {
* small wrapper around PDOStatement to make it behave ,more like an MDB2 Statement
*/
class PDOStatementWrapper{
+ /**
+ * @var PDOStatement
+ */
private $statement=null;
private $lastArguments=array();
diff --git a/lib/eventsource.php b/lib/eventsource.php
index 900b5b101e6..3bada131bdd 100644
--- a/lib/eventsource.php
+++ b/lib/eventsource.php
@@ -38,7 +38,7 @@ class OC_EventSource{
if($this->fallback) {
$this->fallBackId=$_GET['fallback_id'];
header("Content-Type: text/html");
- echo str_repeat('<span></span>'.PHP_EOL,10); //dummy data to keep IE happy
+ echo str_repeat('<span></span>'.PHP_EOL, 10); //dummy data to keep IE happy
}else{
header("Content-Type: text/event-stream");
}
@@ -78,6 +78,6 @@ class OC_EventSource{
* close the connection of the even source
*/
public function close() {
- $this->send('__internal__','close');//server side closing can be an issue, let the client do it
+ $this->send('__internal__', 'close');//server side closing can be an issue, let the client do it
}
-} \ No newline at end of file
+}
diff --git a/lib/filecache.php b/lib/filecache.php
index adcf97753ed..fee3b398251 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -43,14 +43,14 @@ class OC_FileCache{
* - versioned
*/
public static function get($path,$root=false) {
- if(OC_FileCache_Update::hasUpdated($path,$root)) {
+ if(OC_FileCache_Update::hasUpdated($path, $root)) {
if($root===false) {//filesystem hooks are only valid for the default root
- OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$path));
+ OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$path));
}else{
- OC_FileCache_Update::update($path,$root);
+ OC_FileCache_Update::update($path, $root);
}
}
- return OC_FileCache_Cached::get($path,$root);
+ return OC_FileCache_Cached::get($path, $root);
}
/**
@@ -65,21 +65,21 @@ class OC_FileCache{
if($root===false) {
$root=OC_Filesystem::getRoot();
}
- $fullpath=$root.$path;
+ $fullpath=OC_Filesystem::normalizePath($root.'/'.$path);
$parent=self::getParentId($fullpath);
- $id=self::getId($fullpath,'');
+ $id=self::getId($fullpath, '');
if(isset(OC_FileCache_Cached::$savedData[$fullpath])) {
- $data=array_merge(OC_FileCache_Cached::$savedData[$fullpath],$data);
+ $data=array_merge(OC_FileCache_Cached::$savedData[$fullpath], $data);
unset(OC_FileCache_Cached::$savedData[$fullpath]);
}
if($id!=-1) {
- self::update($id,$data);
+ self::update($id, $data);
return;
}
// add parent directory to the file cache if it does not exist yet.
if ($parent == -1 && $fullpath != $root) {
- $parentDir = substr(dirname($path), 0, strrpos(dirname($path), DIRECTORY_SEPARATOR));
+ $parentDir = dirname($path);
self::scanFile($parentDir);
$parent = self::getParentId($fullpath);
}
@@ -102,9 +102,9 @@ class OC_FileCache{
$data['versioned']=(int)$data['versioned'];
$user=OC_User::getUser();
$query=OC_DB::prepare('INSERT INTO `*PREFIX*fscache`(`parent`, `name`, `path`, `path_hash`, `size`, `mtime`, `ctime`, `mimetype`, `mimepart`,`user`,`writable`,`encrypted`,`versioned`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');
- $result=$query->execute(array($parent,basename($fullpath),$fullpath,md5($fullpath),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned']));
+ $result=$query->execute(array($parent, basename($fullpath), $fullpath, md5($fullpath), $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], $mimePart, $user, $data['writable'], $data['encrypted'], $data['versioned']));
if(OC_DB::isError($result)) {
- OC_Log::write('files','error while writing file('.$fullpath.') to cache',OC_Log::ERROR);
+ OC_Log::write('files', 'error while writing file('.$fullpath.') to cache', OC_Log::ERROR);
}
if($cache=OC_Cache::getUserCache(true)) {
@@ -137,11 +137,11 @@ class OC_FileCache{
}
$arguments[]=$id;
- $sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ',$queryParts).' WHERE `id`=?';
+ $sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ', $queryParts).' WHERE `id`=?';
$query=OC_DB::prepare($sql);
$result=$query->execute($arguments);
if(OC_DB::isError($result)) {
- OC_Log::write('files','error while updating file('.$id.') in cache',OC_Log::ERROR);
+ OC_Log::write('files', 'error while updating file('.$id.') in cache', OC_Log::ERROR);
}
}
@@ -163,10 +163,10 @@ class OC_FileCache{
$newPath=$root.$newPath;
$newParent=self::getParentId($newPath);
$query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `parent`=? ,`name`=?, `path`=?, `path_hash`=? WHERE `path_hash`=?');
- $query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath)));
+ $query->execute(array($newParent, basename($newPath), $newPath, md5($newPath), md5($oldPath)));
if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$oldPath)) {
- $cache->set('fileid/'.$newPath,$cache->get('fileid/'.$oldPath));
+ $cache->set('fileid/'.$newPath, $cache->get('fileid/'.$oldPath));
$cache->remove('fileid/'.$oldPath);
}
@@ -175,11 +175,11 @@ class OC_FileCache{
$updateQuery=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `path`=?, `path_hash`=? WHERE `path_hash`=?');
while($row= $query->execute(array($oldPath.'/%'))->fetchRow()) {
$old=$row['path'];
- $new=$newPath.substr($old,$oldLength);
- $updateQuery->execute(array($new,md5($new),md5($old)));
+ $new=$newPath.substr($old, $oldLength);
+ $updateQuery->execute(array($new, md5($new), md5($old)));
if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$old)) {
- $cache->set('fileid/'.$new,$cache->get('fileid/'.$old));
+ $cache->set('fileid/'.$new, $cache->get('fileid/'.$old));
$cache->remove('fileid/'.$old);
}
}
@@ -203,7 +203,7 @@ class OC_FileCache{
OC_Cache::remove('fileid/'.$root.$path);
}
-
+
/**
* return array of filenames matching the querty
* @param string $query
@@ -217,17 +217,23 @@ class OC_FileCache{
}
$rootLen=strlen($root);
if(!$returnData) {
- $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `name` LIKE ? AND `user`=?');
+ $select = '`path`';
}else{
- $query=OC_DB::prepare('SELECT * FROM `*PREFIX*fscache` WHERE `name` LIKE ? AND `user`=?');
+ $select = '*';
+ }
+ if (OC_Config::getValue('dbtype') === 'oci8') {
+ $where = 'LOWER(`name`) LIKE LOWER(?) AND `user`=?';
+ } else {
+ $where = '`name` LIKE ? AND `user`=?';
}
+ $query=OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*fscache` WHERE '.$where);
$result=$query->execute(array("%$search%",OC_User::getUser()));
$names=array();
while($row=$result->fetchRow()) {
if(!$returnData) {
- $names[]=substr($row['path'],$rootLen);
+ $names[]=substr($row['path'], $rootLen);
}else{
- $row['path']=substr($row['path'],$rootLen);
+ $row['path']=substr($row['path'], $rootLen);
$names[]=$row;
}
}
@@ -250,10 +256,10 @@ class OC_FileCache{
* - versioned
*/
public static function getFolderContent($path,$root=false,$mimetype_filter='') {
- if(OC_FileCache_Update::hasUpdated($path,$root,true)) {
- OC_FileCache_Update::updateFolder($path,$root);
+ if(OC_FileCache_Update::hasUpdated($path, $root, true)) {
+ OC_FileCache_Update::updateFolder($path, $root);
}
- return OC_FileCache_Cached::getFolderContent($path,$root,$mimetype_filter);
+ return OC_FileCache_Cached::getFolderContent($path, $root, $mimetype_filter);
}
/**
@@ -263,7 +269,7 @@ class OC_FileCache{
* @return bool
*/
public static function inCache($path,$root=false) {
- return self::getId($path,$root)!=-1;
+ return self::getId($path, $root)!=-1;
}
/**
@@ -285,7 +291,7 @@ class OC_FileCache{
$query=OC_DB::prepare('SELECT `id` FROM `*PREFIX*fscache` WHERE `path_hash`=?');
$result=$query->execute(array(md5($fullPath)));
if(OC_DB::isError($result)) {
- OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
+ OC_Log::write('files', 'error while getting file id of '.$path, OC_Log::ERROR);
return -1;
}
@@ -296,7 +302,7 @@ class OC_FileCache{
$id=-1;
}
if($cache=OC_Cache::getUserCache(true)) {
- $cache->set('fileid/'.$fullPath,$id);
+ $cache->set('fileid/'.$fullPath, $id);
}
return $id;
@@ -313,14 +319,14 @@ class OC_FileCache{
$user=OC_User::getUser();
}
$query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `id`=? AND `user`=?');
- $result=$query->execute(array($id,$user));
+ $result=$query->execute(array($id, $user));
$row=$result->fetchRow();
$path=$row['path'];
$root='/'.$user.'/files';
- if(substr($path,0,strlen($root))!=$root) {
+ if(substr($path, 0, strlen($root))!=$root) {
return false;
}
- return substr($path,strlen($root));
+ return substr($path, strlen($root));
}
/**
@@ -332,7 +338,7 @@ class OC_FileCache{
if($path=='/') {
return -1;
}else{
- return self::getId(dirname($path),'');
+ return self::getId(dirname($path), '');
}
}
@@ -344,7 +350,7 @@ class OC_FileCache{
*/
public static function increaseSize($path,$sizeDiff, $root=false) {
if($sizeDiff==0) return;
- $id=self::getId($path,$root);
+ $id=self::getId($path, $root);
while($id!=-1) {//walk up the filetree increasing the size of all parent folders
$query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?');
$query->execute(array($sizeDiff,$id));
@@ -362,7 +368,7 @@ class OC_FileCache{
*/
public static function scan($path,$eventSource=false,&$count=0,$root=false) {
if($eventSource) {
- $eventSource->send('scanning',array('file'=>$path,'count'=>$count));
+ $eventSource->send('scanning', array('file'=>$path, 'count'=>$count));
}
$lastSend=$count;
// NOTE: Ugly hack to prevent shared files from going into the cache (the source already exists somewhere in the cache)
@@ -374,7 +380,7 @@ class OC_FileCache{
}else{
$view=new OC_FilesystemView($root);
}
- self::scanFile($path,$root);
+ self::scanFile($path, $root);
$dh=$view->opendir($path.'/');
$totalSize=0;
if($dh) {
@@ -382,13 +388,13 @@ class OC_FileCache{
if($filename != '.' and $filename != '..') {
$file=$path.'/'.$filename;
if($view->is_dir($file.'/')) {
- self::scan($file,$eventSource,$count,$root);
+ self::scan($file, $eventSource, $count, $root);
}else{
- $totalSize+=self::scanFile($file,$root);
+ $totalSize+=self::scanFile($file, $root);
$count++;
if($count>$lastSend+25 and $eventSource) {
$lastSend=$count;
- $eventSource->send('scanning',array('file'=>$path,'count'=>$count));
+ $eventSource->send('scanning', array('file'=>$path, 'count'=>$count));
}
}
}
@@ -420,6 +426,7 @@ class OC_FileCache{
$mimetype=$view->getMimeType($path);
$stat=$view->stat($path);
if($mimetype=='httpd/unix-directory') {
+ $stat['size'] = 0;
$writable=$view->is_writable($path.'/');
}else{
$writable=$view->is_writable($path);
@@ -429,7 +436,7 @@ class OC_FileCache{
if($path=='/') {
$path='';
}
- self::put($path,$stat,$root);
+ self::put($path, $stat, $root);
return $stat['size'];
}
@@ -455,14 +462,14 @@ class OC_FileCache{
$user=OC_User::getUser();
if(!$part2) {
$query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `mimepart`=? AND `user`=? AND `path` LIKE ?');
- $result=$query->execute(array($part1,$user, $root));
+ $result=$query->execute(array($part1, $user, $root));
}else{
$query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `mimetype`=? AND `user`=? AND `path` LIKE ? ');
- $result=$query->execute(array($part1.'/'.$part2,$user, $root));
+ $result=$query->execute(array($part1.'/'.$part2, $user, $root));
}
$names=array();
while($row=$result->fetchRow()) {
- $names[]=substr($row['path'],$rootLen);
+ $names[]=substr($row['path'], $rootLen);
}
return $names;
}
@@ -481,16 +488,31 @@ class OC_FileCache{
*/
public static function clear($user='') {
if($user) {
- $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE user=?');
+ $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE `user`=?');
$query->execute(array($user));
}else{
$query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache`');
$query->execute();
}
}
+
+ /**
+ * trigger an update for the cache by setting the mtimes to 0
+ * @param string $user (optional)
+ */
+ public static function triggerUpdate($user=''){
+ if($user) {
+ $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `mtime`=0 WHERE `user`=? AND `mimetype`="httpd/unix-directory"');
+ $query->execute(array($user));
+ }else{
+ $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `mtime`=0 AND `mimetype`="httpd/unix-directory"');
+ $query->execute();
+ }
+ }
}
//watch for changes and try to keep the cache up to date
-OC_Hook::connect('OC_Filesystem','post_write','OC_FileCache_Update','fileSystemWatcherWrite');
-OC_Hook::connect('OC_Filesystem','post_delete','OC_FileCache_Update','fileSystemWatcherDelete');
-OC_Hook::connect('OC_Filesystem','post_rename','OC_FileCache_Update','fileSystemWatcherRename');
+OC_Hook::connect('OC_Filesystem', 'post_write', 'OC_FileCache_Update', 'fileSystemWatcherWrite');
+OC_Hook::connect('OC_Filesystem', 'post_delete', 'OC_FileCache_Update', 'fileSystemWatcherDelete');
+OC_Hook::connect('OC_Filesystem', 'post_rename', 'OC_FileCache_Update', 'fileSystemWatcherRename');
+OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_FileCache_Update', 'deleteFromUser');
diff --git a/lib/filecache/update.php b/lib/filecache/update.php
index 2b64a2a90ff..f9d64d0ae99 100644
--- a/lib/filecache/update.php
+++ b/lib/filecache/update.php
@@ -81,10 +81,13 @@ class OC_FileCache_Update{
$dh=$view->opendir($path.'/');
if($dh) {//check for changed/new files
while (($filename = readdir($dh)) !== false) {
- if($filename != '.' and $filename != '..') {
+ if($filename != '.' and $filename != '..' and $filename != '') {
$file=$path.'/'.$filename;
- if(self::hasUpdated($file, $root)) {
- if($root===false) {//filesystem hooks are only valid for the default root
+ $isDir=$view->is_dir($file);
+ if(self::hasUpdated($file, $root, $isDir)) {
+ if($isDir){
+ self::updateFolder($file, $root);
+ }elseif($root===false) {//filesystem hooks are only valid for the default root
OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$file));
}else{
self::update($file, $root);
@@ -136,7 +139,7 @@ class OC_FileCache_Update{
}
/**
- * update the filecache according to changes to the fileysystem
+ * update the filecache according to changes to the filesystem
* @param string path
* @param string root (optional)
*/
@@ -171,7 +174,9 @@ class OC_FileCache_Update{
}else{
$size=OC_FileCache::scanFile($path, $root);
}
- OC_FileCache::increaseSize(dirname($path), $size-$cachedSize, $root);
+ if($path !== '' and $path !== '/'){
+ OC_FileCache::increaseSize(dirname($path), $size-$cachedSize, $root);
+ }
}
/**
@@ -211,4 +216,12 @@ class OC_FileCache_Update{
OC_FileCache::increaseSize(dirname($newPath), $oldSize, $root);
OC_FileCache::move($oldPath, $newPath);
}
-} \ No newline at end of file
+
+ /**
+ * delete files owned by user from the cache
+ * @param string $parameters$parameters["uid"])
+ */
+ public static function deleteFromUser($parameters) {
+ OC_FileCache::clear($parameters["uid"]);
+ }
+}
diff --git a/lib/filechunking.php b/lib/filechunking.php
index d03af226d8b..55a4d730430 100644
--- a/lib/filechunking.php
+++ b/lib/filechunking.php
@@ -55,12 +55,13 @@ class OC_FileChunking {
public function assemble($f) {
$cache = $this->getCache();
$prefix = $this->getPrefix();
+ $count = 0;
for($i=0; $i < $this->info['chunkcount']; $i++) {
$chunk = $cache->get($prefix.$i);
$cache->remove($prefix.$i);
- fwrite($f,$chunk);
+ $count += fwrite($f, $chunk);
}
- fclose($f);
+ return $count;
}
public function signature_split($orgfile, $input) {
@@ -91,4 +92,57 @@ class OC_FileChunking {
'count' => $count,
);
}
+
+ public function file_assemble($path) {
+ $absolutePath = OC_Filesystem::normalizePath(OC_Filesystem::getView()->getAbsolutePath($path));
+ $data = '';
+ // use file_put_contents as method because that best matches what this function does
+ if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && OC_Filesystem::isValidPath($path)) {
+ $path = OC_Filesystem::getView()->getRelativePath($absolutePath);
+ $exists = OC_Filesystem::file_exists($path);
+ $run = true;
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_create,
+ array(
+ OC_Filesystem::signal_param_path => $path,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_write,
+ array(
+ OC_Filesystem::signal_param_path => $path,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ if(!$run) {
+ return false;
+ }
+ $target = OC_Filesystem::fopen($path, 'w');
+ if($target) {
+ $count = $this->assemble($target);
+ fclose($target);
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_create,
+ array( OC_Filesystem::signal_param_path => $path)
+ );
+ }
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_write,
+ array( OC_Filesystem::signal_param_path => $path)
+ );
+ OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
+ return $count > 0;
+ }else{
+ return false;
+ }
+ }
+ }
}
diff --git a/lib/fileproxy.php b/lib/fileproxy.php
index 17380c656a3..3e7f1aa1c41 100644
--- a/lib/fileproxy.php
+++ b/lib/fileproxy.php
@@ -52,7 +52,7 @@ class OC_FileProxy{
* this implements a dummy proxy for all operations
*/
public function __call($function,$arguments) {
- if(substr($function,0,3)=='pre') {
+ if(substr($function, 0, 3)=='pre') {
return true;
}else{
return $arguments[1];
@@ -70,7 +70,7 @@ class OC_FileProxy{
public static function getProxies($operation) {
$proxies=array();
foreach(self::$proxies as $proxy) {
- if(method_exists($proxy,$operation)) {
+ if(method_exists($proxy, $operation)) {
$proxies[]=$proxy;
}
}
diff --git a/lib/fileproxy/fileoperations.php b/lib/fileproxy/fileoperations.php
new file mode 100644
index 00000000000..23fb63fcfb1
--- /dev/null
+++ b/lib/fileproxy/fileoperations.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Bjoern Schiessle
+ * @copyright 2012 Bjoern Schiessle <schiessle@owncloud.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * check if standard file operations
+ */
+
+class OC_FileProxy_FileOperations extends OC_FileProxy{
+ static $rootView;
+
+ public function premkdir($path) {
+ if(!self::$rootView){
+ self::$rootView = new OC_FilesystemView('');
+ }
+ return !self::$rootView->file_exists($path);
+ }
+
+} \ No newline at end of file
diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php
index adbff3d301a..012be582a51 100644
--- a/lib/fileproxy/quota.php
+++ b/lib/fileproxy/quota.php
@@ -26,52 +26,59 @@
*/
class OC_FileProxy_Quota extends OC_FileProxy{
- private $userQuota=-1;
+ static $rootView;
+ private $userQuota=array();
/**
- * get the quota for the current user
+ * get the quota for the user
+ * @param user
* @return int
*/
- private function getQuota() {
- if($this->userQuota!=-1) {
- return $this->userQuota;
+ private function getQuota($user) {
+ if(in_array($user, $this->userQuota)) {
+ return $this->userQuota[$user];
}
- $userQuota=OC_Preferences::getValue(OC_User::getUser(),'files','quota','default');
+ $userQuota=OC_Preferences::getValue($user,'files','quota','default');
if($userQuota=='default') {
$userQuota=OC_AppConfig::getValue('files','default_quota','none');
}
if($userQuota=='none') {
- $this->userQuota=0;
+ $this->userQuota[$user]=0;
}else{
- $this->userQuota=OC_Helper::computerFileSize($userQuota);
+ $this->userQuota[$user]=OC_Helper::computerFileSize($userQuota);
}
- return $this->userQuota;
+ return $this->userQuota[$user];
}
/**
- * get the free space in the users home folder
+ * get the free space in the path's owner home folder
+ * @param path
* @return int
*/
- private function getFreeSpace() {
- $rootInfo=OC_FileCache_Cached::get('');
+ private function getFreeSpace($path) {
+ $storage=OC_Filesystem::getStorage($path);
+ $owner=$storage->getOwner($path);
+
+ $totalSpace=$this->getQuota($owner);
+ if($totalSpace==0) {
+ return 0;
+ }
+
+ $rootInfo=OC_FileCache::get('', "/".$owner."/files");
// TODO Remove after merge of share_api
- if (OC_FileCache::inCache('/Shared')) {
- $sharedInfo=OC_FileCache_Cached::get('/Shared');
+ if (OC_FileCache::inCache('/Shared', "/".$owner."/files")) {
+ $sharedInfo=OC_FileCache::get('/Shared', "/".$owner."/files");
} else {
$sharedInfo = null;
}
$usedSpace=isset($rootInfo['size'])?$rootInfo['size']:0;
$usedSpace=isset($sharedInfo['size'])?$usedSpace-$sharedInfo['size']:$usedSpace;
- $totalSpace=$this->getQuota();
- if($totalSpace==0) {
- return 0;
- }
return $totalSpace-$usedSpace;
}
-
+
public function postFree_space($path,$space) {
- $free=$this->getFreeSpace();
+ $free=$this->getFreeSpace($path);
if($free==0) {
return $space;
}
@@ -82,18 +89,21 @@ class OC_FileProxy_Quota extends OC_FileProxy{
if (is_resource($data)) {
$data = '';//TODO: find a way to get the length of the stream without emptying it
}
- return (strlen($data)<$this->getFreeSpace() or $this->getFreeSpace()==0);
+ return (strlen($data)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0);
}
public function preCopy($path1,$path2) {
- return (OC_Filesystem::filesize($path1)<$this->getFreeSpace() or $this->getFreeSpace()==0);
+ if(!self::$rootView){
+ self::$rootView = new OC_FilesystemView('');
+ }
+ return (self::$rootView->filesize($path1)<$this->getFreeSpace($path2) or $this->getFreeSpace($path2)==0);
}
public function preFromTmpFile($tmpfile,$path) {
- return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0);
+ return (filesize($tmpfile)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0);
}
public function preFromUploadedFile($tmpfile,$path) {
- return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0);
+ return (filesize($tmpfile)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0);
}
-} \ No newline at end of file
+}
diff --git a/lib/files.php b/lib/files.php
index 63dd96b9509..b4d4de1c995 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -29,6 +29,37 @@ class OC_Files {
static $tmpFiles=array();
/**
+ * get the filesystem info
+ * @param string path
+ * @return array
+ *
+ * returns an associative array with the following keys:
+ * - size
+ * - mtime
+ * - ctime
+ * - mimetype
+ * - encrypted
+ * - versioned
+ */
+ public static function getFileInfo($path) {
+ if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
+ if ($path == '/Shared') {
+ list($info) = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
+ }else{
+ $info['size'] = OC_Filesystem::filesize($path);
+ $info['mtime'] = OC_Filesystem::filemtime($path);
+ $info['ctime'] = OC_Filesystem::filectime($path);
+ $info['mimetype'] = OC_Filesystem::getMimeType($path);
+ $info['encrypted'] = false;
+ $info['versioned'] = false;
+ }
+ } else {
+ $info = OC_FileCache::get($path);
+ }
+ return $info;
+ }
+
+ /**
* get the content of a directory
* @param dir $directory path under datadirectory
*/
@@ -78,7 +109,24 @@ class OC_Files {
return $files;
}
-
+ public static function searchByMime($mimetype_filter) {
+ $files = array();
+ $dirs_to_check = array('');
+ while (!empty($dirs_to_check)) {
+ // get next subdir to check
+ $dir = array_pop($dirs_to_check);
+ $dir_content = self::getDirectoryContent($dir, $mimetype_filter);
+ foreach($dir_content as $file) {
+ if ($file['type'] == 'file') {
+ $files[] = $dir.'/'.$file['name'];
+ }
+ else {
+ $dirs_to_check[] = $dir.'/'.$file['name'];
+ }
+ }
+ }
+ return $files;
+ }
/**
* return the content of a file or return a zip file containning multiply files
@@ -88,17 +136,17 @@ class OC_Files {
* @param boolean $only_header ; boolean to only send header of the request
*/
public static function get($dir,$files, $only_header = false) {
- if(strpos($files,';')) {
- $files=explode(';',$files);
+ if(strpos($files, ';')) {
+ $files=explode(';', $files);
}
if(is_array($files)) {
- self::validateZipDownload($dir,$files);
+ self::validateZipDownload($dir, $files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
$filename = OC_Helper::tmpFile('.zip');
- if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
+ if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
exit("cannot open <$filename>\n");
}
foreach($files as $file) {
@@ -106,24 +154,24 @@ class OC_Files {
if(OC_Filesystem::is_file($file)) {
$tmpFile=OC_Filesystem::toTmpFile($file);
self::$tmpFiles[]=$tmpFile;
- $zip->addFile($tmpFile,basename($file));
+ $zip->addFile($tmpFile, basename($file));
}elseif(OC_Filesystem::is_dir($file)) {
- self::zipAddDir($file,$zip);
+ self::zipAddDir($file, $zip);
}
}
$zip->close();
set_time_limit($executionTime);
}elseif(OC_Filesystem::is_dir($dir.'/'.$files)) {
- self::validateZipDownload($dir,$files);
+ self::validateZipDownload($dir, $files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
$filename = OC_Helper::tmpFile('.zip');
- if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
+ if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
exit("cannot open <$filename>\n");
}
$file=$dir.'/'.$files;
- self::zipAddDir($file,$zip);
+ self::zipAddDir($file, $zip);
$zip->close();
set_time_limit($executionTime);
}else{
@@ -145,7 +193,7 @@ class OC_Files {
}elseif($zip or !OC_Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template( '', '404', 'guest' );
- $tmpl->assign('file',$filename);
+ $tmpl->assign('file', $filename);
$tmpl->printPage();
}else{
header("HTTP/1.0 403 Forbidden");
@@ -157,7 +205,7 @@ class OC_Files {
return ;
}
if($zip) {
- $handle=fopen($filename,'r');
+ $handle=fopen($filename, 'r');
if ($handle) {
$chunkSize = 8*1024;// 1 MB chunks
while (!feof($handle)) {
@@ -187,9 +235,9 @@ class OC_Files {
if(OC_Filesystem::is_file($file)) {
$tmpFile=OC_Filesystem::toTmpFile($file);
OC_Files::$tmpFiles[]=$tmpFile;
- $zip->addFile($tmpFile,$internalDir.$filename);
+ $zip->addFile($tmpFile, $internalDir.$filename);
}elseif(OC_Filesystem::is_dir($file)) {
- self::zipAddDir($file,$zip,$internalDir);
+ self::zipAddDir($file, $zip, $internalDir);
}
}
}
@@ -205,7 +253,7 @@ class OC_Files {
if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')) {
$targetFile=self::normalizePath($targetDir.'/'.$target);
$sourceFile=self::normalizePath($sourceDir.'/'.$source);
- return OC_Filesystem::rename($sourceFile,$targetFile);
+ return OC_Filesystem::rename($sourceFile, $targetFile);
} else {
return false;
}
@@ -223,7 +271,7 @@ class OC_Files {
if(OC_User::isLoggedIn()) {
$targetFile=$targetDir.'/'.$target;
$sourceFile=$sourceDir.'/'.$source;
- return OC_Filesystem::copy($sourceFile,$targetFile);
+ return OC_Filesystem::copy($sourceFile, $targetFile);
}
}
@@ -342,11 +390,11 @@ class OC_Files {
* @return string guessed mime type
*/
static function pull($source,$token,$dir,$file) {
- $tmpfile=tempnam(get_temp_dir(),'remoteCloudFile');
+ $tmpfile=tempnam(get_temp_dir(), 'remoteCloudFile');
$fp=fopen($tmpfile,'w+');
$url=$source.="/files/pull.php?token=$token";
$ch=curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
+ curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
fclose($fp);
@@ -354,7 +402,7 @@ class OC_Files {
$httpCode=$info['http_code'];
curl_close($ch);
if($httpCode==200 or $httpCode==0) {
- OC_Filesystem::fromTmpFile($tmpfile,$dir.'/'.$file);
+ OC_Filesystem::fromTmpFile($tmpfile, $dir.'/'.$file);
return true;
}else{
return false;
@@ -375,8 +423,8 @@ class OC_Files {
$size -=1;
} else {
$size=OC_Helper::humanFileSize($size);
- $size=substr($size,0,-1);//strip the B
- $size=str_replace(' ','',$size); //remove the space between the size and the postfix
+ $size=substr($size, 0, -1);//strip the B
+ $size=str_replace(' ', '', $size); //remove the space between the size and the postfix
}
//don't allow user to break his config -- broken or malicious size input
@@ -399,7 +447,7 @@ class OC_Files {
$setting = 'php_value '.$key.' '.$size;
$hasReplaced = 0;
$content = preg_replace($pattern, $setting, $htaccess, 1, $hasReplaced);
- if($content !== NULL) {
+ if($content !== null) {
$htaccess = $content;
}
if($hasReplaced == 0) {
@@ -411,7 +459,7 @@ class OC_Files {
if(is_writable(OC::$SERVERROOT.'/.htaccess')) {
file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess);
return OC_Helper::computerFileSize($size);
- } else { OC_Log::write('files','Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions',OC_Log::WARN); }
+ } else { OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); }
return false;
}
@@ -426,7 +474,7 @@ class OC_Files {
$old='';
while($old!=$path) {//replace any multiplicity of slashes with a single one
$old=$path;
- $path=str_replace('//','/',$path);
+ $path=str_replace('//', '/', $path);
}
return $path;
}
@@ -438,6 +486,6 @@ function fileCmp($a,$b) {
}elseif($a['type']!='dir' and $b['type']=='dir') {
return 1;
}else{
- return strnatcasecmp($a['name'],$b['name']);
+ return strnatcasecmp($a['name'], $b['name']);
}
}
diff --git a/lib/filestorage.php b/lib/filestorage.php
index 5bfd09253d5..146cecf4efa 100644
--- a/lib/filestorage.php
+++ b/lib/filestorage.php
@@ -63,4 +63,5 @@ abstract class OC_Filestorage{
* returning true for other changes in the folder is optional
*/
abstract public function hasUpdated($path,$time);
+ abstract public function getOwner($path);
}
diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php
index 351714437c5..f24a5704913 100644
--- a/lib/filestorage/common.php
+++ b/lib/filestorage/common.php
@@ -260,7 +260,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
if($dh) {
while($item=readdir($dh)) {
if ($item == '.' || $item == '..') continue;
- if(strstr(strtolower($item),strtolower($query))!==false) {
+ if(strstr(strtolower($item), strtolower($query))!==false) {
$files[]=$dir.'/'.$item;
}
if($this->is_dir($dir.'/'.$item)) {
@@ -279,4 +279,13 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
public function hasUpdated($path,$time) {
return $this->filemtime($path)>$time;
}
+
+ /**
+ * get the owner of a path
+ * @param $path The path to get the owner
+ * @return string uid or false
+ */
+ public function getOwner($path) {
+ return OC_User::getUser();
+ }
}
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 80aa548047c..731ac4a3c72 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -103,7 +103,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
if(!$this->file_exists($path2)) {
$this->mkdir($path2);
}
- $source=substr($path1,strrpos($path1,'/')+1);
+ $source=substr($path1, strrpos($path1,'/')+1);
$path2.=$source;
}
return copy($this->datadir.$path1,$this->datadir.$path2);
@@ -178,7 +178,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
$files=array();
foreach (scandir($this->datadir.$dir) as $item) {
if ($item == '.' || $item == '..') continue;
- if(strstr(strtolower($item),strtolower($query))!==false) {
+ if(strstr(strtolower($item), strtolower($query))!==false) {
$files[]=$dir.'/'.$item;
}
if(is_dir($this->datadir.$dir.'/'.$item)) {
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 92eb4fa4778..bc30dac7fa1 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -46,6 +46,7 @@
class OC_Filesystem{
static private $storages=array();
static private $mounts=array();
+ static private $loadedUsers=array();
public static $loaded=false;
/**
* @var OC_Filestorage $defaultInstance
@@ -147,7 +148,7 @@ class OC_Filesystem{
* @return string
*/
static public function getMountPoint($path) {
- OC_Hook::emit(self::CLASSNAME,'get_mountpoint',array('path'=>$path));
+ OC_Hook::emit(self::CLASSNAME,'get_mountpoint', array('path'=>$path));
if(!$path) {
$path='/';
}
@@ -175,15 +176,28 @@ class OC_Filesystem{
*/
static public function getInternalPath($path) {
$mountPoint=self::getMountPoint($path);
- $internalPath=substr($path,strlen($mountPoint));
+ $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
* @return OC_Filestorage
*/
static public function getStorage($path) {
+ $user = ltrim(substr($path, 0, strpos($path, '/', 1)), '/');
+ // check mount points if file was shared from a different user
+ if ($user != OC_User::getUser() && !self::mountPointsLoaded($user)) {
+ OC_Util::loadUserMountPoints($user);
+ self::loadSystemMountPoints($user);
+ self::$loadedUsers[] = $user;
+ }
+
$mountpoint=self::getMountPoint($path);
if($mountpoint) {
if(!isset(OC_Filesystem::$storages[$mountpoint])) {
@@ -194,56 +208,63 @@ class OC_Filesystem{
}
}
- static public function init($root) {
+ static private function loadSystemMountPoints($user) {
+ if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
+ $mountConfig=include OC::$SERVERROOT.'/config/mount.php';
+ if(isset($mountConfig['global'])) {
+ foreach($mountConfig['global'] as $mountPoint=>$options) {
+ self::mount($options['class'],$options['options'],$mountPoint);
+ }
+ }
+
+ if(isset($mountConfig['group'])) {
+ foreach($mountConfig['group'] as $group=>$mounts) {
+ if(OC_Group::inGroup($user,$group)) {
+ foreach($mounts as $mountPoint=>$options) {
+ $mountPoint=self::setUserVars($mountPoint, $user);
+ foreach($options as &$option) {
+ $option=self::setUserVars($option, $user);
+ }
+ self::mount($options['class'],$options['options'],$mountPoint);
+ }
+ }
+ }
+ }
+
+ if(isset($mountConfig['user'])) {
+ foreach($mountConfig['user'] as $user=>$mounts) {
+ if($user==='all' or strtolower($user)===strtolower($user)) {
+ foreach($mounts as $mountPoint=>$options) {
+ $mountPoint=self::setUserVars($mountPoint, $user);
+ foreach($options as &$option) {
+ $option=self::setUserVars($option, $user);
+ }
+ self::mount($options['class'],$options['options'],$mountPoint);
+ }
+ }
+ }
+ }
+
+ $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;
}
self::$defaultInstance=new OC_FilesystemView($root);
//load custom mount config
- if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
- $mountConfig=include(OC::$SERVERROOT.'/config/mount.php');
- if(isset($mountConfig['global'])) {
- foreach($mountConfig['global'] as $mountPoint=>$options) {
- self::mount($options['class'],$options['options'],$mountPoint);
- }
- }
-
- if(isset($mountConfig['group'])) {
- foreach($mountConfig['group'] as $group=>$mounts) {
- if(OC_Group::inGroup(OC_User::getUser(),$group)) {
- foreach($mounts as $mountPoint=>$options) {
- $mountPoint=self::setUserVars($mountPoint);
- foreach($options as &$option) {
- $option=self::setUserVars($option);
- }
- self::mount($options['class'],$options['options'],$mountPoint);
- }
- }
- }
- }
-
- if(isset($mountConfig['user'])) {
- foreach($mountConfig['user'] as $user=>$mounts) {
- if($user==='all' or strtolower($user)===strtolower(OC_User::getUser())) {
- foreach($mounts as $mountPoint=>$options) {
- $mountPoint=self::setUserVars($mountPoint);
- foreach($options as &$option) {
- $option=self::setUserVars($option);
- }
- self::mount($options['class'],$options['options'],$mountPoint);
- }
- }
- }
- }
-
- $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::clear();
- OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
- }
+ if (!isset($user)) {
+ $user = OC_User::getUser();
}
+ self::loadSystemMountPoints($user);
self::$loaded=true;
}
@@ -253,8 +274,12 @@ class OC_Filesystem{
* @param string intput
* @return string
*/
- private static function setUserVars($input) {
- return str_replace('$user',OC_User::getUser(),$input);
+ private static function setUserVars($input, $user) {
+ if (isset($user)) {
+ return str_replace('$user', $user,$input);
+ } else {
+ return str_replace('$user',OC_User::getUser(),$input);
+ }
}
/**
@@ -357,7 +382,7 @@ class OC_Filesystem{
* @return string
*/
static public function getLocalPath($path) {
- $datadir = OC_User::getHome($user).'/files';
+ $datadir = OC_User::getHome(OC_User::getUser()).'/files';
$newpath = $path;
if (strncmp($newpath, $datadir, strlen($datadir)) == 0) {
$newpath = substr($path, strlen($datadir));
@@ -521,12 +546,20 @@ class OC_Filesystem{
return self::$defaultInstance->hasUpdated($path,$time);
}
- static public function removeETagHook($params) {
+ static public function removeETagHook($params, $root = false) {
if (isset($params['path'])) {
$path=$params['path'];
} else {
$path=$params['oldpath'];
}
+
+ if ($root) { // reduce path to the required part of it (no 'username/files')
+ $fakeRootView = new OC_FilesystemView($root);
+ $count = 1;
+ $path=str_replace(OC_App::getStorage("files")->getAbsolutePath(), "", $fakeRootView->getAbsolutePath($path), $count);
+ }
+
+ $path = self::normalizePath($path);
OC_Connector_Sabre_Node::removeETagPropertyForPath($path);
}
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index 743f9403011..872da992fab 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -251,6 +251,9 @@ class OC_FilesystemView {
return $this->basicOperation('filemtime', $path);
}
public function touch($path, $mtime=null) {
+ if(!is_null($mtime) and !is_numeric($mtime)){
+ $mtime = strtotime($mtime);
+ }
return $this->basicOperation('touch', $path, array('write'), $mtime);
}
public function file_get_contents($path) {
@@ -263,24 +266,26 @@ class OC_FilesystemView {
$path = $this->getRelativePath($absolutePath);
$exists = $this->file_exists($path);
$run = true;
- if(!$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_create,
+ array(
+ OC_Filesystem::signal_param_path => $path,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_create,
+ OC_Filesystem::signal_write,
array(
OC_Filesystem::signal_param_path => $path,
OC_Filesystem::signal_param_run => &$run
)
);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_write,
- array(
- OC_Filesystem::signal_param_path => $path,
- OC_Filesystem::signal_param_run => &$run
- )
- );
if(!$run) {
return false;
}
@@ -289,18 +294,20 @@ class OC_FilesystemView {
$count=OC_Helper::streamCopy($data, $target);
fclose($target);
fclose($data);
- if(!$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_create,
+ array( OC_Filesystem::signal_param_path => $path)
+ );
+ }
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_create,
+ OC_Filesystem::signal_post_write,
array( OC_Filesystem::signal_param_path => $path)
);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_write,
- array( OC_Filesystem::signal_param_path => $path)
- );
OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $count > 0;
}else{
@@ -330,14 +337,16 @@ class OC_FilesystemView {
return false;
}
$run=true;
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath => $path2,
- OC_Filesystem::signal_param_run => &$run
- )
- );
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename,
+ array(
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath => $path2,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
if($run) {
$mp1 = $this->getMountPoint($path1.$postFix1);
$mp2 = $this->getMountPoint($path2.$postFix2);
@@ -353,14 +362,16 @@ class OC_FilesystemView {
$storage1->unlink($this->getInternalPath($path1.$postFix1));
$result = $count>0;
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_rename,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath => $path2
- )
- );
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_rename,
+ array(
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath => $path2
+ )
+ );
+ }
return $result;
}
}
@@ -378,35 +389,37 @@ class OC_FilesystemView {
return false;
}
$run=true;
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_copy,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath=>$path2,
- OC_Filesystem::signal_param_run => &$run
- )
- );
- $exists=$this->file_exists($path2);
- if($run and !$exists) {
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_create,
- array(
- OC_Filesystem::signal_param_path => $path2,
- OC_Filesystem::signal_param_run => &$run
- )
- );
- }
- if($run) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_write,
+ OC_Filesystem::signal_copy,
array(
- OC_Filesystem::signal_param_path => $path2,
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath=>$path2,
OC_Filesystem::signal_param_run => &$run
)
);
+ $exists=$this->file_exists($path2);
+ if($run and !$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_create,
+ array(
+ OC_Filesystem::signal_param_path => $path2,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
+ if($run) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_write,
+ array(
+ OC_Filesystem::signal_param_path => $path2,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
}
if($run) {
$mp1=$this->getMountPoint($path1.$postFix1);
@@ -420,26 +433,31 @@ class OC_FilesystemView {
$target = $this->fopen($path2.$postFix2, 'w');
$result = OC_Helper::streamCopy($source, $target);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_copy,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath=>$path2
- )
- );
- if(!$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_create,
- array(OC_Filesystem::signal_param_path => $path2)
+ OC_Filesystem::signal_post_copy,
+ array(
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath=>$path2
+ )
);
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_create,
+ array(OC_Filesystem::signal_param_path => $path2)
+ );
+ }
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_write,
+ array( OC_Filesystem::signal_param_path => $path2)
+ );
+ } else { // no real copy, file comes from somewhere else, e.g. version rollback -> just update the file cache and the webdav properties without all the other post_write actions
+ OC_FileCache_Update::update($path2, $this->fakeRoot);
+ OC_Filesystem::removeETagHook(array("path" => $path2), $this->fakeRoot);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_write,
- array( OC_Filesystem::signal_param_path => $path2)
- );
return $result;
}
}
@@ -570,7 +588,7 @@ class OC_FilesystemView {
$result = OC_FileProxy::runPostProxies($operation, $this->getAbsolutePath($path), $result);
if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()) {
if($operation!='fopen') {//no post hooks for fopen, the file stream is still open
- $this->runHooks($hooks,$path,true);
+ $this->runHooks($hooks,$path, true);
}
}
return $result;
diff --git a/lib/group.php b/lib/group.php
index b56a4ad456c..a89c6c55e36 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -35,12 +35,15 @@
*/
class OC_Group {
// The backend used for group management
+ /**
+ * @var OC_Group_Interface[]
+ */
private static $_usedBackends = array();
/**
* @brief set the group backend
* @param string $backend The backend to use for user managment
- * @returns true/false
+ * @return bool
*/
public static function useBackend( $backend ) {
if($backend instanceof OC_Group_Interface) {
@@ -57,20 +60,13 @@ class OC_Group {
/**
* @brief Try to create a new group
- * @param $gid The name of the group to create
- * @returns true/false
+ * @param string $gid The name of the group to create
+ * @return bool
*
- * Trys to create a new group. If the group name already exists, false will
+ * Tries to create a new group. If the group name already exists, false will
* be returned. Basic checking of Group name
- *
- * Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-"
*/
public static function createGroup( $gid ) {
- // Check the name for bad characters
- // Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
- if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $gid )) {
- return false;
- }
// No empty group names!
if( !$gid ) {
return false;
@@ -94,6 +90,7 @@ class OC_Group {
return true;
}
+ return false;
}else{
return false;
}
@@ -101,8 +98,8 @@ class OC_Group {
/**
* @brief delete a group
- * @param $gid gid of the group to delete
- * @returns true/false
+ * @param string $gid gid of the group to delete
+ * @return bool
*
* Deletes a group and removes it from the group_user-table
*/
@@ -126,6 +123,7 @@ class OC_Group {
return true;
}
+ return false;
}else{
return false;
}
@@ -133,9 +131,9 @@ class OC_Group {
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -150,9 +148,9 @@ class OC_Group {
/**
* @brief Add a user to a group
- * @param $uid Name of the user to add to group
- * @param $gid Name of the group in which add the user
- * @returns true/false
+ * @param string $uid Name of the user to add to group
+ * @param string $gid Name of the group in which add the user
+ * @return bool
*
* Adds a user to a group.
*/
@@ -167,7 +165,7 @@ class OC_Group {
OC_Hook::emit( "OC_Group", "pre_addToGroup", array( "run" => &$run, "uid" => $uid, "gid" => $gid ));
if($run) {
- $succes=false;
+ $success=false;
//add the user to the all backends that have the group
foreach(self::$_usedBackends as $backend) {
@@ -175,13 +173,13 @@ class OC_Group {
continue;
if($backend->groupExists($gid)) {
- $succes|=$backend->addToGroup($uid, $gid);
+ $success|=$backend->addToGroup($uid, $gid);
}
}
- if($succes) {
+ if($success) {
OC_Hook::emit( "OC_User", "post_addToGroup", array( "uid" => $uid, "gid" => $gid ));
}
- return $succes;
+ return $success;
}else{
return false;
}
@@ -189,9 +187,9 @@ class OC_Group {
/**
* @brief Removes a user from a group
- * @param $uid Name of the user to remove from group
- * @param $gid Name of the group from which remove the user
- * @returns true/false
+ * @param string $uid Name of the user to remove from group
+ * @param string $gid Name of the group from which remove the user
+ * @return bool
*
* removes the user from a group.
*/
@@ -216,8 +214,8 @@ class OC_Group {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -275,7 +273,10 @@ class OC_Group {
/**
* @brief get a list of all users in several groups
* @param array $gids
- * @returns array with user ids
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
$users = array();
diff --git a/lib/group/backend.php b/lib/group/backend.php
index 1ba34c940cf..9ff432d0663 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -47,7 +47,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief Get all supported actions
- * @returns bitwise-or'ed actions
+ * @return int bitwise-or'ed actions
*
* Returns the supported actions as int to be
* compared with OC_USER_BACKEND_CREATE_USER etc.
@@ -65,8 +65,8 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief Check if backend implements actions
- * @param $actions bitwise-or'ed actions
- * @returns boolean
+ * @param int $actions bitwise-or'ed actions
+ * @return boolean
*
* Returns the supported actions as int to be
* compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
@@ -77,9 +77,9 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -89,8 +89,8 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -101,7 +101,10 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief get a list of all groups
- * @returns array with group names
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with group names
*
* Returns a list with all groups
*/
@@ -121,7 +124,11 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief get a list of all users in a group
- * @returns array with user ids
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
return array();
diff --git a/lib/group/database.php b/lib/group/database.php
index f3012563acf..6eca98ba019 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -44,10 +44,10 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Try to create a new group
- * @param $gid The name of the group to create
- * @returns true/false
+ * @param string $gid The name of the group to create
+ * @return bool
*
- * Trys to create a new group. If the group name already exists, false will
+ * Tries to create a new group. If the group name already exists, false will
* be returned.
*/
public function createGroup( $gid ) {
@@ -70,28 +70,28 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief delete a group
- * @param $gid gid of the group to delete
- * @returns true/false
+ * @param string $gid gid of the group to delete
+ * @return bool
*
* Deletes a group and removes it from the group_user-table
*/
public function deleteGroup( $gid ) {
// Delete the group
$stmt = OC_DB::prepare( "DELETE FROM `*PREFIX*groups` WHERE `gid` = ?" );
- $result = $stmt->execute( array( $gid ));
+ $stmt->execute( array( $gid ));
// Delete the group-user relation
$stmt = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `gid` = ?" );
- $result = $stmt->execute( array( $gid ));
+ $stmt->execute( array( $gid ));
return true;
}
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -105,9 +105,9 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Add a user to a group
- * @param $uid Name of the user to add to group
- * @param $gid Name of the group in which add the user
- * @returns true/false
+ * @param string $uid Name of the user to add to group
+ * @param string $gid Name of the group in which add the user
+ * @return bool
*
* Adds a user to a group.
*/
@@ -124,9 +124,9 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Removes a user from a group
- * @param $uid Name of the user to remove from group
- * @param $gid Name of the group from which remove the user
- * @returns true/false
+ * @param string $uid Name of the user to remove from group
+ * @param string $gid Name of the group from which remove the user
+ * @return bool
*
* removes the user from a group.
*/
@@ -139,8 +139,8 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -160,7 +160,10 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief get a list of all groups
- * @returns array with group names
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with group names
*
* Returns a list with all groups
*/
@@ -190,7 +193,11 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief get a list of all users in a group
- * @returns array with user ids
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public function usersInGroup($gid, $search = '', $limit = null, $offset = null) {
$stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` LIKE ?', $limit, $offset);
diff --git a/lib/group/interface.php b/lib/group/interface.php
index 12cc07a5374..4ef3663837f 100644
--- a/lib/group/interface.php
+++ b/lib/group/interface.php
@@ -24,8 +24,8 @@
interface OC_Group_Interface {
/**
* @brief Check if backend implements actions
- * @param $actions bitwise-or'ed actions
- * @returns boolean
+ * @param int $actions bitwise-or'ed actions
+ * @return boolean
*
* Returns the supported actions as int to be
* compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
@@ -34,9 +34,9 @@ interface OC_Group_Interface {
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -44,8 +44,8 @@ interface OC_Group_Interface {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -54,7 +54,10 @@ interface OC_Group_Interface {
/**
* @brief get a list of all groups
- * @returns array with group names
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with group names
*
* Returns a list with all groups
*/
@@ -69,8 +72,12 @@ interface OC_Group_Interface {
/**
* @brief get a list of all users in a group
- * @returns array with user ids
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
-} \ No newline at end of file
+}
diff --git a/lib/helper.php b/lib/helper.php
index 70b2f78862b..2da06c4cc45 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -30,10 +30,11 @@ class OC_Helper {
/**
* @brief Creates an url
- * @param $app app
- * @param $file file
- * @param $args array with param=>value, will be appended to the returned url
- * @returns the url
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * The value of $args will be urlencoded
+ * @return string the url
*
* Returns a url to the given app and file.
*/
@@ -62,8 +63,11 @@ class OC_Helper {
}
}
- foreach($args as $k => $v) {
- $urlLinkTo .= '&'.$k.'='.$v;
+ if (!empty($args)) {
+ $urlLinkTo .= '?';
+ foreach($args as $k => $v) {
+ $urlLinkTo .= '&'.$k.'='.urlencode($v);
+ }
}
return $urlLinkTo;
@@ -71,10 +75,11 @@ class OC_Helper {
/**
* @brief Creates an absolute url
- * @param $app app
- * @param $file file
- * @param $args array with param=>value, will be appended to the returned url
- * @returns the url
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * The value of $args will be urlencoded
+ * @return string the url
*
* Returns a absolute url to the given app and file.
*/
@@ -85,8 +90,8 @@ class OC_Helper {
/**
* @brief Makes an $url absolute
- * @param $url the url
- * @returns the absolute url
+ * @param string $url the url
+ * @return string the absolute url
*
* Returns a absolute url to the given app and file.
*/
@@ -96,20 +101,31 @@ class OC_Helper {
}
/**
+ * @brief Creates an url for remote use
+ * @param string $service id
+ * @return string the url
+ *
+ * Returns a url to the given service.
+ */
+ public static function linkToRemoteBase( $service ) {
+ return self::linkTo( '', 'remote.php') . '/' . $service;
+ }
+
+ /**
* @brief Creates an absolute url for remote use
- * @param $service id
- * @returns the url
+ * @param string $service id
+ * @return string the url
*
* Returns a absolute url to the given service.
*/
public static function linkToRemote( $service, $add_slash = true ) {
- return self::linkToAbsolute( '', 'remote.php') . '/' . $service . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
+ return self::makeURLAbsolute(self::linkToRemoteBase($service)) . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
}
/**
* @brief Creates an absolute url for public use
- * @param $service id
- * @returns the url
+ * @param string $service id
+ * @return string the url
*
* Returns a absolute url to the given service.
*/
@@ -119,9 +135,9 @@ class OC_Helper {
/**
* @brief Creates path to an image
- * @param $app app
- * @param $image image name
- * @returns the url
+ * @param string $app app
+ * @param string $image image name
+ * @return string the url
*
* Returns the path to the image.
*/
@@ -150,8 +166,8 @@ class OC_Helper {
/**
* @brief get path to icon of file type
- * @param $mimetype mimetype
- * @returns the url
+ * @param string $mimetype mimetype
+ * @return string the url
*
* Returns the path to the image of this file type.
*/
@@ -173,7 +189,7 @@ class OC_Helper {
return OC::$WEBROOT."/core/img/filetypes/$mimetype.png";
}
//try only the first part of the filetype
- $mimetype=substr($mimetype,0,strpos($mimetype,'-'));
+ $mimetype=substr($mimetype,0, strpos($mimetype,'-'));
if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) {
return OC::$WEBROOT."/core/img/filetypes/$mimetype.png";
}
@@ -184,8 +200,8 @@ class OC_Helper {
/**
* @brief Make a human file size
- * @param $bytes file size in bytes
- * @returns a human readable file size
+ * @param int $bytes file size in bytes
+ * @return string a human readable file size
*
* Makes 2048 to 2 kB.
*/
@@ -209,15 +225,14 @@ class OC_Helper {
/**
* @brief Make a computer file size
- * @param $str file size in a fancy format
- * @returns a file size in bytes
+ * @param string $str file size in a fancy format
+ * @return int a file size in bytes
*
* Makes 2kB to 2048.
*
* Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
*/
public static function computerFileSize( $str ) {
- $bytes = 0;
$str=strtolower($str);
$bytes_array = array(
@@ -246,10 +261,10 @@ class OC_Helper {
}
/**
- * @brief Recusive editing of file permissions
- * @param $path path to file or folder
- * @param $filemode unix style file permissions as integer
- *
+ * @brief Recursive editing of file permissions
+ * @param string $path path to file or folder
+ * @param int $filemode unix style file permissions
+ * @return bool
*/
static function chmodr($path, $filemode) {
if (!is_dir($path))
@@ -259,22 +274,22 @@ class OC_Helper {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(is_link($fullpath))
- return FALSE;
+ return false;
elseif(!is_dir($fullpath) && !@chmod($fullpath, $filemode))
- return FALSE;
+ return false;
elseif(!self::chmodr($fullpath, $filemode))
- return FALSE;
+ return false;
}
}
closedir($dh);
if(@chmod($path, $filemode))
- return TRUE;
+ return true;
else
- return FALSE;
+ return false;
}
/**
- * @brief Recusive copying of folders
+ * @brief Recursive copying of folders
* @param string $src source folder
* @param string $dest target folder
*
@@ -296,9 +311,9 @@ class OC_Helper {
}
/**
- * @brief Recusive deletion of folders
+ * @brief Recursive deletion of folders
* @param string $dir path to the folder
- *
+ * @return bool
*/
static function rmdirr($dir) {
if(is_dir($dir)) {
@@ -314,12 +329,14 @@ class OC_Helper {
}
if(file_exists($dir)) {
return false;
+ }else{
+ return true;
}
}
/**
* get the mimetype form a local file
- * @param string path
+ * @param string $path
* @return string
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
*/
@@ -333,8 +350,8 @@ class OC_Helper {
if(strpos($path,'.')) {
//try to guess the type by the file extension
- if(!self::$mimetypes || self::$mimetypes != include('mimetypes.list.php')) {
- self::$mimetypes=include('mimetypes.list.php');
+ if(!self::$mimetypes || self::$mimetypes != include 'mimetypes.list.php') {
+ self::$mimetypes=include 'mimetypes.list.php';
}
$extension=strtolower(strrchr(basename($path), "."));
$extension=substr($extension,1);//remove leading .
@@ -346,7 +363,7 @@ class OC_Helper {
if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) {
$info = @strtolower(finfo_file($finfo,$path));
if($info) {
- $mimeType=substr($info,0,strpos($info,';'));
+ $mimeType=substr($info,0, strpos($info,';'));
}
finfo_close($finfo);
}
@@ -356,19 +373,15 @@ class OC_Helper {
}
if (!$isWrapped and $mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) {
// it looks like we have a 'file' command,
- // lets see it it does have mime support
+ // lets see if it does have mime support
$path=escapeshellarg($path);
$fp = popen("file -i -b $path 2>/dev/null", "r");
$reply = fgets($fp);
pclose($fp);
- //trim the character set from the end of the response
- $mimeType=substr($reply,0,strrpos($reply,' '));
-
- //trim ;
- if (strpos($mimeType, ';') !== false) {
- $mimeType = strstr($mimeType, ';', true);
- }
+ // we have smth like 'text/x-c++; charset=us-ascii\n'
+ // and need to eliminate everything starting with semicolon including trailing LF
+ $mimeType = preg_replace('/;.*/ms', '', trim($reply));
}
return $mimeType;
@@ -376,7 +389,7 @@ class OC_Helper {
/**
* get the mimetype form a data string
- * @param string data
+ * @param string $data
* @return string
*/
static function getStringMimeType($data) {
@@ -396,9 +409,9 @@ class OC_Helper {
/**
* @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d.
- * @param $s name of the var to escape, if set.
- * @param $d default value.
- * @returns the print-safe value.
+ * @param string $s name of the var to escape, if set.
+ * @param string $d default value.
+ * @return string the print-safe value.
*
*/
@@ -412,7 +425,7 @@ class OC_Helper {
}
/**
- * returns "checked"-attribut if request contains selected radio element OR if radio element is the default one -- maybe?
+ * returns "checked"-attribute if request contains selected radio element OR if radio element is the default one -- maybe?
* @param string $s Name of radio-button element name
* @param string $v Value of current radio-button element
* @param string $d Value of default radio-button element
@@ -425,8 +438,8 @@ class OC_Helper {
/**
* detect if a given program is found in the search PATH
*
- * @param string program name
- * @param string optional search path, defaults to $PATH
+ * @param string $program name
+ * @param string $optional search path, defaults to $PATH
* @return bool true if executable program found in path
*/
public static function canExecute($name, $path = false) {
@@ -448,18 +461,16 @@ class OC_Helper {
$dirs = explode(PATH_SEPARATOR, $path);
// WARNING : We have to check if open_basedir is enabled :
$obd = ini_get('open_basedir');
- if($obd != "none")
+ if($obd != "none"){
$obd_values = explode(PATH_SEPARATOR, $obd);
- if(count($obd_values) > 0 and $obd_values[0])
- {
- // open_basedir is in effect !
- // We need to check if the program is in one of these dirs :
- $dirs = $obd_values;
- }
- foreach($dirs as $dir)
- {
- foreach($exts as $ext)
- {
+ if(count($obd_values) > 0 and $obd_values[0]){
+ // open_basedir is in effect !
+ // We need to check if the program is in one of these dirs :
+ $dirs = $obd_values;
+ }
+ }
+ foreach($dirs as $dir){
+ foreach($exts as $ext){
if($check_fn("$dir/$name".$ext))
return true;
}
@@ -469,8 +480,8 @@ class OC_Helper {
/**
* copy the contents of one stream to another
- * @param resource source
- * @param resource target
+ * @param resource $source
+ * @param resource $target
* @return int the number of bytes copied
*/
public static function streamCopy($source,$target) {
@@ -479,14 +490,14 @@ class OC_Helper {
}
$count=0;
while(!feof($source)) {
- $count+=fwrite($target,fread($source,8192));
+ $count+=fwrite($target, fread($source,8192));
}
return $count;
}
/**
* create a temporary file with an unique filename
- * @param string postfix
+ * @param string $postfix
* @return string
*
* temporary files are automatically cleaned up after the script is finished
@@ -550,10 +561,10 @@ class OC_Helper {
$ext = substr($filename, $pos);
} else {
$name = $filename;
+ $ext = '';
}
$newpath = $path . '/' . $filename;
- $newname = $filename;
$counter = 2;
while (OC_Filesystem::file_exists($newpath)) {
$newname = $name . ' (' . $counter . ')' . $ext;
@@ -567,8 +578,8 @@ class OC_Helper {
/*
* checks if $sub is a subdirectory of $parent
*
- * @param $sub
- * @param $parent
+ * @param string $sub
+ * @param string $parent
* @return bool
*/
public static function issubdirectory($sub, $parent) {
@@ -601,9 +612,9 @@ class OC_Helper {
/**
* @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
*
- * @param $input The array to work on
- * @param $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
- * @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
+ * @param array $input The array to work on
+ * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
+ * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return array
*
* Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
@@ -622,11 +633,11 @@ class OC_Helper {
/**
* @brief replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.
*
- * @param $input The input string. .Opposite to the PHP build-in function does not accept an array.
- * @param $replacement The replacement string.
- * @param $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
- * @param $length Length of the part to be replaced
- * @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
+ * @param string $input The input string. .Opposite to the PHP build-in function does not accept an array.
+ * @param string $replacement The replacement string.
+ * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
+ * @param int $length Length of the part to be replaced
+ * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string
*
*/
@@ -643,20 +654,20 @@ class OC_Helper {
/**
* @brief Replace all occurrences of the search string with the replacement string
*
- * @param $search The value being searched for, otherwise known as the needle. String.
- * @param $replace The replacement string.
- * @param $subject The string or array being searched and replaced on, otherwise known as the haystack.
- * @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
- * @param $count If passed, this will be set to the number of replacements performed.
+ * @param string $search The value being searched for, otherwise known as the needle.
+ * @param string $replace The replacement
+ * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack.
+ * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
+ * @param int $count If passed, this will be set to the number of replacements performed.
* @return string
*
*/
public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) {
$offset = -1;
$length = mb_strlen($search, $encoding);
- while(($i = mb_strrpos($subject, $search, $offset, $encoding))) {
+ while(($i = mb_strrpos($subject, $search, $offset, $encoding)) !== false ) {
$subject = OC_Helper::mb_substr_replace($subject, $replace, $i, $length);
- $offset = $i - mb_strlen($subject, $encoding) - 1;
+ $offset = $i - mb_strlen($subject, $encoding);
$count++;
}
return $subject;
@@ -664,10 +675,10 @@ class OC_Helper {
/**
* @brief performs a search in a nested array
- * @param haystack the array to be searched
- * @param needle the search string
- * @param $index optional, only search this key name
- * @return the key of the matching field, otherwise false
+ * @param array $haystack the array to be searched
+ * @param string $needle the search string
+ * @param string $index optional, only search this key name
+ * @return mixed the key of the matching field, otherwise false
*
* performs a search in a nested array
*
diff --git a/lib/hook.php b/lib/hook.php
index 1bf80f604f6..26a53693748 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -9,11 +9,11 @@ class OC_Hook{
/**
* @brief connects a function to a hook
- * @param $signalclass class name of emitter
- * @param $signalname name of signal
- * @param $slotclass class name of slot
- * @param $slotname name of slot
- * @returns true/false
+ * @param string $signalclass class name of emitter
+ * @param string $signalname name of signal
+ * @param string $slotclass class name of slot
+ * @param string $slotname name of slot
+ * @return bool
*
* This function makes it very easy to connect to use hooks.
*
@@ -38,11 +38,11 @@ class OC_Hook{
}
/**
- * @brief emitts a signal
- * @param $signalclass class name of emitter
- * @param $signalname name of signal
- * @param $params defautl: array() array with additional data
- * @returns true if slots exists or false if not
+ * @brief emits a signal
+ * @param string $signalclass class name of emitter
+ * @param string $signalname name of signal
+ * @param array $params defautl: array() array with additional data
+ * @return bool, true if slots exists or false if not
*
* Emits a signal. To get data from the slot use references!
*
@@ -68,8 +68,8 @@ class OC_Hook{
/**
* clear hooks
- * @param string signalclass
- * @param string signalname
+ * @param string $signalclass
+ * @param string $signalname
*/
static public function clear($signalclass='', $signalname='') {
if($signalclass) {
diff --git a/lib/image.php b/lib/image.php
index 861353e039d..016d20599b2 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -669,7 +669,7 @@ class OC_Image {
$newWidth = min($maxWidth, $ratio*$maxHeight);
$newHeight = min($maxHeight, $maxWidth/$ratio);
-
+
$this->preciseResize(round($newWidth), round($newHeight));
return true;
}
diff --git a/lib/installer.php b/lib/installer.php
index 9135c60fc05..83d082b804a 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -125,7 +125,7 @@ class OC_Installer{
}
return false;
}
- $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true);
+ $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml', true);
// check the code for not allowed calls
if(!OC_Installer::checkCode($info['id'],$extractDir)) {
OC_Log::write('core','App can\'t be installed because of not allowed code in the App',OC_Log::ERROR);
@@ -187,7 +187,7 @@ class OC_Installer{
//run appinfo/install.php
if((!isset($data['noinstall']) or $data['noinstall']==false) and file_exists($basedir.'/appinfo/install.php')) {
- include($basedir.'/appinfo/install.php');
+ include $basedir.'/appinfo/install.php';
}
//set the installed version
@@ -320,7 +320,7 @@ class OC_Installer{
//run appinfo/install.php
if(is_file(OC_App::getAppPath($app)."/appinfo/install.php")) {
- include(OC_App::getAppPath($app)."/appinfo/install.php");
+ include OC_App::getAppPath($app)."/appinfo/install.php";
}
$info=OC_App::getAppInfo($app);
OC_Appconfig::setValue($app,'installed_version',OC_App::getAppVersion($app));
diff --git a/lib/json.php b/lib/json.php
index 518c3c87c49..cc6cee6caff 100644
--- a/lib/json.php
+++ b/lib/json.php
@@ -58,6 +58,7 @@ class OC_JSON{
*/
public static function checkAdminUser() {
self::checkLoggedIn();
+ self::verifyUser();
if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
@@ -70,6 +71,7 @@ class OC_JSON{
*/
public static function checkSubAdminUser() {
self::checkLoggedIn();
+ self::verifyUser();
if(!OC_Group::inGroup(OC_User::getUser(),'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
@@ -78,6 +80,19 @@ 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 90877cbd747..f1a2523c307 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -58,9 +58,11 @@ class OC_L10N{
* Localization
*/
private $localizations = array(
- 'date' => 'd.m.Y',
- 'datetime' => 'd.m.Y H:i:s',
- 'time' => 'H:i:s');
+ 'jsdate' => 'dd.mm.yy',
+ 'date' => '%d.%m.%Y',
+ 'datetime' => '%d.%m.%Y %H:%M:%S',
+ 'time' => '%H:%M:%S',
+ 'firstday' => 0);
/**
* get an L10N instance
@@ -118,7 +120,7 @@ class OC_L10N{
OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/lib/l10n/') ||
OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/settings')) && file_exists($i18ndir.$lang.'.php')) {
// Include the file, save the data from $CONFIG
- include(strip_tags($i18ndir).strip_tags($lang).'.php');
+ include strip_tags($i18ndir).strip_tags($lang).'.php';
if(isset($TRANSLATIONS) && is_array($TRANSLATIONS)) {
$this->translations = $TRANSLATIONS;
}
@@ -126,7 +128,7 @@ class OC_L10N{
if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')) {
// Include the file, save the data from $CONFIG
- include(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php');
+ include OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php';
if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)) {
$this->localizations = array_merge($this->localizations, $LOCALIZATIONS);
}
@@ -140,7 +142,7 @@ class OC_L10N{
/**
* @brief Translating
* @param $text String The text we need a translation for
- * @param array|\default $parameters default:array() Parameters for sprintf
+ * @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
@@ -216,8 +218,21 @@ class OC_L10N{
case 'time':
if($data instanceof DateTime) return $data->format($this->localizations[$type]);
elseif(is_string($data)) $data = strtotime($data);
- return date($this->localizations[$type], $data);
+ $locales = array(self::findLanguage());
+ if (strlen($locales[0]) == 2) {
+ $locales[] = $locales[0].'_'.strtoupper($locales[0]);
+ }
+ setlocale(LC_TIME, $locales);
+ $format = $this->localizations[$type];
+ // Check for Windows to find and replace the %e modifier correctly
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
+ }
+ return strftime($format, $data);
break;
+ case 'firstday':
+ case 'jsdate':
+ return $this->localizations[$type];
default:
return false;
}
diff --git a/lib/l10n/ar.php b/lib/l10n/ar.php
new file mode 100644
index 00000000000..4934e25a5f6
--- /dev/null
+++ b/lib/l10n/ar.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "المساعدة",
+"Personal" => "شخصي",
+"Settings" => "تعديلات",
+"Users" => "المستخدمين",
+"Authentication error" => "لم يتم التأكد من الشخصية بنجاح",
+"Text" => "معلومات إضافية"
+);
diff --git a/lib/l10n/bg_BG.php b/lib/l10n/bg_BG.php
new file mode 100644
index 00000000000..3eb0660d944
--- /dev/null
+++ b/lib/l10n/bg_BG.php
@@ -0,0 +1,4 @@
+<?php $TRANSLATIONS = array(
+"Personal" => "Лично",
+"Authentication error" => "Проблем с идентификацията"
+);
diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php
index 031207227ec..fa7c27af5a5 100644
--- a/lib/l10n/ca.php
+++ b/lib/l10n/ca.php
@@ -12,6 +12,9 @@
"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.",
+"Files" => "Fitxers",
+"Text" => "Text",
+"Images" => "Imatges",
"seconds ago" => "segons enrere",
"1 minute ago" => "fa 1 minut",
"%d minutes ago" => "fa %d minuts",
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php
index 00815f97533..72d9b955a41 100644
--- a/lib/l10n/cs_CZ.php
+++ b/lib/l10n/cs_CZ.php
@@ -12,6 +12,9 @@
"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.",
+"Files" => "Soubory",
+"Text" => "Text",
+"Images" => "Obrázky",
"seconds ago" => "před vteřinami",
"1 minute ago" => "před 1 minutou",
"%d minutes ago" => "před %d minutami",
diff --git a/lib/l10n/da.php b/lib/l10n/da.php
index 5c68174fa07..ca4a6c6eca6 100644
--- a/lib/l10n/da.php
+++ b/lib/l10n/da.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "Programmet er ikke aktiveret",
"Authentication error" => "Adgangsfejl",
"Token expired. Please reload page." => "Adgang er udløbet. Genindlæs siden.",
+"Files" => "Filer",
+"Text" => "SMS",
"seconds ago" => "sekunder siden",
"1 minute ago" => "1 minut siden",
"%d minutes ago" => "%d minutter siden",
@@ -23,5 +25,6 @@
"last year" => "Sidste år",
"years ago" => "år siden",
"%s is available. Get <a href=\"%s\">more information</a>" => "%s er tilgængelig. Få <a href=\"%s\">mere information</a>",
-"up to date" => "opdateret"
+"up to date" => "opdateret",
+"updates check is disabled" => "Check for opdateringer er deaktiveret"
);
diff --git a/lib/l10n/de.php b/lib/l10n/de.php
index 4a567003de2..4f415e7cbfd 100644
--- a/lib/l10n/de.php
+++ b/lib/l10n/de.php
@@ -11,17 +11,20 @@
"Selected files too large to generate zip file." => "Die gewählten Dateien sind zu groß, um eine ZIP-Datei zu erstellen.",
"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.",
+"Token expired. Please reload page." => "Token abgelaufen. Bitte lade die Seite neu.",
+"Files" => "Dateien",
+"Text" => "Text",
+"Images" => "Bilder",
"seconds ago" => "Vor wenigen Sekunden",
"1 minute ago" => "Vor einer Minute",
"%d minutes ago" => "Vor %d Minuten",
"today" => "Heute",
"yesterday" => "Gestern",
-"%d days ago" => "Vor %d Tagen",
+"%d days ago" => "Vor %d Tag(en)",
"last month" => "Letzten Monat",
-"months ago" => "Vor Monaten",
+"months ago" => "Vor wenigen Monaten",
"last year" => "Letztes Jahr",
-"years ago" => "Vor Jahren",
+"years ago" => "Vor wenigen Jahren",
"%s is available. Get <a href=\"%s\">more information</a>" => "%s ist verfügbar. <a href=\"%s\">Weitere Informationen</a>",
"up to date" => "aktuell",
"updates check is disabled" => "Die Update-Überprüfung ist ausgeschaltet"
diff --git a/lib/l10n/de_DE.php b/lib/l10n/de_DE.php
new file mode 100644
index 00000000000..0f08a3ea71d
--- /dev/null
+++ b/lib/l10n/de_DE.php
@@ -0,0 +1,31 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Hilfe",
+"Personal" => "Persönlich",
+"Settings" => "Einstellungen",
+"Users" => "Benutzer",
+"Apps" => "Apps",
+"Admin" => "Administrator",
+"ZIP download is turned off." => "Der ZIP-Download ist deaktiviert.",
+"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.",
+"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.",
+"Files" => "Dateien",
+"Text" => "Text",
+"Images" => "Bilder",
+"seconds ago" => "Vor wenigen Sekunden",
+"1 minute ago" => "Vor einer Minute",
+"%d minutes ago" => "Vor %d Minuten",
+"today" => "Heute",
+"yesterday" => "Gestern",
+"%d days ago" => "Vor %d Tag(en)",
+"last month" => "Letzten Monat",
+"months ago" => "Vor wenigen Monaten",
+"last year" => "Letztes Jahr",
+"years ago" => "Vor wenigen Jahren",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s ist verfügbar. <a href=\"%s\">Weitere Informationen</a>",
+"up to date" => "aktuell",
+"updates check is disabled" => "Die Update-Überprüfung ist ausgeschaltet"
+);
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index d9f272258e1..e6475ec08aa 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -11,7 +11,9 @@
"Selected files too large to generate zip file." => "Τα επιλεγμένα αρχεία είναι μεγάλα ώστε να δημιουργηθεί αρχείο zip.",
"Application is not enabled" => "Δεν ενεργοποιήθηκε η εφαρμογή",
"Authentication error" => "Σφάλμα πιστοποίησης",
-"Token expired. Please reload page." => "Το αναγνωριστικό έληξε. Παρακαλώ επανα-φορτώστε την σελίδα.",
+"Token expired. Please reload page." => "Το αναγνωριστικό έληξε. Παρακαλώ φορτώστε ξανά την σελίδα.",
+"Files" => "Αρχεία",
+"Text" => "Κείμενο",
"seconds ago" => "δευτερόλεπτα πριν",
"1 minute ago" => "1 λεπτό πριν",
"%d minutes ago" => "%d λεπτά πριν",
@@ -21,5 +23,8 @@
"last month" => "τον προηγούμενο μήνα",
"months ago" => "μήνες πριν",
"last year" => "τον προηγούμενο χρόνο",
-"years ago" => "χρόνια πριν"
+"years ago" => "χρόνια πριν",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s είναι διαθέσιμα. Δείτε <a href=\"%s\">περισσότερες πληροφορίες</a>",
+"up to date" => "ενημερωμένο",
+"updates check is disabled" => "ο έλεγχος ενημερώσεων είναι απενεργοποιημένος"
);
diff --git a/lib/l10n/eo.php b/lib/l10n/eo.php
index b3c1c52ecee..e569101fc6b 100644
--- a/lib/l10n/eo.php
+++ b/lib/l10n/eo.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "La aplikaĵo ne estas kapabligita",
"Authentication error" => "Aŭtentiga eraro",
"Token expired. Please reload page." => "Ĵetono eksvalidiĝis. Bonvolu reŝargi la paĝon.",
+"Files" => "Dosieroj",
+"Text" => "Teksto",
"seconds ago" => "sekundojn antaŭe",
"1 minute ago" => "antaŭ 1 minuto",
"%d minutes ago" => "antaŭ %d minutoj",
diff --git a/lib/l10n/es.php b/lib/l10n/es.php
index 6d2a310ca3b..5064fe2d2f0 100644
--- a/lib/l10n/es.php
+++ b/lib/l10n/es.php
@@ -12,6 +12,8 @@
"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.",
+"Files" => "Archivos",
+"Text" => "Texto",
"seconds ago" => "hace segundos",
"1 minute ago" => "hace 1 minuto",
"%d minutes ago" => "hace %d minutos",
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
new file mode 100644
index 00000000000..a9d9b35b265
--- /dev/null
+++ b/lib/l10n/es_AR.php
@@ -0,0 +1,31 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ayuda",
+"Personal" => "Personal",
+"Settings" => "Ajustes",
+"Users" => "Usuarios",
+"Apps" => "Aplicaciones",
+"Admin" => "Administración",
+"ZIP download is turned off." => "La descarga en ZIP está desactivada.",
+"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.",
+"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.",
+"Files" => "Archivos",
+"Text" => "Texto",
+"Images" => "Imágenes",
+"seconds ago" => "hace unos segundos",
+"1 minute ago" => "hace 1 minuto",
+"%d minutes ago" => "hace %d minutos",
+"today" => "hoy",
+"yesterday" => "ayer",
+"%d days ago" => "hace %d días",
+"last month" => "este mes",
+"months ago" => "hace meses",
+"last year" => "este año",
+"years ago" => "hace años",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está disponible. Conseguí <a href=\"%s\">más información</a>",
+"up to date" => "actualizado",
+"updates check is disabled" => "comprobar actualizaciones está desactivado"
+);
diff --git a/lib/l10n/et_EE.php b/lib/l10n/et_EE.php
index 87f222af838..52d91d37655 100644
--- a/lib/l10n/et_EE.php
+++ b/lib/l10n/et_EE.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "Rakendus pole sisse lülitatud",
"Authentication error" => "Autentimise viga",
"Token expired. Please reload page." => "Kontrollkood aegus. Paelun lae leht uuesti.",
+"Files" => "Failid",
+"Text" => "Tekst",
"seconds ago" => "sekundit tagasi",
"1 minute ago" => "1 minut tagasi",
"%d minutes ago" => "%d minutit tagasi",
diff --git a/lib/l10n/eu.php b/lib/l10n/eu.php
index 461bf458778..c6c0e18ea99 100644
--- a/lib/l10n/eu.php
+++ b/lib/l10n/eu.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "Aplikazioa ez dago gaituta",
"Authentication error" => "Autentikazio errorea",
"Token expired. Please reload page." => "Tokena iraungitu da. Mesedez birkargatu orria.",
+"Files" => "Fitxategiak",
+"Text" => "Testua",
"seconds ago" => "orain dela segundu batzuk",
"1 minute ago" => "orain dela minutu 1",
"%d minutes ago" => "orain dela %d minutu",
diff --git a/lib/l10n/fa.php b/lib/l10n/fa.php
index 3579329820f..31f936b8c98 100644
--- a/lib/l10n/fa.php
+++ b/lib/l10n/fa.php
@@ -4,6 +4,8 @@
"Settings" => "تنظیمات",
"Users" => "کاربران",
"Admin" => "مدیر",
+"Files" => "پرونده‌ها",
+"Text" => "متن",
"seconds ago" => "ثانیه‌ها پیش",
"1 minute ago" => "1 دقیقه پیش",
"%d minutes ago" => "%d دقیقه پیش",
diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php
index 6f0ebcd16e6..47d734ca365 100644
--- a/lib/l10n/fi_FI.php
+++ b/lib/l10n/fi_FI.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "Sovellusta ei ole otettu käyttöön",
"Authentication error" => "Todennusvirhe",
"Token expired. Please reload page." => "Valtuutus vanheni. Lataa sivu uudelleen.",
+"Files" => "Tiedostot",
+"Text" => "Teksti",
"seconds ago" => "sekuntia sitten",
"1 minute ago" => "1 minuutti sitten",
"%d minutes ago" => "%d minuuttia sitten",
diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php
index c10259e6376..ff2356464a2 100644
--- a/lib/l10n/fr.php
+++ b/lib/l10n/fr.php
@@ -12,6 +12,9 @@
"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.",
+"Files" => "Fichiers",
+"Text" => "Texte",
+"Images" => "Images",
"seconds ago" => "à l'instant",
"1 minute ago" => "il y a 1 minute",
"%d minutes ago" => "il y a %d minutes",
diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php
new file mode 100644
index 00000000000..96368ef03db
--- /dev/null
+++ b/lib/l10n/gl.php
@@ -0,0 +1,29 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Axuda",
+"Personal" => "Personal",
+"Settings" => "Preferencias",
+"Users" => "Usuarios",
+"Apps" => "Apps",
+"Admin" => "Administración",
+"ZIP download is turned off." => "Descargas ZIP está deshabilitadas",
+"Files need to be downloaded one by one." => "Os ficheiros necesitan ser descargados de un en un",
+"Back to Files" => "Voltar a ficheiros",
+"Selected files too large to generate zip file." => "Os ficheiros seleccionados son demasiado grandes para xerar un ficheiro ZIP",
+"Application is not enabled" => "O aplicativo non está habilitado",
+"Authentication error" => "Erro na autenticación",
+"Token expired. Please reload page." => "Testemuño caducado. Por favor recargue a páxina.",
+"Text" => "Texto",
+"seconds ago" => "hai segundos",
+"1 minute ago" => "hai 1 minuto",
+"%d minutes ago" => "hai %d minutos",
+"today" => "hoxe",
+"yesterday" => "onte",
+"%d days ago" => "hai %d días",
+"last month" => "último mes",
+"months ago" => "meses atrás",
+"last year" => "último ano",
+"years ago" => "anos atrás",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está dispoñible. Obteña <a href=\"%s\">máis información</a>",
+"up to date" => "ao día",
+"updates check is disabled" => "comprobación de actualizacións está deshabilitada"
+);
diff --git a/lib/l10n/he.php b/lib/l10n/he.php
index 149637d09d2..27bcf7655d5 100644
--- a/lib/l10n/he.php
+++ b/lib/l10n/he.php
@@ -12,6 +12,7 @@
"Application is not enabled" => "יישומים אינם מופעלים",
"Authentication error" => "שגיאת הזדהות",
"Token expired. Please reload page." => "פג תוקף. נא לטעון שוב את הדף.",
+"Text" => "טקסט",
"seconds ago" => "שניות",
"1 minute ago" => "לפני דקה אחת",
"%d minutes ago" => "לפני %d דקות",
diff --git a/lib/l10n/hr.php b/lib/l10n/hr.php
new file mode 100644
index 00000000000..0d2a0f46248
--- /dev/null
+++ b/lib/l10n/hr.php
@@ -0,0 +1,16 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Pomoć",
+"Personal" => "Osobno",
+"Settings" => "Postavke",
+"Users" => "Korisnici",
+"Authentication error" => "Greška kod autorizacije",
+"Files" => "Datoteke",
+"Text" => "Tekst",
+"seconds ago" => "sekundi prije",
+"today" => "danas",
+"yesterday" => "jučer",
+"last month" => "prošli mjesec",
+"months ago" => "mjeseci",
+"last year" => "prošlu godinu",
+"years ago" => "godina"
+);
diff --git a/lib/l10n/hu_HU.php b/lib/l10n/hu_HU.php
index eb074b79c61..3abf96e85a8 100644
--- a/lib/l10n/hu_HU.php
+++ b/lib/l10n/hu_HU.php
@@ -12,6 +12,8 @@
"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ítsd az oldalt.",
+"Files" => "Fájlok",
+"Text" => "Szöveg",
"seconds ago" => "másodperccel ezelőtt",
"1 minute ago" => "1 perccel ezelőtt",
"%d minutes ago" => "%d perccel ezelőtt",
diff --git a/lib/l10n/ia.php b/lib/l10n/ia.php
new file mode 100644
index 00000000000..fb7595d564e
--- /dev/null
+++ b/lib/l10n/ia.php
@@ -0,0 +1,7 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Adjuta",
+"Personal" => "Personal",
+"Settings" => "Configurationes",
+"Users" => "Usatores",
+"Text" => "Texto"
+);
diff --git a/lib/l10n/id.php b/lib/l10n/id.php
new file mode 100644
index 00000000000..40c4532bdd0
--- /dev/null
+++ b/lib/l10n/id.php
@@ -0,0 +1,29 @@
+<?php $TRANSLATIONS = array(
+"Help" => "bantu",
+"Personal" => "perseorangan",
+"Settings" => "pengaturan",
+"Users" => "pengguna",
+"Apps" => "aplikasi",
+"Admin" => "admin",
+"ZIP download is turned off." => "download ZIP sedang dimatikan",
+"Files need to be downloaded one by one." => "file harus di unduh satu persatu",
+"Back to Files" => "kembali ke daftar file",
+"Selected files too large to generate zip file." => "file yang dipilih terlalu besar untuk membuat file zip",
+"Application is not enabled" => "aplikasi tidak diaktifkan",
+"Authentication error" => "autentikasi bermasalah",
+"Token expired. Please reload page." => "token kadaluarsa.mohon perbaharui laman.",
+"Text" => "teks",
+"seconds ago" => "beberapa detik yang lalu",
+"1 minute ago" => "1 menit lalu",
+"%d minutes ago" => "%d menit lalu",
+"today" => "hari ini",
+"yesterday" => "kemarin",
+"%d days ago" => "%d hari lalu",
+"last month" => "bulan kemarin",
+"months ago" => "beberapa bulan lalu",
+"last year" => "tahun kemarin",
+"years ago" => "beberapa tahun lalu",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s tersedia. dapatkan <a href=\"%s\"> info lebih lanjut</a>",
+"up to date" => "terbaru",
+"updates check is disabled" => "pengecekan pembaharuan sedang non-aktifkan"
+);
diff --git a/lib/l10n/it.php b/lib/l10n/it.php
index c4c7d90610b..98ba5973a4a 100644
--- a/lib/l10n/it.php
+++ b/lib/l10n/it.php
@@ -12,6 +12,9 @@
"Application is not enabled" => "L'applicazione non è abilitata",
"Authentication error" => "Errore di autenticazione",
"Token expired. Please reload page." => "Token scaduto. Ricarica la pagina.",
+"Files" => "File",
+"Text" => "Testo",
+"Images" => "Immagini",
"seconds ago" => "secondi fa",
"1 minute ago" => "1 minuto fa",
"%d minutes ago" => "%d minuti fa",
diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php
index 10f7276703a..eb3316b4ab1 100644
--- a/lib/l10n/ja_JP.php
+++ b/lib/l10n/ja_JP.php
@@ -12,6 +12,9 @@
"Application is not enabled" => "アプリケーションは無効です",
"Authentication error" => "認証エラー",
"Token expired. Please reload page." => "トークンが無効になりました。ページを再読込してください。",
+"Files" => "ファイル",
+"Text" => "TTY TDD",
+"Images" => "画像",
"seconds ago" => "秒前",
"1 minute ago" => "1分前",
"%d minutes ago" => "%d 分前",
diff --git a/lib/l10n/ka_GE.php b/lib/l10n/ka_GE.php
new file mode 100644
index 00000000000..69b72e04130
--- /dev/null
+++ b/lib/l10n/ka_GE.php
@@ -0,0 +1,20 @@
+<?php $TRANSLATIONS = array(
+"Help" => "დახმარება",
+"Personal" => "პირადი",
+"Settings" => "პარამეტრები",
+"Users" => "მომხმარებელი",
+"Apps" => "აპლიკაციები",
+"Admin" => "ადმინისტრატორი",
+"Authentication error" => "ავთენტიფიკაციის შეცდომა",
+"Text" => "ტექსტი",
+"seconds ago" => "წამის წინ",
+"1 minute ago" => "1 წუთის წინ",
+"today" => "დღეს",
+"yesterday" => "გუშინ",
+"last month" => "გასულ თვეში",
+"months ago" => "თვის წინ",
+"last year" => "ბოლო წელს",
+"years ago" => "წლის წინ",
+"up to date" => "განახლებულია",
+"updates check is disabled" => "განახლების ძებნა გათიშულია"
+);
diff --git a/lib/l10n/ko.php b/lib/l10n/ko.php
new file mode 100644
index 00000000000..8648eba63b2
--- /dev/null
+++ b/lib/l10n/ko.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "도움말",
+"Personal" => "개인의",
+"Settings" => "설정",
+"Users" => "사용자",
+"Authentication error" => "인증 오류",
+"Text" => "문자 번호"
+);
diff --git a/lib/l10n/ku_IQ.php b/lib/l10n/ku_IQ.php
new file mode 100644
index 00000000000..f89871f23c9
--- /dev/null
+++ b/lib/l10n/ku_IQ.php
@@ -0,0 +1,5 @@
+<?php $TRANSLATIONS = array(
+"Help" => "یارمەتی",
+"Settings" => "ده‌ستكاری",
+"Users" => "به‌كارهێنه‌ر"
+);
diff --git a/lib/l10n/lb.php b/lib/l10n/lb.php
new file mode 100644
index 00000000000..baee630e897
--- /dev/null
+++ b/lib/l10n/lb.php
@@ -0,0 +1,6 @@
+<?php $TRANSLATIONS = array(
+"Personal" => "Perséinlech",
+"Settings" => "Astellungen",
+"Authentication error" => "Authentifikatioun's Fehler",
+"Text" => "SMS"
+);
diff --git a/lib/l10n/lt_LT.php b/lib/l10n/lt_LT.php
index c6702a62287..b34c602af2a 100644
--- a/lib/l10n/lt_LT.php
+++ b/lib/l10n/lt_LT.php
@@ -11,11 +11,20 @@
"Selected files too large to generate zip file." => "Pasirinkti failai per dideli archyvavimui į ZIP.",
"Application is not enabled" => "Programa neįjungta",
"Authentication error" => "Autentikacijos klaida",
+"Token expired. Please reload page." => "Sesija baigėsi. Prašome perkrauti puslapį.",
+"Files" => "Failai",
+"Text" => "Žinučių",
+"seconds ago" => "prieš kelias sekundes",
"1 minute ago" => "prieš 1 minutę",
"%d minutes ago" => "prieš %d minučių",
"today" => "šiandien",
"yesterday" => "vakar",
"%d days ago" => "prieš %d dienų",
"last month" => "praėjusį mėnesį",
-"last year" => "pereitais metais"
+"months ago" => "prieš mėnesį",
+"last year" => "pereitais metais",
+"years ago" => "prieš metus",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s yra galimas. Platesnė <a href=\"%s\">informacija čia</a>",
+"up to date" => "pilnai atnaujinta",
+"updates check is disabled" => "atnaujinimų tikrinimas išjungtas"
);
diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php
new file mode 100644
index 00000000000..fb333bd55c3
--- /dev/null
+++ b/lib/l10n/lv.php
@@ -0,0 +1,7 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Palīdzība",
+"Personal" => "Personīgi",
+"Settings" => "Iestatījumi",
+"Users" => "Lietotāji",
+"Authentication error" => "Ielogošanās kļūme"
+);
diff --git a/lib/l10n/mk.php b/lib/l10n/mk.php
new file mode 100644
index 00000000000..55e010d61ad
--- /dev/null
+++ b/lib/l10n/mk.php
@@ -0,0 +1,7 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Помош",
+"Personal" => "Лично",
+"Settings" => "Параметри",
+"Users" => "Корисници",
+"Text" => "Текст"
+);
diff --git a/lib/l10n/ms_MY.php b/lib/l10n/ms_MY.php
new file mode 100644
index 00000000000..86c7e51b486
--- /dev/null
+++ b/lib/l10n/ms_MY.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Personal" => "Peribadi",
+"Settings" => "Tetapan",
+"Users" => "Pengguna",
+"Authentication error" => "Ralat pengesahan",
+"Files" => "Fail-fail",
+"Text" => "Teks"
+);
diff --git a/lib/l10n/nb_NO.php b/lib/l10n/nb_NO.php
index f751a41d5eb..afb80288b53 100644
--- a/lib/l10n/nb_NO.php
+++ b/lib/l10n/nb_NO.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "Applikasjon er ikke påslått",
"Authentication error" => "Autentiseringsfeil",
"Token expired. Please reload page." => "Symbol utløpt. Vennligst last inn siden på nytt.",
+"Files" => "Filer",
+"Text" => "Tekst",
"seconds ago" => "sekunder siden",
"1 minute ago" => "1 minuitt siden",
"%d minutes ago" => "%d minutter siden",
@@ -21,5 +23,8 @@
"last month" => "forrige måned",
"months ago" => "måneder siden",
"last year" => "i fjor",
-"years ago" => "år siden"
+"years ago" => "år siden",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s er tilgjengelig. Få <a href=\"%s\">mer informasjon</a>",
+"up to date" => "oppdatert",
+"updates check is disabled" => "versjonssjekk er avslått"
);
diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php
index a90fc6caa6c..e209592d96d 100644
--- a/lib/l10n/nl.php
+++ b/lib/l10n/nl.php
@@ -4,7 +4,7 @@
"Settings" => "Instellingen",
"Users" => "Gebruikers",
"Apps" => "Apps",
-"Admin" => "Administrator",
+"Admin" => "Beheerder",
"ZIP download is turned off." => "ZIP download is uitgeschakeld.",
"Files need to be downloaded one by one." => "Bestanden moeten één voor één worden gedownload.",
"Back to Files" => "Terug naar bestanden",
@@ -12,6 +12,9 @@
"Application is not enabled" => "De applicatie is niet actief",
"Authentication error" => "Authenticatie fout",
"Token expired. Please reload page." => "Token verlopen. Herlaad de pagina.",
+"Files" => "Bestanden",
+"Text" => "Tekst",
+"Images" => "Afbeeldingen",
"seconds ago" => "seconden geleden",
"1 minute ago" => "1 minuut geleden",
"%d minutes ago" => "%d minuten geleden",
@@ -23,6 +26,6 @@
"last year" => "vorig jaar",
"years ago" => "jaar geleden",
"%s is available. Get <a href=\"%s\">more information</a>" => "%s is beschikbaar. Verkrijg <a href=\"%s\">meer informatie</a>",
-"up to date" => "Bijgewerkt",
+"up to date" => "bijgewerkt",
"updates check is disabled" => "Meest recente versie controle is uitgeschakeld"
);
diff --git a/lib/l10n/nn_NO.php b/lib/l10n/nn_NO.php
new file mode 100644
index 00000000000..56ce733fc19
--- /dev/null
+++ b/lib/l10n/nn_NO.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Hjelp",
+"Personal" => "Personleg",
+"Settings" => "Innstillingar",
+"Users" => "Brukarar",
+"Authentication error" => "Feil i autentisering",
+"Text" => "Tekst"
+);
diff --git a/lib/l10n/oc.php b/lib/l10n/oc.php
new file mode 100644
index 00000000000..2ac89fc74c1
--- /dev/null
+++ b/lib/l10n/oc.php
@@ -0,0 +1,25 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ajuda",
+"Personal" => "Personal",
+"Settings" => "Configuracion",
+"Users" => "Usancièrs",
+"Apps" => "Apps",
+"Admin" => "Admin",
+"ZIP download is turned off." => "Avalcargar los ZIP es inactiu.",
+"Files need to be downloaded one by one." => "Los fichièrs devan èsser avalcargats un per un.",
+"Back to Files" => "Torna cap als fichièrs",
+"Authentication error" => "Error d'autentificacion",
+"Files" => "Fichièrs",
+"seconds ago" => "segonda a",
+"1 minute ago" => "1 minuta a",
+"%d minutes ago" => "%d minutas a",
+"today" => "uèi",
+"yesterday" => "ièr",
+"%d days ago" => "%d jorns a",
+"last month" => "mes passat",
+"months ago" => "meses a",
+"last year" => "an passat",
+"years ago" => "ans a",
+"up to date" => "a jorn",
+"updates check is disabled" => "la verificacion de mesa a jorn es inactiva"
+);
diff --git a/lib/l10n/pl.php b/lib/l10n/pl.php
index 087aaa227d3..0fb29cbedbf 100644
--- a/lib/l10n/pl.php
+++ b/lib/l10n/pl.php
@@ -12,6 +12,9 @@
"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ę.",
+"Files" => "Pliki",
+"Text" => "Połączenie tekstowe",
+"Images" => "Obrazy",
"seconds ago" => "sekund temu",
"1 minute ago" => "1 minutę temu",
"%d minutes ago" => "%d minut temu",
diff --git a/lib/l10n/pl_PL.php b/lib/l10n/pl_PL.php
new file mode 100644
index 00000000000..67cf0a33259
--- /dev/null
+++ b/lib/l10n/pl_PL.php
@@ -0,0 +1,3 @@
+<?php $TRANSLATIONS = array(
+"Settings" => "Ustawienia"
+);
diff --git a/lib/l10n/pt_BR.php b/lib/l10n/pt_BR.php
new file mode 100644
index 00000000000..5eb2348100a
--- /dev/null
+++ b/lib/l10n/pt_BR.php
@@ -0,0 +1,30 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ajuda",
+"Personal" => "Pessoal",
+"Settings" => "Ajustes",
+"Users" => "Usuários",
+"Apps" => "Aplicações",
+"Admin" => "Admin",
+"ZIP download is turned off." => "Download ZIP está desligado.",
+"Files need to be downloaded one by one." => "Arquivos precisam ser baixados um de cada vez.",
+"Back to Files" => "Voltar para Arquivos",
+"Selected files too large to generate zip file." => "Arquivos selecionados são muito grandes para gerar arquivo zip.",
+"Application is not enabled" => "Aplicação não está habilitada",
+"Authentication error" => "Erro de autenticação",
+"Token expired. Please reload page." => "Token expirou. Por favor recarregue a página.",
+"Files" => "Arquivos",
+"Text" => "Texto",
+"seconds ago" => "segundos atrás",
+"1 minute ago" => "1 minuto atrás",
+"%d minutes ago" => "%d minutos atrás",
+"today" => "hoje",
+"yesterday" => "ontem",
+"%d days ago" => "%d dias atrás",
+"last month" => "último mês",
+"months ago" => "meses atrás",
+"last year" => "último ano",
+"years ago" => "anos atrás",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está disponível. Obtenha <a href=\"%s\">mais informações</a>",
+"up to date" => "atualizado",
+"updates check is disabled" => "checagens de atualização estão desativadas"
+);
diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php
new file mode 100644
index 00000000000..3809e4bdbcc
--- /dev/null
+++ b/lib/l10n/pt_PT.php
@@ -0,0 +1,31 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ajuda",
+"Personal" => "Pessoal",
+"Settings" => "Configurações",
+"Users" => "Utilizadores",
+"Apps" => "Aplicações",
+"Admin" => "Admin",
+"ZIP download is turned off." => "Descarregamento em ZIP está desligado.",
+"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.",
+"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.",
+"Files" => "Ficheiros",
+"Text" => "Texto",
+"Images" => "Imagens",
+"seconds ago" => "há alguns segundos",
+"1 minute ago" => "há 1 minuto",
+"%d minutes ago" => "há %d minutos",
+"today" => "hoje",
+"yesterday" => "ontem",
+"%d days ago" => "há %d dias",
+"last month" => "mês passado",
+"months ago" => "há meses",
+"last year" => "ano passado",
+"years ago" => "há anos",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está disponível. Obtenha <a href=\"%s\">mais informação</a>",
+"up to date" => "actualizado",
+"updates check is disabled" => "a verificação de actualizações está desligada"
+);
diff --git a/lib/l10n/ro.php b/lib/l10n/ro.php
new file mode 100644
index 00000000000..818b3f3eeed
--- /dev/null
+++ b/lib/l10n/ro.php
@@ -0,0 +1,30 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ajutor",
+"Personal" => "Personal",
+"Settings" => "Setări",
+"Users" => "Utilizatori",
+"Apps" => "Aplicații",
+"Admin" => "Admin",
+"ZIP download is turned off." => "Descărcarea ZIP este dezactivată.",
+"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.",
+"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.",
+"Files" => "Fișiere",
+"Text" => "Text",
+"seconds ago" => "secunde în urmă",
+"1 minute ago" => "1 minut în urmă",
+"%d minutes ago" => "%d minute în urmă",
+"today" => "astăzi",
+"yesterday" => "ieri",
+"%d days ago" => "%d zile în urmă",
+"last month" => "ultima lună",
+"months ago" => "luni în urmă",
+"last year" => "ultimul an",
+"years ago" => "ani în urmă",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s este disponibil. Vezi <a href=\"%s\">mai multe informații</a>",
+"up to date" => "la zi",
+"updates check is disabled" => "verificarea după actualizări este dezactivată"
+);
diff --git a/lib/l10n/ru.php b/lib/l10n/ru.php
index 74425f0e134..c703c30ac44 100644
--- a/lib/l10n/ru.php
+++ b/lib/l10n/ru.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "Приложение не разрешено",
"Authentication error" => "Ошибка аутентификации",
"Token expired. Please reload page." => "Токен просрочен. Перезагрузите страницу.",
+"Files" => "Файлы",
+"Text" => "Текст",
"seconds ago" => "менее минуты",
"1 minute ago" => "1 минуту назад",
"%d minutes ago" => "%d минут назад",
diff --git a/lib/l10n/ru_RU.php b/lib/l10n/ru_RU.php
new file mode 100644
index 00000000000..36cc85e8d28
--- /dev/null
+++ b/lib/l10n/ru_RU.php
@@ -0,0 +1,30 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Помощь",
+"Personal" => "Персональный",
+"Settings" => "Настройки",
+"Users" => "Пользователи",
+"Apps" => "Приложения",
+"Admin" => "Админ",
+"ZIP download is turned off." => "Загрузка ZIP выключена.",
+"Files need to be downloaded one by one." => "Файлы должны быть загружены один за другим.",
+"Back to Files" => "Обратно к файлам",
+"Selected files too large to generate zip file." => "Выбранные файлы слишком велики для генерации zip-архива.",
+"Application is not enabled" => "Приложение не запущено",
+"Authentication error" => "Ошибка аутентификации",
+"Token expired. Please reload page." => "Маркер истек. Пожалуйста, перезагрузите страницу.",
+"Files" => "Файлы",
+"Text" => "Текст",
+"seconds ago" => "секунд назад",
+"1 minute ago" => "1 минуту назад",
+"%d minutes ago" => "%d минут назад",
+"today" => "сегодня",
+"yesterday" => "вчера",
+"%d days ago" => "%d дней назад",
+"last month" => "в прошлом месяце",
+"months ago" => "месяц назад",
+"last year" => "в прошлом году",
+"years ago" => "год назад",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s доступно. Получите <a href=\"%s\">more information</a>",
+"up to date" => "до настоящего времени",
+"updates check is disabled" => "Проверка обновлений отключена"
+);
diff --git a/lib/l10n/si_LK.php b/lib/l10n/si_LK.php
new file mode 100644
index 00000000000..040c6d2d171
--- /dev/null
+++ b/lib/l10n/si_LK.php
@@ -0,0 +1,31 @@
+<?php $TRANSLATIONS = array(
+"Help" => "උදව්",
+"Personal" => "පෞද්ගලික",
+"Settings" => "සිටුවම්",
+"Users" => "පරිශීලකයන්",
+"Apps" => "යෙදුම්",
+"Admin" => "පරිපාලක",
+"ZIP download is turned off." => "ZIP භාගත කිරීම් අක්‍රියයි",
+"Files need to be downloaded one by one." => "ගොනු එකින් එක භාගත යුතුයි",
+"Back to Files" => "ගොනු වෙතට නැවත යන්න",
+"Selected files too large to generate zip file." => "තෝරාගත් ගොනු ZIP ගොනුවක් තැනීමට විශාල වැඩිය.",
+"Application is not enabled" => "යෙදුම සක්‍රිය කර නොමැත",
+"Authentication error" => "සත්‍යාපනය කිරීමේ දෝශයක්",
+"Token expired. Please reload page." => "ටෝකනය කල් ඉකුත් වී ඇත. පිටුව නැවුම් කරන්න",
+"Files" => "ගොනු",
+"Text" => "පෙළ",
+"Images" => "අනු රූ",
+"seconds ago" => "තත්පරයන්ට පෙර",
+"1 minute ago" => "1 මිනිත්තුවකට පෙර",
+"%d minutes ago" => "%d මිනිත්තුවන්ට පෙර",
+"today" => "අද",
+"yesterday" => "ඊයේ",
+"%d days ago" => "%d දිනකට පෙර",
+"last month" => "පෙර මාසයේ",
+"months ago" => "මාස කීපයකට පෙර",
+"last year" => "පෙර අවුරුද්දේ",
+"years ago" => "අවුරුදු කීපයකට පෙර",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s යොදාගත හැක. <a href=\"%s\">තව විස්තර</a> ලබාගන්න",
+"up to date" => "යාවත්කාලීනයි",
+"updates check is disabled" => "යාවත්කාලීන බව පරීක්ෂණය අක්‍රියයි"
+);
diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php
new file mode 100644
index 00000000000..9d5e4b9013b
--- /dev/null
+++ b/lib/l10n/sk_SK.php
@@ -0,0 +1,31 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Pomoc",
+"Personal" => "Osobné",
+"Settings" => "Nastavenia",
+"Users" => "Užívatelia",
+"Apps" => "Aplikácie",
+"Admin" => "Správca",
+"ZIP download is turned off." => "Sťahovanie súborov ZIP je vypnuté.",
+"Files need to be downloaded one by one." => "Súbory musia byť nahrávané jeden za druhým.",
+"Back to Files" => "Späť na súbory",
+"Selected files too large to generate zip file." => "Zvolené súbory sú príliž veľké na vygenerovanie zip súboru.",
+"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.",
+"Files" => "Súbory",
+"Text" => "Text",
+"Images" => "Obrázky",
+"seconds ago" => "pred sekundami",
+"1 minute ago" => "pred 1 minútou",
+"%d minutes ago" => "pred %d minútami",
+"today" => "dnes",
+"yesterday" => "včera",
+"%d days ago" => "pred %d dňami",
+"last month" => "minulý mesiac",
+"months ago" => "pred mesiacmi",
+"last year" => "minulý rok",
+"years ago" => "pred rokmi",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s je dostupné. Získať <a href=\"%s\">viac informácií</a>",
+"up to date" => "aktuálny",
+"updates check is disabled" => "sledovanie aktualizácií je vypnuté"
+);
diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php
index eac839e78f3..3dc8753a436 100644
--- a/lib/l10n/sl.php
+++ b/lib/l10n/sl.php
@@ -3,15 +3,17 @@
"Personal" => "Osebno",
"Settings" => "Nastavitve",
"Users" => "Uporabniki",
-"Apps" => "Aplikacije",
-"Admin" => "Skrbnik",
-"ZIP download is turned off." => "ZIP prenos je onemogočen.",
-"Files need to be downloaded one by one." => "Datoteke morajo biti prenešene posamezno.",
+"Apps" => "Programi",
+"Admin" => "Skrbništvo",
+"ZIP download is turned off." => "Prejem datotek ZIP je onemogočen.",
+"Files need to be downloaded one by one." => "Datoteke je mogoče prejeti le posamič.",
"Back to Files" => "Nazaj na datoteke",
-"Selected files too large to generate zip file." => "Izbrane datoteke so prevelike, da bi lahko ustvarili zip datoteko.",
-"Application is not enabled" => "Aplikacija ni omogočena",
+"Selected files too large to generate zip file." => "Izbrane datoteke so prevelike za ustvarjanje datoteke arhiva zip.",
+"Application is not enabled" => "Program ni omogočen",
"Authentication error" => "Napaka overitve",
-"Token expired. Please reload page." => "Žeton je potekel. Prosimo, če spletno stran znova naložite.",
+"Token expired. Please reload page." => "Žeton je potekel. Spletišče je traba znova naložiti.",
+"Files" => "Datoteke",
+"Text" => "Besedilo",
"seconds ago" => "pred nekaj sekundami",
"1 minute ago" => "pred minuto",
"%d minutes ago" => "pred %d minutami",
@@ -22,7 +24,7 @@
"months ago" => "pred nekaj meseci",
"last year" => "lani",
"years ago" => "pred nekaj leti",
-"%s is available. Get <a href=\"%s\">more information</a>" => "%s je na voljo. <a href=\"%s\">Več informacij.</a>",
-"up to date" => "ažuren",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s je na voljo. <a href=\"%s\">Več podrobnosti.</a>",
+"up to date" => "posodobljeno",
"updates check is disabled" => "preverjanje za posodobitve je onemogočeno"
);
diff --git a/lib/l10n/sr.php b/lib/l10n/sr.php
new file mode 100644
index 00000000000..cec7ea703fb
--- /dev/null
+++ b/lib/l10n/sr.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Помоћ",
+"Personal" => "Лично",
+"Settings" => "Подешавања",
+"Users" => "Корисници",
+"Authentication error" => "Грешка при аутентификацији",
+"Text" => "Текст"
+);
diff --git a/lib/l10n/sr@latin.php b/lib/l10n/sr@latin.php
new file mode 100644
index 00000000000..c692ec3c4b7
--- /dev/null
+++ b/lib/l10n/sr@latin.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Pomoć",
+"Personal" => "Lično",
+"Settings" => "Podešavanja",
+"Users" => "Korisnici",
+"Authentication error" => "Greška pri autentifikaciji",
+"Text" => "Tekst"
+);
diff --git a/lib/l10n/sv.php b/lib/l10n/sv.php
index 3d377133f22..cc1e09ea76a 100644
--- a/lib/l10n/sv.php
+++ b/lib/l10n/sv.php
@@ -12,6 +12,9 @@
"Application is not enabled" => "Applikationen är inte aktiverad",
"Authentication error" => "Fel vid autentisering",
"Token expired. Please reload page." => "Ogiltig token. Ladda om sidan.",
+"Files" => "Filer",
+"Text" => "Text",
+"Images" => "Bilder",
"seconds ago" => "sekunder sedan",
"1 minute ago" => "1 minut sedan",
"%d minutes ago" => "%d minuter sedan",
diff --git a/lib/l10n/ta_LK.php b/lib/l10n/ta_LK.php
new file mode 100644
index 00000000000..3c82233cb69
--- /dev/null
+++ b/lib/l10n/ta_LK.php
@@ -0,0 +1,31 @@
+<?php $TRANSLATIONS = array(
+"Help" => "உதவி",
+"Personal" => "தனிப்பட்ட",
+"Settings" => "அமைப்புகள்",
+"Users" => "பயனாளர்கள்",
+"Apps" => "செயலிகள்",
+"Admin" => "நிர்வாகம்",
+"ZIP download is turned off." => "வீசொலிப் பூட்டு பதிவிறக்கம் நிறுத்தப்பட்டுள்ளது.",
+"Files need to be downloaded one by one." => "கோப்புகள்ஒன்றன் பின் ஒன்றாக பதிவிறக்கப்படவேண்டும்.",
+"Back to Files" => "கோப்புகளுக்கு செல்க",
+"Selected files too large to generate zip file." => "வீ சொலிக் கோப்புகளை உருவாக்குவதற்கு தெரிவுசெய்யப்பட்ட கோப்புகள் மிகப்பெரியவை",
+"Application is not enabled" => "செயலி இயலுமைப்படுத்தப்படவில்லை",
+"Authentication error" => "அத்தாட்சிப்படுத்தலில் வழு",
+"Token expired. Please reload page." => "அடையாளவில்லை காலாவதியாகிவிட்டது. தயவுசெய்து பக்கத்தை மீள் ஏற்றுக.",
+"Files" => "கோப்புகள்",
+"Text" => "உரை",
+"Images" => "படங்கள்",
+"seconds ago" => "செக்கன்களுக்கு முன்",
+"1 minute ago" => "1 நிமிடத்திற்கு முன் ",
+"%d minutes ago" => "%d நிமிடங்களுக்கு முன்",
+"today" => "இன்று",
+"yesterday" => "நேற்று",
+"%d days ago" => "%d நாட்களுக்கு முன்",
+"last month" => "கடந்த மாதம்",
+"months ago" => "மாதங்களுக்கு முன்",
+"last year" => "கடந்த வருடம்",
+"years ago" => "வருடங்களுக்கு முன்",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s இன்னும் இருக்கின்றன. <a href=\"%s\">மேலதிக தகவல்களுக்கு</a> எடுக்க",
+"up to date" => "நவீன",
+"updates check is disabled" => "இற்றைப்படுத்தலை சரிபார்ப்பதை செயலற்றதாக்குக"
+);
diff --git a/lib/l10n/th_TH.php b/lib/l10n/th_TH.php
index 2aa2ffaba8c..2767ed643a6 100644
--- a/lib/l10n/th_TH.php
+++ b/lib/l10n/th_TH.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "แอพพลิเคชั่นดังกล่าวยังไม่ได้เปิดใช้งาน",
"Authentication error" => "เกิดข้อผิดพลาดในสิทธิ์การเข้าใช้งาน",
"Token expired. Please reload page." => "รหัสยืนยันความถูกต้องหมดอายุแล้ว กรุณาโหลดหน้าเว็บใหม่อีกครั้ง",
+"Files" => "ไฟล์",
+"Text" => "ข้อความ",
"seconds ago" => "วินาทีที่ผ่านมา",
"1 minute ago" => "1 นาทีมาแล้ว",
"%d minutes ago" => "%d นาทีที่ผ่านมา",
diff --git a/lib/l10n/tr.php b/lib/l10n/tr.php
new file mode 100644
index 00000000000..69067d7ec57
--- /dev/null
+++ b/lib/l10n/tr.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Yardı",
+"Personal" => "Kişisel",
+"Settings" => "Ayarlar",
+"Users" => "Kullanıcılar",
+"Authentication error" => "Kimlik doğrulama hatası",
+"Files" => "Dosyalar",
+"Text" => "Metin"
+);
diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php
index 423aa12b2d7..b08f559595b 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.php
@@ -11,6 +11,8 @@
"Selected files too large to generate zip file." => "Вибрані фали завеликі для генерування zip файлу.",
"Application is not enabled" => "Додаток не увімкнений",
"Authentication error" => "Помилка автентифікації",
+"Files" => "Файли",
+"Text" => "Текст",
"seconds ago" => "секунди тому",
"1 minute ago" => "1 хвилину тому",
"%d minutes ago" => "%d хвилин тому",
diff --git a/lib/l10n/vi.php b/lib/l10n/vi.php
index fc41d69819a..cfc39e5b7a8 100644
--- a/lib/l10n/vi.php
+++ b/lib/l10n/vi.php
@@ -12,6 +12,9 @@
"Application is not enabled" => "Ứng dụng không được BẬT",
"Authentication error" => "Lỗi xác thực",
"Token expired. Please reload page." => "Mã Token đã hết hạn. Hãy tải lại trang.",
+"Files" => "Các tập tin",
+"Text" => "Văn bản",
+"Images" => "Hình ảnh",
"seconds ago" => "1 giây trước",
"1 minute ago" => "1 phút trước",
"%d minutes ago" => "%d phút trước",
diff --git a/lib/l10n/zh_CN.GB2312.php b/lib/l10n/zh_CN.GB2312.php
new file mode 100644
index 00000000000..adc5c3bc6a9
--- /dev/null
+++ b/lib/l10n/zh_CN.GB2312.php
@@ -0,0 +1,30 @@
+<?php $TRANSLATIONS = array(
+"Help" => "帮助",
+"Personal" => "私人",
+"Settings" => "设置",
+"Users" => "用户",
+"Apps" => "程序",
+"Admin" => "管理员",
+"ZIP download is turned off." => "ZIP 下载已关闭",
+"Files need to be downloaded one by one." => "需要逐个下载文件。",
+"Back to Files" => "返回到文件",
+"Selected files too large to generate zip file." => "选择的文件太大而不能生成 zip 文件。",
+"Application is not enabled" => "应用未启用",
+"Authentication error" => "验证错误",
+"Token expired. Please reload page." => "会话过期。请刷新页面。",
+"Files" => "文件",
+"Text" => "文本",
+"seconds ago" => "秒前",
+"1 minute ago" => "1 分钟前",
+"%d minutes ago" => "%d 分钟前",
+"today" => "今天",
+"yesterday" => "昨天",
+"%d days ago" => "%d 天前",
+"last month" => "上个月",
+"months ago" => "月前",
+"last year" => "去年",
+"years ago" => "年前",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s 不可用。获知 <a href=\"%s\">详情</a>",
+"up to date" => "最新",
+"updates check is disabled" => "更新检测已禁用"
+);
diff --git a/lib/l10n/zh_CN.php b/lib/l10n/zh_CN.php
index 8229c77d2dd..6cdfd472510 100644
--- a/lib/l10n/zh_CN.php
+++ b/lib/l10n/zh_CN.php
@@ -12,6 +12,9 @@
"Application is not enabled" => "不需要程序",
"Authentication error" => "认证错误",
"Token expired. Please reload page." => "Token 过期,请刷新页面。",
+"Files" => "文件",
+"Text" => "文本",
+"Images" => "图像",
"seconds ago" => "几秒前",
"1 minute ago" => "1分钟前",
"%d minutes ago" => "%d 分钟前",
diff --git a/lib/l10n/zh_TW.php b/lib/l10n/zh_TW.php
index c9a26a53b2a..3122695033a 100644
--- a/lib/l10n/zh_TW.php
+++ b/lib/l10n/zh_TW.php
@@ -12,6 +12,8 @@
"Application is not enabled" => "應用程式未啟用",
"Authentication error" => "認證錯誤",
"Token expired. Please reload page." => "Token 過期. 請重新整理頁面",
+"Files" => "檔案",
+"Text" => "文字",
"seconds ago" => "幾秒前",
"1 minute ago" => "1 分鐘前",
"%d minutes ago" => "%d 分鐘前",
diff --git a/lib/log.php b/lib/log.php
index 8bb2839be66..4bba62cf4b2 100644
--- a/lib/log.php
+++ b/lib/log.php
@@ -20,6 +20,7 @@ class OC_Log {
const ERROR=3;
const FATAL=4;
+ static public $enabled = true;
static protected $class = null;
/**
@@ -29,11 +30,35 @@ class OC_Log {
* @param int level
*/
public static function write($app, $message, $level) {
- if (!self::$class) {
- self::$class = 'OC_Log_'.ucfirst(OC_Config::getValue('log_type', 'owncloud'));
- call_user_func(array(self::$class, 'init'));
+ if (self::$enabled) {
+ if (!self::$class) {
+ self::$class = 'OC_Log_'.ucfirst(OC_Config::getValue('log_type', 'owncloud'));
+ call_user_func(array(self::$class, 'init'));
+ }
+ $log_class=self::$class;
+ $log_class::write($app, $message, $level);
}
- $log_class=self::$class;
- $log_class::write($app, $message, $level);
+ }
+
+ //Fatal errors handler
+ public static function onShutdown(){
+ $error = error_get_last();
+ if($error) {
+ //ob_end_clean();
+ self::write('PHP', $error['message'] . ' at ' . $error['file'] . '#' . $error['line'], self::FATAL);
+ } else {
+ return true;
+ }
+ }
+
+ // Uncaught exception handler
+ public static function onException($exception){
+ self::write('PHP', $exception->getMessage() . ' at ' . $exception->getFile() . '#' . $exception->getLine(), self::FATAL);
+ }
+
+ //Recoverable errors handler
+ public static function onError($number, $message, $file, $line){
+ self::write('PHP', $message . ' at ' . $file . '#' . $line, self::WARN);
+
}
}
diff --git a/lib/migrate.php b/lib/migrate.php
index 823b3574f16..409d77a1a96 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -66,7 +66,7 @@ class OC_Migrate{
foreach($apps as $app) {
$path = OC_App::getAppPath($app) . '/appinfo/migrate.php';
if( file_exists( $path ) ) {
- include( $path );
+ include $path;
}
}
}
@@ -84,21 +84,15 @@ class OC_Migrate{
$types = array( 'user', 'instance', 'system', 'userfiles' );
if( !in_array( $type, $types ) ) {
OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR );
- return json_encode( array( array( 'success' => false ) ) );
+ return json_encode( array( 'success' => false ) );
}
self::$exporttype = $type;
// Userid?
if( self::$exporttype == 'user' ) {
// Check user exists
- if( !is_null($uid) ) {
- $db = new OC_User_Database;
- if( !$db->userExists( $uid ) ) {
- OC_Log::write('migration', 'User: '.$uid.' is not in the database and so cannot be exported.', OC_Log::ERROR);
- return json_encode( array( 'success' => false ) );
- }
- self::$uid = $uid;
- } else {
- self::$uid = OC_User::getUser();
+ self::$uid = is_null($uid) ? OC_User::getUser() : $uid;
+ if(!OC_User::userExists(self::$uid)){
+ return json_encode( array( 'success' => false) );
}
}
// Calculate zipname
@@ -353,7 +347,7 @@ class OC_Migrate{
OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR );
return false;
}
- if ( self::$zip->open( $path ) != TRUE ) {
+ if ( self::$zip->open( $path ) != true ) {
OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR );
return false;
}
@@ -582,7 +576,7 @@ class OC_Migrate{
OC_Log::write('migration', 'createZip() called but $zip and/or $zippath have not been set', OC_Log::ERROR);
return false;
}
- if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== TRUE ) {
+ if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) {
OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR);
return false;
} else {
diff --git a/lib/migration/content.php b/lib/migration/content.php
index 64b8168cd98..87f8da68c9d 100644
--- a/lib/migration/content.php
+++ b/lib/migration/content.php
@@ -30,7 +30,7 @@ class OC_Migration_Content{
// Holds the MDB2 object
private $db=null;
// Holds an array of tmpfiles to delete after zip creation
- private $tmpfiles=false;
+ private $tmpfiles=array();
/**
* @brief sets up the
@@ -43,18 +43,21 @@ class OC_Migration_Content{
$this->zip = $zip;
$this->db = $db;
- if( !is_null( $db ) ) {
- // Get db path
- $db = $this->db->getDatabase();
- $this->tmpfiles[] = $db;
- }
-
}
// @brief prepares the db
// @param $query the sql query to prepare
public function prepare( $query ) {
+ // Only add database to tmpfiles if actually used
+ if( !is_null( $this->db ) ) {
+ // Get db path
+ $db = $this->db->getDatabase();
+ if(!in_array($db, $this->tmpfiles)){
+ $this->tmpfiles[] = $db;
+ }
+ }
+
// Optimize the query
$query = $this->processQuery( $query );
diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php
index 8386bcb93f3..77b97917583 100644
--- a/lib/mimetypes.list.php
+++ b/lib/mimetypes.list.php
@@ -94,4 +94,5 @@ return array(
'sgf' => 'application/sgf',
'cdr' => 'application/coreldraw',
'impress' => 'text/impress',
+ 'ai' => 'application/illustrator',
);
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 8596ea0b3c7..32c2cfe6e48 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -49,22 +49,39 @@ class OC_OCSClient{
return($url);
}
+ /**
+ * @brief Get the content of an OCS url call.
+ * @returns string of the response
+ * This function calls an OCS server and returns the response. It also sets a sane timeout
+ */
+ private static function getOCSresponse($url) {
+ // set a sensible timeout of 10 sec to stay responsive even if the server is down.
+ $ctx = stream_context_create(
+ array(
+ 'http' => array(
+ 'timeout' => 10
+ )
+ )
+ );
+ $data=@file_get_contents($url, 0, $ctx);
+ 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
* This function returns a list of all the application categories on the OCS server
*/
public static function getCategories() {
if(OC_Config::getValue('appstoreenabled', true)==false) {
- return NULL;
+ return null;
}
$url=OC_OCSClient::getAppStoreURL().'/content/categories';
-
- $xml=@file_get_contents($url);
- if($xml==FALSE) {
- return NULL;
+ $xml=OC_OCSClient::getOCSresponse($url);
+ if($xml==false) {
+ return null;
}
$data=simplexml_load_string($xml);
@@ -103,9 +120,10 @@ class OC_OCSClient{
$filterurl='&filter='.urlencode($filter);
$url=OC_OCSClient::getAppStoreURL().'/content/data?categories='.urlencode($categoriesstring).'&sortmode=new&page='.urlencode($page).'&pagesize=100'.$filterurl.$version;
$apps=array();
- $xml=@file_get_contents($url);
- if($xml==FALSE) {
- return NULL;
+ $xml=OC_OCSClient::getOCSresponse($url);
+
+ if($xml==false) {
+ return null;
}
$data=simplexml_load_string($xml);
@@ -122,6 +140,7 @@ class OC_OCSClient{
$app['preview']=(string)$tmp[$i]->smallpreviewpic1;
$app['changed']=strtotime($tmp[$i]->changed);
$app['description']=(string)$tmp[$i]->description;
+ $app['score']=(string)$tmp[$i]->score;
$apps[]=$app;
}
@@ -137,14 +156,14 @@ class OC_OCSClient{
*/
public static function getApplication($id) {
if(OC_Config::getValue('appstoreenabled', true)==false) {
- return NULL;
+ return null;
}
$url=OC_OCSClient::getAppStoreURL().'/content/data/'.urlencode($id);
+ $xml=OC_OCSClient::getOCSresponse($url);
- $xml=@file_get_contents($url);
- if($xml==FALSE) {
+ if($xml==false) {
OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
- return NULL;
+ return null;
}
$data=simplexml_load_string($xml);
@@ -162,6 +181,7 @@ class OC_OCSClient{
$app['changed']=strtotime($tmp->changed);
$app['description']=$tmp->description;
$app['detailpage']=$tmp->detailpage;
+ $app['score']=$tmp->score;
return $app;
}
@@ -174,14 +194,14 @@ class OC_OCSClient{
*/
public static function getApplicationDownload($id,$item) {
if(OC_Config::getValue('appstoreenabled', true)==false) {
- return NULL;
+ return null;
}
$url=OC_OCSClient::getAppStoreURL().'/content/download/'.urlencode($id).'/'.urlencode($item);
+ $xml=OC_OCSClient::getOCSresponse($url);
- $xml=@file_get_contents($url);
- if($xml==FALSE) {
+ if($xml==false) {
OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
- return NULL;
+ return null;
}
$data=simplexml_load_string($xml);
@@ -215,10 +235,11 @@ class OC_OCSClient{
$url=OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='.$p.'&pagesize='.$s.$searchcmd;
$kbe=array();
- $xml=@file_get_contents($url);
- if($xml==FALSE) {
+ $xml=OC_OCSClient::getOCSresponse($url);
+
+ if($xml==false) {
OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL);
- return NULL;
+ return null;
}
$data=simplexml_load_string($xml);
diff --git a/lib/preferences.php b/lib/preferences.php
index 3d61887785c..b198a18415c 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -40,7 +40,7 @@
class OC_Preferences{
/**
* @brief Get all users using the preferences
- * @returns array with user ids
+ * @return array with user ids
*
* This function returns a list of all users that have at least one entry
* in the preferences table.
@@ -60,8 +60,8 @@ class OC_Preferences{
/**
* @brief Get all apps of a user
- * @param $user user
- * @returns array with app ids
+ * @param string $user user
+ * @return array with app ids
*
* This function returns a list of all apps of the user that have at least
* one entry in the preferences table.
@@ -81,9 +81,9 @@ class OC_Preferences{
/**
* @brief Get the available keys for an app
- * @param $user user
- * @param $app the app we are looking for
- * @returns array with key names
+ * @param string $user user
+ * @param string $app the app we are looking for
+ * @return array with key names
*
* This function gets all keys of an app of an user. Please note that the
* values are not returned.
@@ -103,14 +103,14 @@ class OC_Preferences{
/**
* @brief Gets the preference
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
*
- * This function gets a value from the prefernces table. If the key does
- * not exist the default value will be returnes
+ * This function gets a value from the preferences table. If the key does
+ * not exist the default value will be returned
*/
public static function getValue( $user, $app, $key, $default = null ) {
// Try to fetch the value, return default if not exists.
@@ -127,11 +127,11 @@ class OC_Preferences{
/**
* @brief sets a value in the preferences
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* Adds a value to the preferences. If the key did not exist before, it
* will be added automagically.
@@ -155,63 +155,63 @@ class OC_Preferences{
/**
* @brief Deletes a key
- * @param $user user
- * @param $app app
- * @param $key key
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @return bool
*
* Deletes a key.
*/
public static function deleteKey( $user, $app, $key ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' );
- $result = $query->execute( array( $user, $app, $key ));
+ $query->execute( array( $user, $app, $key ));
return true;
}
/**
* @brief Remove app of user from preferences
- * @param $user user
- * @param $app app
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @return bool
*
* Removes all keys in appconfig belonging to the app and the user.
*/
public static function deleteApp( $user, $app ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' );
- $result = $query->execute( array( $user, $app ));
+ $query->execute( array( $user, $app ));
return true;
}
/**
* @brief Remove user from preferences
- * @param $user user
- * @returns true/false
+ * @param string $user user
+ * @return bool
*
* Removes all keys in appconfig belonging to the user.
*/
public static function deleteUser( $user ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?' );
- $result = $query->execute( array( $user ));
+ $query->execute( array( $user ));
return true;
}
/**
* @brief Remove app from all users
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* Removes all keys in preferences belonging to the app.
*/
public static function deleteAppFromAllUsers( $app ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?' );
- $result = $query->execute( array( $app ));
+ $query->execute( array( $app ));
return true;
}
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php
index aba7d2b7620..24a17836f7f 100644
--- a/lib/public/backgroundjob.php
+++ b/lib/public/backgroundjob.php
@@ -47,6 +47,29 @@ namespace OCP;
*/
class BackgroundJob {
/**
+ * @brief get the execution type of background jobs
+ * @return string
+ *
+ * This method returns the type how background jobs are executed. If the user
+ * did not select something, the type is ajax.
+ */
+ public static function getExecutionType() {
+ return \OC_BackgroundJob::getExecutionType();
+ }
+
+ /**
+ * @brief sets the background jobs execution type
+ * @param $type execution type
+ * @return boolean
+ *
+ * This method sets the execution type of the background jobs. Possible types
+ * are "none", "ajax", "webcron", "cron"
+ */
+ public static function setExecutionType( $type ) {
+ return \OC_BackgroundJob::setExecutionType( $type );
+ }
+
+ /**
* @brief creates a regular task
* @param $klass class name
* @param $method method name
diff --git a/lib/public/config.php b/lib/public/config.php
index 377150115ff..1f163d52617 100644
--- a/lib/public/config.php
+++ b/lib/public/config.php
@@ -40,9 +40,9 @@ namespace OCP;
class Config {
/**
* @brief Gets a value from config.php
- * @param $key key
- * @param $default = null default value
- * @returns the value or $default
+ * @param string $key key
+ * @param string $default = null default value
+ * @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
@@ -53,9 +53,9 @@ class Config {
/**
* @brief Sets a value
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
@@ -66,13 +66,13 @@ class Config {
/**
* @brief Gets the config value
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
*
* This function gets a value from the appconfig table. If the key does
- * not exist the default value will be returnes
+ * not exist the default value will be returned
*/
public static function getAppValue( $app, $key, $default = null ) {
return(\OC_Appconfig::getValue( $app, $key, $default ));
@@ -80,10 +80,10 @@ class Config {
/**
* @brief sets a value in the appconfig
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return string true/false
*
* Sets a value. If the key did not exist before it will be created.
*/
@@ -93,14 +93,14 @@ class Config {
/**
* @brief Gets the preference
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
*
- * This function gets a value from the prefernces table. If the key does
- * not exist the default value will be returnes
+ * This function gets a value from the preferences table. If the key does
+ * not exist the default value will be returned
*/
public static function getUserValue( $user, $app, $key, $default = null ) {
return(\OC_Preferences::getValue( $user, $app, $key, $default ));
@@ -108,16 +108,16 @@ class Config {
/**
* @brief sets a value in the preferences
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @returns bool
*
* Adds a value to the preferences. If the key did not exist before, it
* will be added automagically.
*/
public static function setUserValue( $user, $app, $key, $value ) {
- return(\OC_Preferences::setValue( $user, $app, $key, $value ));
+ return(\OC_Preferences::setValue( $user, $app, $key, $value ));
}
}
diff --git a/lib/public/share.php b/lib/public/share.php
index b215d7f9389..da1c0616390 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -28,6 +28,9 @@ namespace OCP;
/**
* This class provides the ability for apps to share their content between users.
* Apps must create a backend class that implements OCP\Share_Backend and register it with this class.
+*
+* It provides the following hooks:
+* - post_shared
*/
class Share {
@@ -173,6 +176,7 @@ class Share {
*/
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
$uidOwner = \OC_User::getUser();
+ $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
// Verify share type and sharing conditions are met
if ($shareType === self::SHARE_TYPE_USER) {
if ($shareWith == $uidOwner) {
@@ -185,7 +189,7 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
}
- if (\OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global') == 'groups_only') {
+ if ($sharingPolicy == 'groups_only') {
$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
if (empty($inGroup)) {
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of';
@@ -208,7 +212,7 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
}
- if (!\OC_Group::inGroup($uidOwner, $shareWith)) {
+ if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) {
$message = 'Sharing '.$itemSource.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith;
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
@@ -326,6 +330,22 @@ class Share {
}
/**
+ * @brief Unshare an item from all users, groups, and remove all links
+ * @param string Item type
+ * @param string Item source
+ * @return Returns true on success or false on failure
+ */
+ public static function unshareAll($itemType, $itemSource) {
+ if ($shares = self::getItemShared($itemType, $itemSource)) {
+ foreach ($shares as $share) {
+ self::delete($share['id']);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
* @brief Unshare an item shared with the current user
* @param string Item type
* @param string Item target
@@ -418,11 +438,20 @@ class Share {
}
public static function setExpirationDate($itemType, $itemSource, $date) {
- if ($item = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) {
- error_log('setting');
- $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?');
- $query->execute(array($date, $item['id']));
- return true;
+ if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, -1, false)) {
+ if (!empty($items)) {
+ if ($date == '') {
+ $date = null;
+ } else {
+ $date = new \DateTime($date);
+ $date = date('Y-m-d H:i', $date->format('U') - $date->getOffset());
+ }
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?');
+ foreach ($items as $item) {
+ $query->execute(array($date, $item['id']));
+ }
+ return true;
+ }
}
return false;
}
@@ -636,7 +665,7 @@ class Share {
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`';
}
@@ -908,10 +937,23 @@ class Share {
} else {
$fileTarget = null;
}
+ \OC_Hook::emit('OCP\Share', 'post_shared', array(
+ 'itemType' => $itemType,
+ 'itemSource' => $itemSource,
+ 'itemTarget' => $itemTarget,
+ 'parent' => $parent,
+ 'shareType' => self::$shareTypeGroupUserUnique,
+ 'shareWith' => $uid,
+ 'uidOwner' => $uidOwner,
+ 'permissions' => $permissions,
+ 'fileSource' => $fileSource,
+ 'fileTarget' => $fileTarget,
+ 'id' => $parent
+ ));
// Insert an extra row for the group share if the item or file target is unique for this user
if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) {
$query->execute(array($itemType, $itemSource, $itemTarget, $parent, self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), $fileSource, $fileTarget));
- \OC_DB::insertid('*PREFIX*share');
+ $id = \OC_DB::insertid('*PREFIX*share');
}
}
if ($parentFolder === true) {
@@ -937,6 +979,19 @@ class Share {
}
$query->execute(array($itemType, $itemSource, $itemTarget, $parent, $shareType, $shareWith, $uidOwner, $permissions, time(), $fileSource, $fileTarget));
$id = \OC_DB::insertid('*PREFIX*share');
+ \OC_Hook::emit('OCP\Share', 'post_shared', array(
+ 'itemType' => $itemType,
+ 'itemSource' => $itemSource,
+ 'itemTarget' => $itemTarget,
+ 'parent' => $parent,
+ 'shareType' => $shareType,
+ 'shareWith' => $shareWith,
+ 'uidOwner' => $uidOwner,
+ 'permissions' => $permissions,
+ 'fileSource' => $fileSource,
+ 'fileTarget' => $fileTarget,
+ 'id' => $id
+ ));
if ($parentFolder === true) {
$parentFolders['id'] = $id;
// Return parent folder to preserve file target paths for potential children
@@ -966,8 +1021,10 @@ class Share {
} else {
if ($itemType == 'file' || $itemType == 'folder') {
$column = 'file_target';
+ $columnSource = 'file_source';
} else {
$column = 'item_target';
+ $columnSource = 'item_source';
}
if ($shareType == self::SHARE_TYPE_USER) {
// Share with is a user, so set share type to user and groups
@@ -1004,9 +1061,14 @@ class Share {
continue;
}
}
- // If matching target is from the same owner, use the same target. The share type will be different so this isn't the same share.
if ($item['uid_owner'] == $uidOwner) {
- return $target;
+ if ($itemType == 'file' || $itemType == 'folder') {
+ if ($item['file_source'] == \OC_FileCache::getId($itemSource)) {
+ return $target;
+ }
+ } else if ($item['item_source'] == $itemSource) {
+ return $target;
+ }
}
}
if (!isset($exclude)) {
@@ -1014,11 +1076,21 @@ class Share {
}
// Find similar targets to improve backend's chances to generate a unqiue target
if ($userAndGroups) {
- $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` = ? AND `share_type` IN (?,?,?) AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\') AND `'.$column.'` LIKE ?');
- $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique, '%'.$target.'%'));
+ if ($column == 'file_target') {
+ $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` IN (\'file\', \'folder\') AND `share_type` IN (?,?,?) AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')');
+ $result = $checkTargets->execute(array(self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique));
+ } else {
+ $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` = ? AND `share_type` IN (?,?,?) AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')');
+ $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique));
+ }
} else {
- $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` = ? AND `share_type` = ? AND `share_with` = ? AND `'.$column.'` LIKE ?');
- $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_GROUP, $shareWith, '%'.$target.'%'));
+ if ($column == 'file_target') {
+ $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` IN (\'file\', \'folder\') AND `share_type` = ? AND `share_with` = ?');
+ $result = $checkTargets->execute(array(self::SHARE_TYPE_GROUP, $shareWith));
+ } else {
+ $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` = ? AND `share_type` = ? AND `share_with` = ?');
+ $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_GROUP, $shareWith));
+ }
}
while ($row = $result->fetchRow()) {
$exclude[] = $row[$column];
@@ -1046,7 +1118,7 @@ class Share {
$parents = "'".implode("','", $parents)."'";
// Check the owner on the first search of reshares, useful for finding and deleting the reshares by a single user of a group share
if (count($ids) == 1 && isset($uidOwner)) {
- $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?');
+ $query = \OC_DB::prepare('SELECT `id`, `uid_owner`, `item_type`, `item_target`, `parent` FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?');
$result = $query->execute(array($uidOwner));
} else {
$query = \OC_DB::prepare('SELECT `id`, `item_type`, `item_target`, `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')');
diff --git a/lib/public/util.php b/lib/public/util.php
index 747448e62eb..38da7e82171 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -116,6 +116,7 @@ class Util {
* @param $app app
* @param $file file
* @param $args array with param=>value, will be appended to the returned url
+ * The value of $args will be urlencoded
* @returns the url
*
* Returns a absolute url to the given app and file.
@@ -151,6 +152,7 @@ class Util {
* @param $app app
* @param $file file
* @param $args array with param=>value, will be appended to the returned url
+ * The value of $args will be urlencoded
* @returns the url
*
* Returns a url to the given app and file.
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php
index 50e16457672..0d4b332b792 100644
--- a/lib/search/provider/file.php
+++ b/lib/search/provider/file.php
@@ -2,32 +2,43 @@
class OC_Search_Provider_File extends OC_Search_Provider{
function search($query) {
- $files=OC_FileCache::search($query,true);
+ $files=OC_FileCache::search($query, true);
$results=array();
+ $l=OC_L10N::get('lib');
foreach($files as $fileData) {
- $file=$fileData['path'];
- $mime=$fileData['mimetype'];
+ $path = $fileData['path'];
+ $mime = $fileData['mimetype'];
+
+ $name = basename($path);
+ $text = '';
+ $skip = false;
if($mime=='httpd/unix-directory') {
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php', array('dir' => $file)),'Files');
+ $link = OC_Helper::linkTo( 'files', 'index.php', array('dir' => $path));
+ $type = (string)$l->t('Files');
}else{
- $mimeBase=$fileData['mimepart'];
+ $link = OC_Helper::linkTo( 'files', 'download.php', array('file' => $path));
+ $mimeBase = $fileData['mimepart'];
switch($mimeBase) {
case 'audio':
+ $skip = true;
break;
case 'text':
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
+ $type = (string)$l->t('Text');
break;
case 'image':
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Images');
+ $type = (string)$l->t('Images');
break;
default:
if($mime=='application/xml') {
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
+ $type = (string)$l->t('Text');
}else{
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Files');
+ $type = (string)$l->t('Files');
}
}
}
+ if(!$skip) {
+ $results[] = new OC_Search_Result($name, $text, $link, $type);
+ }
}
return $results;
}
diff --git a/lib/setup.php b/lib/setup.php
index c21c8be3957..a072e00f91e 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -5,12 +5,19 @@ $hasMySQL = is_callable('mysql_connect');
$hasPostgreSQL = is_callable('pg_connect');
$hasOracle = is_callable('oci_connect');
$datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
+
+// Test if .htaccess is working
+$content = "deny from all";
+file_put_contents(OC::$SERVERROOT.'/data/.htaccess', $content);
+
$opts = array(
'hasSQLite' => $hasSQLite,
'hasMySQL' => $hasMySQL,
'hasPostgreSQL' => $hasPostgreSQL,
'hasOracle' => $hasOracle,
'directory' => $datadir,
+ 'secureRNG' => OC_Util::secureRNG_available(),
+ 'htaccessWorking' => OC_Util::ishtaccessworking(),
'errors' => array(),
);
@@ -79,75 +86,33 @@ class OC_Setup {
}
//generate a random salt that is used to salt the local user passwords
- $salt=mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000);
+ $salt = OC_Util::generate_random_bytes(30);
OC_Config::setValue('passwordsalt', $salt);
//write the config file
OC_Config::setValue('datadirectory', $datadir);
OC_Config::setValue('dbtype', $dbtype);
- OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
+ OC_Config::setValue('version', implode('.',OC_Util::getVersion()));
if($dbtype == 'mysql') {
$dbuser = $options['dbuser'];
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
$dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
+
OC_Config::setValue('dbname', $dbname);
OC_Config::setValue('dbhost', $dbhost);
OC_Config::setValue('dbtableprefix', $dbtableprefix);
- //check if the database user has admin right
- $connection = @mysql_connect($dbhost, $dbuser, $dbpass);
- if(!$connection) {
+ try {
+ self::setupMySQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username);
+ } 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.'
);
return($error);
}
- else {
- $oldUser=OC_Config::getValue('dbuser', false);
-
- $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql
- if(mysql_query($query, $connection)) {
- //use the admin login data for the new database user
-
- //add prefix to the mysql user name to prevent collisions
- $dbusername=substr('oc_'.$username,0,16);
- if($dbusername!=$oldUser) {
- //hash the password so we don't need to store the admin config in the config file
- $dbpassword=md5(time().$password);
-
- self::createDBUser($dbusername, $dbpassword, $connection);
-
- OC_Config::setValue('dbuser', $dbusername);
- OC_Config::setValue('dbpassword', $dbpassword);
- }
-
- //create the database
- self::createDatabase($dbname, $dbusername, $connection);
- }
- else {
- if($dbuser!=$oldUser) {
- OC_Config::setValue('dbuser', $dbuser);
- OC_Config::setValue('dbpassword', $dbpass);
- }
-
- //create the database
- self::createDatabase($dbname, $dbuser, $connection);
- }
-
- //fill the database if needed
- $query="select count(*) from information_schema.tables where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';";
- $result = mysql_query($query,$connection);
- if($result) {
- $row=mysql_fetch_row($result);
- }
- if(!$result or $row[0]==0) {
- OC_DB::createDbFromStructure('db_structure.xml');
- }
- mysql_close($connection);
- }
}
elseif($dbtype == 'pgsql') {
$dbuser = $options['dbuser'];
@@ -155,82 +120,20 @@ class OC_Setup {
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
$dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
- OC_CONFIG::setValue('dbname', $dbname);
- OC_CONFIG::setValue('dbhost', $dbhost);
- OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
-
- $e_host = addslashes($dbhost);
- $e_user = addslashes($dbuser);
- $e_password = addslashes($dbpass);
- //check if the database user has admin right
- $connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'";
- $connection = @pg_connect($connection_string);
- if(!$connection) {
+
+ OC_Config::setValue('dbname', $dbname);
+ OC_Config::setValue('dbhost', $dbhost);
+ OC_Config::setValue('dbtableprefix', $dbtableprefix);
+
+ try {
+ self::setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username);
+ } catch (Exception $e) {
$error[] = array(
'error' => 'PostgreSQL username and/or password not valid',
'hint' => 'You need to enter either an existing account or the administrator.'
);
return $error;
}
- else {
- $e_user = pg_escape_string($dbuser);
- //check for roles creation rights in postgresql
- $query="SELECT 1 FROM pg_roles WHERE rolcreaterole=TRUE AND rolname='$e_user'";
- $result = pg_query($connection, $query);
- if($result and pg_num_rows($result) > 0) {
- //use the admin login data for the new database user
-
- //add prefix to the postgresql user name to prevent collisions
- $dbusername='oc_'.$username;
- //create a new password so we don't need to store the admin config in the config file
- $dbpassword=md5(time());
-
- self::pg_createDBUser($dbusername, $dbpassword, $connection);
-
- OC_CONFIG::setValue('dbuser', $dbusername);
- OC_CONFIG::setValue('dbpassword', $dbpassword);
-
- //create the database
- self::pg_createDatabase($dbname, $dbusername, $connection);
- }
- else {
- OC_CONFIG::setValue('dbuser', $dbuser);
- OC_CONFIG::setValue('dbpassword', $dbpass);
-
- //create the database
- self::pg_createDatabase($dbname, $dbuser, $connection);
- }
-
- // the connection to dbname=postgres is not needed anymore
- pg_close($connection);
-
- // connect to the ownCloud database (dbname=$dbname) an check if it needs to be filled
- $dbuser = OC_CONFIG::getValue('dbuser');
- $dbpass = OC_CONFIG::getValue('dbpassword');
-
- $e_host = addslashes($dbhost);
- $e_dbname = addslashes($dbname);
- $e_user = addslashes($dbuser);
- $e_password = addslashes($dbpass);
-
- $connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' password='$e_password'";
- $connection = @pg_connect($connection_string);
- if(!$connection) {
- $error[] = array(
- 'error' => 'PostgreSQL username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
- );
- } else {
- $query = "select count(*) FROM pg_class WHERE relname='{$dbtableprefix}users' limit 1";
- $result = pg_query($connection, $query);
- if($result) {
- $row = pg_fetch_row($result);
- }
- if(!$result or $row[0]==0) {
- OC_DB::createDbFromStructure('db_structure.xml');
- }
- }
- }
}
elseif($dbtype == 'oci') {
$dbuser = $options['dbuser'];
@@ -239,116 +142,20 @@ class OC_Setup {
$dbtablespace = $options['dbtablespace'];
$dbhost = isset($options['dbhost'])?$options['dbhost']:'';
$dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
- OC_CONFIG::setValue('dbname', $dbname);
- OC_CONFIG::setValue('dbtablespace', $dbtablespace);
- OC_CONFIG::setValue('dbhost', $dbhost);
- OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
-
- $e_host = addslashes($dbhost);
- $e_dbname = addslashes($dbname);
- //check if the database user has admin right
- if ($e_host == '') {
- $easy_connect_string = $e_dbname; // use dbname as easy connect name
- } else {
- $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
- }
- $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
- if(!$connection) {
- $e = oci_error();
+
+ OC_Config::setValue('dbname', $dbname);
+ OC_Config::setValue('dbtablespace', $dbtablespace);
+ OC_Config::setValue('dbhost', $dbhost);
+ OC_Config::setValue('dbtableprefix', $dbtableprefix);
+
+ try {
+ self::setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username);
+ } catch (Exception $e) {
$error[] = array(
'error' => 'Oracle username and/or password not valid',
'hint' => 'You need to enter either an existing account or the administrator.'
);
return $error;
- } else {
- //check for roles creation rights in oracle
-
- $query="SELECT count(*) FROM user_role_privs, role_sys_privs WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
- $stmt = oci_parse($connection, $query);
- if (!$stmt) {
- $entry='DB Error: "'.oci_last_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- $result = oci_execute($stmt);
- if($result) {
- $row = oci_fetch_row($stmt);
- }
- if($result and $row[0] > 0) {
- //use the admin login data for the new database user
-
- //add prefix to the oracle user name to prevent collisions
- $dbusername='oc_'.$username;
- //create a new password so we don't need to store the admin config in the config file
- $dbpassword=md5(time().$dbpass);
-
- //oracle passwords are treated as identifiers:
- // must start with aphanumeric char
- // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
- $dbpassword=substr($dbpassword, 0, 30);
-
- self::oci_createDBUser($dbusername, $dbpassword, $dbtablespace, $connection);
-
- OC_CONFIG::setValue('dbuser', $dbusername);
- OC_CONFIG::setValue('dbname', $dbusername);
- OC_CONFIG::setValue('dbpassword', $dbpassword);
-
- //create the database not neccessary, oracle implies user = schema
- //self::oci_createDatabase($dbname, $dbusername, $connection);
- } else {
-
- OC_CONFIG::setValue('dbuser', $dbuser);
- OC_CONFIG::setValue('dbname', $dbname);
- OC_CONFIG::setValue('dbpassword', $dbpass);
-
- //create the database not neccessary, oracle implies user = schema
- //self::oci_createDatabase($dbname, $dbuser, $connection);
- }
-
- //FIXME check tablespace exists: select * from user_tablespaces
-
- // the connection to dbname=oracle is not needed anymore
- oci_close($connection);
-
- // connect to the oracle database (schema=$dbuser) an check if the schema needs to be filled
- $dbuser = OC_CONFIG::getValue('dbuser');
- //$dbname = OC_CONFIG::getValue('dbname');
- $dbpass = OC_CONFIG::getValue('dbpassword');
-
- $e_host = addslashes($dbhost);
- $e_dbname = addslashes($dbname);
-
- if ($e_host == '') {
- $easy_connect_string = $e_dbname; // use dbname as easy connect name
- } else {
- $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
- }
- $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
- if(!$connection) {
- $error[] = array(
- 'error' => 'Oracle username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
- );
- return $error;
- } else {
- $query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
- $stmt = oci_parse($connection, $query);
- $un = $dbtableprefix.'users';
- oci_bind_by_name($stmt, ':un', $un);
- if (!$stmt) {
- $entry='DB Error: "'.oci_last_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- $result = oci_execute($stmt);
-
- if($result) {
- $row = oci_fetch_row($stmt);
- }
- if(!$result or $row[0]==0) {
- OC_DB::createDbFromStructure('db_structure.xml');
- }
- }
}
}
else {
@@ -369,8 +176,8 @@ 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', 'installedat', microtime(true));
+ OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
OC_Group::createGroup('admin');
OC_Group::addToGroup($username, 'admin');
@@ -383,7 +190,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);
}
@@ -392,7 +199,56 @@ class OC_Setup {
return $error;
}
- public static function createDatabase($name,$user,$connection) {
+ private static function setupMySQLDatabase($dbhost, $dbuser, $dbpass, $dbtableprefix, $username) {
+ //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');
+ }
+ $oldUser=OC_Config::getValue('dbuser', false);
+
+ $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql
+ if(mysql_query($query, $connection)) {
+ //use the admin login data for the new database user
+
+ //add prefix to the mysql user name to prevent collisions
+ $dbusername=substr('oc_'.$username, 0, 16);
+ if($dbusername!=$oldUser) {
+ //hash the password so we don't need to store the admin config in the config file
+ $dbpassword=md5(time().$password);
+
+ self::createDBUser($dbusername, $dbpassword, $connection);
+
+ OC_Config::setValue('dbuser', $dbusername);
+ OC_Config::setValue('dbpassword', $dbpassword);
+ }
+
+ //create the database
+ self::createMySQLDatabase($dbname, $dbusername, $connection);
+ }
+ else {
+ if($dbuser!=$oldUser) {
+ OC_Config::setValue('dbuser', $dbuser);
+ OC_Config::setValue('dbpassword', $dbpass);
+ }
+
+ //create the database
+ self::createMySQLDatabase($dbname, $dbuser, $connection);
+ }
+
+ //fill the database if needed
+ $query="select count(*) from information_schema.tables where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';";
+ $result = mysql_query($query, $connection);
+ if($result) {
+ $row=mysql_fetch_row($result);
+ }
+ if(!$result or $row[0]==0) {
+ OC_DB::createDbFromStructure('db_structure.xml');
+ }
+ mysql_close($connection);
+ }
+
+ private static function createMySQLDatabase($name,$user,$connection) {
//we cant use OC_BD functions here because we need to connect as the administrative user.
$query = "CREATE DATABASE IF NOT EXISTS `$name`";
$result = mysql_query($query, $connection);
@@ -414,7 +270,73 @@ class OC_Setup {
$result = mysql_query($query, $connection);
}
- public static function pg_createDatabase($name,$user,$connection) {
+ private static function setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username) {
+ $e_host = addslashes($dbhost);
+ $e_user = addslashes($dbuser);
+ $e_password = addslashes($dbpass);
+
+ //check if the database user has admin rights
+ $connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'";
+ $connection = @pg_connect($connection_string);
+ if(!$connection) {
+ throw new Exception('PostgreSQL username and/or password not valid');
+ }
+ $e_user = pg_escape_string($dbuser);
+ //check for roles creation rights in postgresql
+ $query="SELECT 1 FROM pg_roles WHERE rolcreaterole=TRUE AND rolname='$e_user'";
+ $result = pg_query($connection, $query);
+ if($result and pg_num_rows($result) > 0) {
+ //use the admin login data for the new database user
+
+ //add prefix to the postgresql user name to prevent collisions
+ $dbusername='oc_'.$username;
+ //create a new password so we don't need to store the admin config in the config file
+ $dbpassword=md5(time());
+
+ self::pg_createDBUser($dbusername, $dbpassword, $connection);
+
+ OC_Config::setValue('dbuser', $dbusername);
+ OC_Config::setValue('dbpassword', $dbpassword);
+
+ //create the database
+ self::pg_createDatabase($dbname, $dbusername, $connection);
+ }
+ else {
+ OC_Config::setValue('dbuser', $dbuser);
+ OC_Config::setValue('dbpassword', $dbpass);
+
+ //create the database
+ self::pg_createDatabase($dbname, $dbuser, $connection);
+ }
+
+ // the connection to dbname=postgres is not needed anymore
+ pg_close($connection);
+
+ // connect to the ownCloud database (dbname=$dbname) and check if it needs to be filled
+ $dbuser = OC_Config::getValue('dbuser');
+ $dbpass = OC_Config::getValue('dbpassword');
+
+ $e_host = addslashes($dbhost);
+ $e_dbname = addslashes($dbname);
+ $e_user = addslashes($dbuser);
+ $e_password = addslashes($dbpass);
+
+ $connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' password='$e_password'";
+ $connection = @pg_connect($connection_string);
+ if(!$connection) {
+ throw new Exception('PostgreSQL username and/or password not valid');
+ }
+ $query = "select count(*) FROM pg_class WHERE relname='{$dbtableprefix}users' limit 1";
+ $result = pg_query($connection, $query);
+ if($result) {
+ $row = pg_fetch_row($result);
+ }
+ if(!$result or $row[0]==0) {
+ OC_DB::createDbFromStructure('db_structure.xml');
+ }
+ }
+
+ private static function pg_createDatabase($name,$user,$connection) {
//we cant use OC_BD functions here because we need to connect as the administrative user.
$e_name = pg_escape_string($name);
$e_user = pg_escape_string($user);
@@ -470,6 +392,106 @@ class OC_Setup {
}
}
}
+
+ private static function setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username) {
+ $e_host = addslashes($dbhost);
+ $e_dbname = addslashes($dbname);
+ //check if the database user has admin right
+ if ($e_host == '') {
+ $easy_connect_string = $e_dbname; // use dbname as easy connect name
+ } else {
+ $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
+ }
+ $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
+ if(!$connection) {
+ $e = oci_error();
+ throw new Exception('Oracle username and/or password not valid');
+ }
+ //check for roles creation rights in oracle
+
+ $query="SELECT count(*) FROM user_role_privs, role_sys_privs WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
+ $stmt = oci_parse($connection, $query);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ $result = oci_execute($stmt);
+ if($result) {
+ $row = oci_fetch_row($stmt);
+ }
+ if($result and $row[0] > 0) {
+ //use the admin login data for the new database user
+
+ //add prefix to the oracle user name to prevent collisions
+ $dbusername='oc_'.$username;
+ //create a new password so we don't need to store the admin config in the config file
+ $dbpassword=md5(time().$dbpass);
+
+ //oracle passwords are treated as identifiers:
+ // must start with aphanumeric char
+ // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
+ $dbpassword=substr($dbpassword, 0, 30);
+
+ self::oci_createDBUser($dbusername, $dbpassword, $dbtablespace, $connection);
+
+ OC_Config::setValue('dbuser', $dbusername);
+ OC_Config::setValue('dbname', $dbusername);
+ OC_Config::setValue('dbpassword', $dbpassword);
+
+ //create the database not neccessary, oracle implies user = schema
+ //self::oci_createDatabase($dbname, $dbusername, $connection);
+ } else {
+
+ OC_Config::setValue('dbuser', $dbuser);
+ OC_Config::setValue('dbname', $dbname);
+ OC_Config::setValue('dbpassword', $dbpass);
+
+ //create the database not neccessary, oracle implies user = schema
+ //self::oci_createDatabase($dbname, $dbuser, $connection);
+ }
+
+ //FIXME check tablespace exists: select * from user_tablespaces
+
+ // the connection to dbname=oracle is not needed anymore
+ oci_close($connection);
+
+ // connect to the oracle database (schema=$dbuser) an check if the schema needs to be filled
+ $dbuser = OC_Config::getValue('dbuser');
+ //$dbname = OC_Config::getValue('dbname');
+ $dbpass = OC_Config::getValue('dbpassword');
+
+ $e_host = addslashes($dbhost);
+ $e_dbname = addslashes($dbname);
+
+ if ($e_host == '') {
+ $easy_connect_string = $e_dbname; // use dbname as easy connect name
+ } else {
+ $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
+ }
+ $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
+ if(!$connection) {
+ throw new Exception('Oracle username and/or password not valid');
+ }
+ $query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
+ $stmt = oci_parse($connection, $query);
+ $un = $dbtableprefix.'users';
+ oci_bind_by_name($stmt, ':un', $un);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ $result = oci_execute($stmt);
+
+ if($result) {
+ $row = oci_fetch_row($stmt);
+ }
+ if(!$result or $row[0]==0) {
+ OC_DB::createDbFromStructure('db_structure.xml');
+ }
+ }
+
/**
*
* @param String $name
diff --git a/lib/streamwrappers.php b/lib/streamwrappers.php
index 1e5b19a11f0..63b795f4c4d 100644
--- a/lib/streamwrappers.php
+++ b/lib/streamwrappers.php
@@ -6,7 +6,7 @@ class OC_FakeDirStream{
private $index;
public function dir_opendir($path,$options) {
- $this->name=substr($path,strlen('fakedir://'));
+ $this->name=substr($path, strlen('fakedir://'));
$this->index=0;
if(!isset(self::$dirs[$this->name])) {
self::$dirs[$this->name]=array();
@@ -223,7 +223,7 @@ class OC_CloseStreamWrapper{
private $source;
private static $open=array();
public function stream_open($path, $mode, $options, &$opened_path) {
- $path=substr($path,strlen('close://'));
+ $path=substr($path, strlen('close://'));
$this->path=$path;
$this->source=fopen($path,$mode);
if(is_resource($this->source)) {
@@ -279,7 +279,7 @@ class OC_CloseStreamWrapper{
}
public function url_stat($path) {
- $path=substr($path,strlen('close://'));
+ $path=substr($path, strlen('close://'));
if(file_exists($path)) {
return stat($path);
}else{
@@ -295,7 +295,7 @@ class OC_CloseStreamWrapper{
}
public function unlink($path) {
- $path=substr($path,strlen('close://'));
+ $path=substr($path, strlen('close://'));
return unlink($path);
}
}
diff --git a/lib/subadmin.php b/lib/subadmin.php
index 363e4a97cad..9e83e6da430 100644
--- a/lib/subadmin.php
+++ b/lib/subadmin.php
@@ -172,7 +172,7 @@ class OC_SubAdmin{
}
/**
- * @brief delete all SubAdmins8 by gid
+ * @brief delete all SubAdmins by gid
* @param $parameters
* @return boolean
*/
diff --git a/lib/template.php b/lib/template.php
index 8c872a2059b..972d75807c7 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -23,10 +23,10 @@
/**
* @brief make OC_Helper::linkTo available as a simple function
- * @param $app app
- * @param $file file
- * @param $args array with param=>value, will be appended to the returned url
- * @returns link to the file
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * @return string link to the file
*
* For further information have a look at OC_Helper::linkTo
*/
@@ -36,9 +36,9 @@ function link_to( $app, $file, $args = array() ) {
/**
* @brief make OC_Helper::imagePath available as a simple function
- * @param $app app
- * @param $image image
- * @returns link to the image
+ * @param string $app app
+ * @param string $image image
+ * @return string link to the image
*
* For further information have a look at OC_Helper::imagePath
*/
@@ -48,8 +48,8 @@ function image_path( $app, $image ) {
/**
* @brief make OC_Helper::mimetypeIcon available as a simple function
- * @param $mimetype mimetype
- * @returns link to the image
+ * @param string $mimetype mimetype
+ * @return string link to the image
*
* For further information have a look at OC_Helper::mimetypeIcon
*/
@@ -59,8 +59,8 @@ function mimetype_icon( $mimetype ) {
/**
* @brief make OC_Helper::humanFileSize available as a simple function
- * @param $bytes size in bytes
- * @returns size as string
+ * @param int $bytes size in bytes
+ * @return string size as string
*
* For further information have a look at OC_Helper::humanFileSize
*/
@@ -139,10 +139,10 @@ class OC_Template{
/**
* @brief Constructor
- * @param $app app providing the template
- * @param $file name of the template file (without suffix)
- * @param $renderas = ""; produce a full page
- * @returns OC_Template object
+ * @param string $app app providing the template
+ * @param string $file name of the template file (without suffix)
+ * @param string $renderas = ""; produce a full page
+ * @return OC_Template object
*
* This function creates an OC_Template object.
*
@@ -155,19 +155,21 @@ class OC_Template{
$this->renderas = $renderas;
$this->application = $app;
$this->vars = array();
- if($renderas == 'user') {
- $this->vars['requesttoken'] = OC_Util::callRegister();
- }
- $this->l10n = OC_L10N::get($app);
- header('X-Frame-Options: Sameorigin');
- header('X-XSS-Protection: 1; mode=block');
- header('X-Content-Type-Options: nosniff');
+ $this->vars['requesttoken'] = OC_Util::callRegister();
+ $this->vars['requestlifespan'] = OC_Util::$callLifespan;
+ $parts = explode('/', $app); // fix translation when app is something like core/lostpassword
+ $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');
$this->findTemplate($name);
}
/**
- * autodetects the formfactor of the used device
+ * autodetect the formfactor of the used device
* default -> the normal desktop browser interface
* mobile -> interface for smartphones
* tablet -> interface for tablets
@@ -225,7 +227,7 @@ class OC_Template{
/**
* @brief find the template with the given name
- * @param $name of the template file (without suffix)
+ * @param string $name of the template file (without suffix)
*
* Will select the template file for the selected theme and formfactor.
* Checking all the possible locations.
@@ -270,13 +272,13 @@ class OC_Template{
/**
* @brief check Path For Template with and without $fext
- * @param $path to check
- * @param $name of the template file (without suffix)
- * @param $fext formfactor extension
+ * @param string $path to check
+ * @param string $name of the template file (without suffix)
+ * @param string $fext formfactor extension
* @return bool true when found
*
* Will set $this->template and $this->path if there is a template at
- * the specifief $path
+ * the specific $path
*/
protected function checkPathForTemplate($path, $name, $fext)
{
@@ -297,10 +299,10 @@ class OC_Template{
/**
* @brief Assign variables
- * @param $key key
- * @param $value value
- * @param $sanitizeHTML false, if data shouldn't get passed through htmlentities
- * @returns true
+ * @param string $key key
+ * @param string $value value
+ * @param bool $sanitizeHTML false, if data shouldn't get passed through htmlentities
+ * @return bool
*
* This function assigns a variable. It can be accessed via $_[$key] in
* the template.
@@ -315,9 +317,9 @@ class OC_Template{
/**
* @brief Appends a variable
- * @param $key key
- * @param $value value
- * @returns true
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function assigns a variable in an array context. If the key already
* exists, the value will be appended. It can be accessed via
@@ -334,7 +336,7 @@ class OC_Template{
/**
* @brief Add a custom element to the header
- * @param string tag tag name of the element
+ * @param string $tag tag name of the element
* @param array $attributes array of attrobutes for the element
* @param string $text the text content for the element
*/
@@ -344,7 +346,7 @@ class OC_Template{
/**
* @brief Prints the proceeded template
- * @returns true/false
+ * @return bool
*
* This function proceeds the template and prints its output.
*/
@@ -361,7 +363,7 @@ class OC_Template{
/**
* @brief Proceeds the template
- * @returns content
+ * @return bool
*
* This function proceeds the template. If $this->renderas is set, it
* will produce a full page.
@@ -373,6 +375,7 @@ class OC_Template{
$page = new OC_TemplateLayout($this->renderas);
if($this->renderas == 'user') {
$page->assign('requesttoken', $this->vars['requesttoken']);
+ $page->assign('requestlifespan', $this->vars['requestlifespan']);
}
// Add custom headers
@@ -391,7 +394,7 @@ class OC_Template{
/**
* @brief doing the actual work
- * @returns content
+ * @return string content
*
* Includes the template file, fetches its output
*/
@@ -402,7 +405,7 @@ class OC_Template{
// Execute the template
ob_start();
- include( $this->template ); // <-- we have to use include because we pass $_!
+ include $this->template; // <-- we have to use include because we pass $_!
$data = ob_get_contents();
@ob_end_clean();
@@ -412,13 +415,12 @@ class OC_Template{
/**
* @brief Include template
- * @returns returns content of included template
+ * @return string returns content of included template
*
* Includes another template. use <?php echo $this->inc('template'); ?> to
* do this.
*/
public function inc( $file, $additionalparams = null ) {
- // $_ erstellen
$_ = $this->vars;
$l = $this->l10n;
@@ -428,7 +430,7 @@ class OC_Template{
// Include
ob_start();
- include( $this->path.$file.'.php' );
+ include $this->path.$file.'.php';
$data = ob_get_contents();
@ob_end_clean();
@@ -438,10 +440,10 @@ class OC_Template{
/**
* @brief Shortcut to print a simple page for users
- * @param $application The application we render the template for
- * @param $name Name of the template
- * @param $parameters Parameters for the template
- * @returns true/false
+ * @param string $application The application we render the template for
+ * @param string $name Name of the template
+ * @param array $parameters Parameters for the template
+ * @return bool
*/
public static function printUserPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "user" );
@@ -453,10 +455,10 @@ class OC_Template{
/**
* @brief Shortcut to print a simple page for admins
- * @param $application The application we render the template for
- * @param $name Name of the template
- * @param $parameters Parameters for the template
- * @returns true/false
+ * @param string $application The application we render the template for
+ * @param string $name Name of the template
+ * @param array $parameters Parameters for the template
+ * @return bool
*/
public static function printAdminPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "admin" );
@@ -468,10 +470,10 @@ class OC_Template{
/**
* @brief Shortcut to print a simple page for guests
- * @param $application The application we render the template for
- * @param $name Name of the template
- * @param $parameters Parameters for the template
- * @returns true/false
+ * @param string $application The application we render the template for
+ * @param string $name Name of the template
+ * @param string $parameters Parameters for the template
+ * @return bool
*/
public static function printGuestPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "guest" );
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index c898628bcdf..c3da172a7c1 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -12,8 +12,7 @@ class OC_TemplateLayout extends OC_Template {
if( $renderas == 'user' ) {
parent::__construct( 'core', 'layout.user' );
- $this->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' ), false);
- if(array_search(OC_APP::getCurrentApp(),array('settings','admin','help'))!==false) {
+ if(in_array(OC_APP::getCurrentApp(), array('settings','admin','help'))!==false) {
$this->assign('bodyid','body-settings', false);
}else{
$this->assign('bodyid','body-user', false);
@@ -39,7 +38,7 @@ class OC_TemplateLayout extends OC_Template {
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
+ $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');
@@ -50,7 +49,7 @@ class OC_TemplateLayout extends OC_Template {
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
$this->assign('jsfiles', array(), false);
if (!empty(OC_Util::$core_scripts)) {
- $this->append( 'jsfiles', OC_Helper::linkToRemote('core.js', false));
+ $this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false));
}
foreach($jsfiles as $info) {
$root = $info[0];
@@ -63,7 +62,7 @@ class OC_TemplateLayout extends OC_Template {
$cssfiles = self::findStylesheetFiles(OC_Util::$styles);
$this->assign('cssfiles', array());
if (!empty(OC_Util::$core_styles)) {
- $this->append( 'cssfiles', OC_Helper::linkToRemote('core.css', false));
+ $this->append( 'cssfiles', OC_Helper::linkToRemoteBase('core.css', false));
}
foreach($cssfiles as $info) {
$root = $info[0];
diff --git a/lib/updater.php b/lib/updater.php
index ad42f2bf605..f55e55985d9 100644
--- a/lib/updater.php
+++ b/lib/updater.php
@@ -29,8 +29,8 @@ class OC_Updater{
* Check if a new version is available
*/
public static function check() {
- OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true));
- if(OC_Appconfig::getValue('core', 'installedat','')=='') OC_Appconfig::setValue('core', 'installedat',microtime(true));
+ OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
+ if(OC_Appconfig::getValue('core', 'installedat','')=='') OC_Appconfig::setValue('core', 'installedat', microtime(true));
$updaterurl='http://apps.owncloud.com/updater.php';
$version=OC_Util::getVersion();
@@ -42,8 +42,17 @@ class OC_Updater{
//fetch xml data from updater
$url=$updaterurl.'?version='.$versionstring;
- $xml=@file_get_contents($url);
- if($xml==FALSE) {
+
+ // set a sensible timeout of 10 sec to stay responsive even if the update server is down.
+ $ctx = stream_context_create(
+ array(
+ 'http' => array(
+ 'timeout' => 10
+ )
+ )
+ );
+ $xml=@file_get_contents($url, 0, $ctx);
+ if($xml==false) {
return array();
}
$data=@simplexml_load_string($xml);
@@ -63,7 +72,7 @@ class OC_Updater{
if(OC_Config::getValue('updatechecker', true)==true) {
$data=OC_Updater::check();
if(isset($data['version']) and $data['version']<>'') {
- $txt='<span style="color:#AA0000; font-weight:bold;">'.$l->t('%s is available. Get <a href="%s">more information</a>',array($data['versionstring'], $data['web'])).'</span>';
+ $txt='<span style="color:#AA0000; font-weight:bold;">'.$l->t('%s is available. Get <a href="%s">more information</a>', array($data['versionstring'], $data['web'])).'</span>';
}else{
$txt=$l->t('up to date');
}
diff --git a/lib/user.php b/lib/user.php
index 7de2a4b7fe6..064fcbad96f 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -120,11 +120,11 @@ class OC_User {
* setup the configured backends in config.php
*/
public static function setupBackends() {
- $backends=OC_Config::getValue('user_backends',array());
+ $backends=OC_Config::getValue('user_backends', array());
foreach($backends as $i=>$config) {
$class=$config['class'];
$arguments=$config['arguments'];
- if(class_exists($class) and array_search($i,self::$_setupedBackends)===false) {
+ if(class_exists($class) and array_search($i, self::$_setupedBackends)===false) {
// make a reflection object
$reflectionObj = new ReflectionClass($class);
@@ -210,6 +210,10 @@ class OC_User {
}
// Delete the user's keys in preferences
OC_Preferences::deleteUser($uid);
+
+ // Delete user files in /data/
+ OC_Helper::rmdirr(OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/'.$uid.'/');
+
// Emit and exit
OC_Hook::emit( "OC_User", "post_deleteUser", array( "uid" => $uid ));
return true;
@@ -329,6 +333,8 @@ class OC_User {
}
}
}
+ // invalidate all login cookies
+ OC_Preferences::deleteApp($uid, 'login_token');
OC_Hook::emit( "OC_User", "post_setPassword", array( "uid" => $uid, "password" => $password ));
return $success;
}
@@ -472,9 +478,10 @@ class OC_User {
*/
public static function setMagicInCookie($username, $token) {
$secure_cookie = OC_Config::getValue("forcessl", false);
- setcookie("oc_username", $username, time()+60*60*24*15, '', '', $secure_cookie);
- setcookie("oc_token", $token, time()+60*60*24*15, '', '', $secure_cookie);
- setcookie("oc_remember_login", true, time()+60*60*24*15, '', '', $secure_cookie);
+ $expires = time() + OC_Config::getValue('remember_login_cookie_lifetime', 60*60*24*15);
+ setcookie("oc_username", $username, $expires, '', '', $secure_cookie);
+ setcookie("oc_token", $token, $expires, '', '', $secure_cookie, true);
+ setcookie("oc_remember_login", true, $expires, '', '', $secure_cookie);
}
/**
@@ -484,8 +491,8 @@ class OC_User {
unset($_COOKIE["oc_username"]);
unset($_COOKIE["oc_token"]);
unset($_COOKIE["oc_remember_login"]);
- setcookie("oc_username", NULL, -1);
- setcookie("oc_token", NULL, -1);
- setcookie("oc_remember_login", NULL, -1);
+ setcookie("oc_username", null, -1);
+ setcookie("oc_token", null, -1);
+ setcookie("oc_remember_login", null, -1);
}
}
diff --git a/lib/util.php b/lib/util.php
index 5e39fd1f914..4ca84ba75af 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -1,9 +1,9 @@
<?php
-
/**
* Class for utility functions
*
*/
+
class OC_Util {
public static $scripts=array();
public static $styles=array();
@@ -34,7 +34,7 @@ class OC_Util {
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
//first set up the local "root" storage
if(!self::$rootMounted) {
- OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/');
+ OC_Filesystem::mount('OC_Filestorage_Local', array('datadir'=>$CONFIG_DATADIRECTORY),'/');
self::$rootMounted=true;
}
@@ -47,25 +47,13 @@ class OC_Util {
}
//jail the user into his "home" directory
OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user);
- OC_Filesystem::init($user_dir);
+ OC_Filesystem::init($user_dir, $user);
$quotaProxy=new OC_FileProxy_Quota();
+ $fileOperationProxy = new OC_FileProxy_FileOperations();
OC_FileProxy::register($quotaProxy);
+ OC_FileProxy::register($fileOperationProxy);
// Load personal mount config
- if (is_file($user_root.'/mount.php')) {
- $mountConfig = include($user_root.'/mount.php');
- if (isset($mountConfig['user'][$user])) {
- foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
- OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
- }
- }
-
- $mtime=filemtime($user_root.'/mount.php');
- $previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0);
- if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
- OC_FileCache::clear($user);
- OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime);
- }
- }
+ self::loadUserMountPoints($user);
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
}
}
@@ -74,14 +62,35 @@ class OC_Util {
OC_Filesystem::tearDown();
self::$fsSetup=false;
}
+
+ public static function loadUserMountPoints($user) {
+ $user_dir = '/'.$user.'/files';
+ $user_root = OC_User::getHome($user);
+ $userdirectory = $user_root . '/files';
+ if (is_file($user_root.'/mount.php')) {
+ $mountConfig = include $user_root.'/mount.php';
+ if (isset($mountConfig['user'][$user])) {
+ foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
+ OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
+ }
+ }
+
+ $mtime=filemtime($user_root.'/mount.php');
+ $previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0);
+ if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
+ OC_FileCache::triggerUpdate($user);
+ OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime);
+ }
+ }
+ }
/**
* get the current installed version of ownCloud
* @return array
*/
public static function getVersion() {
- // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4,9,0. This is not visible to the user
- return array(4,84,7);
+ // 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,00);
}
/**
@@ -89,7 +98,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '4.5 beta 3a';
+ return '5.0 pre alpha';
}
/**
@@ -160,8 +169,8 @@ class OC_Util {
$offset=$clientTimeZone-$systemTimeZone;
$timestamp=$timestamp+$offset*60;
}
- $timeformat=$dateOnly?'F j, Y':'F j, Y, H:i';
- return date($timeformat,$timestamp);
+ $l=OC_L10N::get('lib');
+ return $l->l($dateOnly ? 'date' : 'datetime', $timestamp);
}
/**
@@ -287,6 +296,14 @@ class OC_Util {
$errors[]=array('error'=>'PHP module zlib is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
+ if(!function_exists('iconv')) {
+ $errors[]=array('error'=>'PHP module iconv is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
+ }
+ if(!function_exists('simplexml_load_string')) {
+ $errors[]=array('error'=>'PHP module SimpleXML is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
+ }
if(floatval(phpversion())<5.3) {
$errors[]=array('error'=>'PHP 5.3 is required.<br/>','hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.');
$web_server_restart= false;
@@ -303,9 +320,11 @@ class OC_Util {
return $errors;
}
- public static function displayLoginPage($display_lostpassword) {
+ public static function displayLoginPage($errors = array()) {
$parameters = array();
- $parameters['display_lostpassword'] = $display_lostpassword;
+ foreach( $errors as $key => $value ) {
+ $parameters[$value] = true;
+ }
if (!empty($_POST['user'])) {
$parameters["username"] =
OC_Util::sanitizeHTML($_POST['user']).'"';
@@ -314,9 +333,6 @@ class OC_Util {
$parameters["username"] = '';
$parameters['user_autofocus'] = true;
}
- $sectoken=rand(1000000,9999999);
- $_SESSION['sectoken']=$sectoken;
- $parameters["sectoken"] = $sectoken;
if (isset($_REQUEST['redirect_url'])) {
$redirect_url = OC_Util::sanitizeHTML($_REQUEST['redirect_url']);
} else {
@@ -344,7 +360,7 @@ class OC_Util {
public static function checkLoggedIn() {
// Check if we are a user
if( !OC_User::isLoggedIn()) {
- header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', array('redirect_url' => urlencode($_SERVER["REQUEST_URI"]))));
+ header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', array('redirect_url' => $_SERVER["REQUEST_URI"])));
exit();
}
}
@@ -355,6 +371,7 @@ class OC_Util {
public static function checkAdminUser() {
// Check if we are a user
self::checkLoggedIn();
+ self::verifyUser();
if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) {
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ));
exit();
@@ -368,6 +385,7 @@ class OC_Util {
public static function checkSubAdminUser() {
// Check if we are a user
self::checkLoggedIn();
+ self::verifyUser();
if(OC_Group::inGroup(OC_User::getUser(),'admin')) {
return true;
}
@@ -379,6 +397,40 @@ 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() {
@@ -407,7 +459,7 @@ class OC_Util {
* @return string
*/
public static function getInstanceId() {
- $id=OC_Config::getValue('instanceid',null);
+ $id=OC_Config::getValue('instanceid', null);
if(is_null($id)) {
$id=uniqid();
OC_Config::setValue('instanceid',$id);
@@ -416,16 +468,31 @@ class OC_Util {
}
/**
- * @brief Register an get/post call. This is important to prevent CSRF attacks
- * Todo: Write howto
+ * @brief Static lifespan (in seconds) when a request token expires.
+ * @see OC_Util::callRegister()
+ * @see OC_Util::isCallRegistered()
+ * @description
+ * Also required for the client side to compute the piont in time when to
+ * request a fresh token. The client will do so when nearly 97% of the
+ * timespan coded here has expired.
+ */
+ public static $callLifespan = 3600; // 3600 secs = 1 hour
+
+ /**
+ * @brief Register an get/post call. Important to prevent CSRF attacks.
+ * @todo Write howto: CSRF protection guide
* @return $token Generated token.
+ * @description
+ * Creates a 'request token' (random) and stores it inside the session.
+ * Ever subsequent (ajax) request must use such a valid token to succeed,
+ * otherwise the request will be denied as a protection against CSRF.
+ * The tokens expire after a fixed lifespan.
+ * @see OC_Util::$callLifespan
+ * @see OC_Util::isCallRegistered()
*/
public static function callRegister() {
- //mamimum time before token exires
- $maxtime=(60*60); // 1 hour
-
// generate a random token.
- $token=mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000);
+ $token = self::generate_random_bytes(20);
// store the token together with a timestamp in the session.
$_SESSION['requesttoken-'.$token]=time();
@@ -436,7 +503,8 @@ class OC_Util {
foreach($_SESSION as $key=>$value) {
// search all tokens in the session
if(substr($key,0,12)=='requesttoken') {
- if($value+$maxtime<time()) {
+ // check if static lifespan has expired
+ if($value+self::$callLifespan<time()) {
// remove outdated tokens
unset($_SESSION[$key]);
}
@@ -447,14 +515,13 @@ class OC_Util {
return($token);
}
-
/**
* @brief Check an ajax get/post call if the request token is valid.
* @return boolean False if request token is not set or is invalid.
+ * @see OC_Util::$callLifespan
+ * @see OC_Util::calLRegister()
*/
public static function isCallRegistered() {
- //mamimum time before token exires
- $maxtime=(60*60); // 1 hour
if(isset($_GET['requesttoken'])) {
$token=$_GET['requesttoken'];
}elseif(isset($_POST['requesttoken'])) {
@@ -467,7 +534,8 @@ class OC_Util {
}
if(isset($_SESSION['requesttoken-'.$token])) {
$timestamp=$_SESSION['requesttoken-'.$token];
- if($timestamp+$maxtime<time()) {
+ // check if static lifespan has expired
+ if($timestamp+self::$callLifespan<time()) {
return false;
}else{
//token valid
@@ -514,6 +582,11 @@ class OC_Util {
// creating a test file
$testfile = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$filename;
+
+ if(file_exists($testfile)){// already running this test, possible recursive call
+ return false;
+ }
+
$fp = @fopen($testfile, 'w');
@fwrite($fp, $testcontent);
@fclose($fp);
@@ -535,4 +608,62 @@ class OC_Util {
}
}
+ /**
+ * @brief Generates a cryptographical secure pseudorandom string
+ * @param Int with the length of the random string
+ * @return String
+ * Please also update secureRNG_available if you change something here
+ */
+ public static function generate_random_bytes($length = 30) {
+
+ // Try to use openssl_random_pseudo_bytes
+ if(function_exists('openssl_random_pseudo_bytes')) {
+ $pseudo_byte = bin2hex(openssl_random_pseudo_bytes($length, $strong));
+ if($strong == true) {
+ return substr($pseudo_byte, 0, $length); // Truncate it to match the length
+ }
+ }
+
+ // Try to use /dev/urandom
+ $fp = @file_get_contents('/dev/urandom', false, null, 0, $length);
+ if ($fp !== false) {
+ $string = substr(bin2hex($fp), 0, $length);
+ return $string;
+ }
+
+ // Fallback to mt_rand()
+ $characters = '0123456789';
+ $characters .= 'abcdefghijklmnopqrstuvwxyz';
+ $charactersLength = strlen($characters)-1;
+ $pseudo_byte = "";
+
+ // Select some random characters
+ for ($i = 0; $i < $length; $i++) {
+ $pseudo_byte .= $characters[mt_rand(0, $charactersLength)];
+ }
+ return $pseudo_byte;
+ }
+
+ /**
+ * @brief Checks if a secure random number generator is available
+ * @return bool
+ */
+ public static function secureRNG_available() {
+
+ // Check openssl_random_pseudo_bytes
+ if(function_exists('openssl_random_pseudo_bytes')) {
+ openssl_random_pseudo_bytes(1, $strong);
+ if($strong == true) {
+ return true;
+ }
+ }
+
+ // Check /dev/urandom
+ $fp = @file_get_contents('/dev/urandom', false, null, 0, 1);
+ if ($fp !== false) {
+ return true;
+ }
+
+ return false;
+ }
}
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 6b1d6a316f1..ba6569a244d 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -222,7 +222,7 @@ class OC_VCategories {
if(!is_array($haystack)) {
return false;
}
- return array_search(strtolower($needle),array_map('strtolower',$haystack));
+ return array_search(strtolower($needle), array_map('strtolower',$haystack));
}
}
diff --git a/lib/vobject.php b/lib/vobject.php
index b5a04b4bf65..2ccf8eda685 100644
--- a/lib/vobject.php
+++ b/lib/vobject.php
@@ -62,7 +62,7 @@ class OC_VObject{
foreach($value as &$i ) {
$i = implode("\\\\;", explode(';', $i));
}
- return implode(';',$value);
+ return implode(';', $value);
}
/**
@@ -71,15 +71,15 @@ class OC_VObject{
* @return array
*/
public static function unescapeSemicolons($value) {
- $array = explode(';',$value);
+ $array = explode(';', $value);
for($i=0;$i<count($array);$i++) {
- if(substr($array[$i],-2,2)=="\\\\") {
+ if(substr($array[$i], -2, 2)=="\\\\") {
if(isset($array[$i+1])) {
- $array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1];
+ $array[$i] = substr($array[$i], 0, count($array[$i])-2).';'.$array[$i+1];
unset($array[$i+1]);
}
else{
- $array[$i] = substr($array[$i],0,count($array[$i])-2).';';
+ $array[$i] = substr($array[$i], 0, count($array[$i])-2).';';
}
$i = $i - 1;
}
@@ -127,8 +127,8 @@ class OC_VObject{
}
public function setUID() {
- $uid = substr(md5(rand().time()),0,10);
- $this->vobject->add('UID',$uid);
+ $uid = substr(md5(rand().time()), 0, 10);
+ $this->vobject->add('UID', $uid);
}
public function setString($name, $string) {