Esempio n. 1
0
 public function testMail()
 {
     $this->mail = Mail::to('*****@*****.**')->from('jceee <*****@*****.**>')->title('hehe,title des')->content("<h1>content</h1>");
     echo '<pre>';
     var_dump($this->mail);
     exit;
 }
Esempio n. 2
0
 /**
  * Hook comment publishing
  *
  * @param object $Comment
  * @param object $Post
  * @param object $Parent
  * @param object $ParentAuthor
  */
 public function hookCommentPublished($Comment, $Post, $Parent = NULL, $ParentAuthor = NULL)
 {
     // If you post comment to your post
     if ($Post->aid != $Comment->aid) {
         $replace = array('$user_link%' => $this->user->getLink(), '%user_name%' => $this->user->getName(), '%post_link%' => $Post->getLink(), '%post_name%' => $Post->name, '%comment%' => $Comment->body, '%reply_link%' => $Post->getLink() . '#comment-' . $Comment->id);
         $mail = new Mail(array('name' => 'comment.post', 'subject' => t('New comment to your post', 'Mail.templates'), 'body' => str_replace(array_keys($replace), array_values($replace), t('User <a href="%user_link%">%user_name%</a> has published a comment to your post <a href="%post_link%">"%post_name%"</a>:
                         <p><i>%comment%</i></p>
                         <p><a href="%reply_link%">Reply &rarr;</a></p>'))));
         if ($PostAuthor = user($Post->aid)) {
             $mail->to($PostAuthor->email);
             $mail->send();
         }
     }
     /**
      * If you reply and not to yourself
      */
     if ($Parent && $Parent->aid != $this->user->id) {
         $replace = array('$user_link%' => $this->user->getLink(), '%user_name%' => $this->user->getName(), '%post_link%' => $Post->getLink(), '%post_name%' => $Post->name, '%comment%' => $Comment->body, '%reply_link%' => $Post->getLink() . '#comment-' . $Comment->id);
         $mail = new Mail(array('name' => 'comment.reply', 'subject' => t('Reply for your comment', 'Mail.templates'), 'body' => str_replace(array_keys($replace), array_values($replace), t('User <a href="%user_link%">%user_name%</a> has answered for you comment to post <a href="%post_link%">"%post_name%"</a>:
                         <p><i>%comment%</i></p>
                         <p><a href="%reply_link%">Reply &rarr;</a></p>', 'Mail.templates'))));
         $mail->to($ParentAuthor->email);
         $mail->send();
     }
     unset($mail);
 }
Esempio n. 3
0
 public function mail()
 {
     $mail = Mail::to(['*****@*****.**', '*****@*****.**'])->from('M**********r <*****@*****.**>')->title('F**k Me!')->content('<h1>Hello~~</h1>');
     if ($mail instanceof Mail) {
         $mailer = new Nette\Mail\SmtpMailer($mail->config);
         $mailer->send($mail);
     }
 }
Esempio n. 4
0
 public function send_link($id, $hash, $email)
 {
     Mail::$to = $email;
     Mail::$subject = 'registr';
     Mail::$text = '
             link: <br>' . Config::get('site_name') . 'reg/activate/' . $id . '/' . $hash;
     if (Mail::Send()) {
         echo 'send true';
         exit;
     } else {
         echo 'send false';
         exit;
     }
 }
Esempio n. 5
0
 public function home()
 {
     /*$url = parse_url($_SERVER['REQUEST_URI']);
     		$method = $_SERVER['REQUEST_METHOD'];
     		echo '<pre>';
     		var_export($method);
     		var_export($url);
     		echo '</pre>';*/
     #echo '<h1>控制器成功</h1>';
     #
     $this->view = View::make("home")->with('article', Article::first())->withTitle('MFFC : -D')->withFuckMe('OK!');
     //发邮件
     $this->mail = Mail::to(['*****@*****.**'])->from('MontherFucker <*****@*****.**>')->title('hello')->content('<h1>HELLO~~~~~</h1>');
 }
Esempio n. 6
0
 function beforeInsert($db)
 {
     $event = $db->get(new Event($this->event));
     if (Variable::istype('Event', $event) && $event->isActive($db)) {
         $this->hash = crypt($this->name . time() . mt_rand(0, 9999));
         if ($this->mail) {
             $parser = new HtmlParser('thanks.mtpl');
             $parser->setVariable('participant', $this);
             $mail = new Mail('*****@*****.**', 'rhaco kaigi');
             $mail->to($this->mail, $this->name);
             $mail->subject('rhaco kaigi');
             $mail->message($parser->read());
             $mail->send();
         }
         return true;
     }
     return false;
 }
Esempio n. 7
0
 /**
  * User Регистрация
  */
 public function register_action($code = NULL)
 {
     $this->theme->template('User/templates/login');
     if (!config('user.register.active', FALSE)) {
         return error(t('Регистрация отключена администрацией сайта.'));
     }
     if ($this->isLogged()) {
         return error('Вы уже авторизированы!');
     }
     $this->showMenu();
     if ($code) {
         $user = new User();
         $user->hash = $code;
         if ($user->find()) {
             $form = new Form('User/forms/verify');
             $form->email->setValue($user->email);
             if ($result = $form->result()) {
                 $user->object()->extend($result);
                 $result->realname && ($user->name = $result->realname);
                 $user->hashPassword();
                 $user->hash = $this->secure->genHash($user->password);
                 $user->reg_date = time();
                 $user->last_visit = time();
                 if ($user->save()) {
                     event('user.register', $user);
                     if ($user->login()) {
                         flash_success(t('Регистрация завершена!'));
                         redirect($user->getLink());
                     }
                 }
             }
             $form->show();
         } else {
             error(t('Регистрационный код не найден.'));
         }
     } else {
         $form = new Form('User/forms/register');
         if ($result = $form->result()) {
             $user = new User();
             $user->email = $result->email;
             $user->find();
             $user->hash = $this->secure->genHash(date('H d.m.Y') . $this->session->get('ip') . $result->email);
             if (config('user.register.verification', TRUE)) {
                 $verify_link = l('/user/register/' . $user->hash, TRUE);
                 $mail = new Mail(array('name' => 'register.verify', 'subject' => t('Регистрация на сайте %s', SITE_URL), 'body' => t('Вы успешно зарегистрировались на сайте http://%s. <br/>
                         Пожалуйста, перейдите по ссылке ниже, для того чтобы подтвердить данный почтовый ящик:<p>
                         <a href="%s">%s</a>', SITE_URL, $verify_link, $verify_link)));
                 $mail->to($user->email);
                 if ($mail->send()) {
                     $user->save();
                     event('user.confirmation', $user);
                     success(t('Письмо с подтвержденим регистрации было отправлено на почтовый адрес <b>%s</b>. Следуйте инструкциям.', $user->email));
                 }
             } else {
                 $user->save();
                 redirect(l('/user/register/' . $user->hash));
             }
         } else {
             $form->show();
         }
     }
 }
Esempio n. 8
0
    unset($_SESSION['pass']);
}
if (isset($_POST['pass']) && $_POST['pass1'] && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $_POST = trimAll($_POST);
    $_POST = m_r_e_sAll($_POST);
    $_POST = htmlAll($_POST);
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $pass1 = $_POST['pass1'];
    if ($pass == $pass1) {
        $pass = md5($pass);
        //зашифрованный пароль можно использ функцию зашифровки в default myHash
    } else {
        $_SESSION['info'] = 'Пароль не правельный';
        header("Location: ../settings.php");
    }
    if ($email == $_SESSION['user']['email']) {
        mysqli_query($connect, "UPDATE capons SET\n                              pass = '******'\n                              WHERE id = '{$coil}'\n                              ") or die(mysqli_error());
        // $id = mysqli_insert_id($connect); //функция возвращает ID последнего добавленного элемента в БД - что-бы передать ID для проверки активации
        Mail::$to = $_POST['email'];
        //класс Mail вызываеться из папка class Mail  - функцией в файле default
        Mail::$subject = 'Вы зарегестрировались на сайте';
        Mail::$text = '....Вам новый пароль:' . $_POST['pass1'];
        Mail::send();
        header("Location: ..//settings.php");
        exit;
    } else {
        $_SESSION['info'] = 'вы ввели неправельный email';
        header("Location: ../settings.php");
    }
}
 /**
  * Sends the mail
  * 
  * @return bool success
  */
 public function send()
 {
     // Add registered recipient
     parent::to($this->to['email'], $this->to['name']);
     // Get sender from recipient data
     $sender = '';
     if ($this->to['object']) {
         switch (get_class($this->to['object'])) {
             case 'Recipient':
                 $sender = $this->to['object']->transfer->user->email;
                 break;
             case 'Guest':
                 $sender = $this->to['object']->user->email;
                 break;
         }
     }
     if (!$sender) {
         $sender = $this->to['email'];
     }
     // Own action
     // Context identifier
     $context = $this->to['object'] ? strtolower(get_class($this->to['object'])) . '-' . $this->to['object']->id : 'no_context';
     // Build from field depending on config
     $from = Config::get('email_from');
     if ($from) {
         if ($from != 'sender' && !filter_var($from, FILTER_VALIDATE_EMAIL)) {
             throw new ConfigBadParameterException('email_from');
         }
         if ($from == 'sender') {
             $from = $sender;
         }
         // Got one, validate and set header
         if ($from) {
             if (!filter_var($from, FILTER_VALIDATE_EMAIL)) {
                 throw new BadEmailException($from);
             }
             $from_name = Config::get('email_from_name');
             if ($from_name) {
                 $from = '"' . mb_encode_mimeheader($from_name) . '" <' . $from . '>';
             }
             $this->addHeader('From', $from);
         }
     }
     // Build reply-to field depending on config
     $reply_to = Config::get('email_reply_to');
     if ($reply_to) {
         if ($reply_to != 'sender' && !filter_var($reply_to, FILTER_VALIDATE_EMAIL)) {
             throw new ConfigBadParameterException('email_reply_to');
         }
         if ($reply_to == 'sender') {
             $reply_to = $sender;
         }
         // Got one, validate and set header
         if ($reply_to) {
             if (!filter_var($reply_to, FILTER_VALIDATE_EMAIL)) {
                 throw new BadEmailException($reply_to);
             }
             $reply_to_name = Config::get('email_reply_to_name');
             if ($reply_to_name) {
                 $reply_to = '"' . mb_encode_mimeheader($reply_to_name) . '" <' . $reply_to . '>';
             }
             $this->addHeader('Reply-To', $reply_to);
         }
     }
     // Build return path field depending on config
     $return_path = Config::get('email_return_path');
     if ($return_path) {
         if ($return_path != 'sender' && !filter_var(str_replace('<verp>', 'verp', $return_path), FILTER_VALIDATE_EMAIL)) {
             throw new ConfigBadParameterException('email_return_path');
         }
         if ($return_path == 'sender') {
             $return_path = $sender;
         }
         // Got one, validate and set property to be passed to PHP's mail internal
         if ($return_path) {
             // If verp pattern insert context so that return path alone tells which object the bounce is related to
             if (preg_match('`^(.+)<verp>(.+)$`i', $return_path, $match)) {
                 $return_path = $match[1] . $context . $match[2];
             }
             if (!filter_var($return_path, FILTER_VALIDATE_EMAIL)) {
                 throw new BadEmailException($return_path);
             }
             $this->return_path = $return_path;
         }
     }
     // Set context in headers so that it is returned along with bounces
     if ($context) {
         $this->msg_id = '<' . $context . '-' . uniqid() . '@filesender>';
         $this->addHeader('X-Notes-Context', $context);
     }
     // Send email
     return parent::send();
 }
Esempio n. 10
0
 public static function template_new_gameserver_mail($param, $is_resend = false)
 {
     $param = json_decode(json_encode($param), FALSE);
     $user_name = str_replace('@gameloft.com', '', $_SERVER['REMOTE_USER']);
     $user_name = str_replace('.', ' ', ucfirst($user_name));
     //$cc[] = MAIL_MEX;
     foreach ($param as $key => $value) {
         unset($to);
         unset($cc);
         unset($bcc);
         $to[] = ENVIRONMENT == LOCAL || ENVIRONMENT == BETA ? $_SERVER['REMOTE_USER'] : MAIL_OGI;
         $cc[] = ENVIRONMENT == LOCAL || ENVIRONMENT == BETA ? $_SERVER['REMOTE_USER'] : MAIL_MEX;
         $dolly_users = explode(',', $param->{$key}->dolly_users);
         foreach ($dolly_users as $key2 => $value2) {
             if (array_search($value2, $dolly_users)) {
                 if ($value2 == $param->{$key}->requested_by) {
                     unset($dolly_users[$key2]);
                 } else {
                     $cc[] = $value2;
                 }
             }
         }
         $product = Product::load($param->{$key}->product_id)->to_array();
         $product_name = $product['name'];
         $tpl = $param->{$key};
         $tpl->server_type = $key;
         $tpl->comments = $param->{$key}->comments_ogi;
         $tpl->dolly_users = $param->{$key}->dolly_users;
         //Get email template
         ob_start();
         $subject = '[TUNA][chklst] ' . $param->{$key}->environment . ' ' . $key . ' checklist for ' . $product_name;
         include 'mail_templates/new_gameserver_checklist.php';
         $body = ob_get_contents();
         ob_end_clean();
         $m = new Mail('text/plain');
         $m->from($_SERVER['REMOTE_USER']);
         $m->to(@implode(',', $to));
         $m->cc(@implode(',', $cc));
         $m->bcc(@implode(',', $bcc));
         $m->subject($subject);
         $m->body($body);
         $m->send();
     }
     TunaLog::info_log(__CLASS__, __FUNCTION__, $_SERVER['REMOTE_USER'], '');
 }
Esempio n. 11
0
 }
 if ($pass == $pass1) {
     $pass = md5($pass);
     //зашифрованный пароль можно использ функцию зашифровки в default myHash
 } else {
     $_SESSION['info'] = 'Пароль не правельный';
     header("Location: ../passback.php");
     exit;
 }
 if (!isset($_SESSION['info'])) {
     $res = mysqli_query($connect, "SELECT email FROM capons\n                              WHERE email = '{$email}'\n                              ") or die(mysqli_error());
     $row = mysqli_fetch_assoc($res);
     if (isset($row['email'])) {
         mysqli_query($connect, "UPDATE capons SET\n                              pass = '******'\n                              WHERE email = '" . $row['email'] . "'\n                              ") or die(mysqli_error());
         // $id = mysqli_insert_id($connect); //функция возвращает ID последнего добавленного элемента в БД - что-бы передать ID для проверки активации
         Mail::$to = $email;
         //класс Mail вызываеться из папка class Mail  - функцией в файле default
         Mail::$subject = 'Ваш новый пароль для bogdandvinin.zzz.com.ua';
         Mail::$text = 'Вам новый:  ' . $pass1;
         //передем ID полученый из нашего добавленного пользавателя и отправляем через GET для проверки
         Mail::send();
         header("Location: ../passback.php");
         exit;
         // проверка отпраки почты ниже
     } else {
         $_SESSION['info'] = 'вы ввели неправельный email';
         header("Location: ../passback.php");
     }
 }
 /*if(isset()){
       mysqli_query($connect, "UPDATE capons SET
Esempio n. 12
0
 /**
  * @param Mail $mail
  * @throws RuntimeException
  */
 public function tryToSendTheMailOrThrowARuntimeException(Mail $mail)
 {
     $couldNotSent = !mail($mail->to(), $mail->subject(), $mail->content(), 'From: ' . $mail->from());
     if ($couldNotSent) {
         throw new RuntimeException('could not sent the mail' . PHP_EOL . 'values: ' . var_export($mail, true));
     }
 }
Esempio n. 13
0
    }
    if ($pass == $pass1) {
        $pass = md5($pass);
        //зашифрованный пароль можно использ функцию зашифровки в default myHash
    } else {
        $_SESSION['info'] = 'Пароли не совпадают';
        header("Location: ../Sett.php");
        exit;
    }
    if ($_SESSION['user']['pass'] == $pass) {
        $_SESSION['info'] = 'пароль похож на старый';
        header("Location: ../Sett.php");
        exit;
    }
    if ($email == $_SESSION['user']['email']) {
        mysqli_query($connect, "UPDATE capons SET\n                              pass = '******'\n                              WHERE id = '{$coil}'\n                              ") or die(mysqli_error());
        // $id = mysqli_insert_id($connect); //функция возвращает ID последнего добавленного элемента в БД - что-бы передать ID для проверки активации
        Mail::$to = $_SESSION['user']['email'];
        //класс Mail вызываеться из папка class Mail  - функцией в файле default
        Mail::$subject = 'Ваш новый пароль на http://bogdandvinin.zzz.com.ua';
        Mail::$text = 'Ваш новый пароль: ' . $pass1;
        //передем ID полученый из нашего добавленного пользавателя и отправляем через GET для проверки
        Mail::send();
        header("Location: ../Sett.php");
        exit;
        // проверка отпраки почты ниже
    } else {
        $_SESSION['info'] = 'вы ввели неправельный email';
        header("Location: ../Sett.php");
    }
}
Esempio n. 14
0
 /**
  * Create or edit an user
  */
 public function edit()
 {
     $user = App::session()->getUser();
     $roles = array_map(function ($role) {
         return $role->getLabel();
     }, Role::getAll('id'));
     $param = array('id' => 'user-profile-form', 'upload' => true, 'object' => $user, 'fieldsets' => array('general' => array('legend' => Lang::get('admin.user-form-general-legend'), new TextInput(array('name' => 'username', 'required' => true, 'label' => Lang::get('admin.user-form-username-label'), 'disabled' => true)), new EmailInput(array('name' => 'email', 'required' => true, 'label' => Lang::get('admin.user-form-email-label')))), 'profile' => array('legend' => Lang::get('admin.user-form-profile-legend')), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get($this->_plugin . '.valid-button'))))), 'onsuccess' => 'app.dialog("close")');
     // Get the user profile questions
     $questions = ProfileQuestion::getAll('name', array(), array('order' => DB::SORT_ASC));
     // Generate the question fields
     foreach ($questions as $question) {
         if ($question->displayInProfile && $question->isAllowedForRole($user->roleId)) {
             $classname = '\\Hawk\\' . ucwords($question->type) . 'Input';
             $field = json_decode($question->parameters, true);
             $field['name'] = $question->name;
             $field['id'] = 'user-form-' . $question->name . '-input';
             $field['independant'] = true;
             $field['label'] = Lang::get('admin.profile-question-' . $question->name . '-label');
             if (isset($field['readonly'])) {
                 if ($field['readonly']) {
                     $field['required'] = false;
                 }
             }
             if ($user) {
                 if ($question->type == "file") {
                     $field['after'] = sprintf('<img src="%s" class="profile-image" />', $user->getProfileData($question->name) ? $user->getProfileData($question->name) : '');
                 } else {
                     $field['default'] = $user->getProfileData($question->name);
                 }
             }
             if ($question->name == 'language') {
                 // Get language options
                 $languages = Language::getAllActive();
                 $options = array();
                 foreach ($languages as $language) {
                     $options[$language->tag] = $language->label;
                 }
                 $field['options'] = $options;
                 if (!$field['default']) {
                     $field['default'] = Option::get($this->_plugin . '.language');
                 }
             }
             $param['fieldsets']['profile'][] = new $classname($field);
         }
     }
     $form = new Form($param);
     if (!$form->submitted()) {
         return NoSidebarTab::make(array('title' => Lang::get('admin.user-form-title'), 'page' => array('content' => $form)));
     } else {
         try {
             foreach ($questions as $question) {
                 if ($question->displayInProfile && $question->isAllowedForRole($user->roleId)) {
                     if ($question->type === 'file') {
                         $upload = Upload::getInstance($question->name);
                         if ($upload) {
                             $file = $upload->getFile(0);
                             $dir = Plugin::current()->getPublicUserfilesDir() . 'img/';
                             $url = Plugin::current()->getUserfilesUrl() . 'img/';
                             if (!is_dir($dir)) {
                                 mkdir($dir, 0755, true);
                             }
                             $basename = uniqid() . $file->extension;
                             $upload->move($file, $dir, $basename);
                             $user->setProfileData($question->name, $url . $basename);
                         }
                     } else {
                         $user->setProfileData($question->name, $form->inputs[$question->name]->dbvalue());
                     }
                 }
             }
             $user->saveProfile();
             if ($form->getData('email') !== $user->email) {
                 // The user asked to reset it email
                 // Check this email is not used by another user on the application
                 $existingUser = User::getByExample(new DBExample(array('id' => array('$ne' => $user->id), 'email' => $form->getData('email'))));
                 if ($existingUser) {
                     return $form->response(Form::STATUS_CHECK_ERROR, Lang::get($this->_plugin . '.reset-email-already-used'));
                 }
                 // Send the email to validate the new email
                 // Create the token to validate the new email
                 $tokenData = array('userId' => $user->id, 'currentEmail' => $user->email, 'newEmail' => $form->getData('email'), 'createTime' => time());
                 $token = base64_encode(Crypto::aes256Encode(json_encode($tokenData)));
                 // Create the email content
                 $emailContent = View::make($this->getPlugin()->getView('change-email-validation.tpl'), array('sitename' => Option::get($this->_plugin . '.sitename'), 'validationUrl' => App::router()->getUrl('validate-new-email', array('token' => $token))));
                 $email = new Mail();
                 $email->to($form->getData('email'))->from(Option::get('main.mailer-from'), Option::get('main.mailer-from-name'))->title(Lang::get($this->_plugin . '.reset-email-title', array('sitename' => Option::get($this->_plugin . '.sitename'))))->content($emailContent)->subject(Lang::get($this->_plugin . '.reset-email-title', array('sitename' => Option::get($this->_plugin . '.sitename'))))->send();
                 return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.user-profile-update-success-with-email'));
             }
             return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.user-profile-update-success'));
         } catch (Exception $e) {
             return $form->response(Form::STATUS_ERROR, Lang::get($this->_plugin . '.user-profile-update-error'));
         }
     }
 }