Esempio n. 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);
     }
 }
Esempio n. 2
0
 public static function av_scan($path)
 {
     $path = $path[\OC\Files\Filesystem::signal_param_path];
     if ($path != '') {
         $files_view = \OCP\Files::getStorage("files");
         if ($files_view->file_exists($path)) {
             $root = OC_User::getHome(OC_User::getUser()) . '/files';
             $file = $root . $path;
             $result = self::clamav_scan($file);
             switch ($result) {
                 case CLAMAV_SCANRESULT_UNCHECKED:
                     //TODO: Show warning to the user: The file can not be checked
                     break;
                 case CLAMAV_SCANRESULT_INFECTED:
                     //remove file
                     $files_view->unlink($path);
                     OCP\JSON::error(array("data" => array("message" => "Virus detected! Can't upload the file.")));
                     $email = OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
                     \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG);
                     if (!empty($email)) {
                         $tmpl = new OC_Template('files_antivirus', 'notification');
                         $tmpl->assign('file', $path);
                         $tmpl->assign('host', OCP\Util::getServerHost());
                         $tmpl->assign('user', OC_User::getUser());
                         $msg = $tmpl->fetchPage();
                         $from = OCP\Util::getDefaultEmailAddress('security-noreply');
                         OCP\Util::sendMail($email, OC_User::getUser(), 'Malware detected', $msg, $from, 'ownCloud', 1);
                     }
                     exit;
                     break;
                 case CLAMAV_SCANRESULT_CLEAN:
                     //do nothing
                     break;
             }
         }
     }
 }
Esempio n. 3
0
            $l = OC_L10N::get('core');
            // setup the email
            $subject = (string) $l->t('%s shared »%s« with you', array($displayName, $file));
            $content = new OC_Template("core", "mail", "");
            $content->assign('link', $link);
            $content->assign('type', $type);
            $content->assign('user_displayname', $displayName);
            $content->assign('filename', $file);
            $text = $content->fetchPage();
            $content = new OC_Template("core", "altmail", "");
            $content->assign('link', $link);
            $content->assign('type', $type);
            $content->assign('user_displayname', $displayName);
            $content->assign('filename', $file);
            $alttext = $content->fetchPage();
            $default_from = OCP\Util::getDefaultEmailAddress('sharing-noreply');
            $from_address = OCP\Config::getUserValue($user, 'settings', 'email', $default_from);
            // send it out now
            try {
                OCP\Util::sendMail($to_address, $to_address, $subject, $text, $from_address, $displayName, 1, $alttext);
                OCP\JSON::success();
            } catch (Exception $exception) {
                OCP\JSON::error(array('data' => array('message' => OC_Util::sanitizeHTML($exception->getMessage()))));
            }
            break;
    }
} else {
    if (isset($_GET['fetch'])) {
        switch ($_GET['fetch']) {
            case 'getItemsSharedStatuses':
                if (isset($_GET['itemType'])) {