Example #1
0
 /**
  * Adds a secret to config.php
  */
 private function addSecret()
 {
     if (\OC::$server->getConfig()->getSystemValue('secret', null) === null) {
         $secret = \OC_Util::generateRandomBytes(96);
         \OC::$server->getConfig()->setSystemValue('secret', $secret);
     }
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
     $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
     $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
     $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
     shell_exec($exec);
     //create imagick object from pdf
     $pdfPreview = null;
     try {
         list($dirname, , , $filename) = array_values(pathinfo($absPath));
         $pdfPreview = $dirname . '/' . $filename . '.pdf';
         $pdf = new \imagick($pdfPreview . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         unlink($absPath);
         unlink($pdfPreview);
         \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($pdfPreview);
     if ($image->valid()) {
         $image->scaleDownToFit($maxX, $maxY);
         return $image;
     }
     return false;
 }
Example #3
0
 protected function setUp()
 {
     parent::setUp();
     if (!getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('objectstore tests are unreliable in some environments');
     }
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // create users
     $users = array('test');
     foreach ($users as $userName) {
         \OC_User::deleteUser($userName);
         \OC_User::createUser($userName, $userName);
     }
     // main test user
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_User::setUserId('test');
     $config = \OC::$server->getConfig()->getSystemValue('objectstore');
     $this->objectStorage = new ObjectStoreToTest($config['arguments']);
     $config['objectstore'] = $this->objectStorage;
     $this->instance = new ObjectStoreStorage($config);
 }
Example #4
0
 protected function init()
 {
     if ($this->started) {
         return;
     }
     $this->started = true;
     // prevent php output buffering, caching and nginx buffering
     OC_Util::obEnd();
     header('Cache-Control: no-cache');
     header('X-Accel-Buffering: no');
     $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
     if ($this->fallback) {
         $this->fallBackId = (int) $_GET['fallback_id'];
         header("Content-Type: text/html");
         echo str_repeat('<span></span>' . PHP_EOL, 10);
         //dummy data to keep IE happy
     } else {
         header("Content-Type: text/event-stream");
     }
     if (!OC_Util::isCallRegistered()) {
         $this->send('error', 'Possible CSRF attack. Connection will be closed.');
         $this->close();
         exit;
     }
     flush();
 }
Example #5
0
 private function themeExist($method)
 {
     if (OC_Util::getTheme() !== '' && method_exists('OC_Theme', $method)) {
         return true;
     }
     return false;
 }
Example #6
0
 public function finishSetup()
 {
     if (file_exists($this->autoConfigFile)) {
         unlink($this->autoConfigFile);
     }
     \OC_Util::redirectToDefaultPage();
 }
Example #7
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 #8
0
 function __construct()
 {
     $this->l = OC_L10N::get('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = 'ownCloud';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = 'ownCloud';
     /* short name, used when referring to the software */
     $this->defaultTitle = 'ownCloud';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = 'https://owncloud.org';
     $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
     $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
     $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
     $this->defaultDocBaseUrl = 'http://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.0';
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('web services under your control');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     if (class_exists('OC_Theme')) {
         $this->theme = new OC_Theme();
     }
 }
Example #9
0
 /**
  * Send the requested parts of the file
  */
 public function sendResponse()
 {
     if (!preg_match('/^bytes=\\d*-\\d*(,\\d*-\\d*)*$/', $_SERVER['HTTP_RANGE'])) {
         $this->sendNotSatisfiable();
     }
     $ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6));
     foreach ($ranges as $range) {
         $parts = explode('-', $range);
         $start = isset($parts[0]) ? $parts[0] : 0;
         $end = isset($parts[1]) ? $parts[1] : $this->getFilesize() - 1;
         if ($start > $end) {
             $this->sendNotSatisfiable();
         }
         $handle = $this->view->fopen($this->filepath, 'rb');
         \fseek($handle, $start);
         $buffer = \fread($handle, $end - $start);
         $md5Sum = md5($buffer);
         \fclose($handle);
         // send the headers and data
         header("Content-Length: " . $end - $start);
         header("Content-md5: " . $md5Sum);
         header("Accept-Ranges: bytes");
         header('Content-Range: bytes ' . $start . '-' . $end . '/' . $this->getFilesize());
         header("Connection: close");
         header("Content-type: " . $this->getMimeType());
         header('Content-Disposition: attachment; filename=' . $this->getFilename());
         \OC_Util::obEnd();
         echo $buffer;
         flush();
     }
 }
Example #10
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('debug')) {
         $this->scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
             $output->writeln("Scanning <info>{$path}</info>");
         });
     }
     $inputPath = $input->getOption('path');
     $path = false;
     if ($inputPath) {
         $path = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $path, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($user);
         $output->writeln("Start scan for <info>{$user}</info>");
         $this->scanner->rescan($user, true, $path ? $path : $this->resolveUserFolder($user), $input->getOption('debug'), $output);
     }
 }
Example #11
0
 /**
  * @param array $data
  * @return string
  */
 function getContentHtml($data = array())
 {
     $this->maxStringLen = $data['maxStringLen'];
     $this->startStringLen = $data['startStringLen'];
     // if problem exists
     if (isset($data['msg'])) {
         return '<div class="msg">' . $this->p($data['msg']) . '</div>';
     }
     $html = '';
     $html .= '<table>';
     foreach ($data['activities'] as $activity) {
         $prioritystyle = 'class="activity-section group"';
         if (isset($activity['priority'])) {
             $prioritystyle = 'class="activity-section group priority-' . $this->p($activity['priority']);
         }
         $priority = $this->p($activity['priority']);
         $link = $this->p($activity['link']);
         $subject = $this->p($activity['subject']);
         $sSub = $this->getNiceSmallText($this->p($activity['subject']));
         $smallSubject = \OC_Util::sanitizeHTML($sSub);
         $time = $this->getRelativeTime($this->p($activity['date']));
         $html .= '<tr><td><div ' . $prioritystyle . ' subject"><a class="preview preview-dir-icon" href="' . $link . '" title="' . $subject . '">' . $smallSubject . '</a><br /><span class="hoverInfo" data-opacitynormal="0.5">' . $time . '</span></div></td></tr>';
     }
     $html .= '</table>';
     return $html;
 }
Example #12
0
 /**
  * @brief Creates path to an image
  * @param string $app app
  * @param string $image image name
  * @return string the url
  *
  * Returns the path to the image.
  */
 public function imagePath($app, $image)
 {
     // Read the selected theme from the config file
     $theme = \OC_Util::getTheme();
     //if a theme has a png but not an svg always use the png
     $basename = substr(basename($image), 0, -4);
     // Check if the app is in the app folder
     if (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$image}")) {
         return \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$image}";
     } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png";
     } elseif (file_exists(\OC_App::getAppPath($app) . "/img/{$image}")) {
         return \OC_App::getAppWebPath($app) . "/img/{$image}";
     } elseif (!file_exists(\OC_App::getAppPath($app) . "/img/{$basename}.svg") && file_exists(\OC_App::getAppPath($app) . "/img/{$basename}.png")) {
         return \OC_App::getAppPath($app) . "/img/{$basename}.png";
     } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$image}")) {
         return \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$image}";
     } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$basename}.png";
     } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/{$app}/img/{$image}")) {
         return \OC::$WEBROOT . "/{$app}/img/{$image}";
     } elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/{$app}/img/{$basename}.png";
     } elseif (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$image}")) {
         return \OC::$WEBROOT . "/themes/{$theme}/core/img/{$image}";
     } elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.png")) {
         return \OC::$WEBROOT . "/themes/{$theme}/core/img/{$basename}.png";
     } elseif (file_exists(\OC::$SERVERROOT . "/core/img/{$image}")) {
         return \OC::$WEBROOT . "/core/img/{$image}";
     } else {
         throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
     }
 }
Example #13
0
 /**
  * This runs all the security checks before a method call. The
  * security checks are determined by inspecting the controller method
  * annotations
  * @param string/Controller $controller the controllername or string
  * @param string $methodName the name of the method
  * @throws AmpacheException when a security check fails
  */
 public function beforeController($controller, $methodName)
 {
     // get annotations from comments
     $annotationReader = new MethodAnnotationReader($controller, $methodName);
     $this->isAmpacheCall = $annotationReader->hasAnnotation('AmpacheAPI');
     // don't try to authenticate for the handshake request
     if ($this->isAmpacheCall && $this->request['action'] !== 'handshake') {
         $token = $this->request['auth'];
         if ($token !== null && $token !== '') {
             $user = $this->mapper->find($token);
             if ($user !== false && array_key_exists('user_id', $user)) {
                 // setup the filesystem for the user - actual login isn't really needed
                 \OC_Util::setupFS($user['user_id']);
                 $this->ampacheUser->setUserId($user['user_id']);
                 return;
             }
         } else {
             // for ping action without token the version information is provided
             if ($this->request['action'] === 'ping') {
                 return;
             }
         }
         throw new AmpacheException('Invalid Login', 401);
     }
 }
Example #14
0
 function __construct()
 {
     $this->l = \OC::$server->getL10N('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = '';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = '';
     /* short name, used when referring to the software */
     $this->defaultTitle = '';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = '';
     $this->defaultSyncClientUrl = '';
     $this->defaultiOSClientUrl = '';
     $this->defaultiTunesAppId = '';
     $this->defaultAndroidClientUrl = '';
     $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.' . $version[1];
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('Web Master - Mayank Agarwal <br>UI - Sambhav Kothari');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
     if (file_exists($themePath)) {
         // prevent defaults.php from printing output
         ob_start();
         require_once $themePath;
         ob_end_clean();
         if (class_exists('OC_Theme')) {
             $this->theme = new OC_Theme();
         }
     }
 }
Example #15
0
 protected function setUp()
 {
     parent::setUp();
     if (\OC_Util::runningOnWindows()) {
         $this->markTestSkipped('[Windows] tar archives are not supported on Windows');
     }
 }
Example #16
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 #17
0
File: tar.php Project: Romua1d/core
 public function setUp()
 {
     if (OC_Util::runningOnWindows()) {
         $this->markTestSkipped('tar archives are not supported on windows');
     }
     parent::setUp();
 }
 /**
  * Check if a new version is available
  */
 public static function check()
 {
     OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
     if (OC_Appconfig::getValue('core', 'installedat', '') == '') {
         OC_Appconfig::setValue('core', 'installedat', microtime(true));
     }
     $updaterurl = 'http://apps.owncloud.com/updater.php';
     $version = OC_Util::getVersion();
     $version['installed'] = OC_Appconfig::getValue('core', 'installedat');
     $version['updated'] = OC_Appconfig::getValue('core', 'lastupdatedat');
     $version['updatechannel'] = 'stable';
     $version['edition'] = OC_Util::getEditionString();
     $versionstring = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterurl . '?version=' . $versionstring;
     $xml = @file_get_contents($url);
     if ($xml == FALSE) {
         return array();
     }
     $data = @simplexml_load_string($xml);
     $tmp = array();
     $tmp['version'] = $data->version;
     $tmp['versionstring'] = $data->versionstring;
     $tmp['url'] = $data->url;
     $tmp['web'] = $data->web;
     return $tmp;
 }
Example #19
0
 /**
  * @param OutputInterface $output
  */
 public function loadCommands(OutputInterface $output)
 {
     // $application is required to be defined in the register_command scripts
     $application = $this->application;
     require_once \OC::$SERVERROOT . '/core/register_command.php';
     if ($this->config->getSystemValue('installed', false)) {
         if (!\OCP\Util::needUpgrade()) {
             OC_App::loadApps();
             foreach (OC_App::getAllApps() as $app) {
                 $file = OC_App::getAppPath($app) . '/appinfo/register_command.php';
                 if (file_exists($file)) {
                     require $file;
                 }
             }
         } else {
             $output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
         }
     } else {
         $output->writeln("ownCloud is not installed - only a limited number of commands are available");
     }
     $input = new ArgvInput();
     if ($input->getFirstArgument() !== 'check') {
         $errors = \OC_Util::checkServer(\OC::$server->getConfig());
         if (!empty($errors)) {
             foreach ($errors as $error) {
                 $output->writeln($error['error']);
                 $output->writeln($error['hint']);
                 $output->writeln('');
             }
             throw new \Exception("Environment not properly prepared.");
         }
     }
 }
Example #20
0
 public static function getByShareToken($token)
 {
     $linkItem = \OCP\Share::getShareByToken($token);
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
         $fileOwner = $rootLinkItem['uid_owner'];
     } else {
         throw new \Exception('This file was probably unshared');
     }
     if (!isset($rootLinkItem['path']) && isset($rootLinkItem['file_target'])) {
         $rootLinkItem['path'] = 'files/' . $rootLinkItem['file_target'];
     }
     $file = new File($rootLinkItem['file_source'], array($rootLinkItem));
     if (isset($rootLinkItem['uid_owner'])) {
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($rootLinkItem['uid_owner']);
         $file->setOwner($rootLinkItem['uid_owner']);
         $file->setPath('/files' . \OC\Files\Filesystem::getPath($linkItem['file_source']));
     }
     if (isset($linkItem['share_with']) && !empty($linkItem['share_with'])) {
         $file->setPasswordProtected(true);
     }
     return $file;
 }
Example #21
0
	/**
	 * @brief Check an ajax get/post call if the request token is valid.
	 * @return json Error msg if not valid.
	 */
	public static function callCheck() {
		if( !OC_Util::isCallRegistered()) {
			$l = OC_L10N::get('lib');
			self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.') )));
			exit();
		}
	}
Example #22
0
 /**
  * Check if a new version is available
  */
 public static function check()
 {
     OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
     if (OC_Appconfig::getValue('core', 'installedat', '') == '') {
         OC_Appconfig::setValue('core', 'installedat', microtime(true));
     }
     $updaterurl = 'http://apps.owncloud.com/updater.php';
     $version = OC_Util::getVersion();
     $version['installed'] = OC_Appconfig::getValue('core', 'installedat');
     $version['updated'] = OC_Appconfig::getValue('core', 'lastupdatedat');
     $version['updatechannel'] = 'stable';
     $version['edition'] = OC_Util::getEditionString();
     $versionstring = implode('x', $version);
     //fetch xml data from updater
     $url = $updaterurl . '?version=' . $versionstring;
     // set a sensible timeout of 10 sec to stay responsive even if the update server is down.
     $ctx = stream_context_create(array('http' => array('timeout' => 10)));
     $xml = @file_get_contents($url, 0, $ctx);
     if ($xml == false) {
         return array();
     }
     $data = @simplexml_load_string($xml);
     $tmp = array();
     $tmp['version'] = $data->version;
     $tmp['versionstring'] = $data->versionstring;
     $tmp['url'] = $data->url;
     $tmp['web'] = $data->web;
     return $tmp;
 }
Example #23
0
 public function setUp()
 {
     if (!getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('objectstore tests are unreliable on travis');
     }
     \OC_App::disable('files_sharing');
     \OC_App::disable('files_versions');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // create users
     $users = array('test');
     foreach ($users as $userName) {
         \OC_User::deleteUser($userName);
         \OC_User::createUser($userName, $userName);
     }
     // main test user
     $userName = '******';
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_User::setUserId('test');
     $testContainer = 'oc-test-container-' . substr(md5(rand()), 0, 7);
     $params = array('username' => 'facebook100000330192569', 'password' => 'Dbdj1sXnRSHxIGc4', 'container' => $testContainer, 'autocreate' => true, 'region' => 'RegionOne', 'url' => 'http://8.21.28.222:5000/v2.0', 'tenantName' => 'facebook100000330192569', 'serviceName' => 'swift', 'user' => \OC_User::getManager()->get($userName));
     $this->objectStorage = new ObjectStoreToTest($params);
     $params['objectstore'] = $this->objectStorage;
     $this->instance = new ObjectStoreStorage($params);
 }
Example #24
0
 public function __construct($global = false)
 {
     $this->prefix = OC_Util::getInstanceId() . '/';
     if (!$global) {
         $this->prefix .= OC_User::getUser() . '/';
     }
 }
Example #25
0
 protected function setUp()
 {
     parent::setUp();
     if (\OC_Util::runningOnWindows()) {
         $this->markTestSkipped('[Windows] ');
     }
 }
Example #26
0
 public function __construct(array $urlParams = [])
 {
     parent::__construct('updater', $urlParams);
     $container = $this->getContainer();
     /**
      * Controllers
      */
     $container->registerService('UpdateController', function ($c) {
         return new UpdateController($c->query('AppName'), $c->query('Request'), $c->query('L10N'));
     });
     $container->registerService('BackupController', function ($c) {
         return new BackupController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
     });
     $container->registerService('AdminController', function ($c) {
         return new AdminController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
     });
     $container->registerService('L10N', function ($c) {
         return $c->query('ServerContainer')->getL10N($c->query('AppName'));
     });
     $container->registerService('Config', function ($c) {
         return new Config($c->query('ServerContainer')->getConfig());
     });
     $container->registerService('Channel', function ($c) {
         return new Channel($c->query('L10N'));
     });
     //Startup
     if (\OC_Util::getEditionString() === '') {
         \OCP\App::registerAdmin('updater', 'admin');
         $appPath = $container->query('Config')->getBackupBase();
         if (!@file_exists($appPath)) {
             Helper::mkdir($appPath);
         }
     }
 }
Example #27
0
 /**
  * @brief reads jpegPhoto and set is as avatar if available
  * @param $uid string ownCloud user name
  * @param $dn string the user's LDAP DN
  * @return void
  */
 private function updateAvatar($uid, $dn)
 {
     $hasLoggedIn = \OCP\Config::getUserValue($uid, 'user_ldap', 'firstLoginAccomplished', 0);
     $lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', 'lastJpegPhotoLookup', 0);
     if ($hasLoggedIn !== '1' || time() - intval($lastChecked) < 86400) {
         //update only once a day
         return;
     }
     $avatarImage = $this->getAvatarImage($uid, $dn);
     if ($avatarImage === false) {
         //not set, nothing left to do;
         return;
     }
     $image = new \OCP\Image();
     $image->loadFromBase64(base64_encode($avatarImage));
     if (!$image->valid()) {
         \OCP\Util::writeLog('user_ldap', 'jpegPhoto data invalid for ' . $dn, \OCP\Util::ERROR);
         return;
     }
     //make sure it is a square and not bigger than 128x128
     $size = min(array($image->width(), $image->height(), 128));
     if (!$image->centerCrop($size)) {
         \OCP\Util::writeLog('user_ldap', 'croping image for avatar failed for ' . $dn, \OCP\Util::ERROR);
         return;
     }
     if (!\OC\Files\Filesystem::$loaded) {
         \OC_Util::setupFS($uid);
     }
     $avatarManager = \OC::$server->getAvatarManager();
     $avatar = $avatarManager->getAvatar($uid);
     $avatar->set($image);
 }
 /**
  * Stub - sends a generic avatar
  */
 public static function sendAvatar()
 {
     $uid = self::preDispatch(false);
     $image = new \OC_Image('iVBORw0KGgoAAAANSUhEUgAAADAAAAAwEAYAAAAHkiXEAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAwAAAAMADO7oxXAAAUWUlEQVR42u1beXBUVfb+3tZLOp21u0nSHbIRQkJYk5QwIhGNLMKAiDiCqGXpaKFSY2mpVTqOC9aUOo4zMjWihcoUboUysqqMDG6MJMAYooQtJJB962ydTi/v9Vt+f1zv73U3aQibOjOcKji5r1/fd9/3nXvuOefeBi7LZbksl+Wy/K8K81MP4GxiNptMDJOQkJ7ucDBMYaHdnprKsnl5RqPRCMTHGwyCAJjNoihJgM83MDA4qGnt7V1dbreq1tW53b29mnbypKZpGqCqP/X7RMvPhoC0NIeDZceNmznziisE4c47y8omTzaZFi9OS0tLS0kZPTo52WYrLJSklBSbLSuL4ywWszkxkec5ThAEgWWDwUBgcFCWvV6Px+1WlN5et7uhAejr6+k5cUJVGxoaGyWpsvKLL/buDQTWr6+pOXxYUbZulaRQCAgE/ucIyM/PyWHZq65atmzxYovlD38YP76oaMyYCRMmTy4t/dWvDAanMytr2jSeNxqNRosFAFS1vx/QNFUdGiLtYJD0JcuApgEsCzAMwxgMAMOwrNUKaJqmWa3A4GBfX309UFv73Xeffur319fX1X3+uap+8snnn3s8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4ud2lraXBlZGlhLm9yZy93aWtpL1B1YmxpY19kb21haW4//erPAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDA5LTExLTI4VDIyOjQ0OjU2LTA3OjAwPv9sWAAAABl0RVh0U291cmNlAFRhbmdvIEljb24gTGlicmFyeVTP7YIAAAA6dEVYdFNvdXJjZV9VUkwAaHR0cDovL3RhbmdvLmZyZWVkZXNrdG9wLm9yZy9UYW5nb19JY29uX0xpYnJhcnm8yK3WAAAAcnRFWHRzdmc6YmFzZS11cmkAZmlsZTovLy9tbnQvb2dyZS9wcml2eS9kb2NzL2ljb25zL29wZW5faWNvbl9saWJyYXJ5LWRldmVsL2ljb25zL3RhbmdvL3N2ZzJwbmcvZW1vdGVzL2ZhY2Utc21pbGUtMi5zdmerBUU8AAAAAElFTkSuQmCC');
     \OC_Util::obEnd();
     echo $image->show();
 }
Example #29
0
 function __construct()
 {
     $this->l = \OC::$server->getL10N('lib');
     $version = OC_Util::getVersion();
     $this->defaultEntity = 'ownCloud';
     /* e.g. company name, used for footers and copyright notices */
     $this->defaultName = 'ownCloud';
     /* short name, used when referring to the software */
     $this->defaultTitle = 'ownCloud';
     /* can be a longer name, for titles */
     $this->defaultBaseUrl = 'https://owncloud.org';
     $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
     $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
     $this->defaultiTunesAppId = '543672169';
     $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
     $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
     $this->defaultDocVersion = $version[0] . '.' . $version[1];
     // used to generate doc links
     $this->defaultSlogan = $this->l->t('web services under your control');
     $this->defaultLogoClaim = '';
     $this->defaultMailHeaderColor = '#1d2d44';
     /* header color of mail notifications */
     $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
     if (file_exists($themePath)) {
         // prevent defaults.php from printing output
         ob_start();
         require_once $themePath;
         ob_end_clean();
         if (class_exists('OC_Theme')) {
             $this->theme = new OC_Theme();
         }
     }
 }
 public function authenticate(Sabre_DAV_Server $server, $realm)
 {
     $config = array("introspectionEndpoint" => $this->introspectionEndpoint, "realm" => $realm);
     try {
         $resourceServer = new RemoteResourceServer($config);
         $tokenIntrospection = $resourceServer->verifyRequest(apache_request_headers(), $_GET);
         $this->currentUser = $tokenIntrospection->getSub();
         OC_User::setUserid($this->currentUser);
         OC_Util::setupFS($this->currentUser);
         return true;
     } catch (RemoteResourceServerException $e) {
         switch ($e->getMessage()) {
             case "insufficient_entitlement":
             case "insufficient_scope":
                 $server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
                 throw new Sabre_DAV_Exception_Forbidden($e->getDescription());
             case "invalid_request":
                 throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
             case "invalid_token":
             case "no_token":
                 $server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
                 throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
             case "internal_server_error":
                 throw new Sabre_DAV_Exception($e->getDescription());
         }
     }
 }