Пример #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
 /**
  * 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();
 }
Пример #3
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();
 }
Пример #4
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();
 }
 /**
  * @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);
 }
Пример #6
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.'));
     }
 }
Пример #7
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($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);
 }
Пример #8
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;
 }
Пример #9
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)));
     }
 }
Пример #10
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;
 }
 /**
  * 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');
 }
 /**
  * Send a mail signaling a user deletion
  * @param \OC\User\User $user
  */
 public function mailUserDeletion(\OC\User\User $user)
 {
     $toAddress = $toName = $this->config->getSystemValue('monitoring_admin_email');
     $theme = new \OC_Defaults();
     $now = new \DateTime();
     $niceNow = date_format($now, 'd/m/Y H:i:s');
     $subject = (string) $this->l->t('%s - User %s just has been deleted (%s)', array($theme->getTitle(), $user->getUID(), $niceNow));
     $html = new \OCP\Template($this->appName, "mail_userdeletion_html", "");
     $html->assign('userUID', $user->getUID());
     $html->assign('datetime', $niceNow);
     $htmlMail = $html->fetchPage();
     $alttext = new \OCP\Template($this->appName, "mail_userdeletion_text", "");
     $alttext->assign('userUID', $user->getUID());
     $alttext->assign('datetime', $niceNow);
     $altMail = $alttext->fetchPage();
     $fromAddress = $fromName = \OCP\Util::getDefaultEmailAddress('owncloud');
     try {
         \OCP\Util::sendMail($toAddress, $toName, $subject, $htmlMail, $fromAddress, $fromName, 1, $altMail);
     } catch (\Exception $e) {
         \OCP\Util::writeLog('user_account_actions', "Can't send mail for user deletion: " . $e->getMessage(), \OCP\Util::ERROR);
     }
 }
Пример #13
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();
 }
 /**
  * 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));
     }
 }
Пример #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
 /**
  * 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);
 }
Пример #17
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;
 }
Пример #18
0
 public static function checkConfig()
 {
     if (file_exists(OC::$SERVERROOT . "/config/config.php") and !is_writable(OC::$SERVERROOT . "/config/config.php")) {
         $defaults = new OC_Defaults();
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => 'This can usually be fixed by ' . '<a href="' . $defaults->getDocBaseUrl() . '/server/5.0/admin_manual/installation/installation_source.html#set-the-directory-permissions" target="_blank">giving the webserver write access to the config directory</a>.')));
         $tmpl->printPage();
         exit;
     }
 }
Пример #19
0
 /**
  * @brief generate v3 UUID based on display name and site url
  *
  * @return string uuid
  */
 public static function genUuid()
 {
     $defaults = new \OC_Defaults();
     $hash = md5(\OCP\User::getDisplayName() . $defaults->getBaseUrl());
     $hash = substr($hash, 0, 8) . '-' . substr($hash, 8, 4) . '-3' . substr($hash, 13, 3) . '-9' . substr($hash, 17, 3) . '-' . substr($hash, 20);
     return $hash;
 }
Пример #20
0
<!DOCTYPE html>
<!--[if lt IE 7]><html class="ng-csp ie ie6 lte9 lte8 lte7"><![endif]-->
<!--[if IE 7]><html class="ng-csp ie ie7 lte9 lte8 lte7"><![endif]-->
<!--[if IE 8]><html class="ng-csp ie ie8 lte9 lte8"><![endif]-->
<!--[if IE 9]><html class="ng-csp ie ie9 lte9"><![endif]-->
<!--[if gt IE 9]><html class="ng-csp ie"><![endif]-->
<!--[if !IE]><!--><html class="ng-csp"><!--<![endif]-->

	<?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'));
Пример #21
0
 *
 * 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/>
 *
 */
OC_Util::checkLoggedIn();
$defaults = new OC_Defaults();
// initialize themable default strings and urls
$certificateManager = \OC::$server->getCertificateManager();
$config = \OC::$server->getConfig();
$urlGenerator = \OC::$server->getURLGenerator();
// Highlight navigation entry
OC_Util::addScript('settings', 'personal');
OC_Util::addScript('settings', 'certificates');
OC_Util::addStyle('settings', 'settings');
\OC_Util::addVendorScript('strengthify/jquery.strengthify');
\OC_Util::addVendorStyle('strengthify/strengthify');
\OC_Util::addScript('files', 'jquery.iframe-transport');
\OC_Util::addScript('files', 'jquery.fileupload');
if ($config->getSystemValue('enable_avatars', true) === true) {
    \OC_Util::addVendorScript('jcrop/js/jquery.Jcrop');
    \OC_Util::addVendorStyle('jcrop/css/jquery.Jcrop');
Пример #22
0
<?php

/**
 * Copyright (c) 2011, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_Util::checkLoggedIn();
OC_App::loadApps();
$defaults = new OC_Defaults();
// initialize themable default strings and urls
// Highlight navigation entry
OC_Util::addScript('settings', 'personal');
OC_Util::addStyle('settings', 'settings');
OC_Util::addScript('3rdparty', 'chosen/chosen.jquery.min');
OC_Util::addStyle('3rdparty', 'chosen');
\OC_Util::addScript('files', 'jquery.fileupload');
if (\OC_Config::getValue('enable_avatars', true) === true) {
    \OC_Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop.min');
    \OC_Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop.min');
}
OC_App::setActiveNavigationEntry('personal');
$storageInfo = OC_Helper::getStorageInfo('/');
$email = OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
$userLang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage());
$languageCodes = OC_L10N::findAvailableLanguages();
//check if encryption was enabled in the past
$enableDecryptAll = OC_Util::encryptedFiles();
// array of common languages
$commonlangcodes = array('en', 'es', 'fr', 'de', 'de_DE', 'ja_JP', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'zh_CN', 'ko');
$languageNames = (include 'languageCodes.php');
Пример #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) {
Пример #24
0
 /**
  * @param $key
  * @return string url to the online documentation
  */
 public static function linkToDocs($key)
 {
     $theme = new OC_Defaults();
     return $theme->getDocBaseUrl() . '/server/6.0/go.php?to=' . $key;
 }
Пример #25
0
 * 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/>
 *
 */
// 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';
Пример #26
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();
Пример #27
0
 * 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/>
 *
 */
// 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';
Пример #28
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();
Пример #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
<?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