예제 #1
0
파일: defaults.php 프로젝트: kenwi/core
 function __construct()
 {
     $this->l = \OC::$server->getL10N('lib');
     $version = \OCP\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();
         }
     }
 }
예제 #2
0
 public function providesLoggerMethods()
 {
     $methods = [['alert'], ['warning'], ['emergency'], ['critical'], ['error'], ['notice'], ['info'], ['debug']];
     if (version_compare(implode('.', \OCP\Util::getVersion()), '8.2', '>=')) {
         $methods[] = ['logException', new \Exception()];
     }
     return $methods;
 }
예제 #3
0
 public static function getCapabilities()
 {
     $result = array();
     list($major, $minor, $micro) = \OCP\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 Result($result);
 }
예제 #4
0
 public function testGetVersion()
 {
     $version = \OCP\Util::getVersion();
     $this->assertTrue(is_array($version));
     foreach ($version as $num) {
         $this->assertTrue(is_int($num));
     }
 }
예제 #5
0
파일: bootstrap.php 프로젝트: sbambach/news
 protected function setUp()
 {
     $this->ownCloudVersion = \OCP\Util::getVersion();
     $this->cleanUp();
     $app = new Application();
     $this->container = $app->getContainer();
     $this->itemMapper = $this->container->query('OCA\\News\\Db\\ItemMapper');
     $this->feedMapper = $this->container->query('OCA\\News\\Db\\FeedMapper');
     $this->folderMapper = $this->container->query('OCA\\News\\Db\\FolderMapper');
     $this->loadFixtures($this->folderMapper, $this->feedMapper, $this->itemMapper);
 }
예제 #6
0
 public static function checkVersion($newVersionArray, $newVersionString)
 {
     $l10n = \OC::$server->getL10N('updater');
     $currentVersionArray = \OCP\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) $l10n->t('Not possible to update %s to %s. Downgrading or skipping major releases is not supported.', [$currentVersion, implode('.', $newVersionArray)]);
         \OC::$server->getLogger()->error($message, ['app' => 'updater']);
         throw new \Exception($message);
     }
 }
예제 #7
0
 /**
  * CAUTION: the @Stuff turn off security checks, for this page no admin is
  *          required and no CSRF check. If you don't know what CSRF is, read
  *          it up in the docs or you might create a security hole. This is
  *          basically the only required method to add this exemption, don't
  *          add it to any other method if you don't exactly know what it does
  *
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $params = array('user' => $this->userId);
     $response = new TemplateResponse('ownmnote', 'main', $params);
     $ocVersion = \OCP\Util::getVersion();
     if ($ocVersion[0] > 8 || $ocVersion[0] == 8 && $ocVersion[1] >= 1) {
         $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
         $csp->addAllowedImageDomain('data:');
         $response->setContentSecurityPolicy($csp);
     }
     return $response;
 }
예제 #8
0
 public static function checkVersion($newVersionArray, $newVersionString)
 {
     $l10n = \OC::$server->getL10N('updater');
     $currentVersionArray = \OCP\Util::getVersion();
     $currentVersion = \OC_Util::getVersionString();
     // https://github.com/owncloud/core/issues/18880
     // Always positive for versions >= 100.0.0.0
     if (version_compare($newVersionString, '100.0.0.0', '>=')) {
         return;
     }
     $difference = intval($newVersionArray[0]) - intval($currentVersionArray[0]);
     if ($difference > 1 || $difference < 0 || version_compare($currentVersion, $newVersionString) > 0) {
         $message = (string) $l10n->t('Not possible to update %s to %s. Downgrading or skipping major releases is not supported.', [$currentVersion, implode('.', $newVersionArray)]);
         \OC::$server->getLogger()->error($message, ['app' => 'updater']);
         throw new \Exception($message);
     }
 }
예제 #9
0
 /**
  * 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 = null)
 {
     // Look up the cache - it is invalidated all 30 minutes
     if ((int) $this->config->getAppValue('core', 'lastupdatedat') + 1800 > time()) {
         return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
     }
     if (is_null($updaterUrl)) {
         $updaterUrl = 'https://updates.owncloud.com/server/';
     }
     $this->config->setAppValue('core', 'lastupdatedat', time());
     if ($this->config->getAppValue('core', 'installedat', '') === '') {
         $this->config->setAppValue('core', 'installedat', microtime(true));
     }
     $version = Util::getVersion();
     $version['installed'] = $this->config->getAppValue('core', 'installedat');
     $version['updated'] = $this->config->getAppValue('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;
     $tmp = [];
     $xml = $this->getUrlContent($url);
     if ($xml) {
         $loadEntities = libxml_disable_entity_loader(true);
         $data = @simplexml_load_string($xml);
         libxml_disable_entity_loader($loadEntities);
         if ($data !== false) {
             $tmp['version'] = (string) $data->version;
             $tmp['versionstring'] = (string) $data->versionstring;
             $tmp['url'] = (string) $data->url;
             $tmp['web'] = (string) $data->web;
         } else {
             libxml_clear_errors();
         }
     } else {
         $data = [];
     }
     // Cache the result
     $this->config->setAppValue('core', 'lastupdateResult', json_encode($data));
     return $tmp;
 }
예제 #10
0
파일: status.php 프로젝트: kenwi/core
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
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('.', \OCP\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);
}
예제 #11
0
파일: base.php 프로젝트: gmurayama/core
 /**
  * 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('.', \OCP\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 = \OCP\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();
 }
예제 #12
0
파일: app.php 프로젝트: pierreozoux/core
 /**
  * @param string $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();
     $ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), $config, \OC::$server->getLogger());
     $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion());
     // 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 = \OCP\Util::getVersion();
         if (!self::isAppCompatible($version, $info)) {
             throw new \Exception($l->t('App "%s" cannot 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($info);
         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;
 }
예제 #13
0
 /**
  * Partially importe this function from owncloud Chat app
  * https://github.com/owncloud/chat/blob/master/app/chat.php
  */
 private function loadContacts()
 {
     $this->contacts = array();
     $this->contactsInverted = array();
     // Cache country because of loops
     $configuredCountry = $this->cfgMapper->getCountry();
     $cm = $this->contactsManager;
     if ($cm == null) {
         return;
     }
     $result = $cm->search('', array('FN'));
     foreach ($result as $r) {
         if (isset($r["TEL"])) {
             $phoneIds = $r["TEL"];
             if (is_array($phoneIds)) {
                 $countPhone = count($phoneIds);
                 for ($i = 0; $i < $countPhone; $i++) {
                     $phoneNumber = preg_replace("#[ ]#", "", $phoneIds[$i]);
                     $this->pushPhoneNumberToCache($phoneNumber, $r["FN"], $configuredCountry);
                 }
             } else {
                 $phoneNumber = preg_replace("#[ ]#", "", $phoneIds);
                 $this->pushPhoneNumberToCache($phoneNumber, $r["FN"], $configuredCountry);
             }
             if (isset($r["PHOTO"])) {
                 // Remove useless prefix
                 $ocversion = \OCP\Util::getVersion();
                 $photoURL = preg_replace("#^VALUE=uri:#", "", $r["PHOTO"], 1);
                 $this->contactPhotos[$r["FN"]] = $photoURL;
             }
         }
     }
 }
예제 #14
0
파일: util.php 프로젝트: Angelos0/core
 /**
  * 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('.', \OCP\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;
     }
 }
예제 #15
0
 /**
  * Tests no error is given when the datadir is not writable during setup
  */
 public function testDataDirNotWritableSetup()
 {
     chmod($this->datadir, 0300);
     $result = \OC_Util::checkServer($this->getConfig(array('installed' => false, 'version' => implode('.', \OCP\Util::getVersion()))));
     chmod($this->datadir, 0700);
     //needed for cleanup
     $this->assertEmpty($result);
 }
예제 #16
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::$server->getAppConfig()->getValue($app, 'ocsid', '');
     if ($ocsid != '') {
         $ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), \OC::$server->getConfig(), \OC::$server->getLogger());
         $ocsdata = $ocsClient->getApplication($ocsid, \OCP\Util::getVersion());
         $ocsversion = (string) $ocsdata['version'];
         $currentversion = OC_App::getAppVersion($app);
         if (version_compare($ocsversion, $currentversion, '>')) {
             return $ocsversion;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
예제 #17
0
파일: app.php 프로젝트: Graf-Zahl/music
\OCP\Util::connectHook('OCP\\Share', 'post_unshare', 'OCA\\Music\\Hooks\\Share', 'itemUnshared');
// TODO: disabled because it can delay the share a lot
/*
\OCP\Util::connectHook(
	'OCP\Share', 'post_shared',
	'OCA\Music\Hooks\Share', 'itemShared'
);
*/
/**
 * register search provider
 */
\OC_Search::registerProvider('OCA\\Music\\Utility\\Search');
/**
 * register settings
 */
\OCP\App::registerPersonal($c->query('AppName'), 'settings/user');
/**
 * load styles and scripts
 */
$appName = $c->query('AppName');
if (version_compare(implode('.', \OCP\Util::getVersion()), '7.8', '<=')) {
    // fileactions
    $c->query('API')->addScript('public/fileactions', $appName);
    // file player for public sharing page
    $c->query('API')->addScript('public/musicFilePlayer', $appName);
} else {
    // fileactions
    \OCP\Util::addScript($appName, 'public/fileactions');
    // file player for public sharing page
    \OCP\Util::addScript($appName, 'public/musicFilePlayer');
}
예제 #18
0
파일: status.php 프로젝트: gmurayama/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $values = array('installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), 'version' => implode('.', \OCP\Util::getVersion()), 'versionstring' => \OC_Util::getVersionString(), 'edition' => \OC_Util::getEditionString());
     $this->writeArrayInOutputFormat($input, $output, $values);
 }
예제 #19
0
파일: platform.php 프로젝트: gmurayama/core
 /**
  * @return string
  */
 public function getOcVersion()
 {
     $v = \OCP\Util::getVersion();
     return join('.', $v);
 }
예제 #20
0
<?php

if (!defined('PHPUNIT_RUN')) {
    define('PHPUNIT_RUN', 1);
}
require_once __DIR__ . '/../../../lib/base.php';
if (!class_exists('PHPUnit_Framework_TestCase')) {
    require_once 'PHPUnit/Autoload.php';
}
OC_Hook::clear();
OCP\Util::connectHook('OCA\\Contacts', 'pre_deleteContact', '\\OCA\\Contacts\\Hooks', 'contactDeletion');
Sabre\VObject\Component\VCard::$componentMap['VCARD'] = '\\OCA\\Contacts\\VObject\\VCard';
Sabre\VObject\Component\VCard::$propertyMap['CATEGORIES'] = '\\OCA\\Contacts\\VObject\\GroupProperty';
if (version_compare(implode('.', \OCP\Util::getVersion()), '8.2', '>=')) {
    \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
    \OC_App::loadApp('contacts');
}
예제 #21
0
파일: updater.php 프로젝트: kenwi/core
 /**
  * @param string $baseUrl
  * @return string
  */
 private function buildUpdateUrl($baseUrl)
 {
     return $baseUrl . '?version=' . implode('x', \OCP\Util::getVersion()) . 'xinstalledatxlastupdatedatx' . \OC_Util::getChannel() . 'x' . \OC_Util::getEditionString() . 'x';
 }
예제 #22
0
파일: config.php 프로젝트: gmurayama/core
// 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" => $config->getSystemValue('debug', false) ? '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'))), "dayNamesShort" => json_encode(array((string) $l->t('Sun.'), (string) $l->t('Mon.'), (string) $l->t('Tue.'), (string) $l->t('Wed.'), (string) $l->t('Thu.'), (string) $l->t('Fri.'), (string) $l->t('Sat.'))), "dayNamesMin" => json_encode(array((string) $l->t('Su'), (string) $l->t('Mo'), (string) $l->t('Tu'), (string) $l->t('We'), (string) $l->t('Th'), (string) $l->t('Fr'), (string) $l->t('Sa'))), "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'))), "monthNamesShort" => json_encode(array((string) $l->t('Jan.'), (string) $l->t('Feb.'), (string) $l->t('Mar.'), (string) $l->t('Apr.'), (string) $l->t('May.'), (string) $l->t('Jun.'), (string) $l->t('Jul.'), (string) $l->t('Aug.'), (string) $l->t('Sep.'), (string) $l->t('Oct.'), (string) $l->t('Nov.'), (string) $l->t('Dec.'))), "firstDay" => json_encode($l->getFirstWeekDay()), "oc_config" => json_encode(array('session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true), 'version' => implode('.', \OCP\Util::getVersion()), 'versionstring' => OC_Util::getVersionString(), 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true), 'lost_password_link' => \OC::$server->getConfig()->getSystemValue('lost_password_link', null), 'modRewriteWorking' => getenv('front_controller_active') === '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(), 'folder' => OC_Util::getTheme())));
// 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";
}
예제 #23
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');
         }
         // Code integrity notification
         $integrityChecker = \OC::$server->getIntegrityCodeChecker();
         if (!$integrityChecker->hasPassedCheck()) {
             \OCP\Util::addScript('core', 'integritycheck-failed-notification');
         }
         // 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();
         $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0;
         if ($appsMgmtActive) {
             $l = \OC::$server->getL10N('lib');
             $this->assign('application', $l->t('Apps'));
         }
         $this->assign('user_displayname', $userDisplayName);
         $this->assign('user_uid', \OC_User::getUser());
         $this->assign('appsmanagement_active', $appsMgmtActive);
         $this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true) === true);
         if (\OC_User::getUser() === false) {
             $this->assign('userAvatarSet', false);
         } else {
             $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
         }
     } 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 (\OC::$server->getSystemConfig()->getValue('installed', false)) {
         if (empty(self::$versionHash)) {
             $v = \OC_App::getAppVersions();
             $v['core'] = implode('.', \OCP\Util::getVersion());
             self::$versionHash = md5(implode(',', $v));
         }
     } else {
         self::$versionHash = md5('not installed');
     }
     $useAssetPipeline = self::isAssetPipelineEnabled();
     if ($useAssetPipeline) {
         $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash]));
         $this->generateAssets();
     } else {
         // Add the js files
         $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
         $this->assign('jsfiles', array());
         if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
             $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['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);
         }
     }
 }
예제 #24
0
 protected function getCoreVersions()
 {
     return implode('.', \OCP\Util::getVersion());
 }
예제 #25
0
파일: setup.php 프로젝트: kenwi/core
 /**
  * @param $options
  * @return array
  */
 public function install($options)
 {
     $l = $this->l10n;
     $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($l, 'db_structure.xml', $this->config, $this->logger, $this->random);
     $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;
     }
     $request = \OC::$server->getRequest();
     //no errors, good
     if (isset($options['trusted_domains']) && is_array($options['trusted_domains'])) {
         $trustedDomains = $options['trusted_domains'];
     } else {
         $trustedDomains = [$request->getInsecureServerHost()];
     }
     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 = $this->random->generate(30);
     // generate a secret
     $secret = $this->random->generate(48);
     //write the config file
     $this->config->setSystemValues(['passwordsalt' => $salt, 'secret' => $secret, 'trusted_domains' => $trustedDomains, 'datadirectory' => $dataDir, 'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT, 'dbtype' => $dbType, 'version' => implode('.', \OCP\Util::getVersion())]);
     try {
         $dbSetup->initialize($options);
         $dbSetup->setupDatabase($username);
     } catch (\OC\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
     $user = null;
     try {
         $user = \OC::$server->getUserManager()->createUser($username, $password);
         if (!$user) {
             $error[] = "User <{$username}> could not be created.";
         }
     } catch (Exception $exception) {
         $error[] = $exception->getMessage();
     }
     if (count($error) == 0) {
         $config = \OC::$server->getConfig();
         $config->setAppValue('core', 'installedat', microtime(true));
         $config->setAppValue('core', 'lastupdatedat', microtime(true));
         $group = \OC::$server->getGroupManager()->createGroup('admin');
         $group->addUser($user);
         \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($config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
         // Update .htaccess files
         Setup::updateHtaccess();
         Setup::protectDataDirectory();
         //try to write logtimezone
         if (date_default_timezone_get()) {
             $config->setSystemValue('logtimezone', date_default_timezone_get());
         }
         //and we are done
         $config->setSystemValue('installed', true);
     }
     return $error;
 }
예제 #26
0
 /**
  * Prints the upgrade page
  */
 private static function printUpgradePage()
 {
     $systemConfig = \OC::$server->getSystemConfig();
     $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false);
     $tooBig = false;
     if (!$disableWebUpdater) {
         $apps = \OC::$server->getAppManager();
         $tooBig = $apps->isInstalled('user_ldap') || $apps->isInstalled('user_shibboleth');
         if (!$tooBig) {
             // count users
             $stats = \OC::$server->getUserManager()->countUsers();
             $totalUsers = array_sum($stats);
             $tooBig = $totalUsers > 50;
         }
     }
     if ($disableWebUpdater || $tooBig) {
         // send http status 503
         header('HTTP/1.1 503 Service Temporarily Unavailable');
         header('Status: 503 Service Temporarily Unavailable');
         header('Retry-After: 120');
         // render error page
         $template = new OC_Template('', 'update.use-cli', 'guest');
         $template->assign('productName', 'ownCloud');
         // for now
         $template->assign('version', OC_Util::getVersionString());
         $template->assign('tooBig', $tooBig);
         $template->printPage();
         die;
     }
     // check whether this is a core update or apps update
     $installedVersion = $systemConfig->getValue('version', '0.0.0');
     $currentVersion = implode('.', \OCP\Util::getVersion());
     // if not a core upgrade, then it's apps upgrade
     $isAppsOnlyUpgrade = version_compare($currentVersion, $installedVersion, '=');
     $oldTheme = $systemConfig->getValue('theme');
     $systemConfig->setValue('theme', '');
     \OCP\Util::addScript('config');
     // needed for web root
     \OCP\Util::addScript('update');
     \OCP\Util::addStyle('update');
     $appManager = \OC::$server->getAppManager();
     $tmpl = new OC_Template('', 'update.admin', 'guest');
     $tmpl->assign('version', OC_Util::getVersionString());
     $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade);
     // get third party apps
     $ocVersion = \OCP\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();
 }
예제 #27
0
 /**
  * @return bool
  */
 private function isCodeUpgrade()
 {
     $installedVersion = $this->config->getSystemValue('version', '0.0.0');
     $currentVersion = implode('.', \OCP\Util::getVersion());
     if (version_compare($currentVersion, $installedVersion, '>')) {
         return true;
     }
     return false;
 }
예제 #28
0
파일: main.php 프로젝트: Graf-Zahl/music
\OCP\Util::addScript('music', 'vendor/angular/angular.min');
\OCP\Util::addScript('music', 'vendor/angular-route/angular-route.min');
\OCP\Util::addScript('music', 'vendor/soundmanager/script/soundmanager2-nodebug-jsmin');
\OCP\Util::addScript('music', 'vendor/restangular/dist/restangular.min');
\OCP\Util::addScript('music', 'vendor/angular-gettext/dist/angular-gettext.min');
\OCP\Util::addScript('music', 'vendor/aurora/aurora');
\OCP\Util::addScript('music', 'vendor/aurora/flac');
\OCP\Util::addScript('music', 'vendor/aurora/mp3');
\OCP\Util::addScript('music', 'public/app');
\OCP\Util::addStyle('music', 'style-controls');
\OCP\Util::addStyle('music', 'style-sidebar');
\OCP\Util::addStyle('music', 'style');
\OCP\Util::addStyle('music', 'mobile');
\OCP\Util::addStyle('music', 'tablet');
// stylesheets for different OC versions
$version = \OCP\Util::getVersion();
// owncloud 6
if ($version[0] === 6 || $version[0] === 5 && $version[1] >= 80) {
    \OCP\Util::addStyle('music', 'stable6-fixes');
}
?>


<div id="app" ng-app="Music" ng-cloak ng-init="started = false; lang = '<?php 
p($_['lang']);
?>
'">

	<script type="text/ng-template" id="overview.html">
		<?php 
print_unescaped($this->inc('partials/overview'));
예제 #29
0
 /**
  * Get all available apps in a category
  *
  * @param string $category
  * @param bool $includeUpdateInfo Should we check whether there is an update
  *                                in the app store?
  * @return array
  */
 public function listApps($category = '', $includeUpdateInfo = true)
 {
     $category = $this->getCategory($category);
     $cacheName = 'listApps-' . $category . '-' . (int) $includeUpdateInfo;
     if (!is_null($this->cache->get($cacheName))) {
         $apps = $this->cache->get($cacheName);
     } else {
         switch ($category) {
             // installed apps
             case 0:
                 $apps = $this->getInstalledApps($includeUpdateInfo);
                 usort($apps, function ($a, $b) {
                     $a = (string) $a['name'];
                     $b = (string) $b['name'];
                     if ($a === $b) {
                         return 0;
                     }
                     return $a < $b ? -1 : 1;
                 });
                 $version = \OCP\Util::getVersion();
                 foreach ($apps as $key => $app) {
                     if (!array_key_exists('level', $app) && array_key_exists('ocsid', $app)) {
                         $remoteAppEntry = $this->ocsClient->getApplication($app['ocsid'], $version);
                         if (is_array($remoteAppEntry) && array_key_exists('level', $remoteAppEntry)) {
                             $apps[$key]['level'] = $remoteAppEntry['level'];
                         }
                     }
                 }
                 break;
                 // not-installed apps
             // not-installed apps
             case 1:
                 $apps = \OC_App::listAllApps(true, $includeUpdateInfo, $this->ocsClient);
                 $apps = array_filter($apps, function ($app) {
                     return !$app['active'];
                 });
                 $version = \OCP\Util::getVersion();
                 foreach ($apps as $key => $app) {
                     if (!array_key_exists('level', $app) && array_key_exists('ocsid', $app)) {
                         $remoteAppEntry = $this->ocsClient->getApplication($app['ocsid'], $version);
                         if (is_array($remoteAppEntry) && array_key_exists('level', $remoteAppEntry)) {
                             $apps[$key]['level'] = $remoteAppEntry['level'];
                         }
                     }
                 }
                 usort($apps, function ($a, $b) {
                     $a = (string) $a['name'];
                     $b = (string) $b['name'];
                     if ($a === $b) {
                         return 0;
                     }
                     return $a < $b ? -1 : 1;
                 });
                 break;
             default:
                 $filter = $this->config->getSystemValue('appstore.experimental.enabled', false) ? 'all' : 'approved';
                 $apps = \OC_App::getAppstoreApps($filter, $category, $this->ocsClient);
                 if (!$apps) {
                     $apps = array();
                 } else {
                     // don't list installed apps
                     $installedApps = $this->getInstalledApps(false);
                     $installedApps = array_map(function ($app) {
                         if (isset($app['ocsid'])) {
                             return $app['ocsid'];
                         }
                         return $app['id'];
                     }, $installedApps);
                     $apps = array_filter($apps, function ($app) use($installedApps) {
                         return !in_array($app['id'], $installedApps);
                     });
                     // show tooltip if app is downloaded from remote server
                     $inactiveApps = $this->getInactiveApps();
                     foreach ($apps as &$app) {
                         $app['needsDownload'] = !in_array($app['id'], $inactiveApps);
                     }
                 }
                 // sort by score
                 usort($apps, function ($a, $b) {
                     $a = (int) $a['score'];
                     $b = (int) $b['score'];
                     if ($a === $b) {
                         return 0;
                     }
                     return $a > $b ? -1 : 1;
                 });
                 break;
         }
     }
     // fix groups to be an array
     $dependencyAnalyzer = new DependencyAnalyzer(new Platform($this->config), $this->l10n);
     $apps = array_map(function ($app) use($dependencyAnalyzer) {
         // fix groups
         $groups = array();
         if (is_string($app['groups'])) {
             $groups = json_decode($app['groups']);
         }
         $app['groups'] = $groups;
         $app['canUnInstall'] = !$app['active'] && $app['removable'];
         // fix licence vs license
         if (isset($app['license']) && !isset($app['licence'])) {
             $app['licence'] = $app['license'];
         }
         // analyse dependencies
         $missing = $dependencyAnalyzer->analyze($app);
         $app['canInstall'] = empty($missing);
         $app['missingDependencies'] = $missing;
         $app['missingMinOwnCloudVersion'] = !isset($app['dependencies']['owncloud']['@attributes']['min-version']);
         $app['missingMaxOwnCloudVersion'] = !isset($app['dependencies']['owncloud']['@attributes']['max-version']);
         return $app;
     }, $apps);
     $this->cache->set($cacheName, $apps, 300);
     return ['apps' => $apps, 'status' => 'success'];
 }
예제 #30
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function retrieveAllPeers()
 {
     $phoneList = $this->smsMapper->getLastMessageTimestampForAllPhonesNumbers($this->userId);
     $contactsSrc = $this->contactCache->getContacts();
     $contacts = array();
     $photos = $this->contactCache->getContactPhotos();
     // Cache country because of loops
     $configuredCountry = $this->configMapper->getCountry();
     foreach ($phoneList as $number => $ts) {
         $fmtPN = PhoneNumberFormatter::format($configuredCountry, $number);
         if (isset($contactsSrc[$number])) {
             $contacts[$number] = $contactsSrc[$number];
         } elseif (isset($contactsSrc[$fmtPN])) {
             $contacts[$number] = $contactsSrc[$fmtPN];
         } elseif (isset($contacts[$fmtPN])) {
             $contacts[$number] = $fmtPN;
         } else {
             $contacts[$number] = $fmtPN;
         }
     }
     $lastRead = $this->convStateMapper->getLast($this->userId);
     $ocversion = \OCP\Util::getVersion();
     $photoversion = 1;
     if (version_compare($ocversion[0] . "." . $ocversion[1] . "." . $ocversion[2], "9.0.0", ">=")) {
         $photoversion = 2;
     }
     return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos, "photo_version" => $photoversion));
 }