Example #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::generate_random_bytes(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 {
                 OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             } 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);
     }
 }
Example #2
0
 public static function sendEmail($args)
 {
     if (OC_User::userExists($_POST['user'])) {
         $token = hash('sha256', OC_Util::generate_random_bytes(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 = 'lostpassword-noreply@' . OCP\Util::getServerHost();
             OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             echo 'Mailsent';
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
Example #3
0
 /**
  * @brief Handle the request
  */
 public static function handleRequest()
 {
     // load all the classpaths from the enabled apps so they are available
     // in the routing files of each app
     OC::loadAppClassPaths();
     // Check if ownCloud is installed or in maintenance (update) mode
     if (!OC_Config::getValue('installed', false)) {
         require_once 'core/setup.php';
         exit;
     }
     $request = OC_Request::getPathInfo();
     if (substr($request, -3) !== '.js') {
         // we need these files during the upgrade
         self::checkMaintenanceMode();
         self::checkUpgrade();
     }
     if (!self::$CLI) {
         try {
             if (!OC_Config::getValue('maintenance', false)) {
                 OC_App::loadApps();
             }
             OC::getRouter()->match(OC_Request::getRawPathInfo());
             return;
         } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
             //header('HTTP/1.0 404 Not Found');
         } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
             OC_Response::setStatus(405);
             return;
         }
     }
     $app = OC::$REQUESTEDAPP;
     $file = OC::$REQUESTEDFILE;
     $param = array('app' => $app, 'file' => $file);
     // Handle app css files
     if (substr($file, -3) == 'css') {
         self::loadCSSFile($param);
         return;
     }
     // Handle redirect URL for logged in users
     if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
         $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
         // Deny the redirect if the URL contains a @
         // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
         if (strpos($location, '@') === FALSE) {
             header('Location: ' . $location);
             return;
         }
     }
     // Handle WebDAV
     if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
         header('location: ' . OC_Helper::linkToRemote('webdav'));
         return;
     }
     // Someone is logged in :
     if (OC_User::isLoggedIn()) {
         OC_App::loadApps();
         OC_User::setupBackends();
         if (isset($_GET["logout"]) and $_GET["logout"]) {
             if (isset($_COOKIE['oc_token'])) {
                 OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
             }
             OC_User::logout();
             header("Location: " . OC::$WEBROOT . '/');
         } else {
             if (is_null($file)) {
                 $param['file'] = 'index.php';
             }
             $file_ext = substr($param['file'], -3);
             if ($file_ext != 'php' || !self::loadAppScriptFile($param)) {
                 header('HTTP/1.0 404 Not Found');
             }
         }
         return;
     }
     // Not handled and not logged in
     self::handleLogin();
 }
Example #4
0
 /**
  * @small
  * test absolute URL construction
  * @dataProvider provideSubDirURLs
  */
 function testMakeAbsoluteURLSubDir($url, $expectedResult)
 {
     \OC::$WEBROOT = '/owncloud';
     $result = \OC_Helper::makeURLAbsolute($url);
     $this->assertEquals($expectedResult, $result);
 }
Example #5
0
 /**
  * @brief Check if the htaccess file is working
  * @return bool
  * @description Check if the htaccess file is working by creating a test
  * file in the data directory and trying to access via http
  */
 public static function isHtAccessWorking()
 {
     if (!\OC_Config::getValue("check_for_working_htaccess", true)) {
         return true;
     }
     // testdata
     $fileName = '/htaccesstest.txt';
     $testContent = 'testcontent';
     // creating a test file
     $testFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $fileName;
     if (file_exists($testFile)) {
         // already running this test, possible recursive call
         return false;
     }
     $fp = @fopen($testFile, 'w');
     @fwrite($fp, $testContent);
     @fclose($fp);
     // accessing the file via http
     $url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName);
     $fp = @fopen($url, 'r');
     $content = @fread($fp, 2048);
     @fclose($fp);
     // cleanup
     @unlink($testFile);
     // does it work ?
     if ($content == $testContent) {
         return false;
     } else {
         return true;
     }
 }
Example #6
0
File: util.php Project: gwdg/core
 /**
  * Check if the .htaccess file is working
  * @param \OCP\IConfig $config
  * @return bool
  * @throws Exception
  * @throws \OC\HintException If the test file can't get written.
  */
 public function isHtaccessWorking(\OCP\IConfig $config)
 {
     if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
         return true;
     }
     // php dev server does not support htaccess
     if (php_sapi_name() === 'cli-server') {
         return false;
     }
     // testdata
     $fileName = '/htaccesstest.txt';
     $testContent = 'testcontent';
     // creating a test file
     $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
     if (file_exists($testFile)) {
         // already running this test, possible recursive call
         return false;
     }
     $fp = @fopen($testFile, 'w');
     if (!$fp) {
         throw new OC\HintException('Can\'t create test file to check for working .htaccess file.', 'Make sure it is possible for the webserver to write to ' . $testFile);
     }
     fwrite($fp, $testContent);
     fclose($fp);
     // accessing the file via http
     $url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName);
     try {
         $content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody();
     } catch (\Exception $e) {
         $content = false;
     }
     // cleanup
     @unlink($testFile);
     /*
      * If the content is not equal to test content our .htaccess
      * is working as required
      */
     return $content !== $testContent;
 }
		<?php 
p($l->t('You are accessing the server from an untrusted domain.'));
?>
<br/>

		<p class='hint'>
			<?php 
p($l->t('Please contact your administrator. If you are an administrator of this instance, configure the "trusted_domain" setting in config/config.php. An example configuration is provided in config/config.sample.php.'));
?>
			<br/>
			<?php 
p($l->t('Depending on your configuration, as an administrator you might also be able to use the button below to trust this domain.'));
?>
			<br/><br/>
			<p style="text-align:center;">
				<a href="<?php 
print_unescaped(OC_Helper::makeURLAbsolute(\OCP\Util::linkToRoute('settings_admin')));
?>
?trustDomain=<?php 
p($_['domain']);
?>
" class="button">
					<?php 
p($l->t('Add "%s" as trusted domain', array($_['domain'])));
?>
				</a>
			</p>
		</p>
	</li>
</ul>
Example #8
0
 /**
  * Handle the request
  */
 public static function handleRequest()
 {
     \OC::$server->getEventLogger()->start('handle_request', 'Handle request');
     $systemConfig = \OC::$server->getSystemConfig();
     // load all the classpaths from the enabled apps so they are available
     // in the routing files of each app
     OC::loadAppClassPaths();
     // Check if ownCloud is installed or in maintenance (update) mode
     if (!$systemConfig->getValue('installed', false)) {
         \OC::$server->getSession()->clear();
         $setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom());
         $controller = new OC\Core\Setup\Controller($setupHelper);
         $controller->run($_POST);
         exit;
     }
     $request = \OC::$server->getRequest()->getPathInfo();
     if (substr($request, -3) !== '.js') {
         // we need these files during the upgrade
         self::checkMaintenanceMode();
         self::checkUpgrade();
     }
     // Always load authentication apps
     OC_App::loadApps(['authentication']);
     // Load minimum set of apps
     if (!self::checkUpgrade(false) && !$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
         // For logged-in users: Load everything
         if (OC_User::isLoggedIn()) {
             OC_App::loadApps();
         } else {
             // For guests: Load only filesystem and logging
             OC_App::loadApps(array('filesystem', 'logging'));
             \OC_User::tryBasicAuthLogin();
         }
     }
     if (!self::$CLI and (!isset($_GET["logout"]) or $_GET["logout"] !== 'true')) {
         try {
             if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
                 OC_App::loadApps(array('filesystem', 'logging'));
                 OC_App::loadApps();
             }
             self::checkSingleUserMode();
             OC_Util::setupFS();
             OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo());
             return;
         } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
             //header('HTTP/1.0 404 Not Found');
         } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
             OC_Response::setStatus(405);
             return;
         }
     }
     // Handle redirect URL for logged in users
     if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
         $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
         // Deny the redirect if the URL contains a @
         // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
         if (strpos($location, '@') === false) {
             header('Location: ' . $location);
             return;
         }
     }
     // Handle WebDAV
     if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
         // not allowed any more to prevent people
         // mounting this root directly.
         // Users need to mount remote.php/webdav instead.
         header('HTTP/1.1 405 Method Not Allowed');
         header('Status: 405 Method Not Allowed');
         return;
     }
     // Redirect to index if the logout link is accessed without valid session
     // this is needed to prevent "Token expired" messages while login if a session is expired
     // @see https://github.com/owncloud/core/pull/8443#issuecomment-42425583
     if (isset($_GET['logout']) && !OC_User::isLoggedIn()) {
         header("Location: " . OC::$WEBROOT . (empty(OC::$WEBROOT) ? '/' : ''));
         return;
     }
     // Someone is logged in
     if (OC_User::isLoggedIn()) {
         OC_App::loadApps();
         OC_User::setupBackends();
         OC_Util::setupFS();
         if (isset($_GET["logout"]) and $_GET["logout"]) {
             OC_JSON::callCheck();
             if (isset($_COOKIE['oc_token'])) {
                 \OC::$server->getConfig()->deleteUserValue(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
             }
             OC_User::logout();
             // redirect to webroot and add slash if webroot is empty
             header("Location: " . OC::$WEBROOT . (empty(OC::$WEBROOT) ? '/' : ''));
         } else {
             // Redirect to default application
             OC_Util::redirectToDefaultPage();
         }
     } else {
         // Not handled and not logged in
         self::handleLogin();
     }
 }
Example #9
0
 /**
  * @brief Handle the request
  */
 public static function handleRequest()
 {
     // load all the classpaths from the enabled apps so they are available
     // in the routing files of each app
     OC::loadAppClassPaths();
     // Check if ownCloud is installed or in maintenance (update) mode
     if (!OC_Config::getValue('installed', false)) {
         require_once 'core/setup.php';
         exit;
     }
     $host = OC_Request::insecureServerHost();
     // if the host passed in headers isn't trusted
     if (!OC::$CLI && OC_Request::getOverwriteHost() === null && !OC_Request::isTrustedDomain($host)) {
         header('HTTP/1.1 400 Bad Request');
         header('Status: 400 Bad Request');
         OC_Template::printErrorPage('You are accessing the server from an untrusted domain.', 'Please contact your administrator. If you are an administrator of this instance, configure the "trusted_domain" setting in config/config.php. An example configuration is provided in config/config.sample.php.');
         return;
     }
     $request = OC_Request::getPathInfo();
     if (substr($request, -3) !== '.js') {
         // we need these files during the upgrade
         self::checkMaintenanceMode();
         self::checkUpgrade();
     }
     // Test it the user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
     OC::tryBasicAuthLogin();
     if (!self::$CLI and (!isset($_GET["logout"]) or $_GET["logout"] !== 'true')) {
         try {
             if (!OC_Config::getValue('maintenance', false)) {
                 OC_App::loadApps();
             }
             self::checkSingleUserMode();
             OC::getRouter()->match(OC_Request::getRawPathInfo());
             return;
         } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
             //header('HTTP/1.0 404 Not Found');
         } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
             OC_Response::setStatus(405);
             return;
         }
     }
     $app = OC::$REQUESTEDAPP;
     $file = OC::$REQUESTEDFILE;
     $param = array('app' => $app, 'file' => $file);
     // Handle app css files
     if (substr($file, -3) == 'css') {
         self::loadCSSFile($param);
         return;
     }
     // Handle redirect URL for logged in users
     if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
         $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
         // Deny the redirect if the URL contains a @
         // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
         if (strpos($location, '@') === false) {
             header('Location: ' . $location);
             return;
         }
     }
     // Handle WebDAV
     if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
         // not allowed any more to prevent people
         // mounting this root directly.
         // Users need to mount remote.php/webdav instead.
         header('HTTP/1.1 405 Method Not Allowed');
         header('Status: 405 Method Not Allowed');
         return;
     }
     // Someone is logged in :
     if (OC_User::isLoggedIn()) {
         OC_App::loadApps();
         OC_User::setupBackends();
         if (isset($_GET["logout"]) and $_GET["logout"]) {
             if (isset($_COOKIE['oc_token'])) {
                 OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
             }
             OC_User::logout();
             header("Location: " . OC::$WEBROOT . '/');
         } else {
             if (is_null($file)) {
                 $param['file'] = 'index.php';
             }
             $file_ext = substr($param['file'], -3);
             if ($file_ext != 'php' || !self::loadAppScriptFile($param)) {
                 header('HTTP/1.0 404 Not Found');
             }
         }
         return;
     }
     // Not handled and not logged in
     self::handleLogin();
 }
Example #10
0
 /**
  * Handle the request
  */
 public static function handleRequest()
 {
     $l = \OC_L10N::get('lib');
     // load all the classpaths from the enabled apps so they are available
     // in the routing files of each app
     OC::loadAppClassPaths();
     // Check if ownCloud is installed or in maintenance (update) mode
     if (!OC_Config::getValue('installed', false)) {
         $controller = new OC\Core\Setup\Controller();
         $controller->run($_POST);
         exit;
     }
     $host = OC_Request::insecureServerHost();
     // if the host passed in headers isn't trusted
     if (!OC::$CLI && OC_Request::getOverwriteHost() === null && !OC_Request::isTrustedDomain($host)) {
         header('HTTP/1.1 400 Bad Request');
         header('Status: 400 Bad Request');
         OC_Template::printErrorPage($l->t('You are accessing the server from an untrusted domain.'), $l->t('Please contact your administrator. If you are an administrator of this instance, configure the "trusted_domain" setting in config/config.php. An example configuration is provided in config/config.sample.php.'));
         return;
     }
     $request = OC_Request::getPathInfo();
     if (substr($request, -3) !== '.js') {
         // we need these files during the upgrade
         self::checkMaintenanceMode();
         self::checkUpgrade();
     }
     if (!OC_User::isLoggedIn()) {
         // Test it the user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
         OC::tryBasicAuthLogin();
     }
     if (!self::$CLI and (!isset($_GET["logout"]) or $_GET["logout"] !== 'true')) {
         try {
             if (!OC_Config::getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
                 OC_App::loadApps(array('authentication'));
                 OC_App::loadApps(array('filesystem', 'logging'));
                 OC_App::loadApps();
             }
             self::checkSingleUserMode();
             OC::$server->getRouter()->match(OC_Request::getRawPathInfo());
             return;
         } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
             //header('HTTP/1.0 404 Not Found');
         } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
             OC_Response::setStatus(405);
             return;
         }
     }
     // Load minimum set of apps
     if (!self::checkUpgrade(false)) {
         // For logged-in users: Load everything
         if (OC_User::isLoggedIn()) {
             OC_App::loadApps();
         } else {
             // For guests: Load only authentication, filesystem and logging
             OC_App::loadApps(array('authentication'));
             OC_App::loadApps(array('filesystem', 'logging'));
         }
     }
     // Handle redirect URL for logged in users
     if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
         $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
         // Deny the redirect if the URL contains a @
         // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
         if (strpos($location, '@') === false) {
             header('Location: ' . $location);
             return;
         }
     }
     // Handle WebDAV
     if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
         // not allowed any more to prevent people
         // mounting this root directly.
         // Users need to mount remote.php/webdav instead.
         header('HTTP/1.1 405 Method Not Allowed');
         header('Status: 405 Method Not Allowed');
         return;
     }
     // Redirect to index if the logout link is accessed without valid session
     // this is needed to prevent "Token expired" messages while login if a session is expired
     // @see https://github.com/owncloud/core/pull/8443#issuecomment-42425583
     if (isset($_GET['logout']) && !OC_User::isLoggedIn()) {
         header("Location: " . OC::$WEBROOT . (empty(OC::$WEBROOT) ? '/' : ''));
         return;
     }
     // Someone is logged in
     if (OC_User::isLoggedIn()) {
         OC_App::loadApps();
         OC_User::setupBackends();
         if (isset($_GET["logout"]) and $_GET["logout"]) {
             OC_JSON::callCheck();
             if (isset($_COOKIE['oc_token'])) {
                 OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
             }
             if (isset($_SERVER['PHP_AUTH_USER'])) {
                 if (isset($_COOKIE['oc_ignore_php_auth_user'])) {
                     // Ignore HTTP Authentication for 5 more mintues.
                     setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], time() + 300, OC::$WEBROOT . (empty(OC::$WEBROOT) ? '/' : ''));
                 } elseif ($_SERVER['PHP_AUTH_USER'] === self::$session->get('loginname')) {
                     // Ignore HTTP Authentication to allow a different user to log in.
                     setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], 0, OC::$WEBROOT . (empty(OC::$WEBROOT) ? '/' : ''));
                 }
             }
             OC_User::logout();
             // redirect to webroot and add slash if webroot is empty
             header("Location: " . OC::$WEBROOT . (empty(OC::$WEBROOT) ? '/' : ''));
         } else {
             // Redirect to default application
             OC_Util::redirectToDefaultPage();
         }
     } else {
         // Not handled and not logged in
         self::handleLogin();
     }
 }
Example #11
0
 /**
  * Check if the htaccess file is working by creating a test file in the data directory and trying to access via http
  */
 public static function ishtaccessworking()
 {
     // testdata
     $filename = '/htaccesstest.txt';
     $testcontent = 'testcontent';
     // creating a test file
     $testfile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $filename;
     $fp = @fopen($testfile, 'w');
     @fwrite($fp, $testcontent);
     @fclose($fp);
     // accessing the file via http
     $url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $filename);
     $fp = @fopen($url, 'r');
     $content = @fread($fp, 2048);
     @fclose($fp);
     // cleanup
     @unlink($testfile);
     // does it work ?
     if ($content == $testcontent) {
         return false;
     } else {
         return true;
     }
 }
Example #12
0
 /**
  * Makes an URL absolute
  * @param string $url the url
  * @return string the absolute url
  */
 public function getAbsoluteURL($url)
 {
     # TODO: use public api
     return \OC_Helper::makeURLAbsolute($url);
 }
Example #13
0
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td>
<table cellspacing="0" cellpadding="0" border="0" width="600px">
<tr>
<td bgcolor="#1d2d44" width="20px">&nbsp;</td>
<td bgcolor="#1d2d44">
<img src="<?php 
print_unescaped(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif')));
?>
" alt="<?php 
p($theme->getName());
?>
"/>
</td>
</tr>
<tr><td bgcolor="#f8f8f8" colspan="2">&nbsp;</td></tr>
<tr>
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php 
print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared »%s« with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
if (isset($_['expiration'])) {
    p($l->t("The share will expire on %s.", array($_['expiration'])));
    print_unescaped('<br><br>');
}
p($l->t('Cheers!'));
?>
</td>
</tr>
<tr><td bgcolor="#f8f8f8" colspan="2">&nbsp;</td></tr>
<tr>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td>
			<table cellspacing="0" cellpadding="0" border="0" width="600px">
				<tr>
					<td bgcolor="<?php 
p($theme->getMailHeaderColor());
?>
" width="20px">&nbsp;</td>
					<td bgcolor="<?php 
p($theme->getMailHeaderColor());
?>
">
						<img src="<?php 
p(OC_Helper::makeURLAbsolute(image_path('user_deletion_request', 'logo-mail.gif')));
?>
" alt="<?php 
p($theme->getName());
?>
"/>
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td width="20px">&nbsp;</td>
					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
						<p><?php 
p($l->t('Hello,'));
Example #15
0
 /**
  * Send a notification to one user
  *
  * @param string $user Username of the recipient
  * @param string $email Email address of the recipient
  * @param string $lang Selected language of the recipient
  * @param array $mailData Notification data we send to the user
  */
 public function sendEmailToUser($user, $email, $lang, $mailData)
 {
     $l = $this->getLanguage($lang);
     $dataHelper = new DataHelper(\OC::$server->getActivityManager(), new ParameterHelper(new \OC\Files\View(''), $l), $l);
     $activityList = array();
     foreach ($mailData as $activity) {
         $activityList[] = $dataHelper->translation($activity['amq_appid'], $activity['amq_subject'], unserialize($activity['amq_subjectparams']));
     }
     $alttext = new \OCP\Template('activity', 'email.notification', '');
     $alttext->assign('username', $user);
     $alttext->assign('timeframe', $this->getLangForApproximatedTimeFrame($mailData[0]['amq_timestamp']));
     $alttext->assign('activities', $activityList);
     $alttext->assign('owncloud_installation', \OC_Helper::makeURLAbsolute('/'));
     $emailText = $alttext->fetchPage();
     try {
         \OC_Mail::send($email, $user, $l->t('Activity notification'), $emailText, $this->getSenderData('email'), $this->getSenderData('name'));
     } catch (\Exception $e) {
         \OCP\Util::writeLog('Activity', 'A problem occurred while sending the e-mail. Please revisit your settings.', \OCP\Util::ERROR);
     }
 }
Example #16
0
 /**
  * @param $pattern
  * @param $searchProperties
  * @param $options
  * @return array|false
  */
 public function search($pattern, $searchProperties, $options)
 {
     $ids = array();
     $results = array();
     $query = 'SELECT DISTINCT `contactid` FROM `' . self::PROPERTY_TABLE . '` WHERE (';
     $params = array();
     foreach ($searchProperties as $property) {
         $params[] = $property;
         $params[] = '%' . $pattern . '%';
         $query .= '(`name` = ? AND `value` LIKE ?) OR ';
     }
     $query = substr($query, 0, strlen($query) - 4);
     $query .= ')';
     $stmt = \OCP\DB::prepare($query);
     $result = $stmt->execute($params);
     if (\OCP\DB::isError($result)) {
         \OCP\Util::writeLog('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
         return false;
     }
     while ($row = $result->fetchRow()) {
         $ids[] = $row['contactid'];
     }
     if (count($ids) > 0) {
         foreach ($ids as $id) {
             $contact = $this->addressBook->getChild($id);
             $j = JSONSerializer::serializeContact($contact);
             $j['data']['id'] = $id;
             if (isset($contact->PHOTO)) {
                 $url = \OCP\Util::linkToRoute('contacts_contact_photo', array('backend' => $contact->getBackend()->name, 'addressBookId' => $this->addressBook->getId(), 'contactId' => $contact->getId()));
                 $url = \OC_Helper::makeURLAbsolute($url);
                 $j['data']['PHOTO'] = "VALUE=uri:{$url}";
             }
             $results[] = $this->convertToSearchResult($j);
         }
     }
     return $results;
 }
 */
?>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td>
<table cellspacing="0" cellpadding="0" border="0" width="600px">
<tr>
<td bgcolor="<?php 
p($theme->getMailHeaderColor());
?>
" width="20px">&nbsp;</td>
<td bgcolor="<?php 
p($theme->getMailHeaderColor());
?>
">
<img src="<?php 
p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.png')));
?>
" alt="<?php 
p($theme->getName());
?>
"/>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php 
print_unescaped($l->t("<p>User %s just has been created (%s)</p>\n", array($_['userUID'], $_['datetime'])));
print_unescaped($l->t("<p>Home directory: %s.</p>\n<br/>\n", array($_['home'])));
?>
    /**
     * @param $pattern
     * @param $searchProperties
     * @param $options
     * @return array|false
     */
    public function search($pattern, $searchProperties, $options)
    {
        $propTable = self::PROPERTY_TABLE;
        $contTable = self::CONTACT_TABLE;
        $addrTable = self::ADDRESSBOOK_TABLE;
        $results = array();
        /**
         * This query will fetch all contacts which match the $searchProperties
         * It will look up the addressbookid of the contact and the user id of the owner of the contact app
         */
        $query = <<<SQL
\t\t\tSELECT
\t\t\t\tDISTINCT
\t\t\t\t`{$propTable}`.`contactid`,
\t\t\t\t`{$contTable}`.`addressbookid`,
\t\t\t\t`{$addrTable}`.`userid`

\t\t\tFROM
\t\t\t\t`{$propTable}`
\t\t\tINNER JOIN
\t\t\t\t`{$contTable}`
\t\t\tON `{$contTable}`.`id` = `{$propTable}`.`contactid`
  \t\t\t\tINNER JOIN `{$addrTable}`
\t\t\tON `{$addrTable}`.id = `{$contTable}`.addressbookid
\t\t\tWHERE
\t\t\t\t`{$contTable}`.addressbookid = ? AND
\t\t\t\t(
SQL;
        $params = array();
        $meta = $this->addressBook->getMetaData();
        $params[] = $meta['id'];
        foreach ($searchProperties as $property) {
            $params[] = $property;
            $params[] = '%' . $pattern . '%';
            $query .= '(`name` = ? AND `value` LIKE ?) OR ';
        }
        $query = substr($query, 0, strlen($query) - 4);
        $query .= ')';
        $stmt = \OCP\DB::prepare($query);
        $result = $stmt->execute($params);
        if (\OCP\DB::isError($result)) {
            \OCP\Util::writeLog('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
            return false;
        }
        while ($row = $result->fetchRow()) {
            $id = $row['contactid'];
            $addressbookKey = $row['addressbookid'];
            // Check if we are the owner of the contact
            if ($row['userid'] !== \OCP\User::getUser()) {
                // we aren't the owner of the contact
                try {
                    // it is possible that the contact is shared with us
                    // if so, $contact will be an object
                    // if not getContact will throw an Exception
                    $contact = $this->app->getContact('shared', $addressbookKey, $id);
                } catch (\Exception $e) {
                    // the contact isn't shared with us
                    $contact = null;
                }
            } else {
                // We are the owner of the contact
                // thus we can easily fetch it
                $contact = $this->app->getContact('local', $addressbookKey, $id);
            }
            if ($contact !== null) {
                $j = JSONSerializer::serializeContact($contact);
                $j['data']['id'] = $id;
                if (isset($contact->PHOTO)) {
                    $url = \OCP\Util::linkToRoute('contacts_contact_photo', array('backend' => $contact->getBackend()->name, 'addressBookId' => $addressbookKey, 'contactId' => $contact->getId()));
                    $url = \OC_Helper::makeURLAbsolute($url);
                    $j['data']['PHOTO'] = "VALUE=uri:{$url}";
                }
                $results[] = $this->convertToSearchResult($j);
            }
        }
        return $results;
    }
Example #19
0
 /**
  * Check if the .htaccess file is working
  *
  * @throws OC\HintException If the testfile can't get written.
  * @return bool
  * @description Check if the .htaccess file is working by creating a test
  * file in the data directory and trying to access via http
  */
 public static function isHtaccessWorking()
 {
     if (!OC::$server->getConfig()->getSystemValue('check_for_working_htaccess', true)) {
         return true;
     }
     // testdata
     $fileName = '/htaccesstest.txt';
     $testContent = 'testcontent';
     // creating a test file
     $testFile = OC::$server->getConfig()->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
     if (file_exists($testFile)) {
         // already running this test, possible recursive call
         return false;
     }
     $fp = @fopen($testFile, 'w');
     if (!$fp) {
         throw new OC\HintException('Can\'t create test file to check for working .htaccess file.', 'Make sure it is possible for the webserver to write to ' . $testFile);
     }
     fwrite($fp, $testContent);
     fclose($fp);
     // accessing the file via http
     $url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName);
     $content = self::getUrlContent($url);
     // cleanup
     @unlink($testFile);
     /*
      * If the content is not equal to test content our .htaccess
      * is working as required
      */
     return $content !== $testContent;
 }
Example #20
0
" />
		<p><em><?php 
p($l->t('This setting specifies the folder which will be scanned for music.'));
?>
.</em></p>
	</div>
<!--
	<h3>Ampache</h3>
	<div class="warning">
		<?php 
print_unescaped($l->t('Keep in mind, that the Ampache API is just a preview and is unstable. Feel free to report your ' . 'experience with this feature in the corresponding <a href="https://github.com/owncloud/music/issues/60">issue</a>. ' . 'I would also like to have a list of clients to test with. Thanks'));
?>
	</div>
	<div>
		<code><?php 
p(\OC_Helper::makeURLAbsolute(\OC_Helper::linkToRoute('music_ampache')));
?>
</code><br />
		<em><?php 
p($l->t('Use this address to browse your music collection from any Ampache compatible player.'));
?>
</em>
	</div>
	<div>
		<?php 
p($l->t("Here you can generate passwords to use with the Ampache API, because they " . "can't be stored in a really secure way due to the design of the Ampache API. " . "You can generate as many passwords as you want and revoke them anytime."));
?>
	</div>
	<table id="music-ampache-keys" class="grid <?php 
if (!count($_['ampacheKeys'])) {
    ?>