コード例 #1
1
ファイル: password.php プロジェクト: HarriLu/gallery3
 private function _send_reset($form)
 {
     $user_name = $form->reset->inputs["name"]->value;
     $user = user::lookup_by_name($user_name);
     if ($user && !empty($user->email)) {
         $user->hash = random::hash();
         $user->save();
         $message = new View("reset_password.html");
         $message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
         $message->user = $user;
         Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->message($message->render())->send();
         log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
     } else {
         if (!$user) {
             // Don't include the username here until you're sure that it's XSS safe
             log::warning("user", t("Password reset email requested for user %user_name, which does not exist.", array("user_name" => $user_name)));
         } else {
             log::warning("user", t("Password reset failed for %user_name (has no email address on record).", array("user_name" => $user->name)));
         }
     }
     // Always pretend that an email has been sent to avoid leaking
     // information on what user names are actually real.
     message::success(t("Password reset email sent"));
     json::reply(array("result" => "success"));
 }
コード例 #2
0
ファイル: update-showtimes.php プロジェクト: xxdf/showtimes
function update_showtimes()
{
    $start = microtime(true);
    $path = Env::path() . 'cinema/br';
    $cinemas = Helper::get_file_list($path);
    $updated = array();
    $invalid = array();
    $erros = array();
    foreach ($cinemas as $value) {
        $classname = basename($value, '.php');
        try {
            if (class_exists($classname)) {
                $cinema_class = new $classname();
                $cinema = $cinema_class->update();
                if (!empty($cinema)) {
                    $updated[] = $cinema;
                    if ($cinema->status == 'INVALID') {
                        $invalid[] = $cinema;
                    }
                }
            }
        } catch (Exception $e) {
            $erros[] = $classname . ' - ' . $e->getMessage();
        }
    }
    if (count($updated) > 0) {
        callback_subscribers($updated);
        Sendmail::to_admin(count($updated) . " cinemas atualizados", $updated);
    }
    Sendmail::to_admin(count($invalid) . " cinemas invalidos", $invalid);
    Sendmail::to_admin(count($erros) . " erros atualizando cinemas", $erros);
    $total = Helper::elapsed_time($start);
    Log::write("Tempo total atualizando cinemas: {$total}");
}
コード例 #3
0
ファイル: password.php プロジェクト: ChrisRut/gallery3
 private function _send_reset()
 {
     $form = $this->_reset_form();
     $valid = $form->validate();
     if ($valid) {
         $user = user::lookup_by_name($form->reset->inputs["name"]->value);
         if (!$user->loaded || empty($user->email)) {
             $form->reset->inputs["name"]->add_error("no_email", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $user->hash = md5(rand());
         $user->save();
         $message = new View("reset_password.html");
         $message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
         $message->user = $user;
         Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send();
         log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
     } else {
         // Don't include the username here until you're sure that it's XSS safe
         log::warning("user", "Password reset email requested for bogus user");
     }
     message::success(t("Password reset email sent"));
     print json_encode(array("result" => "success"));
 }
コード例 #4
0
ファイル: discover-cinemas.php プロジェクト: xxdf/showtimes
function find_cinemas_brazil()
{
    $start = microtime(true);
    $cinemas_br = Env::path('temp/brasil.json');
    $cinemas_br = file_get_contents($cinemas_br);
    $cinemas_br = json_decode($cinemas_br);
    //loop em todos os estados e cidades do estado
    $new_cinemas = array();
    $invalid_cinemas = array();
    foreach ($cinemas_br as $value) {
        $estado = $value->nome;
        $uf = $value->codigo;
        $cidades = $value->cidades;
        $cinema_finder = new CinemaFinder('br', $uf, $cidades);
        $cinemas = $cinema_finder->get_all_cinemas();
        $template = new CinemaTemplate();
        foreach ($cinemas as $cinema) {
            $base_dir = "cinema/br/";
            //passa o codigo do estado temporariamente para depois alterar e verificar se o cinema é realmente desse local
            $cinema->state_code = $uf;
            $template->create($base_dir, $cinema);
        }
        $new_cinemas = array_merge($new_cinemas, $template->get_new_cinemas());
        $invalid_cinemas = array_merge($invalid_cinemas, $template->get_invalid_cinemas());
    }
    $total = Helper::elapsed_time($start);
    Log::write("Tempo total procurando cinemas: {$total}");
    Sendmail::to_admin(count($new_cinemas) . " cinemas novos", $new_cinemas);
    Sendmail::to_admin(count($invalid_cinemas) . " cinemas sem cidade", $invalid_cinemas);
}
コード例 #5
0
ファイル: Example.php プロジェクト: 469306621/Languages
	public function send_mail() {
		$tmpl = Template::mail('example.php');
		$tmpl->replace(array(
			'name' => 'John Smith'
		));
	
		Sendmail::send(array(
			'to' 		=> '*****@*****.**',
			'subject' 	=> 'Hello new user!',
			'body'		=> 	$tmpl->render()
		));
	}
コード例 #6
0
ファイル: ecard.php プロジェクト: Glooper/gallery3-contrib
 private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc)
 {
     $sendmail = Sendmail::factory();
     $sendmail->to($to)->from($from)->subject($subject);
     if (isset($bcc)) {
         $sendmail->header("bcc", $bcc);
     }
     foreach ($headers as $key => $value) {
         $sendmail->header($key, $value);
     }
     $sendmail->message($text)->send();
     return;
 }
コード例 #7
0
ファイル: user_profile.php プロジェクト: andyst/gallery3
 public function send($id)
 {
     access::verify_csrf();
     $user = identity::lookup_user($id);
     $form = user_profile::get_contact_form($user);
     if ($form->validate()) {
         Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
         message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
         print json_encode(array("result" => "success"));
     } else {
         print json_encode(array("result" => "error", "form" => (string) $form));
     }
 }
コード例 #8
0
ファイル: Sendmail.php プロジェクト: huzhaer/yaf-web
 private static function connect()
 {
     self::$connection = $connection = fsockopen(self::$smtp, self::$port);
     if ($connection) {
         fgets($connection);
         //必须要获取一次,否则下次读取的是上一次的值
         self::write('HELO ' . self::$smtp . "\r\n", 250);
         self::write("auth login \r\n", 334);
         self::write(base64_encode(self::$user) . "\r\n", 334);
         self::write(base64_encode(self::$pwd) . "\r\n", 235);
     } else {
         exit('请检查邮件类成员属性是否正确');
     }
 }
コード例 #9
0
ファイル: user_profile.php プロジェクト: kandsten/gallery3
 public function send($id)
 {
     access::verify_csrf();
     $user = identity::lookup_user($id);
     if (!$this->_can_view_profile_pages($user)) {
         throw new Kohana_404_Exception();
     }
     $form = user_profile::get_contact_form($user);
     if ($form->validate()) {
         Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
         message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
         json::reply(array("result" => "success"));
     } else {
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
コード例 #10
0
ファイル: 500.php プロジェクト: jedaika/Trainings
    function displayBody()
    {
        Sendmail::toAdmin();
        parent::displayBody();
        $translator = new Translator();
        echo <<<EOF
<div class="container">
      <div class="page-header">
        <h1>{$translator->Error_500_Header}</h1>
      </div>
      <p class="lead">{$translator->Error_500_Desc}</p>
      <p >{$translator->Error_Back}</p>
</div>

EOF;
    }
コード例 #11
0
ファイル: register_user.php プロジェクト: jedaika/Trainings
    function addUser()
    {
        $translator = new Translator();
        $user = new User();
        try {
            $user->add($_POST);
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->User_registered}</h1>
      </div>
   <p class="lead">{$translator->User_registered_Desc}</p>
      <p >{$translator->Error_Back}</p>
</div>

EOF;
        } catch (Exception $e) {
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->Error_User_register}</h1>
      </div>

EOF;
            switch ($e->getCode()) {
                case User::EXISTS:
                    echo "   <p class=\"lead\">{$translator->Error_User_exists_Desc}</p>";
                    break;
                case User::NO_DATA:
                    echo "   <p class=\"lead\">{$translator->Error_User_no_data_Desc}</p>";
                    break;
                case User::BAD_PASSWORD:
                    echo "   <p class=\"lead\">{$translator->Error_User_bad_password_Desc}</p>";
                    break;
                default:
                    echo "   <p class=\"lead\">{$translator->Error_User_register_Desc}</p>";
                    Sendmail::toAdmin(var_export($e, true));
            }
            echo <<<EOF
      <p >{$translator->Error_Back}</p>
</div>

EOF;
        }
    }
コード例 #12
0
ファイル: notification.php プロジェクト: kandsten/gallery3
 private static function _notify($email, $locale, $item, $text, $subject)
 {
     if (!batch::in_progress()) {
         Sendmail::factory()->to($email)->subject($subject)->header("Mime-Version", "1.0")->header("Content-Type", "text/html; charset=UTF-8")->message($text)->send();
     } else {
         $pending = ORM::factory("pending_notification");
         $pending->subject = $subject;
         $pending->text = $text;
         $pending->email = $email;
         $pending->locale = $locale;
         $pending->save();
     }
 }
コード例 #13
0
ファイル: register.php プロジェクト: Glooper/gallery3-contrib
 private static function _sendemail($email, $subject, $message)
 {
     Sendmail::factory()->to($email)->subject($subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send();
 }
コード例 #14
0
ファイル: notification.php プロジェクト: xafr/gallery3
 private static function _notify_subscribers($item, $text, $subject)
 {
     $users = self::get_subscribers($item);
     if (!empty($users)) {
         if (!batch::in_progress()) {
             Sendmail::factory()->to($users)->subject($subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($text)->send();
         } else {
             foreach ($users as $user) {
                 $pending = ORM::factory("pending_notification");
                 $pending->subject = $subject;
                 $pending->text = $text;
                 $pending->email = $user;
                 $pending->save();
             }
         }
     }
 }
コード例 #15
0
 private static function _send_message($item, $body)
 {
     $users = self::get_subscribers($item);
     if (!empty($users)) {
         Sendmail::factory()->to($users)->subject($body->subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($body->render())->send();
     }
 }
コード例 #16
0
ファイル: recover.php プロジェクト: Kloadut/noalyss_ynh
        list($user_id, $user_email, $user_login) = array_values($array[0]);
        if (trim($user_email) != " ") {
            $valid = true;
        }
    }
    if ($valid == true) {
        $request_id = generate_random(SIZE_REQUEST);
        $user_password = generate_random(10);
        /*
         * save the request into 
         */
        $cn->exec_sql("insert into recover_pass(use_id,request,password,created_on,created_host) " . " values (\$1,\$2,\$3,now(),\$4)", array($user_id, $request_id, $user_password, $_SERVER['REMOTE_ADDR']));
        /*
         * send an email
         */
        $mail = new Sendmail();
        $mail->set_from(ADMIN_WEB);
        $mail->mailto($user_email);
        $mail->set_subject("NOALYSS : Réinitialisation de mot de passe");
        $message = <<<EOF
     Bonjour,
      
Une demande de réinitialisation de votre mot de passe a été demandée par {$_SERVER['REMOTE_ADDR']}
   
Votre nom d'utilisateur est {$user_login}
Votre mot de passe est {$user_password}

Suivez ce lien pour activer le changement ou ignorer ce message si vous n'êtes pas l'auteur de cette demande.
Ce lien ne sera actif que 12 heures.
   
   
コード例 #17
0
 public function sendemail($user_id)
 {
     // Validate the form, then send the actual email.
     // If this page is disabled, show a 404 error.
     if ($user_id == "-1" && module::get_var("contactowner", "contact_owner_link") != true) {
         throw new Kohana_404_Exception();
     } elseif ($user_id >= 0 && module::get_var("contactowner", "contact_user_link") != true) {
         throw new Kohana_404_Exception();
     }
     // Make sure the form submission was valid.
     $form = $this->get_email_form($user_id);
     $valid = $form->validate();
     if ($valid) {
         // Copy the data from the email form into a couple of variables.
         $str_emailsubject = Input::instance()->post("email_subject");
         $str_emailfrom = Input::instance()->post("email_from");
         $str_emailbody = Input::instance()->post("email_body");
         // Add in some <br> tags to the message body where ever there are line breaks.
         $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
         // Gallery's Sendmail library doesn't allow for custom from addresses,
         //   so add the from email to the beginning of the message body instead.
         //   Also add in the admin-defined message header.
         $str_emailbody = module::get_var("contactowner", "contact_owner_header") . "<br/>\r\n" . "Message Sent From " . $str_emailfrom . "<br/>\r\n<br/>\r\n" . $str_emailbody;
         // Figure out where the email is going to.
         $str_emailto = "";
         if ($user_id == -1) {
             // If the email id is "-1" send the message to a pre-determined
             //   owner email address.
             $str_emailto = module::get_var("contactowner", "contact_owner_email");
         } else {
             // or else grab the email from the user table.
             $userDetails = ORM::factory("user")->where("id", "=", $user_id)->find_all();
             $str_emailto = $userDetails[0]->email;
         }
         // Send the email message.
         Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send();
         message::info(t("Your Message Has Been Sent."));
         json::reply(array("result" => "success"));
     } else {
         // Set up and display the actual page.
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
コード例 #18
0
 public function sendemail()
 {
     // Process the data from the form into an email,
     //   then send the email.
     // Copy the data from the email from into a couple of variables.
     $str_emailsubject = Input::instance()->post("email_subject");
     $str_emailtoid = Input::instance()->post("email_to_id");
     $str_emailfrom = Input::instance()->post("email_from");
     $str_emailbody = Input::instance()->post("email_body");
     // Add in some <br> tags to the message body where ever there are line breaks.
     $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
     // Gallery's Sendmail library doesn't allow for custom from addresses,
     //   so add the from email to the beginning of the message body instead.
     $str_emailbody = "Message Sent From " . $str_emailfrom . "\r\n\r\n<br/><br/>" . $str_emailbody;
     // Figure out where the email is going to.
     $str_emailto = "";
     if ($str_emailtoid == -1) {
         // If the email id is "-1" send the message to a pre-determined
         //   owner email address.
         $str_emailto = module::get_var("contactowner", "contact_owner_email");
     } else {
         // or else grab the email from the user table.
         $userDetails = ORM::factory("user")->where("id", $str_emailtoid)->find_all();
         $str_emailto = $userDetails[0]->email;
     }
     // Send the email message.
     Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send();
     // Display a message telling the visitor that their email has been sent.
     $template = new Theme_View("page.html", "Contact");
     $template->content = new View("contactowner_emailform.html");
     $template->content->sendmail_form = t("Your Message Has Been Sent.");
     print $template;
 }
コード例 #19
0
<h3>Add example</h3>
<?php 
if ($_POST) {
    $channel = isset($_POST['channel']) ? htmlspecialchars($_POST['channel']) : '';
    $url = isset($_POST['url']) ? htmlspecialchars($_POST['url']) : '';
    $network = isset($_POST['network']) ? htmlspecialchars($_POST['network']) : '';
    $maintainer = isset($_POST['maintainer']) ? htmlspecialchars($_POST['maintainer']) : '';
    $email = isset($_POST['email']) ? $db->quote($_POST['email']) : '';
    $sql = sprintf("INSERT INTO examples (channel, url, network, maintainer) VALUES (%s, %s, %s, %s)", $db->quote($channel), $db->quote($url), $db->quote($network), $db->quote($maintainer));
    $db->exec($sql);
    include 'sendmail.php';
    $mail = new Sendmail();
    $to = '*****@*****.**';
    $subject = 'Example addition';
    $message = "Example to be added:\n\n        Channel: {$channel}\n\n        URL: {$url}\n\n        Network: {$network}\n\n        Maintainer: {$maintainer}";
    $mail->send($to, $subject, $message, $email);
    ?>

<p>Thank you for the submission. The URL and the data you submitted will be
reviewed within the next couple of days, and then your page will appear on
the 'examples' page.</p> 

<?php 
} else {
    ?>
<p>Here you can add a statistics page. The page will only be added to the
examples if you enter sane input.</p>

<form method="POST" action="">
<table width="100%" cellpadding="2" cellspacing="0" border="0">
 <tr>
コード例 #20
0
 public function sendemail()
 {
     // Process the data from the form into an email,
     //   then send the email.
     // Make sure the form was submitted.
     if ($_POST) {
         // Set up some rules to validate the form against.
         $post = new Validation($_POST);
         $post->add_rules('email_from', 'required', 'valid::email');
         $post->add_rules('email_subject', 'required');
         $post->add_rules('email_body', 'required');
         // If the form was filled out properly then...
         if ($post->validate()) {
             // Copy the data from the email form into a couple of variables.
             $str_emailsubject = Input::instance()->post("email_subject");
             $str_emailtoid = Input::instance()->post("email_to_id");
             $str_emailfrom = Input::instance()->post("email_from");
             $str_emailbody = Input::instance()->post("email_body");
             // Add in some <br> tags to the message body where ever there are line breaks.
             $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
             // Gallery's Sendmail library doesn't allow for custom from addresses,
             //   so add the from email to the beginning of the message body instead.
             //   Also add in the admin-defined message header.
             $str_emailbody = module::get_var("contactowner", "contact_owner_header") . "<br/>\r\n" . "Message Sent From " . $str_emailfrom . "<br/>\r\n<br/>\r\n" . $str_emailbody;
             // Figure out where the email is going to.
             $str_emailto = "";
             if ($str_emailtoid == -1) {
                 // If the email id is "-1" send the message to a pre-determined
                 //   owner email address.
                 $str_emailto = module::get_var("contactowner", "contact_owner_email");
             } else {
                 // or else grab the email from the user table.
                 $userDetails = ORM::factory("user")->where("id", "=", $str_emailtoid)->find_all();
                 $str_emailto = $userDetails[0]->email;
             }
             // Send the email message.
             Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send();
             // Display a message telling the visitor that their email has been sent.
             $template = new Theme_View("page.html", "other", "Contact");
             $template->content = new View("contactowner_emailform.html");
             $template->content->sendmail_form = t("Your Message Has Been Sent.");
             print $template;
         } else {
             // Display a message telling the visitor that their email has been not been sent,
             //   along with the reason(s) why.
             $template = new Theme_View("page.html", "other", "Contact");
             $template->content = new View("contactowner_emailform.html");
             $template->content->sendmail_form = t("Your Message Has Not Been Sent.");
             $template->content->sendmail_form = $template->content->sendmail_form . "<br/><br/>" . t("Reason(s):") . "<br/>";
             foreach ($post->errors('form_error_messages') as $error) {
                 $template->content->sendmail_form = $template->content->sendmail_form . " - " . t($error) . "<br/>";
             }
             print $template;
         }
     }
 }
コード例 #21
0
ファイル: CinemaFinder.php プロジェクト: xxdf/showtimes
 private function notify_invalid_cinemas()
 {
     if (count($this->_cinemas) == 0) {
         Log::write("Não achou cinemas para " . $this->_state);
         return;
     }
     $invalid = array_filter($this->_cinemas, function ($var) {
         return empty($var->id) || empty($var->address);
     });
     $cinemas = array();
     foreach ($invalid as $key => $value) {
         $uf = Helper::clean_string($value->state_code);
         $cidade = Helper::clean_string($value->city);
         $nome = Helper::clean_string($value->name);
         $cinema = "{$uf}/{$cidade}/{$nome}";
         $cinemas[] = $cinema;
     }
     Sendmail::to_admin("Cinemas Incompletos", $cinemas);
 }
コード例 #22
0
 private static function _send_mail($mailto, $subject, $message)
 {
     //Send the notification mail
     $message = nl2br($message);
     return Sendmail::factory()->to($mailto)->subject($subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($message)->send();
 }
コード例 #23
0
ファイル: BasicTest.php プロジェクト: xxdf/showtimes
 function xtest_mail()
 {
     $subject = 'teste';
     $body = 'Teste de corpo <br> Proxima linha';
     Sendmail::to_admin($subject, $body);
 }