Example #1
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 #2
0
 /**
  * @brief Constructor
  * @param string $app app providing the template
  * @param string $name of the template file (without suffix)
  * @param string $renderas = ""; produce a full page
  * @return OC_Template object
  *
  * This function creates an OC_Template object.
  *
  * If $renderas is set, OC_Template will try to produce a full page in the
  * according layout. For now, renderas can be set to "guest", "user" or
  * "admin".
  */
 public function __construct($app, $name, $renderas = "")
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $requesttoken = OC::$session ? OC_Util::callRegister() : '';
     $parts = explode('/', $app);
     // fix translation when app is something like core/lostpassword
     $l10n = OC_L10N::get($parts[0]);
     $themeDefaults = new OC_Defaults();
     list($path, $template) = $this->findTemplate($theme, $app, $name, $fext);
     // Set the private data
     $this->renderas = $renderas;
     $this->path = $path;
     parent::__construct($template, $requesttoken, $l10n, $themeDefaults);
     // Some headers to enhance security
     header('X-XSS-Protection: 1; mode=block');
     // Enforce browser based XSS filters
     header('X-Content-Type-Options: nosniff');
     // Disable sniffing the content type for IE
     // iFrame Restriction Policy
     $xFramePolicy = OC_Config::getValue('xframe_restriction', true);
     if ($xFramePolicy) {
         header('X-Frame-Options: Sameorigin');
         // Disallow iFraming from other domains
     }
     // Content Security Policy
     // If you change the standard policy, please also change it in config.sample.php
     $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; ' . 'script-src \'self\' \'unsafe-eval\'; ' . 'style-src \'self\' \'unsafe-inline\'; ' . 'frame-src *; ' . 'img-src *; ' . 'font-src \'self\' data:; ' . 'media-src *');
     header('Content-Security-Policy:' . $policy);
     // Standard
 }
Example #3
0
 private function themeExist($method)
 {
     if (OC_Util::getTheme() !== '' && method_exists('OC_Theme', $method)) {
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * @brief Creates path to an image
  * @param string $app app
  * @param string $image image name
  * @return string the url
  *
  * Returns the path to the image.
  */
 public function imagePath($app, $image)
 {
     // Read the selected theme from the config file
     $theme = \OC_Util::getTheme();
     //if a theme has a png but not an svg always use the png
     $basename = substr(basename($image), 0, -4);
     // Check if the app is in the app folder
     if (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$image}")) {
         return \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$image}";
     } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png";
     } elseif (file_exists(\OC_App::getAppPath($app) . "/img/{$image}")) {
         return \OC_App::getAppWebPath($app) . "/img/{$image}";
     } elseif (!file_exists(\OC_App::getAppPath($app) . "/img/{$basename}.svg") && file_exists(\OC_App::getAppPath($app) . "/img/{$basename}.png")) {
         return \OC_App::getAppPath($app) . "/img/{$basename}.png";
     } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$image}")) {
         return \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$image}";
     } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$basename}.png";
     } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/{$app}/img/{$image}")) {
         return \OC::$WEBROOT . "/{$app}/img/{$image}";
     } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/{$app}/img/{$basename}.png";
     } elseif (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$image}")) {
         return \OC::$WEBROOT . "/themes/{$theme}/core/img/{$image}";
     } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/themes/{$theme}/core/img/{$basename}.png";
     } elseif (file_exists(\OC::$SERVERROOT . "/core/img/{$image}")) {
         return \OC::$WEBROOT . "/core/img/{$image}";
     } else {
         throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
     }
 }
Example #5
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 #6
0
 /**
  * Constructor
  * @param string $app app providing the template
  * @param string $name of the template file (without suffix)
  * @param string $renderas = ""; produce a full page
  * @param bool $registerCall = true
  * @return OC_Template object
  *
  * This function creates an OC_Template object.
  *
  * If $renderas is set, OC_Template will try to produce a full page in the
  * according layout. For now, renderas can be set to "guest", "user" or
  * "admin".
  */
 public function __construct($app, $name, $renderas = "", $registerCall = true)
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     $requesttoken = (OC::$server->getSession() and $registerCall) ? OC_Util::callRegister() : '';
     $parts = explode('/', $app);
     // fix translation when app is something like core/lostpassword
     $l10n = \OC::$server->getL10N($parts[0]);
     $themeDefaults = new OC_Defaults();
     list($path, $template) = $this->findTemplate($theme, $app, $name);
     // Set the private data
     $this->renderas = $renderas;
     $this->path = $path;
     $this->app = $app;
     parent::__construct($template, $requesttoken, $l10n, $themeDefaults);
 }
Example #7
0
 /**
  * @brief Constructor
  * @param string $app app providing the template
  * @param string $name of the template file (without suffix)
  * @param string $renderas = ""; produce a full page
  * @return OC_Template object
  *
  * This function creates an OC_Template object.
  *
  * If $renderas is set, OC_Template will try to produce a full page in the
  * according layout. For now, renderas can be set to "guest", "user" or
  * "admin".
  */
 public function __construct($app, $name, $renderas = "")
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $requesttoken = OC::$session ? OC_Util::callRegister() : '';
     $parts = explode('/', $app);
     // fix translation when app is something like core/lostpassword
     $l10n = OC_L10N::get($parts[0]);
     $themeDefaults = new OC_Defaults();
     list($path, $template) = $this->findTemplate($theme, $app, $name, $fext);
     // Set the private data
     $this->renderas = $renderas;
     $this->path = $path;
     parent::__construct($template, $requesttoken, $l10n, $themeDefaults);
 }
Example #8
0
 /**
  * @param array $scripts
  * @return array
  */
 public static function findJavascriptFiles($scripts)
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $locator = new \OC\Template\JSResourceLocator($theme, $fext, array(OC::$SERVERROOT => OC::$WEBROOT), array(OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT));
     $locator->find($scripts);
     return $locator->getResources();
 }
Example #9
0
 /**
  * @param array $scripts
  * @return array
  */
 public static function findJavascriptFiles($scripts)
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     $locator = new \OC\Template\JSResourceLocator(OC::$server->getLogger(), $theme, array(OC::$SERVERROOT => OC::$WEBROOT), array(OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT));
     $locator->find($scripts);
     return $locator->getResources();
 }
Example #10
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" => $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', 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(), '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";
}
Example #11
0
 /**
  * Gathers system information like database type and does
  * a few system checks.
  *
  * @return array of system info, including an "errors" value
  * in case of errors/warnings
  */
 public function getSystemInfo()
 {
     $hasSQLite = class_exists('SQLite3');
     $hasMySQL = is_callable('mysql_connect');
     $hasPostgreSQL = is_callable('pg_connect');
     $hasOracle = is_callable('oci_connect');
     $hasMSSQL = is_callable('sqlsrv_connect');
     $databases = array();
     if ($hasSQLite) {
         $databases['sqlite'] = 'SQLite';
     }
     if ($hasMySQL) {
         $databases['mysql'] = 'MySQL/MariaDB';
     }
     if ($hasPostgreSQL) {
         $databases['pgsql'] = 'PostgreSQL';
     }
     if ($hasOracle) {
         $databases['oci'] = 'Oracle';
     }
     if ($hasMSSQL) {
         $databases['mssql'] = 'MS SQL';
     }
     $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data');
     $vulnerableToNullByte = false;
     if (@file_exists(__FILE__ . "Nullbyte")) {
         // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
         $vulnerableToNullByte = true;
     }
     $errors = array();
     // Protect data directory here, so we can test if the protection is working
     \OC_Setup::protectDataDirectory();
     try {
         $htaccessWorking = \OC_Util::isHtaccessWorking();
     } catch (\OC\HintException $e) {
         $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
         $htaccessWorking = false;
     }
     if (\OC_Util::runningOnMac()) {
         $l10n = \OC::$server->getL10N('core');
         $themeName = \OC_Util::getTheme();
         $theme = new \OC_Defaults();
         $errors[] = array('error' => $l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $theme->getName()), 'hint' => $l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
     }
     return array('hasSQLite' => $hasSQLite, 'hasMySQL' => $hasMySQL, 'hasPostgreSQL' => $hasPostgreSQL, 'hasOracle' => $hasOracle, 'hasMSSQL' => $hasMSSQL, 'databases' => $databases, 'directory' => $datadir, 'htaccessWorking' => $htaccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors);
 }
Example #12
0
<?php

if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php')) {
    require_once 'themes/' . OC_Util::getTheme() . '/defaults.php';
}
/**
 * Default strings and values which differ between the enterprise and the
 * community edition. Use the get methods to always get the right strings.
 */
class OC_Defaults
{
    private $theme;
    private $l;
    private $defaultEntity;
    private $defaultName;
    private $defaultTitle;
    private $defaultBaseUrl;
    private $defaultSyncClientUrl;
    private $defaultDocBaseUrl;
    private $defaultDocVersion;
    private $defaultSlogan;
    private $defaultLogoClaim;
    private $defaultMailHeaderColor;
    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 */
Example #13
0
 /**
  * @brief Creates path to an image
  * @param string $app app
  * @param string $image image name
  * @return string the url
  *
  * Returns the path to the image.
  */
 public static function imagePath($app, $image)
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Check if the app is in the app folder
     if (file_exists(OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$image}")) {
         return OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$image}";
     } elseif (file_exists(OC_App::getAppPath($app) . "/img/{$image}")) {
         return OC_App::getAppWebPath($app) . "/img/{$image}";
     } elseif (!empty($app) and file_exists(OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$image}")) {
         return OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$image}";
     } elseif (!empty($app) and file_exists(OC::$SERVERROOT . "/{$app}/img/{$image}")) {
         return OC::$WEBROOT . "/{$app}/img/{$image}";
     } elseif (file_exists(OC::$SERVERROOT . "/themes/{$theme}/core/img/{$image}")) {
         return OC::$WEBROOT . "/themes/{$theme}/core/img/{$image}";
     } elseif (file_exists(OC::$SERVERROOT . "/core/img/{$image}")) {
         return OC::$WEBROOT . "/core/img/{$image}";
     } else {
         echo 'image not found: image:' . $image . ' webroot:' . OC::$WEBROOT . ' serverroot:' . OC::$SERVERROOT;
         die;
     }
 }
Example #14
0
				'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");
}
Example #15
0
 /**
  * Creates path to an image
  * @param string $app app
  * @param string $image image name
  * @throws \RuntimeException If the image does not exist
  * @return string the url
  *
  * Returns the path to the image.
  */
 public function imagePath($app, $image)
 {
     $cache = $this->cacheFactory->create('imagePath');
     $cacheKey = $app . '-' . $image;
     if ($key = $cache->get($cacheKey)) {
         return $key;
     }
     // Read the selected theme from the config file
     $theme = \OC_Util::getTheme();
     //if a theme has a png but not an svg always use the png
     $basename = substr(basename($image), 0, -4);
     $appPath = \OC_App::getAppPath($app);
     // Check if the app is in the app folder
     $path = '';
     if (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$image}")) {
         $path = \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$image}";
     } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png")) {
         $path = \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png";
     } elseif ($appPath && file_exists($appPath . "/img/{$image}")) {
         $path = \OC_App::getAppWebPath($app) . "/img/{$image}";
     } elseif ($appPath && !file_exists($appPath . "/img/{$basename}.svg") && file_exists($appPath . "/img/{$basename}.png")) {
         $path = \OC_App::getAppWebPath($app) . "/img/{$basename}.png";
     } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$image}")) {
         $path = \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$image}";
     } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.png")) {
         $path = \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$basename}.png";
     } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/{$app}/img/{$image}")) {
         $path = \OC::$WEBROOT . "/{$app}/img/{$image}";
     } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.png")) {
         $path = \OC::$WEBROOT . "/{$app}/img/{$basename}.png";
     } elseif (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$image}")) {
         $path = \OC::$WEBROOT . "/themes/{$theme}/core/img/{$image}";
     } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.png")) {
         $path = \OC::$WEBROOT . "/themes/{$theme}/core/img/{$basename}.png";
     } elseif (file_exists(\OC::$SERVERROOT . "/core/img/{$image}")) {
         $path = \OC::$WEBROOT . "/core/img/{$image}";
     }
     if ($path !== '') {
         $cache->set($cacheKey, $path);
         return $path;
     } else {
         throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
     }
 }
Example #16
0
 /**
  * Gathers system information like database type and does
  * a few system checks.
  *
  * @return array of system info, including an "errors" value
  * in case of errors/warnings
  */
 public function getSystemInfo()
 {
     $setup = new \OC_Setup($this->config);
     $databases = $setup->getSupportedDatabases();
     $datadir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
     $vulnerableToNullByte = false;
     if (@file_exists(__FILE__ . "Nullbyte")) {
         // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
         $vulnerableToNullByte = true;
     }
     $errors = array();
     // Create data directory to test whether the .htaccess works
     // Notice that this is not necessarily the same data directory as the one
     // that will effectively be used.
     @mkdir($datadir);
     if (is_dir($datadir) && is_writable($datadir)) {
         // Protect data directory here, so we can test if the protection is working
         \OC_Setup::protectDataDirectory();
         try {
             $htaccessWorking = \OC_Util::isHtaccessWorking();
         } catch (\OC\HintException $e) {
             $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
             $htaccessWorking = false;
         }
     }
     if (\OC_Util::runningOnMac()) {
         $l10n = \OC_L10N::get('core');
         $themeName = \OC_Util::getTheme();
         $theme = new \OC_Defaults();
         $errors[] = array('error' => $l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $theme->getName()), 'hint' => $l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
     }
     return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'hasMSSQL' => isset($databases['mssql']), 'databases' => $databases, 'directory' => $datadir, 'secureRNG' => \OC_Util::secureRNGAvailable(), 'htaccessWorking' => $htaccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors);
 }
Example #17
0
 /**
  * @brief find the template with the given name
  * @param string $name of the template file (without suffix)
  *
  * Will select the template file for the selected theme and formfactor.
  * Checking all the possible locations.
  */
 protected function findTemplate($name)
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $app = $this->application;
     // Check if it is a app template or not.
     if ($app != "") {
         // Check if the app is in the app folder or in the root
         if (file_exists(OC_App::getAppPath($app) . "/templates/")) {
             // Check if the template is overwritten by the selected theme
             if ($this->checkPathForTemplate(OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/templates/", $name, $fext)) {
             } elseif ($this->checkPathForTemplate(OC_App::getAppPath($app) . "/templates/", $name, $fext)) {
             }
         } else {
             // Check if the template is overwritten by the selected theme
             if ($this->checkPathForTemplate(OC::$SERVERROOT . "/themes/{$theme}/{$app}/templates/", $name, $fext)) {
             } elseif ($this->checkPathForTemplate(OC::$SERVERROOT . "/{$app}/templates/", $name, $fext)) {
             } else {
                 echo 'template not found: template:' . $name . ' formfactor:' . $fext . ' webroot:' . OC::$WEBROOT . ' serverroot:' . OC::$SERVERROOT;
                 die;
             }
         }
     } else {
         // Check if the template is overwritten by the selected theme
         if ($this->checkPathForTemplate(OC::$SERVERROOT . "/themes/{$theme}/core/templates/", $name, $fext)) {
         } elseif ($this->checkPathForTemplate(OC::$SERVERROOT . "/core/templates/", $name, $fext)) {
         } else {
             echo 'template not found: template:' . $name . ' formfactor:' . $fext . ' webroot:' . OC::$WEBROOT . ' serverroot:' . OC::$SERVERROOT;
             die;
         }
     }
 }
Example #18
0
 public static function findJavascriptFiles($scripts)
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $files = array();
     foreach ($scripts as $script) {
         // Is it in 3rd party?
         if (self::appendIfExist($files, OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script . '.js')) {
             // Is it in apps and overwritten by the theme?
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/{$theme}/apps/{$script}{$fext}.js")) {
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/{$theme}/apps/{$script}.js")) {
             // Is it in the owncloud root but overwritten by the theme?
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/{$theme}/{$script}{$fext}.js")) {
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/{$theme}/{$script}.js")) {
             // Is it in the owncloud root ?
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "{$script}{$fext}.js")) {
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "{$script}.js")) {
             // Is in core but overwritten by a theme?
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/{$theme}/core/{$script}{$fext}.js")) {
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/{$theme}/core/{$script}.js")) {
             // Is it in core?
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/{$script}{$fext}.js")) {
         } elseif (self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/{$script}.js")) {
         } else {
             // Is it part of an app?
             $append = false;
             foreach (OC::$APPSROOTS as $apps_dir) {
                 if (self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT . $apps_dir['url'], "{$script}{$fext}.js")) {
                     $append = true;
                     break;
                 } elseif (self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT . $apps_dir['url'], "{$script}.js")) {
                     $append = true;
                     break;
                 }
             }
             if (!$append) {
                 echo 'js file not found: script:' . $script . ' formfactor:' . $fext . ' webroot:' . OC::$WEBROOT . ' serverroot:' . OC::$SERVERROOT;
                 die;
             }
         }
     }
     return $files;
 }