コード例 #1
0
 /**
  *
  */
 function run()
 {
     if ($this->checkGet('app', 'usv2')) {
         $uid = $this->tokens->getUserId();
         if ($uid === false || $uid === null) {
             if ($this->appConfig->getValue('user_servervars2', 'stop_if_empty', false)) {
                 throw new \Exception('token error');
             }
             // Danger: possibilité de fabriquer une boucle avec janus
             $ssoURL = $this->appConfig->getValue('user_servervars2', 'sso_url', 'http://localhost/sso');
             $this->redirector->redirectTo($ssoURL);
         } else {
             $isLoggedIn = $this->uag->isLoggedIn();
             if (!$isLoggedIn) {
                 $isLoggedIn = $this->uag->login($uid);
             }
             if (!$isLoggedIn) {
                 // if ( !$this->uag->isLoggedIn())  {
                 \OC_Log::write('servervars', 'Error trying to log-in the user' . $uid, \OC_Log::DEBUG);
                 return;
             }
             \OC::$REQUESTEDAPP = '';
             $this->redirector->redirectToDefaultPage();
         }
     }
 }
コード例 #2
0
ファイル: scanner.php プロジェクト: CDN-Sparks/owncloud
 public static function scan($id, $path, $storage)
 {
     $file = $storage->getLocalFile($path);
     $result = OC_Files_Antivirus::clamav_scan($file);
     switch ($result) {
         case CLAMAV_SCANRESULT_UNCHECKED:
             \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is not checked', \OCP\Util::ERROR);
             break;
         case CLAMAV_SCANRESULT_INFECTED:
             $infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
             if ($infected_action == 'delete') {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected, file deleted', \OCP\Util::ERROR);
                 unlink($file);
             } else {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected', \OCP\Util::ERROR);
             }
             break;
         case CLAMAV_SCANRESULT_CLEAN:
             $stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
             try {
                 $result = $stmt->execute(array($id, time()));
                 if (\OC_DB::isError($result)) {
                     \OC_Log::write('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                     return;
                 }
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             }
             break;
     }
 }
コード例 #3
0
 public function getThumbnail($path)
 {
     $gallery_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/gallery';
     if (file_exists($gallery_path . $path)) {
         return new \OC_Image($gallery_path . $path);
     }
     if (!\OC_Filesystem::file_exists($path)) {
         \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
     if (!$image->valid()) {
         return false;
     }
     $image->fixOrientation();
     $ret = $image->preciseResize(floor(150 * $image->width() / $image->height()), 150);
     if (!$ret) {
         \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
         unset($image);
         return false;
     }
     $image->save($gallery_path . '/' . $path);
     return $image;
 }
コード例 #4
0
ファイル: hook.php プロジェクト: Kevin-ZK/vaneDisk
 /**
  * emits a signal
  *
  * @param string $signalClass class name of emitter
  * @param string $signalName name of signal
  * @param mixed $params default: array() array with additional data
  * @return bool true if slots exists or false if not
  *
  * Emits a signal. To get data from the slot use references!
  *
  * TODO: write example
  */
 public static function emit($signalClass, $signalName, $params = array())
 {
     // Return false if no hook handlers are listening to this
     // emitting class
     if (!array_key_exists($signalClass, self::$registered)) {
         return false;
     }
     // Return false if no hook handlers are listening to this
     // emitting method
     if (!array_key_exists($signalName, self::$registered[$signalClass])) {
         return false;
     }
     // Call all slots
     foreach (self::$registered[$signalClass][$signalName] as $i) {
         try {
             call_user_func(array($i["class"], $i["name"]), $params);
         } catch (Exception $e) {
             self::$thrownExceptions[] = $e;
             $class = $i["class"];
             if (is_object($i["class"])) {
                 $class = get_class($i["class"]);
             }
             $message = $e->getMessage();
             if (empty($message)) {
                 $message = get_class($e);
             }
             OC_Log::write('hook', 'error while running hook (' . $class . '::' . $i["name"] . '): ' . $message, OC_Log::ERROR);
             if ($e instanceof \OC\ServerNotAvailableException) {
                 throw $e;
             }
         }
     }
     // return true
     return true;
 }
コード例 #5
0
ファイル: svg.php プロジェクト: WYSAC/oregon-owncloud
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     try {
         $svg = new Imagick();
         $svg->setBackgroundColor(new \ImagickPixel('transparent'));
         $content = stream_get_contents($fileview->fopen($path, 'r'));
         if (substr($content, 0, 5) !== '<?xml') {
             $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
         }
         // Do not parse SVG files with references
         if (stripos($content, 'xlink:href') !== false) {
             return false;
         }
         $svg->readImageBlob($content);
         $svg->setImageFormat('png32');
     } catch (\Exception $e) {
         \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
         return false;
     }
     //new image object
     $image = new \OC_Image();
     $image->loadFromData($svg);
     //check if image object is valid
     return $image->valid() ? $image : false;
 }
コード例 #6
0
ファイル: hook.php プロジェクト: droiter/openwrt-on-android
 /**
  * emits a signal
  * @param string $signalclass class name of emitter
  * @param string $signalname name of signal
  * @param mixed $params default: array() array with additional data
  * @return bool, true if slots exists or false if not
  *
  * Emits a signal. To get data from the slot use references!
  *
  * TODO: write example
  */
 public static function emit($signalclass, $signalname, $params = array())
 {
     // Return false if no hook handlers are listening to this
     // emitting class
     if (!array_key_exists($signalclass, self::$registered)) {
         return false;
     }
     // Return false if no hook handlers are listening to this
     // emitting method
     if (!array_key_exists($signalname, self::$registered[$signalclass])) {
         return false;
     }
     // Call all slots
     foreach (self::$registered[$signalclass][$signalname] as $i) {
         try {
             call_user_func(array($i["class"], $i["name"]), $params);
         } catch (Exception $e) {
             OC_Log::write('hook', 'error while running hook (' . $i["class"] . '::' . $i["name"] . '): ' . $e->getMessage(), OC_Log::ERROR);
             if ($e instanceof \OC\ServerNotAvailableException && $signalclass === 'OC_Filesystem' && $signalname === 'setup') {
                 throw $e;
             }
         }
     }
     // return true
     return true;
 }
コード例 #7
0
ファイル: rotate.php プロジェクト: Kevin-ZK/vaneDisk
 protected function rotate($logfile)
 {
     $rotatedLogfile = $logfile . '.1';
     rename($logfile, $rotatedLogfile);
     $msg = 'Log file "' . $logfile . '" was over ' . $this->max_log_size . ' bytes, moved to "' . $rotatedLogfile . '"';
     \OC_Log::write('OC\\Log\\Rotate', $msg, \OC_Log::WARN);
 }
コード例 #8
0
ファイル: adapter.php プロジェクト: Combustible/core
 /**
  * insert the @input values when they do not exist yet
  * @param string $table name
  * @param array $input key->value pairs
  * @return int count of inserted rows
  */
 public function insertIfNotExist($table, $input)
 {
     $query = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($input)) . '`) SELECT ' . str_repeat('?,', count($input) - 1) . '? ' . 'FROM `' . $table . '` WHERE ';
     $inserts = array_values($input);
     foreach ($input as $key => $value) {
         $query .= '`' . $key . '`';
         if (is_null($value)) {
             $query .= ' IS NULL AND ';
         } else {
             $inserts[] = $value;
             $query .= ' = ? AND ';
         }
     }
     $query = substr($query, 0, strlen($query) - 5);
     $query .= ' HAVING COUNT(*) = 0';
     try {
         return $this->conn->executeUpdate($query, $inserts);
     } catch (\Doctrine\DBAL\DBALException $e) {
         $entry = 'DB Error: "' . $e->getMessage() . '"<br />';
         $entry .= 'Offending command was: ' . $query . '<br />';
         \OC_Log::write('core', $entry, \OC_Log::FATAL);
         error_log('DB error: ' . $entry);
         \OC_Template::printErrorPage($entry);
     }
 }
コード例 #9
0
ファイル: user_pwauth.php プロジェクト: netcon-source/apps
 public function checkPassword($uid, $password)
 {
     $uid = strtolower($uid);
     $unix_user = posix_getpwnam($uid);
     // checks if the Unix UID number is allowed to connect
     if (empty($unix_user)) {
         return false;
     }
     //user does not exist
     if (!in_array($unix_user['uid'], $this->pwauth_uid_list)) {
         return false;
     }
     $handle = popen($this->pwauth_bin_path, 'w');
     if ($handle === false) {
         // Can't open pwauth executable
         OC_Log::write('OC_USER_PWAUTH', 'Cannot open pwauth executable, check that it is installed on server.', 3);
         return false;
     }
     if (fwrite($handle, "{$uid}\n{$password}\n") === false) {
         // Can't pipe uid and password
         return false;
     }
     // Is the password valid?
     $result = pclose($handle);
     if ($result == 0) {
         return $uid;
     }
     return false;
 }
コード例 #10
0
 /**
  * insert the @input values when they do not exist yet
  * @param string $table name
  * @param array $input key->value pair, key has to be sanitized properly
  * @throws \OC\HintException
  * @return int count of inserted rows
  */
 public function insertIfNotExist($table, $input)
 {
     $query = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($input)) . '`) SELECT ' . str_repeat('?,', count($input) - 1) . '? ' . 'FROM `' . $table . '` WHERE ';
     $inserts = array_values($input);
     foreach ($input as $key => $value) {
         $query .= '`' . $key . '`';
         if (is_null($value)) {
             $query .= ' IS NULL AND ';
         } else {
             $inserts[] = $value;
             $query .= ' = ? AND ';
         }
     }
     $query = substr($query, 0, strlen($query) - 5);
     $query .= ' HAVING COUNT(*) = 0';
     try {
         return $this->conn->executeUpdate($query, $inserts);
     } catch (\Doctrine\DBAL\DBALException $e) {
         $entry = 'DB Error: "' . $e->getMessage() . '"<br />';
         $entry .= 'Offending command was: ' . $query . '<br />';
         \OC_Log::write('core', $entry, \OC_Log::FATAL);
         $l = \OC::$server->getL10N('lib');
         throw new \OC\HintException($l->t('Database Error'), $l->t('Please contact your system administrator.'), 0, $e);
     }
 }
コード例 #11
0
ファイル: office-cl.php プロジェクト: olucao/owncloud-core
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = get_temp_dir();
     $defaultParameters = ' --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);
     $export = 'export HOME=/' . $tmpDir;
     shell_exec($export . "\n" . $exec);
     //create imagick object from pdf
     try {
         $pdf = new \imagick($absPath . '.pdf' . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         unlink($absPath);
         unlink($absPath . '.pdf');
         \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($absPath . '.pdf');
     return $image->valid() ? $image : false;
 }
コード例 #12
0
ファイル: connection.php プロジェクト: olucao/owncloud-core
 /**
  * Prepares an SQL statement.
  *
  * @param string $statement The SQL statement to prepare.
  * @param int $limit
  * @param int $offset
  * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
  */
 public function prepare($statement, $limit = null, $offset = null)
 {
     if ($limit === -1) {
         $limit = null;
     }
     if (!is_null($limit)) {
         $platform = $this->getDatabasePlatform();
         $statement = $platform->modifyLimitQuery($statement, $limit, $offset);
     } else {
         if (isset($this->preparedQueries[$statement]) && $this->cachingQueryStatementEnabled) {
             return $this->preparedQueries[$statement];
         }
         $origStatement = $statement;
     }
     $statement = $this->replaceTablePrefix($statement);
     $statement = $this->adapter->fixupStatement($statement);
     if (\OC_Config::getValue('log_query', false)) {
         \OC_Log::write('core', 'DB prepare : ' . $statement, \OC_Log::DEBUG);
     }
     $result = parent::prepare($statement);
     if (is_null($limit) && $this->cachingQueryStatementEnabled) {
         $this->preparedQueries[$origStatement] = $result;
     }
     return $result;
 }
コード例 #13
0
ファイル: office.php プロジェクト: adolfo2103/hcloudfilem
 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = get_temp_dir();
     $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);
         \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($pdfPreview);
     return $image->valid() ? $image : false;
 }
コード例 #14
0
ファイル: mail.php プロジェクト: noci2012/owncloud
 /**
  * send an email
  *
  * @param string $toaddress
  * @param string $toname
  * @param string $subject
  * @param string $mailtext
  * @param string $fromaddress
  * @param string $fromname
  * @param bool $html
  */
 public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '')
 {
     $SMTPMODE = OC_Config::getValue('mail_smtpmode', 'sendmail');
     $SMTPHOST = OC_Config::getValue('mail_smtphost', '127.0.0.1');
     $SMTPAUTH = OC_Config::getValue('mail_smtpauth', false);
     $SMTPUSERNAME = OC_Config::getValue('mail_smtpname', '');
     $SMTPPASSWORD = OC_Config::getValue('mail_smtppassword', '');
     $mailo = new PHPMailer(true);
     if ($SMTPMODE == 'sendmail') {
         $mailo->IsSendmail();
     } elseif ($SMTPMODE == 'smtp') {
         $mailo->IsSMTP();
     } elseif ($SMTPMODE == 'qmail') {
         $mailo->IsQmail();
     } else {
         $mailo->IsMail();
     }
     $mailo->Host = $SMTPHOST;
     $mailo->SMTPAuth = $SMTPAUTH;
     $mailo->Username = $SMTPUSERNAME;
     $mailo->Password = $SMTPPASSWORD;
     $mailo->From = $fromaddress;
     $mailo->FromName = $fromname;
     $mailo->Sender = $fromaddress;
     $a = explode(' ', $toaddress);
     try {
         foreach ($a as $ad) {
             $mailo->AddAddress($ad, $toname);
         }
         if ($ccaddress != '') {
             $mailo->AddCC($ccaddress, $ccname);
         }
         if ($bcc != '') {
             $mailo->AddBCC($bcc);
         }
         $mailo->AddReplyTo($fromaddress, $fromname);
         $mailo->WordWrap = 50;
         if ($html == 1) {
             $mailo->IsHTML(true);
         } else {
             $mailo->IsHTML(false);
         }
         $mailo->Subject = $subject;
         if ($altbody == '') {
             $mailo->Body = $mailtext . OC_MAIL::getfooter();
             $mailo->AltBody = '';
         } else {
             $mailo->Body = $mailtext;
             $mailo->AltBody = $altbody;
         }
         $mailo->CharSet = 'UTF-8';
         $mailo->Send();
         unset($mailo);
         OC_Log::write('mail', 'Mail from ' . $fromname . ' (' . $fromaddress . ')' . ' to: ' . $toname . '(' . $toaddress . ')' . ' subject: ' . $subject, OC_Log::DEBUG);
     } catch (Exception $exception) {
         OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
         throw $exception;
     }
 }
コード例 #15
0
 /**
  * write a message in the log
  * @param string $app
  * @param string $message
  * @param int level
  */
 public static function write($app, $message, $level)
 {
     if (!self::$class) {
         self::$class = 'OC_Log_' . ucfirst(OC_Config::getValue('log_type', 'owncloud'));
         call_user_func(array(self::$class, 'init'));
     }
     $log_class = self::$class;
     $log_class::write($app, $message, $level);
 }
コード例 #16
0
ファイル: hooks.php プロジェクト: nanowish/apps
 public static function logout($parameters)
 {
     $samlBackend = new OC_USER_SAML();
     if ($samlBackend->auth->isAuthenticated()) {
         OC_Log::write('saml', 'Executing SAML logout: ' . $parameters['uid'], OC_Log::DEBUG);
         $samlBackend->auth->logout();
     }
     return true;
 }
コード例 #17
0
ファイル: naturalsort.php プロジェクト: Kevin-ZK/vaneDisk
 /**
  * Instantiate a new \OC\NaturalSort instance.
  * @param object $injectedCollator
  */
 public function __construct($injectedCollator = null)
 {
     // inject an instance of \Collator('en_US') to force using the php5-intl Collator
     // or inject an instance of \OC\NaturalSort_DefaultCollator to force using Owncloud's default collator
     if (isset($injectedCollator)) {
         $this->collator = $injectedCollator;
         \OC_Log::write('core', 'forced use of ' . get_class($injectedCollator), \OC_Log::DEBUG);
     }
 }
コード例 #18
0
 private function getJSON()
 {
     $con = @file_get_contents($this->url);
     if ($con != '') {
         $this->json = json_decode($con);
         return true;
     } else {
         \OC_Log::write('dashboard', "Bitcoin price could not be loaded.", \OC_Log::WARN);
         return false;
     }
 }
コード例 #19
0
ファイル: main.php プロジェクト: pierre-alain-b/passwords
function isSecure()
{
    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (false !== strpos($url, 'd=1')) {
        OC_Log::write('passwords', 'Passwords app accessed without secure connection.', OC_Log::WARN);
        return true;
    }
    // test if at least one is true in:
    // (1) header, (2) port number, (3) config.php setting, (4) admin setting
    return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 || \OC_Config::getValue('forcessl', '') || \OCP\Config::getAppValue('passwords', 'https_check', 'true') == 'false';
}
コード例 #20
0
ファイル: hooks.php プロジェクト: AdamWill/apps
 public static function logout($parameters)
 {
     $samlBackend = new OC_USER_SAML();
     if ($samlBackend->auth->isAuthenticated()) {
         OC_Log::write('saml', 'Executing SAML logout', OC_Log::DEBUG);
         unset($_COOKIE["SimpleSAMLAuthToken"]);
         setcookie('SimpleSAMLAuthToken', '', time() - 3600, \OC::$WEBROOT);
         setcookie('SimpleSAMLAuthToken', '', time() - 3600, \OC::$WEBROOT . '/');
         $samlBackend->auth->logout();
     }
     return true;
 }
コード例 #21
0
ファイル: hooks.php プロジェクト: CDN-Sparks/owncloud
 /**
  * @brief Startup encryption backend upon user login
  * @note This method should never be called for users using client side encryption
  */
 public static function login($params)
 {
     $l = new \OC_L10N('files_encryption');
     //check if all requirements are met
     if (!Helper::checkRequirements()) {
         $error_msg = $l->t("Missing requirements.");
         $hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that the OpenSSL PHP extension is enabled and configured properly. For now, the encryption app has been disabled.');
         \OC_App::disable('files_encryption');
         \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);
         \OCP\Template::printErrorPage($error_msg, $hint);
     }
     $view = new \OC_FilesystemView('/');
     // ensure filesystem is loaded
     if (!\OC\Files\Filesystem::$loaded) {
         \OC_Util::setupFS($params['uid']);
     }
     $util = new Util($view, $params['uid']);
     // setup user, if user not ready force relogin
     if (Helper::setupUser($util, $params['password']) === false) {
         return false;
     }
     $encryptedKey = Keymanager::getPrivateKey($view, $params['uid']);
     $privateKey = Crypt::decryptPrivateKey($encryptedKey, $params['password']);
     if ($privateKey === false) {
         \OCP\Util::writeLog('Encryption library', 'Private key for user "' . $params['uid'] . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access', \OCP\Util::ERROR);
     }
     $session = new \OCA\Encryption\Session($view);
     $session->setPrivateKey($privateKey);
     // Check if first-run file migration has already been performed
     $ready = false;
     if ($util->getMigrationStatus() === Util::MIGRATION_OPEN) {
         $ready = $util->beginMigration();
     }
     // If migration not yet done
     if ($ready) {
         $userView = new \OC_FilesystemView('/' . $params['uid']);
         // Set legacy encryption key if it exists, to support
         // depreciated encryption system
         if ($userView->file_exists('encryption.key') && ($encLegacyKey = $userView->file_get_contents('encryption.key'))) {
             $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
             $session->setLegacyKey($plainLegacyKey);
         }
         // Encrypt existing user files:
         // This serves to upgrade old versions of the encryption
         // app (see appinfo/spec.txt)
         if ($util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])) {
             \OC_Log::write('Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed', \OC_Log::INFO);
         }
         // Register successful migration in DB
         $util->finishMigration();
     }
     return true;
 }
コード例 #22
0
ファイル: hooks.php プロジェクト: omusico/isle-web-framework
 /**
  * @brief Startup encryption backend upon user login
  * @note This method should never be called for users using client side encryption
  */
 public static function login($params)
 {
     if (\OCP\App::isEnabled('files_encryption') === false) {
         return true;
     }
     $l = new \OC_L10N('files_encryption');
     $view = new \OC_FilesystemView('/');
     // ensure filesystem is loaded
     if (!\OC\Files\Filesystem::$loaded) {
         \OC_Util::setupFS($params['uid']);
     }
     $privateKey = \OCA\Encryption\Keymanager::getPrivateKey($view, $params['uid']);
     // if no private key exists, check server configuration
     if (!$privateKey) {
         //check if all requirements are met
         if (!Helper::checkRequirements() || !Helper::checkConfiguration()) {
             $error_msg = $l->t("Missing requirements.");
             $hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled.');
             \OC_App::disable('files_encryption');
             \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);
             \OCP\Template::printErrorPage($error_msg, $hint);
         }
     }
     $util = new Util($view, $params['uid']);
     // setup user, if user not ready force relogin
     if (Helper::setupUser($util, $params['password']) === false) {
         return false;
     }
     $session = $util->initEncryption($params);
     // Check if first-run file migration has already been performed
     $ready = false;
     if ($util->getMigrationStatus() === Util::MIGRATION_OPEN) {
         $ready = $util->beginMigration();
     }
     // If migration not yet done
     if ($ready) {
         $userView = new \OC_FilesystemView('/' . $params['uid']);
         // Set legacy encryption key if it exists, to support
         // depreciated encryption system
         if ($userView->file_exists('encryption.key') && ($encLegacyKey = $userView->file_get_contents('encryption.key'))) {
             $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
             $session->setLegacyKey($plainLegacyKey);
         }
         // Encrypt existing user files:
         if ($util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])) {
             \OC_Log::write('Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed', \OC_Log::INFO);
         }
         // Register successful migration in DB
         $util->finishMigration();
     }
     return true;
 }
コード例 #23
0
 /**
  * get the possible paths for a class
  *
  * @param string $class
  * @return array|bool an array of possible paths or false if the class is not part of ownCloud
  */
 public function findClass($class)
 {
     $class = trim($class, '\\');
     $paths = array();
     if (array_key_exists($class, $this->classPaths)) {
         $paths[] = $this->classPaths[$class];
     } else {
         if ($this->useGlobalClassPath and array_key_exists($class, \OC::$CLASSPATH)) {
             $paths[] = \OC::$CLASSPATH[$class];
             /**
              * @TODO: Remove this when necessary
              * Remove "apps/" from inclusion path for smooth migration to mutli app dir
              */
             if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) {
                 \OC_Log::write('core', 'include path for class "' . $class . '" starts with "apps/"', \OC_Log::DEBUG);
                 $paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]);
             }
         } elseif (strpos($class, 'OC_') === 0) {
             // first check for legacy classes if underscores are used
             $paths[] = 'private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
             $paths[] = 'private/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
         } elseif (strpos($class, 'OC\\') === 0) {
             $paths[] = 'private/' . strtolower(str_replace('\\', '/', substr($class, 3)) . '.php');
             $paths[] = strtolower(str_replace('\\', '/', substr($class, 3)) . '.php');
         } elseif (strpos($class, 'OCP\\') === 0) {
             $paths[] = 'public/' . strtolower(str_replace('\\', '/', substr($class, 4)) . '.php');
         } elseif (strpos($class, 'OCA\\') === 0) {
             list(, $app, $rest) = explode('\\', $class, 3);
             $app = strtolower($app);
             foreach (\OC::$APPSROOTS as $appDir) {
                 if (stream_resolve_include_path($appDir['path'] . '/' . $app)) {
                     $paths[] = $appDir['path'] . '/' . $app . '/' . strtolower(str_replace('\\', '/', $rest) . '.php');
                     // If not found in the root of the app directory, insert '/lib' after app id and try again.
                     $paths[] = $appDir['path'] . '/' . $app . '/lib/' . strtolower(str_replace('\\', '/', $rest) . '.php');
                 }
             }
         } elseif (strpos($class, 'Test_') === 0) {
             $paths[] = 'tests/lib/' . strtolower(str_replace('_', '/', substr($class, 5)) . '.php');
         } elseif (strpos($class, 'Test\\') === 0) {
             $paths[] = 'tests/lib/' . strtolower(str_replace('\\', '/', substr($class, 5)) . '.php');
         } else {
             foreach ($this->prefixPaths as $prefix => $dir) {
                 if (0 === strpos($class, $prefix)) {
                     $path = str_replace('\\', '/', $class) . '.php';
                     $path = str_replace('_', '/', $path);
                     $paths[] = $dir . '/' . $path;
                 }
             }
         }
     }
     return $paths;
 }
コード例 #24
0
 /**
  * Notify member about file/folder sharing
  */
 public static function notifyFileShare($args)
 {
     try {
         if (strcasecmp($args['itemType'], 'file') == 0 || strcasecmp($args['itemType'], 'folder') == 0) {
             $content = 'A ' . $args['itemType'] . ' has been shared with you at location /Shared' . $args['fileTarget'];
             OC_Collaboration_Post::createPost('File Shared', $content, $args['uidOwner'], NULL, 'File Share', array($args['shareWith']));
             OC_Log::write('collaboration', 'File share notification posted.', OCP\Util::INFO);
         }
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
コード例 #25
0
ファイル: vobject.php プロジェクト: noci2012/owncloud
 /**
  * @brief Parses the VObject
  * @param string VObject as string
  * @returns Sabre_VObject or null
  */
 public static function parse($data)
 {
     try {
         Sabre_VObject_Property::$classMap['LAST-MODIFIED'] = 'Sabre_VObject_Property_DateTime';
         $vobject = Sabre_VObject_Reader::read($data);
         if ($vobject instanceof Sabre_VObject_Component) {
             $vobject = new OC_VObject($vobject);
         }
         return $vobject;
     } catch (Exception $e) {
         OC_Log::write('vobject', $e->getMessage(), OC_Log::ERROR);
         return null;
     }
 }
コード例 #26
0
ファイル: mount.php プロジェクト: hjimmy/owncloud
 /**
  * create the storage that is mounted
  *
  * @return \OC\Files\Storage\Storage
  */
 private function createStorage()
 {
     if (class_exists($this->class)) {
         try {
             return $this->loader->load($this->mountPoint, $this->class, $this->arguments);
         } catch (\Exception $exception) {
             \OC_Log::write('core', $exception->getMessage(), \OC_Log::ERROR);
             return null;
         }
     } else {
         \OC_Log::write('core', 'storage backend ' . $this->class . ' not found', \OC_Log::ERROR);
         return null;
     }
 }
コード例 #27
0
ファイル: user_saml.php プロジェクト: blablubli/owncloudapps
 public function checkPassword($uid, $password)
 {
     if (!$this->auth->isAuthenticated()) {
         return false;
     }
     $attributes = $this->auth->getAttributes();
     if (array_key_exists($this->usernameMapping, $attributes)) {
         $uid = $attributes[$this->usernameMapping][0];
         OC_Log::write('saml', 'Authenticated user ' . $uid, OC_Log::DEBUG);
     } else {
         OC_Log::write('saml', 'Not found attribute used to get the username ("' . $this->usernameMapping . '") at the requested saml attribute assertion', OC_Log::DEBUG);
     }
     return $uid;
 }
コード例 #28
0
ファイル: file.php プロジェクト: olucao/owncloud-core
 /**
  * Returns the cache storage for the logged in user
  * @return \OC\Files\View cache storage
  */
 protected function getStorage()
 {
     if (isset($this->storage)) {
         return $this->storage;
     }
     if (\OC_User::isLoggedIn()) {
         \OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
         $this->storage = new \OC\Files\View('/' . \OC_User::getUser() . '/cache');
         return $this->storage;
     } else {
         \OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
         throw new \OC\ForbiddenException('Can\\t get cache storage, user not logged in');
     }
 }
コード例 #29
0
ファイル: user_webdavauth.php プロジェクト: ryanshoover/core
 public function checkPassword($uid, $password)
 {
     $url = 'http://' . urlencode($uid) . ':' . urlencode($password) . '@' . $this->webdavauth_url;
     $headers = get_headers($url);
     if ($headers == false) {
         OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to connect to WebDAV Url: "' . $this->webdavauth_url . '" ', 3);
         return false;
     }
     $returncode = substr($headers[0], 9, 3);
     if ($returncode == '401' or $returncode == '403') {
         return false;
     } else {
         return $uid;
     }
 }
コード例 #30
0
ファイル: mysql.php プロジェクト: riso/owncloud-core
 private function createDatabase($connection)
 {
     $name = $this->dbname;
     $user = $this->dbuser;
     //we cant use OC_BD functions here because we need to connect as the administrative user.
     $query = "CREATE DATABASE IF NOT EXISTS `{$name}` CHARACTER SET utf8 COLLATE utf8_bin;";
     $result = mysql_query($query, $connection);
     if (!$result) {
         $entry = $this->trans->t('DB Error: "%s"', array(mysql_error($connection))) . '<br />';
         $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
         \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
     }
     $query = "GRANT ALL PRIVILEGES ON `{$name}` . * TO '{$user}'";
     //this query will fail if there aren't the right permissions, ignore the error
     mysql_query($query, $connection);
 }