/**
  * @brief checks whether or not an app is enabled
  * @param $app app
  * @returns true/false
  *
  * This function checks whether or not an app is enabled.
  */
 public static function isEnabled($app)
 {
     if ('yes' == OC_Appconfig::getValue($app, 'enabled')) {
         return true;
     }
     return false;
 }
 /**
  * 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));
     }
     $updaterurl = 'http://apps.owncloud.com/updater.php';
     $version = OC_Util::getVersion();
     $version['installed'] = OC_Appconfig::getValue('core', 'installedat');
     $version['updated'] = OC_Appconfig::getValue('core', 'lastupdatedat');
     $version['updatechannel'] = 'stable';
     $version['edition'] = OC_Util::getEditionString();
     $versionstring = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterurl . '?version=' . $versionstring;
     $xml = @file_get_contents($url);
     if ($xml == FALSE) {
         return array();
     }
     $data = @simplexml_load_string($xml);
     $tmp = array();
     $tmp['version'] = $data->version;
     $tmp['versionstring'] = $data->versionstring;
     $tmp['url'] = $data->url;
     $tmp['web'] = $data->web;
     return $tmp;
 }
Exemple #3
0
 /**
  * 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));
     }
     $updaterurl = 'http://apps.owncloud.com/updater.php';
     $version = OC_Util::getVersion();
     $version['installed'] = OC_Appconfig::getValue('core', 'installedat');
     $version['updated'] = OC_Appconfig::getValue('core', 'lastupdatedat');
     $version['updatechannel'] = 'stable';
     $version['edition'] = OC_Util::getEditionString();
     $versionstring = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterurl . '?version=' . $versionstring;
     // 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);
     $tmp = array();
     $tmp['version'] = $data->version;
     $tmp['versionstring'] = $data->versionstring;
     $tmp['url'] = $data->url;
     $tmp['web'] = $data->web;
     return $tmp;
 }
 /**
  * Check if a new version is available
  * @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
  * @return array | bool
  */
 public function check($updaterUrl)
 {
     // Look up the cache - it is invalidated all 30 minutes
     if (\OC_Appconfig::getValue('core', 'lastupdatedat') + 1800 > time()) {
         return json_decode(\OC_Appconfig::getValue('core', 'lastupdateResult'), true);
     }
     \OC_Appconfig::setValue('core', 'lastupdatedat', time());
     if (\OC_Appconfig::getValue('core', 'installedat', '') == '') {
         \OC_Appconfig::setValue('core', 'installedat', microtime(true));
     }
     $version = \OC_Util::getVersion();
     $version['installed'] = \OC_Appconfig::getValue('core', 'installedat');
     $version['updated'] = \OC_Appconfig::getValue('core', 'lastupdatedat');
     $version['updatechannel'] = \OC_Util::getChannel();
     $version['edition'] = \OC_Util::getEditionString();
     $version['build'] = \OC_Util::getBuild();
     $versionString = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterUrl . '?version=' . $versionString;
     // 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);
     $tmp = array();
     $tmp['version'] = $data->version;
     $tmp['versionstring'] = $data->versionstring;
     $tmp['url'] = $data->url;
     $tmp['web'] = $data->web;
     // Cache the result
     \OC_Appconfig::setValue('core', 'lastupdateResult', json_encode($data));
     return $tmp;
 }
Exemple #5
0
 /**
  * gets user info
  */
 public static function getUser($parameters)
 {
     $userid = $parameters['userid'];
     $return = array();
     $return['email'] = OC_Preferences::getValue($userid, 'settings', 'email', '');
     $default = OC_Appconfig::getValue('files', 'default_quota', 0);
     $return['quota'] = OC_Preferences::getValue($userid, 'files', 'quota', $default);
     return $return;
 }
 function __construct()
 {
     $this->ldap_host = OC_Appconfig::getValue('user_ldap', 'ldap_host', '');
     $this->ldap_port = OC_Appconfig::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT);
     $this->ldap_dn = OC_Appconfig::getValue('user_ldap', 'ldap_dn', '');
     $this->ldap_password = OC_Appconfig::getValue('user_ldap', 'ldap_password', '');
     $this->ldap_base = OC_Appconfig::getValue('user_ldap', 'ldap_base', '');
     $this->ldap_filter = OC_Appconfig::getValue('user_ldap', 'ldap_filter', '');
     if (!empty($this->ldap_host) && !empty($this->ldap_port) && !empty($this->ldap_dn) && !empty($this->ldap_password) && !empty($this->ldap_base) && !empty($this->ldap_filter)) {
         $this->configured = true;
     }
 }
Exemple #7
0
 public function testGetValue()
 {
     $query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?');
     $result = $query->execute(array('testapp', 'installed_version'));
     $expected = $result->fetchRow();
     $value = \OC_Appconfig::getValue('testapp', 'installed_version');
     $this->assertEquals($expected['configvalue'], $value);
     $value = \OC_Appconfig::getValue('testapp', 'nonexistant');
     $this->assertNull($value);
     $value = \OC_Appconfig::getValue('testapp', 'nonexistant', 'default');
     $this->assertEquals('default', $value);
 }
 public static function checkNext()
 {
     // check both 1 file and 1 folder, this way new files are detected quicker because there are less folders than files usually
     $previousFile = \OC_Appconfig::getValue('files', 'backgroundwatcher_previous_file', 0);
     $previousFolder = \OC_Appconfig::getValue('files', 'backgroundwatcher_previous_folder', 0);
     $nextFile = self::getNextFileId($previousFile, false);
     $nextFolder = self::getNextFileId($previousFolder, true);
     \OC_Appconfig::setValue('files', 'backgroundwatcher_previous_file', $nextFile);
     \OC_Appconfig::setValue('files', 'backgroundwatcher_previous_folder', $nextFolder);
     if ($nextFile > 0) {
         self::checkUpdate($nextFile);
     }
     if ($nextFolder > 0) {
         self::checkUpdate($nextFolder);
     }
 }
 function __construct()
 {
     $this->db_conn = false;
     $db_host = OC_Appconfig::getValue('user_django_auth', 'django_auth_db_host', '');
     $db_name = OC_Appconfig::getValue('user_django_auth', 'django_auth_db_name', '');
     $db_driver = OC_Appconfig::getValue('user_django_auth', 'django_auth_db_driver', 'mysql');
     $db_user = OC_Appconfig::getValue('user_django_auth', 'django_auth_db_user', '');
     $db_password = OC_Appconfig::getValue('user_django_auth', 'django_auth_db_password', '');
     $dsn = "{$db_driver}:host={$db_host};dbname={$db_name}";
     try {
         $this->db = new PDO($dsn, $db_user, $db_password);
         $this->db_conn = true;
     } catch (PDOException $e) {
         OC_Log::write('OC_User_Django_Auth', 'OC_User_Django_Auth, Failed to connect to django auth database: ' . $e->getMessage(), OC_Log::ERROR);
     }
     return false;
 }
Exemple #10
0
 /**
  * @brief does a single task
  * @return boolean
  *
  * This method executes one task. It saves the last state and continues
  * with the next step. This method should be used by webcron and ajax
  * services.
  */
 public static function doNextStep()
 {
     $laststep = OC_Appconfig::getValue('core', 'backgroundjobs_step', 'regular_tasks');
     if ($laststep == 'regular_tasks') {
         // get last app
         $lasttask = OC_Appconfig::getValue('core', 'backgroundjobs_task', '');
         // What's the next step?
         $regular_tasks = OC_BackgroundJob_RegularTask::all();
         ksort($regular_tasks);
         $done = false;
         // search for next background job
         foreach ($regular_tasks as $key => $value) {
             if (strcmp($key, $lasttask) > 0) {
                 OC_Appconfig::setValue('core', 'backgroundjobs_task', $key);
                 $done = true;
                 call_user_func($value);
                 break;
             }
         }
         if ($done == false) {
             // Next time load queued tasks
             OC_Appconfig::setValue('core', 'backgroundjobs_step', 'queued_tasks');
         }
     } else {
         $tasks = OC_BackgroundJob_QueuedTask::all();
         if (count($tasks)) {
             $task = $tasks[0];
             // delete job before we execute it. This prevents endless loops
             // of failing jobs.
             OC_BackgroundJob_QueuedTask::delete($task['id']);
             // execute job
             call_user_func(array($task['klass'], $task['method']), $task['parameters']);
         } else {
             // Next time load queued tasks
             OC_Appconfig::setValue('core', 'backgroundjobs_step', 'regular_tasks');
             OC_Appconfig::setValue('core', 'backgroundjobs_task', '');
         }
     }
     return true;
 }
Exemple #11
0
 public function __construct()
 {
     $this->pwauth_bin_path = OC_Appconfig::getValue('user_pwauth', 'pwauth_path', OC_USER_BACKEND_PWAUTH_PATH);
     $list = explode(";", OC_Appconfig::getValue('user_pwauth', 'uid_list', OC_USER_BACKEND_PWAUTH_UID_LIST));
     $r = array();
     foreach ($list as $entry) {
         if (strpos($entry, "-") === FALSE) {
             $r[] = $entry;
         } else {
             $range = explode("-", $entry);
             if ($range[0] < 0) {
                 $range[0] = 0;
             }
             if ($range[1] < $range[0]) {
                 $range[1] = $range[0];
             }
             for ($i = $range[0]; $i <= $range[1]; $i++) {
                 $r[] = $i;
             }
         }
     }
     $this->pwauth_uid_list = $r;
 }
Exemple #12
0
 /**
  * @brief if session is started, check if ownCloud key pair is set up, if not create it
  * @param \OC_FilesystemView $view
  *
  * @note The ownCloud key pair is used to allow public link sharing even if encryption is enabled
  */
 public function __construct($view)
 {
     $this->view = $view;
     if (!$this->view->is_dir('owncloud_private_key')) {
         $this->view->mkdir('owncloud_private_key');
     }
     $publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId');
     if ($publicShareKeyId === null) {
         $publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8);
         \OC_Appconfig::setValue('files_encryption', 'publicShareKeyId', $publicShareKeyId);
     }
     if (!$this->view->file_exists("/public-keys/" . $publicShareKeyId . ".public.key") || !$this->view->file_exists("/owncloud_private_key/" . $publicShareKeyId . ".private.key")) {
         $keypair = Crypt::createKeypair();
         // Disable encryption proxy to prevent recursive calls
         $proxyStatus = \OC_FileProxy::$enabled;
         \OC_FileProxy::$enabled = false;
         // Save public key
         if (!$view->is_dir('/public-keys')) {
             $view->mkdir('/public-keys');
         }
         $this->view->file_put_contents('/public-keys/' . $publicShareKeyId . '.public.key', $keypair['publicKey']);
         // Encrypt private key empty passphrase
         $encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], '');
         // Save private key
         $this->view->file_put_contents('/owncloud_private_key/' . $publicShareKeyId . '.private.key', $encryptedPrivateKey);
         \OC_FileProxy::$enabled = $proxyStatus;
     }
     if (\OCA\Encryption\Helper::isPublicAccess()) {
         // Disable encryption proxy to prevent recursive calls
         $proxyStatus = \OC_FileProxy::$enabled;
         \OC_FileProxy::$enabled = false;
         $encryptedKey = $this->view->file_get_contents('/owncloud_private_key/' . $publicShareKeyId . '.private.key');
         $privateKey = Crypt::decryptPrivateKey($encryptedKey, '');
         $this->setPublicSharePrivateKey($privateKey);
         \OC_FileProxy::$enabled = $proxyStatus;
     }
 }
 public function getParams()
 {
     $array = array();
     foreach ($this->params as $key => $param) {
         $array[$param] = OC_Appconfig::getValue('user_wordpress', $param, '');
     }
     if (empty($array['wordpress_db_host'])) {
         $array['wordpress_db_host'] = OC_Config::getValue("dbhost", "");
     }
     if (empty($array['wordpress_db_name'])) {
         $array['wordpress_db_name'] = OC_Config::getValue("dbname", "owncloud");
     }
     if (empty($array['wordpress_db_user'])) {
         $array['wordpress_db_user'] = OC_Config::getValue("dbuser", "");
     }
     if (empty($array['wordpress_db_password'])) {
         $array['wordpress_db_password'] = OC_Config::getValue("dbpassword", "");
     }
     if (empty($array['wordpress_have_to_be_logged'])) {
         $array['wordpress_have_to_be_logged'] = '0';
         OC_Appconfig::setValue('user_wordpress', 'wordpress_have_to_be_logged', '0');
     }
     return $array;
 }
Exemple #14
0
 /**
  * Check if an update for the app is available
  * @param string $app
  * @return string|false false or the version number of the update
  *
  * The function will check if an update for a version is available
  */
 public static function isUpdateAvailable($app)
 {
     static $isInstanceReadyForUpdates = null;
     if ($isInstanceReadyForUpdates === null) {
         $installPath = OC_App::getInstallPath();
         if ($installPath === false || $installPath === null) {
             $isInstanceReadyForUpdates = false;
         } else {
             $isInstanceReadyForUpdates = true;
         }
     }
     if ($isInstanceReadyForUpdates === false) {
         return false;
     }
     $ocsid = OC_Appconfig::getValue($app, 'ocsid', '');
     if ($ocsid != '') {
         $ocsdata = OC_OCSClient::getApplication($ocsid);
         $ocsversion = (string) $ocsdata['version'];
         $currentversion = OC_App::getAppVersion($app);
         if (version_compare($ocsversion, $currentversion, '>')) {
             return $ocsversion;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemple #15
0
 /**
  * @brief Erase a file's versions which exceed the set quota
  */
 private static function expire($filename, $versionsSize = null, $offset = 0)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         list($uid, $filename) = self::getUidAndFilename($filename);
         $versionsFileview = new \OC\Files\View('/' . $uid . '/files_versions');
         // get available disk space for user
         $softQuota = true;
         $quota = \OC_Preferences::getValue($uid, 'files', 'quota');
         if ($quota === null || $quota === 'default') {
             $quota = \OC_Appconfig::getValue('files', 'default_quota');
         }
         if ($quota === null || $quota === 'none') {
             $quota = \OC\Files\Filesystem::free_space('/');
             $softQuota = false;
         } else {
             $quota = \OCP\Util::computerFileSize($quota);
         }
         // make sure that we have the current size of the version history
         if ($versionsSize === null) {
             $versionsSize = self::getVersionsSize($uid);
             if ($versionsSize === false || $versionsSize < 0) {
                 $versionsSize = self::calculateSize($uid);
             }
         }
         // calculate available space for version history
         // subtract size of files and current versions size from quota
         if ($softQuota) {
             $files_view = new \OC\Files\View('/' . $uid . '/files');
             $rootInfo = $files_view->getFileInfo('/');
             $free = $quota - $rootInfo['size'];
             // remaining free space for user
             if ($free > 0) {
                 $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - ($versionsSize + $offset);
                 // how much space can be used for versions
             } else {
                 $availableSpace = $free - $versionsSize - $offset;
             }
         } else {
             $availableSpace = $quota - $offset;
         }
         // with the  probability of 0.1% we reduce the number of all versions not only for the current file
         $random = rand(0, 1000);
         if ($random == 0) {
             $allFiles = true;
         } else {
             $allFiles = false;
         }
         $allVersions = Storage::getVersions($uid, $filename);
         $versionsByFile[$filename] = $allVersions;
         $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
         $availableSpace = $availableSpace + $sizeOfDeletedVersions;
         $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         // if still not enough free space we rearrange the versions from all files
         if ($availableSpace <= 0 || $allFiles) {
             $result = Storage::getAllVersions($uid);
             $versionsByFile = $result['by_file'];
             $allVersions = $result['all'];
             $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
             $availableSpace = $availableSpace + $sizeOfDeletedVersions;
             $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         }
         // Check if enough space is available after versions are rearranged.
         // If not we delete the oldest versions until we meet the size limit for versions,
         // but always keep the two latest versions
         $numOfVersions = count($allVersions) - 2;
         $i = 0;
         while ($availableSpace < 0 && $i < $numOfVersions) {
             $version = current($allVersions);
             $versionsFileview->unlink($version['path'] . '.v' . $version['version']);
             $versionsSize -= $version['size'];
             $availableSpace += $version['size'];
             next($allVersions);
             $i++;
         }
         return $versionsSize;
         // finally return the new size of the version history
     }
     return false;
 }
Exemple #16
0
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size));
if ($_POST && OC_Util::isCallRegistered()) {
    if (isset($_POST['maxUploadSize'])) {
        if (($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
            $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize);
        }
    }
}
OCP\App::setActiveNavigationEntry("files_administration");
$htaccessWritable = is_writable(OC::$SERVERROOT . '/.htaccess');
$tmpl = new OCP\Template('files', 'admin');
/* 
* extended version
* + only users with permission can delete files(in the files app only)
* + file type restriction
*/
$filetyprestriction = \OC_Appconfig::getValue('core', 'filetyperes_enabled', 'no');
$allowed_types = \OC_Appconfig::getValue('core', 'allowed_filetypes', '');
$deleteGroupsList = \OC_Appconfig::getValue('core', 'delete', '');
$deleteGroupsList = explode(',', $deleteGroupsList);
$tmpl->assign('deleteGroupsList', implode('|', $deleteGroupsList));
$tmpl->assign('fileTypeRes', $filetyprestriction);
$tmpl->assign('allowed_filetypes', $allowed_types);
$tmpl->assign('uploadChangable', $htaccessWorking and $htaccessWritable);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
// max possible makes only sense on a 32 bit system
$tmpl->assign('displayMaxPossibleUploadSize', PHP_INT_SIZE === 4);
$tmpl->assign('maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX));
return $tmpl->fetchPage();
Exemple #17
0
 /**
  * Returns the URL of the default page
  * based on the system configuration and
  * the apps visible for the current user
  *
  * @return string URL
  */
 public static function getDefaultPageUrl()
 {
     $urlGenerator = \OC::$server->getURLGenerator();
     if (isset($_REQUEST['redirect_url'])) {
         $location = urldecode($_REQUEST['redirect_url']);
     } else {
         $defaultPage = OC_Appconfig::getValue('core', 'defaultpage');
         if ($defaultPage) {
             $location = $urlGenerator->getAbsoluteURL($defaultPage);
         } else {
             $appId = 'files';
             $defaultApps = explode(',', \OCP\Config::getSystemValue('defaultapp', 'files'));
             // find the first app that is enabled for the current user
             foreach ($defaultApps as $defaultApp) {
                 $defaultApp = OC_App::cleanAppId(strip_tags($defaultApp));
                 if (OC_App::isEnabled($defaultApp)) {
                     $appId = $defaultApp;
                     break;
                 }
             }
             $location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/');
         }
     }
     return $location;
 }
Exemple #18
0
	/**
	 * Returns the URL of the default page
	 * based on the system configuration and
	 * the apps visible for the current user
	 *
	 * @return string URL
	 */
	public static function getDefaultPageUrl() {
		$urlGenerator = \OC::$server->getURLGenerator();
		// Deny the redirect if the URL contains a @
		// This prevents unvalidated redirects like ?redirect_url=:user@domain.com
		if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) {
			$location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url']));
		} else {
			$defaultPage = OC_Appconfig::getValue('core', 'defaultpage');
			if ($defaultPage) {
				$location = $urlGenerator->getAbsoluteURL($defaultPage);
			} else {
				$appId = 'files';
				$defaultApps = explode(',', \OCP\Config::getSystemValue('defaultapp', 'files'));
				// find the first app that is enabled for the current user
				foreach ($defaultApps as $defaultApp) {
					$defaultApp = OC_App::cleanAppId(strip_tags($defaultApp));
					if (OC_App::isEnabled($defaultApp)) {
						$appId = $defaultApp;
						break;
					}
				}
				$location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/');
			}
		}
		return $location;
	}
Exemple #19
0
 /**
  * check if user can only share with group members
  * @return bool
  */
 public static function shareWithGroupMembersOnly()
 {
     $value = \OC_Appconfig::getValue('core', 'shareapi_only_share_with_group_members', 'no');
     return $value === 'yes' ? true : false;
 }
Exemple #20
0
<?php

/**
 * ownCloud - Updater plugin
 *
 * @author Victor Dubiniuk
 * @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Updater;

\OCP\User::checkAdminUser();
\OCP\Util::addScript(App::APP_ID, '3rdparty/angular');
\OCP\Util::addScript(App::APP_ID, 'app');
\OCP\Util::addScript(App::APP_ID, 'controllers');
\OCP\Util::addStyle(App::APP_ID, 'updater');
if (!@file_exists(App::getBackupBase())) {
    Helper::mkdir(App::getBackupBase());
}
$data = App::getFeed();
$isNewVersionAvailable = isset($data['version']) && $data['version'] != '' && $data['version'] !== array();
$tmpl = new \OCP\Template(App::APP_ID, 'admin');
$lastCheck = \OC_Appconfig::getValue('core', 'lastupdatedat');
$tmpl->assign('checkedAt', \OCP\Util::formatDate($lastCheck));
$tmpl->assign('isNewVersionAvailable', $isNewVersionAvailable ? 'true' : 'false');
$tmpl->assign('channels', Channel::getChannels());
$tmpl->assign('currentChannel', Channel::getCurrentChannel());
$tmpl->assign('version', isset($data['versionstring']) ? $data['versionstring'] : '');
return $tmpl->fetchPage();
Exemple #21
0
 * 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/>.
 * 
 */
namespace OCA\Documents;

\OCP\User::checkLoggedIn();
\OCP\JSON::checkAppEnabled('documents');
\OCP\App::setActiveNavigationEntry('documents_index');
\OCP\Util::addStyle('documents', 'style');
\OCP\Util::addStyle('documents', '3rdparty/webodf/dojo-app');
\OCP\Util::addScript('documents', 'documents');
\OCP\Util::addScript('files', 'file-upload');
\OCP\Util::addScript('files', 'jquery.iframe-transport');
\OCP\Util::addScript('files', 'jquery.fileupload');
$tmpl = new \OCP\Template('documents', 'documents', 'user');
$previewsEnabled = \OC::$server->getConfig()->getSystemValue('enable_previews', true);
$unstable = \OCP\Config::getAppValue('documents', 'unstable', 'false');
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
$tmpl->assign('enable_previews', $previewsEnabled);
$tmpl->assign('useUnstable', $unstable);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign('savePath', $savePath);
$tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes'));
$tmpl->printPage();
Exemple #22
0
<?php

$currentVersion = OC_Appconfig::getValue('search_lucene', 'installed_version');
if (version_compare($currentVersion, '0.5.0', '<')) {
    //force reindexing of files
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*lucene_status` WHERE 1=1');
    $stmt->execute();
    //clear old background jobs
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*queuedtasks` WHERE `app`=?');
    $stmt->execute(array('search_lucene'));
}
Exemple #23
0
 /**
  * @large
  */
 function testRecoveryForUser()
 {
     // login as admin
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
     $result = \OCA\Encryption\Helper::adminEnableRecovery(null, 'test123');
     $this->assertTrue($result);
     $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId');
     // login as user2
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
     $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
     // enable recovery for admin
     $this->assertTrue($util->setRecoveryForUser(1));
     // add recovery keys for existing files (e.g. the auto-generated welcome.txt)
     $util->addRecoveryKeys();
     // create folder structure
     $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1);
     $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder);
     $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder);
     // save file with content
     $cryptedFile1 = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename, $this->dataShort);
     $cryptedFile2 = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort);
     // test that data was successfully written
     $this->assertTrue(is_int($cryptedFile1));
     $this->assertTrue(is_int($cryptedFile2));
     // check if share key for user and recovery exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey'));
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey'));
     // login as admin
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
     // change password
     \OC_User::setPassword(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'test', 'test123');
     $params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'password' => 'test', 'recoveryPassword' => 'test123');
     \OCA\Encryption\Hooks::setPassphrase($params);
     // login as user2
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, false, 'test');
     // get file contents
     $retrievedCryptedFile1 = file_get_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
     $retrievedCryptedFile2 = file_get_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename);
     // check if data is the same as we previously written
     $this->assertEquals($this->dataShort, $retrievedCryptedFile1);
     $this->assertEquals($this->dataShort, $retrievedCryptedFile2);
     // cleanup
     $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/');
     $this->view->unlink($this->folder1);
     $this->view->unlink($this->filename);
     $this->view->chroot('/');
     // check if share key for user and recovery exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey'));
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey'));
     // disable recovery for admin
     $this->assertTrue($util->setRecoveryForUser(0));
     \OCA\Encryption\Helper::adminDisableRecovery('test123');
     $this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled'));
     //clean up, reset passwords
     \OC_User::setPassword(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'test123');
     $params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'password' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'recoveryPassword' => 'test123');
     \OCA\Encryption\Hooks::setPassphrase($params);
 }
Exemple #24
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @param string $currentVersion current version to upgrade to
  * @param string $installedVersion previous version from which to upgrade from
  *
  * @throws \Exception
  * @return bool true if the operation succeeded, false otherwise
  */
 private function doUpgrade($currentVersion, $installedVersion)
 {
     // Stop update if the update is over several major versions
     if (!self::isUpgradePossible($installedVersion, $currentVersion)) {
         throw new \Exception('Updates between multiple major versions are unsupported.');
     }
     // Update htaccess files for apache hosts
     if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
         \OC_Setup::updateHtaccess();
     }
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     /*
      * START CONFIG CHANGES FOR OLDER VERSIONS
      */
     if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) {
         // Add the trusted_domains config if it is not existant
         // This is added to prevent host header poisoning
         \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
     }
     /*
      * STOP CONFIG CHANGES FOR OLDER VERSIONS
      */
     // pre-upgrade repairs
     $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
     $repair->run();
     // simulate DB upgrade
     if ($this->simulateStepEnabled) {
         $this->checkCoreUpgrade();
         // simulate apps DB upgrade
         $this->checkAppUpgrade($currentVersion);
     }
     // upgrade from OC6 to OC7
     // TODO removed it again for OC8
     $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
     if ($sharePolicy === 'groups_only') {
         \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
     }
     if ($this->updateStepEnabled) {
         $this->doCoreUpgrade();
         $disabledApps = \OC_App::checkAppsRequirements();
         if (!empty($disabledApps)) {
             $this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps));
         }
         $this->doAppUpgrade();
         // post-upgrade repairs
         $repair = new \OC\Repair(\OC\Repair::getRepairSteps());
         $repair->run();
         //Invalidate update feed
         \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
         // only set the final version if everything went well
         \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
     }
 }
Exemple #25
0
 /**
  * Gets the config value
  * @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 returned
  */
 public static function getAppValue($app, $key, $default = null)
 {
     return \OC_Appconfig::getValue($app, $key, $default);
 }
Exemple #26
0
$linkItem = $data['linkItem'];
// Load the files
$dir = $data['realPath'];
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\JSON::error(array('success' => false));
    exit;
}
$data = array();
// make filelist
$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
$formattedFiles = array();
foreach ($files as $file) {
    $entry = \OCA\Files\Helper::formatFileInfo($file);
    unset($entry['directory']);
    // for now
    $entry['permissions'] = \OCP\PERMISSION_READ;
    $formattedFiles[] = $entry;
}
$data['directory'] = $relativePath;
$data['files'] = $formattedFiles;
$data['dirToken'] = $linkItem['token'];
$permissions = $linkItem['permissions'];
// if globally disabled
if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') {
    // only allow reading
    $permissions = \OCP\PERMISSION_READ;
}
$data['permissions'] = $permissions;
OCP\JSON::success(array('data' => $data));
Exemple #27
0
OC_Util::addStyle("settings", "settings");
OC_Util::addScript("settings", "apps");
OC_App::setActiveNavigationEntry("core_apps");
$installedApps = OC_App::getAllApps();
//TODO which apps do we want to blacklist and how do we integrate blacklisting with the multi apps folder feature?
$blacklist = array('files');
//we dont want to show configuration for these
$appList = array();
foreach ($installedApps as $app) {
    if (array_search($app, $blacklist) === false) {
        $info = OC_App::getAppInfo($app);
        if (!isset($info['name'])) {
            OC_Log::write('core', 'App id "' . $app . '" has no name in appinfo', OC_Log::ERROR);
            continue;
        }
        if (OC_Appconfig::getValue($app, 'enabled', 'no') == 'yes') {
            $active = true;
        } else {
            $active = false;
        }
        $info['active'] = $active;
        if (isset($info['shipped']) and $info['shipped'] == 'true') {
            $info['internal'] = true;
            $info['internallabel'] = 'Internal App';
        } else {
            $info['internal'] = false;
            $info['internallabel'] = '3rd Party App';
        }
        $info['preview'] = OC_Helper::imagePath('settings', 'trans.png');
        $info['version'] = OC_App::getAppVersion($app);
        $appList[] = $info;
Exemple #28
0
 public static function init()
 {
     // register autoloader
     spl_autoload_register(array('OC', 'autoload'));
     OC_Util::issetlocaleworking();
     // set some stuff
     //ob_start();
     error_reporting(E_ALL | E_STRICT);
     if (defined('DEBUG') && DEBUG) {
         ini_set('display_errors', 1);
     }
     self::$CLI = php_sapi_name() == 'cli';
     date_default_timezone_set('UTC');
     ini_set('arg_separator.output', '&amp;');
     // try to switch magic quotes off.
     if (get_magic_quotes_gpc() == 1) {
         ini_set('magic_quotes_runtime', 0);
     }
     //try to configure php to enable big file uploads.
     //this doesn´t work always depending on the webserver and php configuration.
     //Let´s try to overwrite some defaults anyways
     //try to set the maximum execution time to 60min
     @set_time_limit(3600);
     @ini_set('max_execution_time', 3600);
     @ini_set('max_input_time', 3600);
     //try to set the maximum filesize to 10G
     @ini_set('upload_max_filesize', '10G');
     @ini_set('post_max_size', '10G');
     @ini_set('file_uploads', '50');
     //copy http auth headers for apache+php-fcgid work around
     if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) {
         $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION'];
     }
     //set http auth headers for apache+php-cgi work around
     if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) {
         list($name, $password) = explode(':', base64_decode($matches[1]), 2);
         $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
         $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
     }
     //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
     if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) {
         list($name, $password) = explode(':', base64_decode($matches[1]), 2);
         $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
         $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
     }
     self::initPaths();
     // set debug mode if an xdebug session is active
     if (!defined('DEBUG') || !DEBUG) {
         if (isset($_COOKIE['XDEBUG_SESSION'])) {
             define('DEBUG', true);
         }
     }
     if (!defined('PHPUNIT_RUN') and !(defined('DEBUG') and DEBUG)) {
         register_shutdown_function(array('OC_Log', 'onShutdown'));
         set_error_handler(array('OC_Log', 'onError'));
         set_exception_handler(array('OC_Log', 'onException'));
     }
     // register the stream wrappers
     stream_wrapper_register('fakedir', 'OC\\Files\\Stream\\Dir');
     stream_wrapper_register('static', 'OC\\Files\\Stream\\StaticStream');
     stream_wrapper_register('close', 'OC\\Files\\Stream\\Close');
     stream_wrapper_register('oc', 'OC\\Files\\Stream\\OC');
     self::initTemplateEngine();
     self::checkConfig();
     self::checkInstalled();
     self::checkSSL();
     self::initSession();
     $errors = OC_Util::checkServer();
     if (count($errors) > 0) {
         OC_Template::printGuestPage('', 'error', array('errors' => $errors));
         exit;
     }
     //try to set the session lifetime
     $sessionLifeTime = self::getSessionLifeTime();
     @ini_set('gc_maxlifetime', (string) $sessionLifeTime);
     // User and Groups
     if (!OC_Config::getValue("installed", false)) {
         $_SESSION['user_id'] = '';
     }
     OC_User::useBackend(new OC_User_Database());
     OC_Group::useBackend(new OC_Group_Database());
     if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SESSION['user_id']) && $_SERVER['PHP_AUTH_USER'] != $_SESSION['user_id']) {
         OC_User::logout();
     }
     // Load Apps
     // This includes plugins for users and filesystems as well
     global $RUNTIME_NOAPPS;
     global $RUNTIME_APPTYPES;
     if (!$RUNTIME_NOAPPS) {
         if ($RUNTIME_APPTYPES) {
             OC_App::loadApps($RUNTIME_APPTYPES);
         } else {
             OC_App::loadApps();
         }
     }
     //setup extra user backends
     OC_User::setupBackends();
     self::registerCacheHooks();
     self::registerFilesystemHooks();
     self::registerShareHooks();
     //make sure temporary files are cleaned up
     register_shutdown_function(array('OC_Helper', 'cleanTmp'));
     //parse the given parameters
     self::$REQUESTEDAPP = isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? OC_App::cleanAppId(strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files');
     if (substr_count(self::$REQUESTEDAPP, '?') != 0) {
         $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?'));
         $param = substr($_GET['app'], strpos($_GET['app'], '?') + 1);
         parse_str($param, $get);
         $_GET = array_merge($_GET, $get);
         self::$REQUESTEDAPP = $app;
         $_GET['app'] = $app;
     }
     self::$REQUESTEDFILE = isset($_GET['getfile']) ? $_GET['getfile'] : null;
     if (substr_count(self::$REQUESTEDFILE, '?') != 0) {
         $file = substr(self::$REQUESTEDFILE, 0, strpos(self::$REQUESTEDFILE, '?'));
         $param = substr(self::$REQUESTEDFILE, strpos(self::$REQUESTEDFILE, '?') + 1);
         parse_str($param, $get);
         $_GET = array_merge($_GET, $get);
         self::$REQUESTEDFILE = $file;
         $_GET['getfile'] = $file;
     }
     if (!is_null(self::$REQUESTEDFILE)) {
         $subdir = OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . self::$REQUESTEDFILE;
         $parent = OC_App::getAppPath(OC::$REQUESTEDAPP);
         if (!OC_Helper::issubdirectory($subdir, $parent)) {
             self::$REQUESTEDFILE = null;
             header('HTTP/1.0 404 Not Found');
             exit;
         }
     }
     // write error into log if locale can't be set
     if (OC_Util::issetlocaleworking() == false) {
         OC_Log::write('core', 'setting locale to en_US.UTF-8/en_US.UTF8 failed. Support is probably not installed on your system', OC_Log::ERROR);
     }
     if (OC_Config::getValue('installed', false) && !self::checkUpgrade(false)) {
         if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
             OC_Util::addScript('backgroundjobs');
         }
     }
 }
Exemple #29
0
 /**
  * Lists all apps, this is used in apps.php
  * @return array
  */
 public static function listAllApps($onlyLocal = false)
 {
     $installedApps = OC_App::getAllApps();
     //TODO which apps do we want to blacklist and how do we integrate
     // blacklisting with the multi apps folder feature?
     $blacklist = array('files');
     //we don't want to show configuration for these
     $appList = array();
     $l = \OC::$server->getL10N('core');
     foreach ($installedApps as $app) {
         if (array_search($app, $blacklist) === false) {
             $info = OC_App::getAppInfo($app);
             if (!isset($info['name'])) {
                 OC_Log::write('core', 'App id "' . $app . '" has no name in appinfo', OC_Log::ERROR);
                 continue;
             }
             $enabled = OC_Appconfig::getValue($app, 'enabled', 'no');
             $info['groups'] = null;
             if ($enabled === 'yes') {
                 $active = true;
             } else {
                 if ($enabled === 'no') {
                     $active = false;
                 } else {
                     $active = true;
                     $info['groups'] = $enabled;
                 }
             }
             $info['active'] = $active;
             if (isset($info['shipped']) and $info['shipped'] == 'true') {
                 $info['internal'] = true;
                 $info['internallabel'] = (string) $l->t('Recommended');
                 $info['internalclass'] = 'recommendedapp';
                 $info['removable'] = false;
             } else {
                 $info['internal'] = false;
                 $info['removable'] = true;
             }
             $info['update'] = OC_Installer::isUpdateAvailable($app);
             $appIcon = self::getAppPath($app) . '/img/' . $app . '.svg';
             if (file_exists($appIcon)) {
                 $info['preview'] = OC_Helper::imagePath($app, $app . '.svg');
                 $info['previewAsIcon'] = true;
             } else {
                 $appIcon = self::getAppPath($app) . '/img/app.svg';
                 if (file_exists($appIcon)) {
                     $info['preview'] = OC_Helper::imagePath($app, 'app.svg');
                     $info['previewAsIcon'] = true;
                 }
             }
             $info['version'] = OC_App::getAppVersion($app);
             $appList[] = $info;
         }
     }
     if ($onlyLocal) {
         $remoteApps = array();
     } else {
         $remoteApps = OC_App::getAppstoreApps();
     }
     if ($remoteApps) {
         // Remove duplicates
         foreach ($appList as $app) {
             foreach ($remoteApps as $key => $remote) {
                 if ($app['name'] === $remote['name'] || isset($app['ocsid']) && $app['ocsid'] === $remote['id']) {
                     unset($remoteApps[$key]);
                 }
             }
         }
         $combinedApps = array_merge($appList, $remoteApps);
     } else {
         $combinedApps = $appList;
     }
     // bring the apps into the right order with a custom sort function
     usort($combinedApps, function ($a, $b) {
         // priority 1: active
         if ($a['active'] != $b['active']) {
             return $b['active'] - $a['active'];
         }
         // priority 2: shipped
         $aShipped = array_key_exists('shipped', $a) && $a['shipped'] === 'true' ? 1 : 0;
         $bShipped = array_key_exists('shipped', $b) && $b['shipped'] === 'true' ? 1 : 0;
         if ($aShipped !== $bShipped) {
             return $bShipped - $aShipped;
         }
         // priority 3: recommended
         $internalClassA = isset($a['internalclass']) ? $a['internalclass'] : '';
         $internalClassB = isset($b['internalclass']) ? $b['internalclass'] : '';
         if ($internalClassA != $internalClassB) {
             $aTemp = $internalClassA == 'recommendedapp' ? 1 : 0;
             $bTemp = $internalClassB == 'recommendedapp' ? 1 : 0;
             return $bTemp - $aTemp;
         }
         // priority 4: alphabetical
         return strcasecmp($a['name'], $b['name']);
     });
     return $combinedApps;
 }
Exemple #30
0
<?php

$currentVersion = OC_Appconfig::getValue('gallery', 'installed_version');
if (version_compare($currentVersion, '0.5.0', '<')) {
    $stmt = OCP\DB::prepare('DROP TABLE IF EXISTS `*PREFIX*gallery_photos`');
    $stmt->execute();
    $stmt = OCP\DB::prepare('DROP TABLE IF EXISTS `*PREFIX*gallery_albums`');
    $stmt->execute();
    \OC_DB::createDbFromStructure(OC_App::getAppPath($appid) . '/appinfo/database.xml');
}