/**
  * 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;
 }
Example #2
0
 function __construct()
 {
     $this->l = OC_L10N::get('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = 'ownCloud';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = 'ownCloud';
     /* short name, used when referring to the software */
     $this->defaultTitle = 'ownCloud';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = 'https://owncloud.org';
     $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
     $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
     $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
     $this->defaultDocBaseUrl = 'http://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.0';
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('web services under your control');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     if (class_exists('OC_Theme')) {
         $this->theme = new OC_Theme();
     }
 }
Example #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;
 }
Example #4
0
 function __construct()
 {
     $this->l = \OC::$server->getL10N('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = '';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = '';
     /* short name, used when referring to the software */
     $this->defaultTitle = '';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = '';
     $this->defaultSyncClientUrl = '';
     $this->defaultiOSClientUrl = '';
     $this->defaultiTunesAppId = '';
     $this->defaultAndroidClientUrl = '';
     $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.' . $version[1];
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('Web Master - Mayank Agarwal <br>UI - Sambhav Kothari');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
     if (file_exists($themePath)) {
         // prevent defaults.php from printing output
         ob_start();
         require_once $themePath;
         ob_end_clean();
         if (class_exists('OC_Theme')) {
             $this->theme = new OC_Theme();
         }
     }
 }
Example #5
0
 function __construct()
 {
     $this->l = \OC::$server->getL10N('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = 'ownCloud';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = 'ownCloud';
     /* short name, used when referring to the software */
     $this->defaultTitle = 'ownCloud';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = 'https://owncloud.org';
     $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
     $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
     $this->defaultiTunesAppId = '543672169';
     $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
     $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.' . $version[1];
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('web services under your control');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
     if (file_exists($themePath)) {
         // prevent defaults.php from printing output
         ob_start();
         require_once $themePath;
         ob_end_clean();
         if (class_exists('OC_Theme')) {
             $this->theme = new OC_Theme();
         }
     }
 }
Example #6
0
	public function testGetVersion() {
		$version = \OC_Util::getVersion();
		$this->assertTrue(is_array($version));
		foreach ($version as $num) {
			$this->assertTrue(is_int($num));
		}
	}
Example #7
0
 public static function getCapabilities()
 {
     $result = array();
     list($major, $minor, $micro) = OC_Util::getVersion();
     $result['version'] = array('major' => $major, 'minor' => $minor, 'micro' => $micro, 'string' => OC_Util::getVersionString(), 'edition' => OC_Util::getEditionString());
     $result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities();
     return new OC_OCS_Result($result);
 }
Example #8
0
 public static function getCapabilities($parameters)
 {
     $result = array();
     list($major, $minor, $micro) = OC_Util::getVersion();
     $result['version'] = array('major' => $major, 'minor' => $minor, 'micro' => $micro, 'string' => OC_Util::getVersionString(), 'edition' => OC_Util::getEditionString());
     $result['capabilities'] = array('core' => array('pollinterval' => OC_Config::getValue('pollinterval', 60)));
     return new OC_OCS_Result($result);
 }
Example #9
0
 public static function checkVersion($newVersionArray, $newVersionString)
 {
     $currentVersionArray = \OC_Util::getVersion();
     $currentVersion = \OC_Util::getVersionString();
     $difference = intval($newVersionArray[0]) - intval($currentVersionArray[0]);
     if ($difference > 1 || $difference < 0 || version_compare($currentVersion, $newVersionString) > 0) {
         $message = (string) App::$l10n->t('Not possible to update %s to %s. Downgrading or skipping major releases is not supported.', array($currentVersion, implode('.', $newVersionArray)));
         App::log($message);
         throw new \Exception($message);
     }
 }
Example #10
0
 function __construct()
 {
     $this->l = OC_L10N::get('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = "ownCloud";
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = "ownCloud";
     /* short name, used when referring to the software */
     $this->defaultTitle = "ownCloud";
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = "https://owncloud.org";
     $this->defaultSyncClientUrl = "https://owncloud.org/sync-clients/";
     $this->defaultDocBaseUrl = "http://doc.owncloud.org";
     $this->defaultDocVersion = $version[0] . ".0";
     // used to generate doc links
     $this->defaultSlogan = $this->l->t("web services under your control");
     $this->defaultLogoClaim = "";
     $this->defaultMailHeaderColor = "#1d2d44";
     /* header color of mail notifications */
     if (class_exists("OC_Theme")) {
         $this->theme = new OC_Theme();
     }
 }
Example #11
0
 /**
  * Check whether the instance needs to perform an upgrade,
  * either when the core version is higher or any app requires
  * an upgrade.
  *
  * @return bool whether the core or any app needs an upgrade
  */
 public static function needUpgrade()
 {
     if (OC_Config::getValue('installed', false)) {
         $installedVersion = OC_Config::getValue('version', '0.0.0');
         $currentVersion = implode('.', OC_Util::getVersion());
         if (version_compare($currentVersion, $installedVersion, '>')) {
             return true;
         }
         // also check for upgrades for apps (independently from the user)
         $apps = \OC_App::getEnabledApps(false, true);
         $shouldUpgrade = false;
         foreach ($apps as $app) {
             if (\OC_App::shouldUpgrade($app)) {
                 $shouldUpgrade = true;
                 break;
             }
         }
         return $shouldUpgrade;
     } else {
         return false;
     }
 }
Example #12
0
// Set the content type to Javascript
header("Content-type: text/javascript");
// Disallow caching
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Enable l10n support
$l = \OC::$server->getL10N('core');
// Enable OC_Defaults support
$defaults = new OC_Defaults();
// Get the config
$apps_paths = array();
foreach (OC_App::getEnabledApps() as $app) {
    $apps_paths[$app] = OC_App::getAppWebPath($app);
}
$config = \OC::$server->getConfig();
$value = $config->getAppValue('core', 'shareapi_default_expire_date', 'no');
$defaultExpireDateEnabled = $value === 'yes' ? true : false;
$defaultExpireDate = $enforceDefaultExpireDate = null;
if ($defaultExpireDateEnabled) {
    $defaultExpireDate = (int) $config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
    $value = $config->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
    $enforceDefaultExpireDate = $value === 'yes' ? true : false;
}
$outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes';
$array = array("oc_debug" => defined('DEBUG') && DEBUG ? 'true' : 'false', "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false', "oc_webroot" => "\"" . OC::$WEBROOT . "\"", "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), "datepickerFormatDate" => json_encode($l->getDateFormat()), "dayNames" => json_encode(array((string) $l->t('Sunday'), (string) $l->t('Monday'), (string) $l->t('Tuesday'), (string) $l->t('Wednesday'), (string) $l->t('Thursday'), (string) $l->t('Friday'), (string) $l->t('Saturday'))), "monthNames" => json_encode(array((string) $l->t('January'), (string) $l->t('February'), (string) $l->t('March'), (string) $l->t('April'), (string) $l->t('May'), (string) $l->t('June'), (string) $l->t('July'), (string) $l->t('August'), (string) $l->t('September'), (string) $l->t('October'), (string) $l->t('November'), (string) $l->t('December'))), "firstDay" => json_encode($l->getFirstWeekDay()), "oc_config" => json_encode(array('session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')), ini_get('session.gc_maxlifetime')), 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true), 'version' => implode('.', OC_Util::getVersion()), 'versionstring' => OC_Util::getVersionString(), 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true))), "oc_appconfig" => json_encode(array("core" => array('defaultExpireDateEnabled' => $defaultExpireDateEnabled, 'defaultExpireDate' => $defaultExpireDate, 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), 'resharingAllowed' => \OCP\Share::isResharingAllowed(), 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, 'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated')))), "oc_defaults" => json_encode(array('entity' => $defaults->getEntity(), 'name' => $defaults->getName(), 'title' => $defaults->getTitle(), 'baseUrl' => $defaults->getBaseUrl(), 'syncClientUrl' => $defaults->getSyncClientUrl(), 'docBaseUrl' => $defaults->getDocBaseUrl(), 'slogan' => $defaults->getSlogan(), 'logoClaim' => $defaults->getLogoClaim(), 'shortFooter' => $defaults->getShortFooter(), 'longFooter' => $defaults->getLongFooter())));
// Allow hooks to modify the output values
OC_Hook::emit('\\OCP\\Config', 'js', array('array' => &$array));
// Echo it
foreach ($array as $setting => $value) {
    echo "var " . $setting . "=" . $value . ";\n";
}
Example #13
0
 /**
  * @param string $renderAs
  * @param string $appId application id
  */
 public function __construct($renderAs, $appId = '')
 {
     // yes - should be injected ....
     $this->config = \OC::$server->getConfig();
     // Decide which page we show
     if ($renderAs == 'user') {
         parent::__construct('core', 'layout.user');
         if (in_array(OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) {
             $this->assign('bodyid', 'body-settings');
         } else {
             $this->assign('bodyid', 'body-user');
         }
         // Update notification
         if ($this->config->getSystemValue('updatechecker', true) === true && OC_User::isAdminUser(OC_User::getUser())) {
             $updater = new \OC\Updater(\OC::$server->getHTTPHelper(), \OC::$server->getConfig());
             $data = $updater->check();
             if (isset($data['version']) && $data['version'] != '' and $data['version'] !== array()) {
                 $this->assign('updateAvailable', true);
                 $this->assign('updateVersion', $data['versionstring']);
                 $this->assign('updateLink', $data['web']);
                 \OCP\Util::addScript('core', 'update-notification');
             } else {
                 $this->assign('updateAvailable', false);
                 // No update available or not an admin user
             }
         } else {
             $this->assign('updateAvailable', false);
             // Update check is disabled
         }
         // Add navigation entry
         $this->assign('application', '');
         $this->assign('appid', $appId);
         $navigation = OC_App::getNavigation();
         $this->assign('navigation', $navigation);
         $settingsNavigation = OC_App::getSettingsNavigation();
         $this->assign('settingsnavigation', $settingsNavigation);
         foreach ($navigation as $entry) {
             if ($entry['active']) {
                 $this->assign('application', $entry['name']);
                 break;
             }
         }
         foreach ($settingsNavigation as $entry) {
             if ($entry['active']) {
                 $this->assign('application', $entry['name']);
                 break;
             }
         }
         $userDisplayName = OC_User::getDisplayName();
         $this->assign('user_displayname', $userDisplayName);
         $this->assign('user_uid', OC_User::getUser());
         $this->assign('appsmanagement_active', strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0);
         $this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true));
         $this->assign('userAvatarSet', \OC_Helper::userAvatarSet(OC_User::getUser()));
     } else {
         if ($renderAs == 'error') {
             parent::__construct('core', 'layout.guest', '', false);
             $this->assign('bodyid', 'body-login');
         } else {
             if ($renderAs == 'guest') {
                 parent::__construct('core', 'layout.guest');
                 $this->assign('bodyid', 'body-login');
             } else {
                 parent::__construct('core', 'layout.base');
             }
         }
     }
     // Send the language to our layouts
     $this->assign('language', OC_L10N::findLanguage());
     if (empty(self::$versionHash)) {
         $v = OC_App::getAppVersions();
         $v['core'] = implode('.', \OC_Util::getVersion());
         self::$versionHash = md5(implode(',', $v));
     }
     $useAssetPipeline = self::isAssetPipelineEnabled();
     if ($useAssetPipeline) {
         $this->append('jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
         $this->generateAssets();
     } else {
         // Add the js files
         $jsFiles = self::findJavascriptFiles(OC_Util::$scripts);
         $this->assign('jsfiles', array(), false);
         if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
             $this->append('jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
         }
         foreach ($jsFiles as $info) {
             $web = $info[1];
             $file = $info[2];
             $this->append('jsfiles', $web . '/' . $file . '?v=' . self::$versionHash);
         }
         // Add the css files
         $cssFiles = self::findStylesheetFiles(OC_Util::$styles);
         $this->assign('cssfiles', array());
         foreach ($cssFiles as $info) {
             $web = $info[1];
             $file = $info[2];
             $this->append('cssfiles', $web . '/' . $file . '?v=' . self::$versionHash);
         }
     }
 }
Example #14
0
 /**
  * @param $options
  * @return array
  */
 public static function install($options)
 {
     $l = self::getTrans();
     $error = array();
     $dbType = $options['dbtype'];
     if (empty($options['adminlogin'])) {
         $error[] = $l->t('Set an admin username.');
     }
     if (empty($options['adminpass'])) {
         $error[] = $l->t('Set an admin password.');
     }
     if (empty($options['directory'])) {
         $options['directory'] = OC::$SERVERROOT . "/data";
     }
     if (!isset(self::$dbSetupClasses[$dbType])) {
         $dbType = 'sqlite';
     }
     $username = htmlspecialchars_decode($options['adminlogin']);
     $password = htmlspecialchars_decode($options['adminpass']);
     $dataDir = htmlspecialchars_decode($options['directory']);
     $class = self::$dbSetupClasses[$dbType];
     /** @var \OC\Setup\AbstractDatabase $dbSetup */
     $dbSetup = new $class(self::getTrans(), 'db_structure.xml');
     $error = array_merge($error, $dbSetup->validate($options));
     // validate the data directory
     if (!is_dir($dataDir) and !mkdir($dataDir) or !is_writable($dataDir)) {
         $error[] = $l->t("Can't create or write into the data directory %s", array($dataDir));
     }
     if (count($error) != 0) {
         return $error;
     }
     //no errors, good
     if (isset($options['trusted_domains']) && is_array($options['trusted_domains'])) {
         $trustedDomains = $options['trusted_domains'];
     } else {
         $trustedDomains = array(OC_Request::serverHost());
     }
     if (OC_Util::runningOnWindows()) {
         $dataDir = rtrim(realpath($dataDir), '\\');
     }
     //use sqlite3 when available, otherwise sqlite2 will be used.
     if ($dbType == 'sqlite' and class_exists('SQLite3')) {
         $dbType = 'sqlite3';
     }
     //generate a random salt that is used to salt the local user passwords
     $salt = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(30);
     \OC::$server->getConfig()->setSystemValue('passwordsalt', $salt);
     // generate a secret
     $secret = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(48);
     \OC::$server->getConfig()->setSystemValue('secret', $secret);
     //write the config file
     \OC::$server->getConfig()->setSystemValue('trusted_domains', $trustedDomains);
     \OC::$server->getConfig()->setSystemValue('datadirectory', $dataDir);
     \OC::$server->getConfig()->setSystemValue('overwrite.cli.url', \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT);
     \OC::$server->getConfig()->setSystemValue('dbtype', $dbType);
     \OC::$server->getConfig()->setSystemValue('version', implode('.', OC_Util::getVersion()));
     try {
         $dbSetup->initialize($options);
         $dbSetup->setupDatabase($username);
     } catch (DatabaseSetupException $e) {
         $error[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
         return $error;
     } catch (Exception $e) {
         $error[] = array('error' => 'Error while trying to create admin user: '******'hint' => '');
         return $error;
     }
     //create the user and group
     try {
         OC_User::createUser($username, $password);
     } catch (Exception $exception) {
         $error[] = $exception->getMessage();
     }
     if (count($error) == 0) {
         $appConfig = \OC::$server->getAppConfig();
         $appConfig->setValue('core', 'installedat', microtime(true));
         $appConfig->setValue('core', 'lastupdatedat', microtime(true));
         OC_Group::createGroup('admin');
         OC_Group::addToGroup($username, 'admin');
         OC_User::login($username, $password);
         //guess what this does
         OC_Installer::installShippedApps();
         // create empty file in data dir, so we can later find
         // out that this is indeed an ownCloud data directory
         file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/.ocdata', '');
         // Update htaccess files for apache hosts
         if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
             self::updateHtaccess();
             self::protectDataDirectory();
         }
         //and we are done
         OC_Config::setValue('installed', true);
     }
     return $error;
 }
Example #15
0
<?php

try {
    require_once 'lib/base.php';
    $systemConfig = \OC::$server->getSystemConfig();
    $installed = $systemConfig->getValue('installed') == 1;
    $maintenance = $systemConfig->getValue('maintenance', false);
    $values = array('installed' => $installed, 'maintenance' => $maintenance, 'version' => implode('.', OC_Util::getVersion()), 'versionstring' => OC_Util::getVersionString(), 'edition' => OC_Util::getEditionString());
    if (OC::$CLI) {
        print_r($values);
    } else {
        header('Access-Control-Allow-Origin: *');
        header('Content-Type: application/json');
        echo json_encode($values);
    }
} catch (Exception $ex) {
    OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
    \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
}
Example #16
0
 /**
  * @param mixed $app
  * @return bool
  * @throws Exception if app is not compatible with this version of ownCloud
  * @throws Exception if no app-name was specified
  */
 public static function installApp($app)
 {
     $l = \OC::$server->getL10N('core');
     $config = \OC::$server->getConfig();
     $appData = OC_OCSClient::getApplication($app);
     // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
     if (!is_numeric($app)) {
         $shippedVersion = self::getAppVersion($app);
         if ($appData && version_compare($shippedVersion, $appData['version'], '<')) {
             $app = self::downloadApp($app);
         } else {
             $app = OC_Installer::installShippedApp($app);
         }
     } else {
         // Maybe the app is already installed - compare the version in this
         // case and use the local already installed one.
         // FIXME: This is a horrible hack. I feel sad. The god of code cleanness may forgive me.
         $internalAppId = self::getInternalAppIdByOcs($app);
         if ($internalAppId !== false) {
             if ($appData && version_compare(\OC_App::getAppVersion($internalAppId), $appData['version'], '<')) {
                 $app = self::downloadApp($app);
             } else {
                 self::enable($internalAppId);
                 $app = $internalAppId;
             }
         } else {
             $app = self::downloadApp($app);
         }
     }
     if ($app !== false) {
         // check if the app is compatible with this version of ownCloud
         $info = self::getAppInfo($app);
         $version = OC_Util::getVersion();
         if (!self::isAppCompatible($version, $info)) {
             throw new \Exception($l->t('App \\"%s\\" can\'t be installed because it is not compatible with this version of ownCloud.', array($info['name'])));
         }
         // check for required dependencies
         $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
         $missing = $dependencyAnalyzer->analyze($app);
         if (!empty($missing)) {
             $missingMsg = join(PHP_EOL, $missing);
             throw new \Exception($l->t('App \\"%s\\" cannot be installed because the following dependencies are not fulfilled: %s', array($info['name'], $missingMsg)));
         }
         $config->setAppValue($app, 'enabled', 'yes');
         if (isset($appData['id'])) {
             $config->setAppValue($app, 'ocsid', $appData['id']);
         }
         \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
     } else {
         throw new \Exception($l->t("No app name specified"));
     }
     return $app;
 }
Example #17
0
 /**
  * check if the current enabled apps are compatible with the current
  * ownCloud version. disable them if not.
  * This is important if you upgrade ownCloud and have non ported 3rd
  * party apps installed.
  */
 public static function checkAppsRequirements($apps = array())
 {
     if (empty($apps)) {
         $apps = OC_App::getEnabledApps();
     }
     $version = OC_Util::getVersion();
     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 !self::isAppVersionCompatible($version, $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);
             OC_Hook::emit('update', 'success', 'Disabled ' . $info['name'] . ' app because it is not compatible');
         }
     }
 }
Example #18
0
 /**
  * Checks if the .htaccess contains the current version parameter
  *
  * @return bool
  */
 private function isCurrentHtaccess()
 {
     $version = \OC_Util::getVersion();
     unset($version[3]);
     return !strpos(file_get_contents($this->pathToHtaccess()), 'Version: ' . implode('.', $version)) === false;
 }
Example #19
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
		try {
			Setup::updateHtaccess();
			Setup::protectDataDirectory();
		} catch (\Exception $e) {
			throw new \Exception($e->getMessage());
		}

		// 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($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');

		// pre-upgrade repairs
		$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
		$this->emitRepairMessages($repair);
		$repair->run();

		// simulate DB upgrade
		if ($this->simulateStepEnabled) {
			$this->checkCoreUpgrade();

			// simulate apps DB upgrade
			$this->checkAppUpgrade($currentVersion);

		}

		if ($this->updateStepEnabled) {
			$this->doCoreUpgrade();

			// update all shipped apps
			$disabledApps = $this->checkAppsRequirements();
			$this->doAppUpgrade();

			// upgrade appstore apps
			$this->upgradeAppStoreApps($disabledApps);


			// post-upgrade repairs
			$repair = new Repair(Repair::getRepairSteps());
			$this->emitRepairMessages($repair);
			$repair->run();

			//Invalidate update feed
			$this->config->setAppValue('core', 'lastupdatedat', 0);

			// only set the final version if everything went well
			$this->config->setSystemValue('version', implode('.', \OC_Util::getVersion()));
		}
	}
Example #20
0
<?php

/**
 * ownCloud - Files ConoHa
 *
 * @copyright 2015 Stylez Corp. <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
if (\OC_App::isEnabled('files_external') && \OC_App::isEnabled('files_external_conoha')) {
    $l = \OC::$server->getL10N('files_external_conoha');
    $user = OC_User::getUser();
    OC::$CLASSPATH['OC\\Files\\Storage\\ConoHa'] = 'files_external_conoha/lib/conoha.php';
    OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php';
    $version = OC_Util::getVersion();
    // Support for ver 8.2 higher
    if ($version[0] >= 8 && $version[1] >= 2) {
        OC::$CLASSPATH['OCA\\Files\\External\\Api'] = 'files_external/lib/api.php';
        OC::$CLASSPATH['OCA\\Files_External\\Lib\\Backend\\ConoHa'] = 'files_external_conoha/lib/backend/conoha.php';
        $container = OC_Mount_Config::$app->getContainer();
        $container->registerService('L10n', function ($c) use($l) {
            return $l;
        });
        $service = $container->query('OCA\\Files_External\\Service\\BackendService');
        $service->registerBackend($container->query('OCA\\Files_External\\Lib\\Backend\\ConoHa'));
    } else {
        OC_Mount_Config::registerBackend('\\OC\\Files\\Storage\\ConoHa', array('backend' => (string) $l->t('ConoHa Object Storage'), 'priority' => 100, 'configuration' => array('user' => (string) $l->t('Username'), 'password' => '&*' . $l->t('Password (required for ConoHa Object Storage)'), 'region' => '&' . $l->t('Region (optional for ConoHa Object Storage)'), 'url' => '&' . $l->t('URL of identity endpoint (required for ConoHa Object Storage)'), 'tenant' => '&' . $l->t('Tenantname (required for ConoHa Object Storage)'), 'service_name' => '&' . $l->t('Service Name (required for ConoHa Object Storage)'), 'bucket' => (string) $l->t('Bucket'), 'timeout' => '&' . $l->t('Timeout of HTTP requests in seconds')), 'has_dependencies' => true));
    }
}
Example #21
0
 /**
  * Checks if the version requires an update and shows
  * @param bool $showTemplate Whether an update screen should get shown
  * @return bool|void
  */
 public static function checkUpgrade($showTemplate = true)
 {
     if (\OCP\Util::needUpgrade()) {
         $systemConfig = \OC::$server->getSystemConfig();
         if ($showTemplate && !$systemConfig->getValue('maintenance', false)) {
             $version = OC_Util::getVersion();
             $oldTheme = $systemConfig->getValue('theme');
             $systemConfig->setValue('theme', '');
             OC_Util::addScript('config');
             // needed for web root
             OC_Util::addScript('update');
             $tmpl = new OC_Template('', 'update.admin', 'guest');
             $tmpl->assign('version', OC_Util::getVersionString());
             // get third party apps
             $apps = OC_App::getEnabledApps();
             $incompatibleApps = array();
             foreach ($apps as $appId) {
                 $info = OC_App::getAppInfo($appId);
                 if (!OC_App::isAppCompatible($version, $info)) {
                     $incompatibleApps[] = $info;
                 }
             }
             $tmpl->assign('appList', $incompatibleApps);
             $tmpl->assign('productName', 'ownCloud');
             // for now
             $tmpl->assign('oldTheme', $oldTheme);
             $tmpl->printPage();
             exit;
         } else {
             return true;
         }
     }
     return false;
 }
Example #22
0
 public static function checkUpgrade($showTemplate = true)
 {
     if (OC_Config::getValue('installed', false)) {
         $installedVersion = OC_Config::getValue('version', '0.0.0');
         $currentVersion = implode('.', OC_Util::getVersion());
         if (version_compare($currentVersion, $installedVersion, '>')) {
             if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
                 OC_Config::setValue('theme', '');
                 $minimizerCSS = new OC_Minimizer_CSS();
                 $minimizerCSS->clearCache();
                 $minimizerJS = new OC_Minimizer_JS();
                 $minimizerJS->clearCache();
                 OC_Util::addscript('update');
                 $tmpl = new OC_Template('', 'update', 'guest');
                 $tmpl->assign('version', OC_Util::getVersionString());
                 $tmpl->printPage();
                 exit;
             } else {
                 return true;
             }
         }
         return false;
     }
 }
Example #23
0
 /**
  * @brief Get all the applications from the OCS server
  * @returns array with application data
  *
  * This function returns a list of all the applications on the OCS server
  */
 public static function getApplications($categories, $page, $filter)
 {
     if (OC_Config::getValue('appstoreenabled', true) == false) {
         return array();
     }
     if (is_array($categories)) {
         $categoriesstring = implode('x', $categories);
     } else {
         $categoriesstring = $categories;
     }
     $version = '&version=' . implode('x', \OC_Util::getVersion());
     $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 = OC_OCSClient::getOCSresponse($url);
     if ($xml == false) {
         return null;
     }
     $loadEntities = libxml_disable_entity_loader(true);
     $data = simplexml_load_string($xml);
     libxml_disable_entity_loader($loadEntities);
     $tmp = $data->data->content;
     for ($i = 0; $i < count($tmp); $i++) {
         $app = array();
         $app['id'] = (string) $tmp[$i]->id;
         $app['name'] = (string) $tmp[$i]->name;
         $app['label'] = (string) $tmp[$i]->label;
         $app['version'] = (string) $tmp[$i]->version;
         $app['type'] = (string) $tmp[$i]->typeid;
         $app['typename'] = (string) $tmp[$i]->typename;
         $app['personid'] = (string) $tmp[$i]->personid;
         $app['license'] = (string) $tmp[$i]->license;
         $app['detailpage'] = (string) $tmp[$i]->detailpage;
         $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;
     }
     return $apps;
 }
Example #24
0
 /**
  * Check whether the instance needs to perform an upgrade,
  * either when the core version is higher or any app requires
  * an upgrade.
  *
  * @param \OCP\IConfig $config
  * @return bool whether the core or any app needs an upgrade
  */
 public static function needUpgrade(\OCP\IConfig $config)
 {
     if ($config->getSystemValue('installed', false)) {
         $installedVersion = $config->getSystemValue('version', '0.0.0');
         $currentVersion = implode('.', OC_Util::getVersion());
         $versionDiff = version_compare($currentVersion, $installedVersion);
         if ($versionDiff > 0) {
             return true;
         } else {
             if ($versionDiff < 0) {
                 // downgrade attempt, throw exception
                 throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
             }
         }
         // also check for upgrades for apps (independently from the user)
         $apps = \OC_App::getEnabledApps(false, true);
         $shouldUpgrade = false;
         foreach ($apps as $app) {
             if (\OC_App::shouldUpgrade($app)) {
                 $shouldUpgrade = true;
                 break;
             }
         }
         return $shouldUpgrade;
     } else {
         return false;
     }
 }
Example #25
0
 /**
  * get the current installed version of ownCloud
  * @return array
  * @since 4.0.0
  */
 public static function getVersion()
 {
     return \OC_Util::getVersion();
 }
Example #26
0
 /**
  * Prints the upgrade page
  */
 private static function printUpgradePage()
 {
     $systemConfig = \OC::$server->getSystemConfig();
     $oldTheme = $systemConfig->getValue('theme');
     $systemConfig->setValue('theme', '');
     \OCP\Util::addScript('config');
     // needed for web root
     \OCP\Util::addScript('update');
     // check whether this is a core update or apps update
     $installedVersion = $systemConfig->getValue('version', '0.0.0');
     $currentVersion = implode('.', OC_Util::getVersion());
     $appManager = \OC::$server->getAppManager();
     $tmpl = new OC_Template('', 'update.admin', 'guest');
     $tmpl->assign('version', OC_Util::getVersionString());
     // if not a core upgrade, then it's apps upgrade
     if (version_compare($currentVersion, $installedVersion, '=')) {
         $tmpl->assign('isAppsOnlyUpgrade', true);
     } else {
         $tmpl->assign('isAppsOnlyUpgrade', false);
     }
     // get third party apps
     $ocVersion = OC_Util::getVersion();
     $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
     $tmpl->assign('incompatibleAppsList', $appManager->getIncompatibleApps($ocVersion));
     $tmpl->assign('productName', 'ownCloud');
     // for now
     $tmpl->assign('oldTheme', $oldTheme);
     $tmpl->printPage();
 }
Example #27
0
 /**
  * check an app's integrity
  * @param array $data
  * @param string $extractDir
  * @param bool $isShipped
  * @return array
  * @throws \Exception
  */
 public static function checkAppsIntegrity($data = array(), $extractDir, $path, $isShipped = false)
 {
     $l = \OC::$server->getL10N('lib');
     //load the info.xml file of the app
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         //try to find it in a subdir
         $dh = opendir($extractDir);
         if (is_resource($dh)) {
             while (($folder = readdir($dh)) !== false) {
                 if ($folder[0] != '.' and is_dir($extractDir . '/' . $folder)) {
                     if (is_file($extractDir . '/' . $folder . '/appinfo/info.xml')) {
                         $extractDir .= '/' . $folder;
                     }
                 }
             }
         }
     }
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         throw new \Exception($l->t("App does not provide an info.xml file"));
     }
     $info = OC_App::getAppInfo($extractDir . '/appinfo/info.xml', true);
     // check the code for not allowed calls
     if (!$isShipped && !OC_Installer::checkCode($info['id'], $extractDir)) {
         OC_Helper::rmdirr($extractDir);
         throw new \Exception($l->t("App can't be installed because of not allowed code in the App"));
     }
     // check if the app is compatible with this version of ownCloud
     if (!OC_App::isAppCompatible(OC_Util::getVersion(), $info)) {
         OC_Helper::rmdirr($extractDir);
         throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud"));
     }
     // check if shipped tag is set which is only allowed for apps that are shipped with ownCloud
     if (!$isShipped && isset($info['shipped']) && $info['shipped'] == 'true') {
         OC_Helper::rmdirr($extractDir);
         throw new \Exception($l->t("App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps"));
     }
     // check if the ocs version is the same as the version in info.xml/version
     $versionFile = $extractDir . '/appinfo/version';
     if (is_file($versionFile)) {
         $version = trim(file_get_contents($versionFile));
     } else {
         $version = trim($info['version']);
     }
     if (isset($data['appdata']['version']) && $version != trim($data['appdata']['version'])) {
         OC_Helper::rmdirr($extractDir);
         throw new \Exception($l->t("App can't be installed because the version in info.xml/version is not the same as the version reported from the app store"));
     }
     return $info;
 }
Example #28
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()));
     }
 }
Example #29
0
 /**
  * @param string $webRoot
  */
 public function __construct($webRoot)
 {
     $this->webRoot = $webRoot;
     $this->registerService('ContactsManager', function ($c) {
         return new ContactsManager();
     });
     $this->registerService('PreviewManager', function (Server $c) {
         return new PreviewManager($c->getConfig());
     });
     $this->registerService('EncryptionManager', function (Server $c) {
         return new Encryption\Manager($c->getConfig(), $c->getLogger(), $c->getL10N('core'));
     });
     $this->registerService('EncryptionFileHelper', function (Server $c) {
         $util = new \OC\Encryption\Util(new \OC\Files\View(), $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\File($util);
     });
     $this->registerService('EncryptionKeyStorage', function (Server $c) {
         $view = new \OC\Files\View();
         $util = new \OC\Encryption\Util($view, $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\Keys\Storage($view, $util);
     });
     $this->registerService('TagMapper', function (Server $c) {
         return new TagMapper($c->getDatabaseConnection());
     });
     $this->registerService('TagManager', function (Server $c) {
         $tagMapper = $c->query('TagMapper');
         return new TagManager($tagMapper, $c->getUserSession());
     });
     $this->registerService('RootFolder', function (Server $c) {
         // TODO: get user and user manager from container as well
         $user = \OC_User::getUser();
         /** @var $c SimpleContainer */
         $userManager = $c->query('UserManager');
         $user = $userManager->get($user);
         $manager = \OC\Files\Filesystem::getMountManager();
         $view = new View();
         return new Root($manager, $view, $user);
     });
     $this->registerService('UserManager', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\User\Manager($config);
     });
     $this->registerService('GroupManager', function (Server $c) {
         $groupManager = new \OC\Group\Manager($this->getUserManager());
         $groupManager->listen('\\OC\\Group', 'preCreate', function ($gid) {
             \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
         });
         $groupManager->listen('\\OC\\Group', 'postCreate', function (\OC\Group\Group $gid) {
             \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         return $groupManager;
     });
     $this->registerService('UserSession', function (Server $c) {
         $manager = $c->getUserManager();
         $userSession = new \OC\User\Session($manager, new \OC\Session\Memory(''));
         $userSession->listen('\\OC\\User', 'preCreateUser', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postCreateUser', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'preDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'postDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'preLogin', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postLogin', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'logout', function () {
             \OC_Hook::emit('OC_User', 'logout', array());
         });
         return $userSession;
     });
     $this->registerService('NavigationManager', function ($c) {
         return new \OC\NavigationManager();
     });
     $this->registerService('AllConfig', function (Server $c) {
         return new \OC\AllConfig($c->getSystemConfig());
     });
     $this->registerService('SystemConfig', function ($c) {
         return new \OC\SystemConfig();
     });
     $this->registerService('AppConfig', function ($c) {
         return new \OC\AppConfig(\OC_DB::getConnection());
     });
     $this->registerService('L10NFactory', function ($c) {
         return new \OC\L10N\Factory();
     });
     $this->registerService('URLGenerator', function (Server $c) {
         $config = $c->getConfig();
         $cacheFactory = $c->getMemCacheFactory();
         return new \OC\URLGenerator($config, $cacheFactory);
     });
     $this->registerService('AppHelper', function ($c) {
         return new \OC\AppHelper();
     });
     $this->registerService('UserCache', function ($c) {
         return new Cache\File();
     });
     $this->registerService('MemCacheFactory', function (Server $c) {
         $config = $c->getConfig();
         if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
             $v = \OC_App::getAppVersions();
             $v['core'] = implode('.', \OC_Util::getVersion());
             $version = implode(',', $v);
             $instanceId = \OC_Util::getInstanceId();
             $path = \OC::$SERVERROOT;
             $prefix = md5($instanceId . '-' . $version . '-' . $path);
             return new \OC\Memcache\Factory($prefix, $config->getSystemValue('memcache.local', null), $config->getSystemValue('memcache.distributed', null), $config->getSystemValue('memcache.locking', null));
         }
         return new \OC\Memcache\Factory('', new ArrayCache(), new ArrayCache(), new ArrayCache());
     });
     $this->registerService('ActivityManager', function (Server $c) {
         return new ActivityManager($c->getRequest(), $c->getUserSession(), $c->getConfig());
     });
     $this->registerService('AvatarManager', function ($c) {
         return new AvatarManager();
     });
     $this->registerService('Logger', function (Server $c) {
         $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
         $logger = 'OC_Log_' . ucfirst($logClass);
         call_user_func(array($logger, 'init'));
         return new Log($logger);
     });
     $this->registerService('JobList', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
     });
     $this->registerService('Router', function (Server $c) {
         $cacheFactory = $c->getMemCacheFactory();
         if ($cacheFactory->isAvailable()) {
             $router = new \OC\Route\CachingRouter($cacheFactory->create('route'));
         } else {
             $router = new \OC\Route\Router();
         }
         return $router;
     });
     $this->registerService('Search', function ($c) {
         return new Search();
     });
     $this->registerService('SecureRandom', function ($c) {
         return new SecureRandom();
     });
     $this->registerService('Crypto', function (Server $c) {
         return new Crypto($c->getConfig(), $c->getSecureRandom());
     });
     $this->registerService('Hasher', function (Server $c) {
         return new Hasher($c->getConfig());
     });
     $this->registerService('DatabaseConnection', function (Server $c) {
         $factory = new \OC\DB\ConnectionFactory();
         $systemConfig = $c->getSystemConfig();
         $type = $systemConfig->getValue('dbtype', 'sqlite');
         if (!$factory->isValidType($type)) {
             throw new \OC\DatabaseException('Invalid database type');
         }
         $connectionParams = $factory->createConnectionParams($systemConfig);
         $connection = $factory->getConnection($type, $connectionParams);
         $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
         return $connection;
     });
     $this->registerService('Db', function (Server $c) {
         return new Db($c->getDatabaseConnection());
     });
     $this->registerService('HTTPHelper', function (Server $c) {
         $config = $c->getConfig();
         return new HTTPHelper($config, $c->getHTTPClientService());
     });
     $this->registerService('HttpClientService', function (Server $c) {
         $user = \OC_User::getUser();
         $uid = $user ? $user : null;
         return new ClientService($c->getConfig(), new \OC\Security\CertificateManager($uid, new \OC\Files\View()));
     });
     $this->registerService('EventLogger', function (Server $c) {
         if (defined('DEBUG') and DEBUG) {
             return new EventLogger();
         } else {
             return new NullEventLogger();
         }
     });
     $this->registerService('QueryLogger', function ($c) {
         if (defined('DEBUG') and DEBUG) {
             return new QueryLogger();
         } else {
             return new NullQueryLogger();
         }
     });
     $this->registerService('TempManager', function (Server $c) {
         return new TempManager(get_temp_dir(), $c->getLogger());
     });
     $this->registerService('AppManager', function (Server $c) {
         return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
     });
     $this->registerService('DateTimeZone', function (Server $c) {
         return new DateTimeZone($c->getConfig(), $c->getSession());
     });
     $this->registerService('DateTimeFormatter', function (Server $c) {
         $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
         return new DateTimeFormatter($c->getDateTimeZone()->getTimeZone(), $c->getL10N('lib', $language));
     });
     $this->registerService('MountConfigManager', function () {
         $loader = \OC\Files\Filesystem::getLoader();
         return new \OC\Files\Config\MountProviderCollection($loader);
     });
     $this->registerService('IniWrapper', function ($c) {
         return new IniGetWrapper();
     });
     $this->registerService('AsyncCommandBus', function (Server $c) {
         $jobList = $c->getJobList();
         return new AsyncBus($jobList);
     });
     $this->registerService('TrustedDomainHelper', function ($c) {
         return new TrustedDomainHelper($this->getConfig());
     });
     $this->registerService('Request', function ($c) {
         if (isset($this['urlParams'])) {
             $urlParams = $this['urlParams'];
         } else {
             $urlParams = [];
         }
         if ($this->getSession()->exists('requesttoken')) {
             $requestToken = $this->getSession()->get('requesttoken');
         } else {
             $requestToken = false;
         }
         if (defined('PHPUNIT_RUN') && PHPUNIT_RUN && in_array('fakeinput', stream_get_wrappers())) {
             $stream = 'fakeinput://data';
         } else {
             $stream = 'php://input';
         }
         return new Request(['get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'server' => $_SERVER, 'env' => $_ENV, 'cookies' => $_COOKIE, 'method' => isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null, 'urlParams' => $urlParams, 'requesttoken' => $requestToken], $this->getSecureRandom(), $this->getConfig(), $stream);
     });
     $this->registerService('Mailer', function (Server $c) {
         return new Mailer($c->getConfig(), $c->getLogger(), new \OC_Defaults());
     });
     $this->registerService('OcsClient', function (Server $c) {
         return new OCSClient($this->getHTTPClientService(), $this->getConfig(), $this->getLogger());
     });
     $this->registerService('LockingProvider', function (Server $c) {
         if ($c->getConfig()->getSystemValue('filelocking.enabled', false) or defined('PHPUNIT_RUN') && PHPUNIT_RUN) {
             /** @var \OC\Memcache\Factory $memcacheFactory */
             $memcacheFactory = $c->getMemCacheFactory();
             $memcache = $memcacheFactory->createLocking('lock');
             if (!$memcache instanceof \OC\Memcache\NullCache) {
                 return new MemcacheLockingProvider($memcache);
             }
             throw new HintException('File locking is enabled but the locking cache class was not found', 'Please check the "memcache.locking" setting and make sure the matching PHP module is installed and enabled');
         }
         return new NoopLockingProvider();
     });
 }
Example #30
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $values = array('installed' => \OC_Config::getValue('installed') ? 'true' : 'false', 'version' => implode('.', \OC_Util::getVersion()), 'versionstring' => \OC_Util::getVersionString(), 'edition' => \OC_Util::getEditionString());
     print_r($values);
 }