예제 #1
0
 public static function sendEmail($args)
 {
     $isEncrypted = \OC_App::isEnabled('files_encryption');
     if (!$isEncrypted || isset($_POST['continue'])) {
         $continue = true;
     } else {
         $continue = false;
     }
     if (\OC_User::userExists($_POST['user']) && $continue) {
         $token = hash('sha256', \OC_Util::generateRandomBytes(30) . \OC_Config::getValue('passwordsalt', ''));
         \OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
         // Hash the token again to prevent timing attacks
         $email = \OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
         if (!empty($email)) {
             $link = \OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
             $link = \OC_Helper::makeURLAbsolute($link);
             $tmpl = new \OC_Template('core/lostpassword', 'email');
             $tmpl->assign('link', $link, false);
             $msg = $tmpl->fetchPage();
             $l = \OC_L10N::get('core');
             $from = \OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
             try {
                 $defaults = new \OC_Defaults();
                 \OC_Mail::send($email, $_POST['user'], $l->t('%s password reset', array($defaults->getName())), $msg, $from, $defaults->getName());
             } catch (Exception $e) {
                 \OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
             }
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
예제 #2
0
파일: setup.php 프로젝트: kenwi/core
 /**
  * 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($allowAllDatabases = false)
 {
     $databases = $this->getSupportedDatabases($allowAllDatabases);
     $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
     $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);
     $htAccessWorking = true;
     if (is_dir($dataDir) && is_writable($dataDir)) {
         // Protect data directory here, so we can test if the protection is working
         \OC\Setup::protectDataDirectory();
         try {
             $util = new \OC_Util();
             $htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig());
         } catch (\OC\HintException $e) {
             $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
             $htAccessWorking = false;
         }
     }
     if (\OC_Util::runningOnMac()) {
         $errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
     }
     if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
         $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4 GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.'));
     }
     return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'databases' => $databases, 'directory' => $dataDir, 'htaccessWorking' => $htAccessWorking, 'errors' => $errors);
 }
 /**
  * @NoAdminRequired
  *
  * @param string $username
  * @param string $password
  * @param array $groups
  * @param string $email
  * @return DataResponse
  */
 public function create($username, $password, array $groups = array(), $email = '')
 {
     if ($email !== '' && !$this->mail->validateAddress($email)) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mail address')), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     if (!$this->isAdmin) {
         $userId = $this->userSession->getUser()->getUID();
         if (!empty($groups)) {
             foreach ($groups as $key => $group) {
                 if (!$this->subAdminFactory->isGroupAccessible($userId, $group)) {
                     unset($groups[$key]);
                 }
             }
         }
         if (empty($groups)) {
             $groups = $this->subAdminFactory->getSubAdminsOfGroups($userId);
         }
     }
     if ($this->userManager->userExists($username)) {
         return new DataResponse(array('message' => (string) $this->l10n->t('A user with that name already exists.')), Http::STATUS_CONFLICT);
     }
     try {
         $user = $this->userManager->createUser($username, $password);
     } catch (\Exception $exception) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
     }
     if ($user instanceof User) {
         if ($groups !== null) {
             foreach ($groups as $groupName) {
                 $group = $this->groupManager->get($groupName);
                 if (empty($group)) {
                     $group = $this->groupManager->createGroup($groupName);
                 }
                 $group->addUser($user);
             }
         }
         /**
          * Send new user mail only if a mail is set
          */
         if ($email !== '') {
             $this->config->setUserValue($username, 'settings', 'email', $email);
             // data for the mail template
             $mailData = array('username' => $username, 'url' => $this->urlGenerator->getAbsoluteURL('/'));
             $mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
             $mailContent = $mail->render();
             $mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
             $plainTextMailContent = $mail->render();
             $subject = $this->l10n->t('Your %s account was created', [$this->defaults->getName()]);
             try {
                 $this->mail->send($email, $username, $subject, $mailContent, $this->fromMailAddress, $this->defaults->getName(), 1, $plainTextMailContent);
             } catch (\Exception $e) {
                 $this->log->error("Can't send new user mail to {$email}: " . $e->getMessage(), array('app' => 'settings'));
             }
         }
         // fetch users groups
         $userGroups = $this->groupManager->getUserGroupIds($user);
         return new DataResponse($this->formatUserForIndex($user, $userGroups), Http::STATUS_CREATED);
     }
     return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
 }
예제 #4
0
 protected function sendEmail($user, $proceed)
 {
     if ($this->isDataEncrypted && !$proceed) {
         throw new EncryptedDataException();
     }
     if (!$this->userManager->userExists($user)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure ' . 'your username is correct.'));
     }
     $token = hash('sha256', \OC_Util::generateRandomBytes(30));
     // Hash the token again to prevent timing attacks
     $this->config->setUserValue($user, 'owncloud', 'lostpassword', hash('sha256', $token));
     $email = $this->config->getUserValue($user, 'settings', 'email');
     if (empty($email)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email because there is no ' . 'email address for this username. Please ' . 'contact your administrator.'));
     }
     $link = $this->getLink('core.lost.resetform', $user, $token);
     $tmpl = new \OC_Template('core/lostpassword', 'email');
     $tmpl->assign('link', $link, false);
     $msg = $tmpl->fetchPage();
     try {
         // FIXME: should be added to the container and injected in here
         \OC_Mail::send($email, $user, $this->l10n->t('%s password reset', array($this->defaults->getName())), $msg, $this->from, $this->defaults->getName());
     } catch (\Exception $e) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please contact your administrator.'));
     }
 }
예제 #5
0
 /**
  * FedAuth constructor.
  *
  * @param DbHandler $db
  */
 public function __construct(DbHandler $db)
 {
     $this->db = $db;
     $this->principalPrefix = 'principals/system/';
     // setup realm
     $defaults = new \OC_Defaults();
     $this->realm = $defaults->getName();
 }
예제 #6
0
 /**
  * @param IRequest $request
  * @param IManager $shareManager
  * @param ISession $session
  */
 public function __construct(IRequest $request, IManager $shareManager, ISession $session)
 {
     $this->request = $request;
     $this->shareManager = $shareManager;
     $this->session = $session;
     // setup realm
     $defaults = new \OC_Defaults();
     $this->realm = $defaults->getName();
 }
예제 #7
0
 /**
  * @param ISession $session
  * @param Session $userSession
  * @param IRequest $request
  * @param Manager $twoFactorManager
  * @param string $principalPrefix
  */
 public function __construct(ISession $session, Session $userSession, IRequest $request, Manager $twoFactorManager, $principalPrefix = 'principals/users/')
 {
     $this->session = $session;
     $this->userSession = $userSession;
     $this->twoFactorManager = $twoFactorManager;
     $this->request = $request;
     $this->principalPrefix = $principalPrefix;
     // setup realm
     $defaults = new \OC_Defaults();
     $this->realm = $defaults->getName();
 }
 /**
  * Send a mail to test the settings
  * @return array
  */
 public function sendTestMail()
 {
     $email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
     if (!empty($email)) {
         try {
             $this->mail->send($email, $this->userSession->getUser()->getDisplayName(), $this->l10n->t('test email settings'), $this->l10n->t('If you received this email, the settings seem to be correct.'), $this->defaultMailAddress, $this->defaults->getName());
         } catch (\Exception $e) {
             return array('data' => array('message' => (string) $this->l10n->t('A problem occurred while sending the email. Please revise your settings.')), 'status' => 'error');
         }
         return array('data' => array('message' => (string) $this->l10n->t('Email sent')), 'status' => 'success');
     }
     return array('data' => array('message' => (string) $this->l10n->t('You need to set your user email before being able to send test emails.')), 'status' => 'error');
 }
예제 #9
0
 /**
  * Send the specified message. Also sets the from address to the value defined in config.php
  * if no-one has been passed.
  *
  * @param Message $message Message to send
  * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and
  * therefore should be considered
  * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
  * has been supplied.)
  */
 public function send(Message $message)
 {
     $debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
     if (sizeof($message->getFrom()) === 0) {
         $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName())]);
     }
     $failedRecipients = [];
     $mailer = $this->getInstance();
     // Enable logger if debug mode is enabled
     if ($debugMode) {
         $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
         $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
     }
     $mailer->send($message->getSwiftMessage(), $failedRecipients);
     // Debugging logging
     $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
     $this->logger->debug($logMessage, ['app' => 'core']);
     if ($debugMode && isset($mailLogger)) {
         $this->logger->debug($mailLogger->dump(), ['app' => 'core']);
     }
     return $failedRecipients;
 }
예제 #10
0
 /**
  * @brief Authenticate user by HTTP Basic Authentication
  * with user name and password
  */
 public static function authenticateUser()
 {
     if (!isset($_SERVER['PHP_AUTH_USER'])) {
         $defaults = new \OC_Defaults();
         $realm = $defaults->getName();
         header("HTTP/1.0 401 Unauthorized");
         header('WWW-Authenticate: Basic realm="' . $realm . '"');
         exit;
     }
     $userName = $_SERVER['PHP_AUTH_USER'];
     // Check the password in the ownCloud database
     return self::checkPassword($userName, $_SERVER['PHP_AUTH_PW']);
 }
예제 #11
0
 /**
  * @param string $baseUri
  * @param string $requestUri
  * @param BackendInterface $authBackend
  * @param callable $viewCallBack callback that should return the view for the dav endpoint
  * @return Server
  */
 public function createServer($baseUri, $requestUri, BackendInterface $authBackend, callable $viewCallBack)
 {
     // Fire up server
     $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
     $server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
     // Set URL explicitly due to reverse-proxy situations
     $server->httpRequest->setUrl($requestUri);
     $server->setBaseUri($baseUri);
     // Load plugins
     $defaults = new \OC_Defaults();
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
     $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
     // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin($objectTree));
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\ListenerPlugin($this->dispatcher));
     // wait with registering these until auth is handled and the filesystem is setup
     $server->on('beforeMethod', function () use($server, $objectTree, $viewCallBack) {
         // ensure the skeleton is copied
         \OC::$server->getUserFolder();
         /** @var \OC\Files\View $view */
         $view = $viewCallBack();
         $rootInfo = $view->getFileInfo('');
         // Create ownCloud Dir
         if ($rootInfo->getType() === 'dir') {
             $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo);
         } else {
             $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
         }
         $objectTree->init($root, $view, $this->mountManager);
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($objectTree, $view));
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
         if ($this->userSession->isLoggedIn()) {
             $server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
             // custom properties plugin must be the last one
             $server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend($objectTree, $this->databaseConnection, $this->userSession->getUser())));
         }
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
     }, 30);
     // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
     return $server;
 }
 /**
  * Sends new user notification email to admin
  * @param array $to
  * @param string $username the new user
  * @return null
  * @throws \Exception
  */
 private function sendNewUserNotifEmail(array $to, string $username)
 {
     $template_var = ['user' => $username, 'sitename' => $this->defaults->getName()];
     $html_template = new TemplateResponse('registration', 'email.newuser_html', $template_var, 'blank');
     $html_part = $html_template->render();
     $plaintext_template = new TemplateResponse('registration', 'email.newuser_plaintext', $template_var, 'blank');
     $plaintext_part = $plaintext_template->render();
     $subject = $this->l10n->t('A new user "%s" had created an account on %s', [$username, $this->defaults->getName()]);
     $from = Util::getDefaultEmailAddress('register');
     $message = $this->mailer->createMessage();
     $message->setFrom([$from => $this->defaults->getName()]);
     $message->setTo($to);
     $message->setSubject($subject);
     $message->setPlainBody($plaintext_part);
     $message->setHtmlBody($html_part);
     $failed_recipients = $this->mailer->send($message);
     if (!empty($failed_recipients)) {
         throw new \Exception('Failed recipients: ' . print_r($failed_recipients, true));
     }
 }
예제 #13
0
 /**
  * Send a mail to test the settings
  */
 public static function sendTestMail()
 {
     \OC_Util::checkAdminUser();
     \OCP\JSON::callCheck();
     $l = \OC::$server->getL10N('settings');
     $email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
     if (!empty($email)) {
         $defaults = new \OC_Defaults();
         try {
             \OC_Mail::send($email, \OC_User::getDisplayName(), $l->t('test email settings'), $l->t('If you received this email, the settings seem to be correct.'), \OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
         } catch (\Exception $e) {
             $message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
             \OC_JSON::error(array("data" => array("message" => $message)));
             exit;
         }
         \OC_JSON::success(array("data" => array("message" => $l->t("Email sent"))));
     } else {
         $message = $l->t('You need to set your user email before being able to send test emails.');
         \OC_JSON::error(array("data" => array("message" => $message)));
     }
 }
예제 #14
0
 /**
  * @brief serve opds feed for given directory
  *
  * @param string $dir full path to directory
  * @param int $id requested id
  */
 public static function serveFeed($dir, $id)
 {
     if (isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
         header('Content-Type: application/atom+xml');
     } else {
         header('Content-Type: text/xml; charset=UTF-8');
     }
     $sortAttribute = 'name';
     $sortDirection = false;
     $defaults = new \OC_Defaults();
     $tmpl = new \OCP\Template('files_opds', 'feed');
     $tmpl->assign('files', Files::formatFileInfos(Files::getFiles($dir, $sortAttribute, $sortDirection)));
     $tmpl->assign('bookshelf', Files::formatFileInfos(Bookshelf::get()));
     $tmpl->assign('bookshelf-count', Bookshelf::count());
     $tmpl->assign('feed_id', self::getFeedId());
     $tmpl->assign('id', $id);
     $tmpl->assign('dir', $dir);
     $tmpl->assign('user', \OCP\User::getDisplayName());
     $tmpl->assign('feed_title', Config::get('feed_title', \OCP\User::getDisplayName() . "'s Library"));
     $tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog"));
     $tmpl->assign('feed_updated', time());
     $tmpl->printPage();
 }
예제 #15
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);
     $htAccessWorking = true;
     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()) {
         $errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
     }
     if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
         $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to  64bit PHP.'));
     }
     if (!function_exists('curl_init') && PHP_INT_SIZE === 4) {
         $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32bit PHP environment and cURL is not installed. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.'));
     }
     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, 'htaccessWorking' => $htAccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors);
 }
예제 #16
0
<?php

if (!isset($_)) {
    //also provide standalone error page
    require_once __DIR__ . '/../../../lib/base.php';
    $l = OC_L10N::get('files_encryption');
    if (isset($_GET['errorCode'])) {
        $errorCode = $_GET['errorCode'];
        switch ($errorCode) {
            case \OCA\Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR:
                $errorMsg = $l->t('Encryption app not initialized! Maybe the encryption app was re-enabled during your session. Please try to log out and log back in to initialize the encryption app.');
                break;
            case \OCA\Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR:
                $theme = new OC_Defaults();
                $errorMsg = $l->t('Your private key is not valid! Likely your password was changed outside of %s (e.g. your corporate directory). You can update your private key password in your personal settings to recover access to your encrypted files.', array($theme->getName()));
                break;
            case \OCA\Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND:
                $errorMsg = $l->t('Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
                break;
            default:
                $errorMsg = $l->t("Unknown error. Please check your system settings or contact your administrator");
                break;
        }
    } else {
        $errorCode = \OCA\Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
        $errorMsg = $l->t("Unknown error. Please check your system settings or contact your administrator");
    }
    if (isset($_GET['p']) && $_GET['p'] === '1') {
        header('HTTP/1.0 403 ' . $errorMsg);
    }
    // check if ajax request
예제 #17
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);
 }
예제 #18
0
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Files_Opds;

\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
$defaults = new \OC_Defaults();
$l = new \OC_L10N('files_opds');
if (isset($_POST['opdsCoverX'])) {
    // set dimensions, using sane defaults just in case
    $opdsCoverX = isset($_POST['opdsCoverX']) ? (int) $_POST['opdsCoverX'] : 200;
    $opdsCoverY = isset($_POST['opdsCoverY']) ? (int) $_POST['opdsCoverY'] : 200;
    $opdsThumbX = isset($_POST['opdsThumbX']) ? (int) $_POST['opdsThumbX'] : 36;
    $opdsThumbY = isset($_POST['opdsThumbY']) ? (int) $_POST['opdsThumbY'] : 36;
    $opdsFeedSubtitle = isset($_POST['opdsFeedSubtitle']) ? $_POST['opdsFeedSubtitle'] : $l->t("%s OPDS catalog", $defaults->getName());
    $opdsIsbndbKey = isset($_POST['opdsIsbndbKey']) ? $_POST['opdsIsbndbKey'] : '';
    $opdsGoogleKey = isset($_POST['opdsGoogleKey']) ? $_POST['opdsGoogleKey'] : '';
    Config::setApp('cover-x', $opdsCoverX);
    Config::setApp('cover-y', $opdsCoverY);
    Config::setApp('thumb-x', $opdsThumbX);
    Config::setApp('thumb-y', $opdsThumbX);
    Config::setApp('feed_subtitle', $opdsFeedSubtitle);
    Config::setApp('isbndb-key', $opdsIsbndbKey);
    Config::setApp('google-key', $opdsGoogleKey);
} else {
    // set preview preferences
    $opdsPreviewEpub = $_POST['opdsPreviewEpub'];
    $opdsPreviewPdf = $_POST['opdsPreviewPdf'];
    $opdsPreviewOpenDocument = $_POST['opdsPreviewOpenDocument'];
    $opdsPreviewMsOffice = $_POST['opdsPreviewMsOffice'];
예제 #19
0
 /**
  * Get the sender data
  * @param string $setting Either `email` or `name`
  * @return string
  */
 protected function getSenderData($setting)
 {
     if (empty($this->senderAddress)) {
         $this->senderAddress = \OCP\Util::getDefaultEmailAddress('no-reply');
     }
     if (empty($this->senderName)) {
         $defaults = new \OC_Defaults();
         $this->senderName = $defaults->getName();
     }
     if ($setting === 'email') {
         return $this->senderAddress;
     }
     return $this->senderName;
 }
예제 #20
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);
 }
예제 #21
0
파일: console.php 프로젝트: hjimmy/owncloud
/**
 * Copyright (c) 2013 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
use Symfony\Component\Console\Application;
$RUNTIME_NOAPPS = true;
require_once 'lib/base.php';
// set to run indefinitely if needed
set_time_limit(0);
// Don't do anything if ownCloud has not been installed yet
if (!OC_Config::getValue('installed', false)) {
    echo "Console can only be used once ownCloud has been installed" . PHP_EOL;
    exit(0);
}
if (!OC::$CLI) {
    echo "This script can be run from the command line only" . PHP_EOL;
    exit(0);
}
$defaults = new OC_Defaults();
$application = new Application($defaults->getName(), \OC_Util::getVersionString());
require_once 'core/register_command.php';
foreach (OC_App::getAllApps() as $app) {
    $file = OC_App::getAppPath($app) . '/appinfo/register_command.php';
    if (file_exists($file)) {
        require $file;
    }
}
$application->run();
예제 #22
0
			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));
예제 #23
0
// load needed apps
$RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging');
OC_App::loadApps($RUNTIME_APPTYPES);
OC_Util::obEnd();
// Backends
$authBackend = new OCA\Files_Sharing\Connector\PublicAuth(\OC::$server->getConfig());
$lockBackend = new OC_Connector_Sabre_Locks();
$requestBackend = new OC_Connector_Sabre_Request();
// Fire up server
$objectTree = new \OC\Connector\Sabre\ObjectTree();
$server = new OC_Connector_Sabre_Server($objectTree);
$server->httpRequest = $requestBackend;
$server->setBaseUri($baseuri);
// Load plugins
$defaults = new OC_Defaults();
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
$server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend));
$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false));
// Show something in the Browser, but no upload
$server->addPlugin(new OC_Connector_Sabre_FilesPlugin());
$server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav'));
// wait with registering these until auth is handled and the filesystem is setup
$server->subscribeEvent('beforeMethod', function () use($server, $objectTree, $authBackend) {
    $share = $authBackend->getShare();
    $rootShare = \OCP\Share::resolveReShare($share);
    $owner = $rootShare['uid_owner'];
    $isWritable = $share['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
    $fileId = $share['file_source'];
    if (!$isWritable) {
        \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
예제 #24
0
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// load needed apps
$RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging');
OC_App::loadApps($RUNTIME_APPTYPES);
OC_Util::obEnd();
// Backends
$authBackend = new OC_Connector_Sabre_Auth();
$lockBackend = new OC_Connector_Sabre_Locks();
$requestBackend = new OC_Connector_Sabre_Request();
// Create ownCloud Dir
$rootDir = new OC_Connector_Sabre_Directory('');
$objectTree = new \OC\Connector\Sabre\ObjectTree($rootDir);
// Fire up server
$server = new OC_Connector_Sabre_Server($objectTree);
$server->httpRequest = $requestBackend;
$server->setBaseUri($baseuri);
// Load plugins
$defaults = new OC_Defaults();
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, $defaults->getName()));
$server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend));
$server->addPlugin(new Sabre_DAV_Browser_Plugin(false));
// Show something in the Browser, but no upload
$server->addPlugin(new OC_Connector_Sabre_FilesPlugin());
$server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin());
$server->addPlugin(new OC_Connector_Sabre_QuotaPlugin());
$server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
// And off we go!
$server->exec();
예제 #25
0
<?php

/**
 * ownCloud - Files_Opds app
 *
 * Copyright (c) 2014 Frank de Lange
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
namespace OCA\Files_Opds;

$l = new \OC_L10N('files_opds');
\OCP\Util::addScript('files_opds', 'admin');
\OCP\Util::addStyle('files_opds', 'settings');
$defaults = new \OC_Defaults();
$formats = array(["epub" => Config::getPreview('OC\\Preview\\Epub') ? 1 : 0], ["pdf" => Config::getPreview('OC\\Preview\\PDF') ? 1 : 0], ["opendocument" => Config::getPreview('OC\\Preview\\OpenDocument') ? 1 : 0], ["msoffice" => Config::getPreview('OC\\Preview\\MSOfficeDoc') ? 1 : 0]);
$tmpl = new \OCP\Template('files_opds', 'admin');
$tmpl->assign('feedSubtitle', Config::getApp('feed-subtitle', $l->t("%s OPDS catalog", $defaults->getName())));
$tmpl->assign('isbndbKey', Config::getApp('isbndb-key', ''));
$tmpl->assign('googleKey', Config::getApp('google-key', ''));
$tmpl->assign('previewFormats', $formats);
$tmpl->assign('cover-x', Config::getApp('cover-x', '200'));
$tmpl->assign('cover-y', Config::getApp('cover-y', '200'));
$tmpl->assign('thumb-x', Config::getApp('thumb-x', '36'));
$tmpl->assign('thumb-y', Config::getApp('thumb-y', '36'));
return $tmpl->fetchPage();
예제 #26
0
	<?php 
$defaults = new OC_Defaults();
// initialize themable default strings and urls
?>
	
	<head data-user="******" data-requesttoken="<?php 
p($_['requesttoken']);
?>
">
		<title>
			<?php 
p(!empty($_['application']) ? $_['application'] . ' | ' : '');
p($defaults->getName());
p(trim($_['user_displayname']) != '' ? ' (' . $_['user_displayname'] . ') ' : '');
?>
		</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="apple-itunes-app" content="app-id=543672169">
		<link rel="shortcut icon" href="<?php 
print_unescaped(image_path('', 'favicon.png'));
?>
" />
		<link rel="apple-touch-icon-precomposed" href="<?php 
print_unescaped(image_path('', 'favicon-touch.png'));
?>
" />
		<?php 
foreach ($_['cssfiles'] as $cssfile) {
예제 #27
0
파일: config.php 프로젝트: samj1912/repo
// 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";
}
예제 #28
0
파일: config.php 프로젝트: matt407/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->l('jsdate', null)), "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->l('firstday', null)), "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(), 'docPlaceholderUrl' => $defaults->buildDocLinkToKey('PLACEHOLDER'), '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";
}
예제 #29
0
 /**
  * return the footer for a mail
  *
  */
 public static function getfooter()
 {
     $defaults = new OC_Defaults();
     $txt = "\n--\n";
     $txt .= $defaults->getName() . "\n";
     $txt .= $defaults->getSlogan() . "\n";
     return $txt;
 }
예제 #30
0
 /**
  * @param string $baseUri
  * @param string $requestUri
  * @param BackendInterface $authBackend
  * @param callable $viewCallBack callback that should return the view for the dav endpoint
  * @return Server
  */
 public function createServer($baseUri, $requestUri, BackendInterface $authBackend, callable $viewCallBack)
 {
     // Fire up server
     $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
     $server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
     // Set URL explicitly due to reverse-proxy situations
     $server->httpRequest->setUrl($requestUri);
     $server->setBaseUri($baseUri);
     // Load plugins
     $defaults = new \OC_Defaults();
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
     $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
     // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
     $server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
     // Some WebDAV clients do require Class 2 WebDAV support (locking), since
     // we do not provide locking we emulate it using a fake locking plugin.
     if ($this->request->isUserAgent(['/WebDAVFS/', '/Microsoft Office OneNote 2013/', '/Microsoft-WebDAV-MiniRedir/'])) {
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
     }
     if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
         $server->addPlugin(new BrowserErrorPagePlugin());
     }
     // wait with registering these until auth is handled and the filesystem is setup
     $server->on('beforeMethod', function () use($server, $objectTree, $viewCallBack) {
         // ensure the skeleton is copied
         $userFolder = \OC::$server->getUserFolder();
         /** @var \OC\Files\View $view */
         $view = $viewCallBack($server);
         $rootInfo = $view->getFileInfo('');
         // Create ownCloud Dir
         if ($rootInfo->getType() === 'dir') {
             $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
         } else {
             $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
         }
         $objectTree->init($root, $view, $this->mountManager);
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($objectTree, $view, $this->config, false, !$this->config->getSystemValue('debug', false)));
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
         if ($this->userSession->isLoggedIn()) {
             $server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
             $server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin($objectTree, $this->userSession, $userFolder, \OC::$server->getShareManager()));
             $server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
             $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin($objectTree, $view, \OC::$server->getSystemTagManager(), \OC::$server->getSystemTagObjectMapper(), $this->userSession, \OC::$server->getGroupManager(), $userFolder));
             // custom properties plugin must be the last one
             $server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend($objectTree, $this->databaseConnection, $this->userSession->getUser())));
         }
         $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
     }, 30);
     // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
     return $server;
 }