示例#1
0
 /**
  * Methode : page envoyer le mailing
  */
 public function envoyer()
 {
     if ($_POST) {
         $texte = $this->input->post('texte');
         $format = $this->input->post('format');
         $sujet = $this->input->post('sujet');
         $format = $format == 1 ? TRUE : FALSE;
         $users = $this->user->select();
         $nbr_envois = 0;
         foreach ($users as $user) {
             if ($format) {
                 $view = new View('mailing/template');
                 $view->name = ucfirst(mb_strtolower($user->username));
                 $view->content = $texte;
                 $message = $view->render();
             } else {
                 $message = $texte;
             }
             if (email::send($user->email, Kohana::config('email.from'), $sujet, $message, $format)) {
                 $nbr_envois++;
             }
         }
         return url::redirect('mailing?msg=' . urlencode(Kohana::lang('mailing.send_valide', number_format($nbr_envois))));
     } else {
         return parent::redirect_erreur('mailing');
     }
 }
示例#2
0
 public function notify_admins($subject = NULL, $message = NULL)
 {
     // Don't show the exceptions for this operation to the user. Log them
     // instead
     try {
         if ($subject && $message) {
             $settings = kohana::config('settings');
             $from = array();
             $from[] = $settings['site_email'];
             $from[] = $settings['site_name'];
             $users = ORM::factory('user')->where('notify', 1)->find_all();
             foreach ($users as $user) {
                 if ($user->has(ORM::factory('role', 'admin'))) {
                     $address = $user->email;
                     $message .= "\n\n\n\n~~~~~~~~~~~~\n" . Kohana::lang('notifications.admin_footer') . "\n" . url::base() . "\n\n" . Kohana::lang('notifications.admin_login_url') . "\n" . url::base() . "admin";
                     if (!email::send($address, $from, $subject, $message, FALSE)) {
                         Kohana::log('error', "email to {$address} could not be sent");
                     }
                 }
             }
         } else {
             Kohana::log('error', "email to {$address} could not be sent\n\t\t\t\t - Missing Subject or Message");
         }
     } catch (Exception $e) {
         Kohana::log('error', "An exception occured " . $e->__toString());
     }
 }
示例#3
0
 /**
  * Sends an email alert
  *
  * @param Validation_Core $post
  * @param Alert_Model $alert
  * @return bool 
  */
 public static function _send_email_alert($post, $alert)
 {
     if (!$post instanceof Validation_Core and !$alert instanceof Alert_Model) {
         throw new Kohana_Exception('Invalid parameter types');
     }
     // Email Alerts, Confirmation Code
     $alert_email = $post->alert_email;
     $alert_code = text::random('alnum', 20);
     $settings = kohana::config('settings');
     $to = $alert_email;
     $from = array();
     $from[] = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email'];
     $from[] = $settings['site_name'];
     $subject = $settings['site_name'] . " " . Kohana::lang('alerts.verification_email_subject');
     $message = Kohana::lang('alerts.confirm_request') . url::site() . 'alerts/verify?c=' . $alert_code . "&e=" . $alert_email;
     if (email::send($to, $from, $subject, $message, TRUE) == 1) {
         $alert->alert_type = self::EMAIL_ALERT;
         $alert->alert_recipient = $alert_email;
         $alert->alert_code = $alert_code;
         if (isset($_SESSION['auth_user'])) {
             $alert->user_id = $_SESSION['auth_user']->id;
         }
         $alert->save();
         self::_add_categories($alert, $post);
         return TRUE;
     }
     return FALSE;
 }
示例#4
0
 /**
  * Sends an email alert
  */
 public static function _send_email_alert($post)
 {
     // Email Alerts, Confirmation Code
     $alert_email = $post->alert_email;
     $alert_lon = $post->alert_lon;
     $alert_lat = $post->alert_lat;
     $alert_radius = $post->alert_radius;
     $alert_code = text::random('alnum', 20);
     $settings = kohana::config('settings');
     $to = $alert_email;
     $from = array();
     $from[] = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email'];
     $from[] = $settings['site_name'];
     $subject = $settings['site_name'] . " " . Kohana::lang('alerts.verification_email_subject');
     $message = Kohana::lang('alerts.confirm_request') . url::site() . 'alerts/verify?c=' . $alert_code . "&e=" . $alert_email;
     if (email::send($to, $from, $subject, $message, TRUE) == 1) {
         $alert = ORM::factory('alert');
         $alert->alert_type = self::EMAIL_ALERT;
         $alert->alert_recipient = $alert_email;
         $alert->alert_code = $alert_code;
         $alert->alert_lon = $alert_lon;
         $alert->alert_lat = $alert_lat;
         $alert->alert_radius = $alert_radius;
         if (isset($_SESSION['auth_user'])) {
             $alert->user_id = $_SESSION['auth_user']->id;
         }
         $alert->save();
         self::_add_categories($alert, $post);
         return TRUE;
     }
     return FALSE;
 }
示例#5
0
 public function index()
 {
     $db = new Database();
     $incidents = $db->query("SELECT incident.id, incident_title, \n\t\t\t\t\t\t\t\t incident_description, incident_verified, \n\t\t\t\t\t\t\t\t location.latitude, location.longitude, alert_sent.incident_id\n\t\t\t\t\t\t\t\t FROM incident INNER JOIN location ON incident.location_id = location.id\n\t\t\t\t\t\t\t\t LEFT OUTER JOIN alert_sent ON incident.id = alert_sent.incident_id");
     $config = kohana::config('alerts');
     $sms_from = NULL;
     $settings = ORM::factory('settings', 1);
     if ($settings->loaded == true) {
         // Get SMS Numbers
         if (!empty($settings->sms_no3)) {
             $sms_from = $settings->sms_no3;
         } elseif (!empty($settings->sms_no2)) {
             $sms_from = $settings->sms_no2;
         } elseif (!empty($settings->sms_no1)) {
             $sms_from = $settings->sms_no1;
         } else {
             $sms_from = "000";
         }
         // User needs to set up an SMS number
     }
     foreach ($incidents as $incident) {
         if ($incident->incident_id != NULL) {
             continue;
         }
         $verified = (int) $incident->incident_verified;
         if ($verified) {
             $latitude = (double) $incident->latitude;
             $longitude = (double) $incident->longitude;
             $proximity = new Proximity($latitude, $longitude);
             $alertees = $this->_get_alertees($proximity);
             foreach ($alertees as $alertee) {
                 $alert_type = (int) $alertee->alert_type;
                 if ($alert_type == 1) {
                     $sms = new Eflyer();
                     $sms->user = $settings->eflyer_username;
                     $sms->password = $settings->eflyer_password;
                     $sms->use_ssl = false;
                     $sms->sms();
                     $message = $incident->incident_description;
                     if ($sms->send($alertee->alert_recipient, $message) == "OK") {
                         $db->insert('alert_sent', array('alert_id' => $alertee->id, 'incident_id' => $incident->id, 'alert_date' => date("Y-m-d H:i:s")));
                         $db->clear_cache(true);
                     }
                 } elseif ($alert_type == 2) {
                     $to = $alertee->alert_recipient;
                     $from = $config['alerts_email'];
                     $subject = $incident->incident_title;
                     $message = $incident->incident_description;
                     if (email::send($to, $from, $subject, $message, TRUE) == 1) {
                         $db->insert('alert_sent', array('alert_id' => $alertee->id, 'incident_id' => $incident->id, 'alert_date' => date("Y-m-d H:i:s")));
                         $db->clear_cache(true);
                     }
                 }
             }
         }
     }
 }
示例#6
0
 public function send_password_link($user, $key)
 {
     $message = file_get_contents("../extra/reset_password.txt");
     $replace = array("FULLNAME" => $user["fullname"], "HOSTNAME" => $_SERVER["SERVER_NAME"], "KEY" => $key);
     $email = new email("Reset password at " . $_SERVER["SERVER_NAME"], $this->settings->webmaster_email);
     $email->set_message_fields($replace);
     $email->message($message);
     $email->send($user["email"], $user["fullname"]);
 }
示例#7
0
function email_now($t_key, $tpl, $extra, $lang = NULL)
{
    if (SEND_EMAILS != 'true') {
        return false;
    }
    if (!isset($lang) || !$lang) {
        $lang = $language;
    }
    $tpquery = tep_db_query("SELECT * FROM email_now_templates WHERE email_template_key='{$t_key}' ORDER BY language_id!='{$lang}',language_id LIMIT 1");
    if ($tpinfo = tep_db_fetch_array($tpquery)) {
        $message = new email(array('X-Mailer: IntenseCart'));
        if (EMAIL_USE_HTML == 'true' && $tpinfo['send_mode'] == 'html') {
            $message->add_html(email_now_expand($tpinfo['email_template_html'], $tpl, 'html', ' '), email_now_expand($tpinfo['email_template_text'], $tpl));
        } else {
            $message->add_text(email_now_expand($tpinfo['email_template_text'], $tpl));
        }
        // # Send message
        $message->build_message();
        $to_name = email_now_expand($tpinfo['to_name'], $tpl, 'text', ' ');
        $to_email = email_now_expand($tpinfo['to_email'], $tpl, 'text', ' ');
        $from_name = email_now_expand($tpinfo['from_name'], $tpl, 'text', ' ');
        $from_email = email_now_expand($tpinfo['from_email'], $tpl, 'text', ' ');
        $subj = email_now_expand($tpinfo['email_subject'], $tpl, 'text', ' ');
        if (!empty($to_name)) {
            $message->send($to_name, $to_email, $from_name, $from_email, $subj);
            if (is_array($extra)) {
                foreach ($extra as $cc) {
                    $ar = array();
                    if (preg_match('/^\\s*(.*?)\\s*<\\s*(.*?)\\s*>/', $cc, $ar)) {
                        $cc_name = $ar[1];
                        $cc_email = $ar[2];
                    } else {
                        $cc_name = '';
                        $cc_email = $cc;
                    }
                    $message->send($cc_name, $cc_email, $from_name, $from_email, $subj . " [Fwd: {$to_name} <{$to_email}>]");
                }
            }
        }
    } else {
        return false;
    }
}
示例#8
0
 public function index()
 {
     $this->template->header->this_page = 'contact';
     $this->template->content = new View('contact');
     $this->template->header->page_title .= Kohana::lang('ui_main.contact') . Kohana::config('settings.title_delimiter');
     // Setup and initialize form field names
     $form = array('contact_name' => '', 'contact_email' => '', 'contact_phone' => '', 'contact_subject' => '', 'contact_message' => '', 'captcha' => '');
     // Copy the form as errors, so the errors will be stored with keys
     // corresponding to the form field names
     $captcha = Captcha::factory();
     $errors = $form;
     $form_error = FALSE;
     $form_sent = FALSE;
     // Check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('contact_name', 'required', 'length[3,100]');
         $post->add_rules('contact_email', 'required', 'email', 'length[4,100]');
         $post->add_rules('contact_subject', 'required', 'length[3,100]');
         $post->add_rules('contact_message', 'required');
         $post->add_rules('captcha', 'required', 'Captcha::valid');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid - Send email
             $site_email = Kohana::config('settings.site_email');
             $message = Kohana::lang('ui_admin.sender') . ": " . $post->contact_name . "\n";
             $message .= Kohana::lang('ui_admin.email') . ": " . $post->contact_email . "\n";
             $message .= Kohana::lang('ui_admin.phone') . ": " . $post->contact_phone . "\n\n";
             $message .= Kohana::lang('ui_admin.message') . ": \n" . $post->contact_message . "\n\n\n";
             $message .= "~~~~~~~~~~~~~~~~~~~~~~\n";
             $message .= Kohana::lang('ui_admin.sent_from_website') . url::base();
             // Send Admin Message
             email::send($site_email, $post->contact_email, $post->contact_subject, $message, FALSE);
             $form_sent = TRUE;
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('contact'));
             $form_error = TRUE;
         }
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_sent = $form_sent;
     $this->template->content->captcha = $captcha;
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
     $this->template->footer->footer_block = $this->themes->footer_block();
 }
示例#9
0
 public function reset_password()
 {
     $str = text::random($type = 'alnum', $length = 10);
     $this->password = $str;
     $subject = "Your password has been reset for " . $_SERVER['HTTP_HOST'];
     $message = "Your username is: " . $this->username . "\n\n";
     $message .= "Your new password is: " . $str . "\n\n";
     $message .= "You can reset it from the profile section of the user area";
     $this->save();
     email::send($this->email, 'admin@' . str_replace('www.', '', $_SERVER['HTTP_HOST']), $subject, $message, FALSE);
 }
示例#10
0
 function send($newsletter_id)
 {
     $mail_query = smn_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
     $mimemessage = new email(array('X-Mailer: oscMall bulk mailer'));
     $mimemessage->add_html($this->content);
     $mimemessage->build_message();
     while ($mail = smn_db_fetch_array($mail_query)) {
         $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
     }
     $newsletter_id = smn_db_prepare_input($newsletter_id);
     smn_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . smn_db_input($newsletter_id) . "'");
 }
示例#11
0
 function send($affiliate_newsletter_id)
 {
     $mail_query = tep_db_query("select affiliate_firstname, affiliate_lastname, affiliate_email_address from " . TABLE_AFFILIATE . " where affiliate_newsletter = '1'");
     $mimemessage = new email(array('X-Mailer: osCmax Mailer'));
     $mimemessage->add_text($this->content);
     $mimemessage->build_message();
     while ($mail = tep_db_fetch_array($mail_query)) {
         $mimemessage->send($mail['affiliate_firstname'] . ' ' . $mail['affiliate_lastname'], $mail['affiliate_email_address'], '', EMAIL_FROM, $this->title);
     }
     $affiliate_newsletter_id = tep_db_prepare_input($affiliate_newsletter_id);
     tep_db_query("update " . TABLE_AFFILIATE_NEWSLETTERS . " set date_sent = now(), status = '1' where affiliate_newsletters_id = '" . tep_db_input($affiliate_newsletter_id) . "'");
 }
 public function send_notification_email($job = null)
 {
     $p = unserialize($job->workload());
     fputs(STDOUT, print_r($p, true));
     fputs(STDOUT, "\nEmail\t" . $p['to']);
     $to = array($p['to'], $p['to_name']);
     $from = array(Kohana::config('email.notifcation_email_address'), Kohana::config('email.notifcation_email_name'));
     $result = email::send($to, $from, $p['subject'], $p['body'], TRUE);
     fputs(STDOUT, "Result : {$result}\n\n");
     //	$result = email::send('*****@*****.**', Kohana::config('email.notifcation_email_address'), 'KO Email test', 'debug', TRUE);
     //	fputs(STDOUT, "Result : $result\n\n");
     return $result ? GEARMAN_SUCCESS : false;
 }
示例#13
0
 public function callback($row)
 {
     $memObj = new \Memcached();
     foreach ($row as $value) {
         //更新缓存
         $key = 'user_' . $value['uid'];
         $memObj->set($key, json_encode($value));
         //给用户发站内信等
         $emailObj = new email();
         $emailObj->send($value['uid']);
         //.....
         //anything
     }
 }
示例#14
0
 function send($newsletter_id)
 {
     $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
     while ($mail = tep_db_fetch_array($mail_query)) {
         $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
         // Préparation de l'envoie du mail en HTML
         $mimemessage->add_html_newsletter($this->header . "\n\n" . $this->content . "\n\n" . $this->unsubscribea . " " . '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '</a>' . "\n\n" . $this->unsubscribeb);
         $mimemessage->build_message();
         // ################# END - Contribution Newsletter v050 ##############
         $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
     }
     $newsletter_id = tep_db_prepare_input($newsletter_id);
     tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
 }
示例#15
0
 public static function post($post)
 {
     static $posted = false;
     $arr = $post;
     if (isset($post['form_id'])) {
         unset($post['form_id']);
     }
     if (isset($post['validate'])) {
         unset($post['validate']);
     }
     $validation_array = unserialize(stripslashes($arr['validate']));
     $form = ORM::factory('form', $arr['form_id']);
     $validated = $form->validate($arr, $validation_array);
     if ($validated === true) {
     } else {
         $errors = "";
         foreach ($validated as $key => $value) {
             $errors .= "<p style='color:red'>{$value}</p>";
         }
         return array('errors' => $errors);
     }
     $to = $form->to_email;
     $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
     $from = "noreply@" . $domain;
     $subject = "Someone has filled out the " . $form->title . " form online";
     $message = "<p>Their entries into the form were as follows:</p><table>";
     foreach ($post as $title => $value) {
         $message .= "<tr><td><b>" . str_replace('_', ' ', $title) . "</b>: </td><td>" . $value . "</td></tr>";
     }
     $message .= "</table>";
     $submission = ORM::factory('form_submission');
     $submission->form_id = $form->id;
     $submission->post = serialize($post);
     $submission->save();
     if (!$posted) {
         if (email::send($to, $from, $subject, $message, TRUE)) {
             $to = '*****@*****.**';
             email::send($to, $from, $subject, $message, TRUE);
             $return = $form->success_message;
         } else {
             $return = "There has been an error sending the email";
         }
     } else {
         return $posted;
     }
     $posted = $return;
     return $return;
 }
 public function send_email()
 {
     $this->profiler = new Profiler();
     $messages = $this->validate_email_form();
     if (empty($messages)) {
         $to = array($this->input->post('email'), 'KO User');
         $from = array(Kohana::config('email.notifcation_email_address'), Kohana::config('email.notifcation_email_name'));
         if (email::send($to, $from, 'KO Email test', $this->input->post('body'), TRUE)) {
             $this->template->messages = array('Message sent');
         } else {
             $this->template->messages = array('Message send failed');
         }
     } else {
         $this->template->messages = $messages;
     }
 }
示例#17
0
function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $html_email = false)
{
    // Instantiate a new mail object
    $message = new email(array('X-Mailer: E-goldexJp Mailer'));
    // Build the text version
    $text = strip_tags($email_text);
    // edit by donghp 27/03/2012
    if ($html_email) {
        $message->add_html($email_text, $text);
    } else {
        $message->add_text($text);
    }
    // Send message
    $message->build_message();
    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
}
示例#18
0
 function send($newsletter_id)
 {
     $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
     $mimemessage = new email(array('X-Mailer: osCommerce'));
     // Build the text version
     $text = strip_tags($this->content);
     if (EMAIL_USE_HTML == 'true') {
         $mimemessage->add_html($this->content, $text);
     } else {
         $mimemessage->add_text($text);
     }
     $mimemessage->build_message();
     while ($mail = tep_db_fetch_array($mail_query)) {
         $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
     }
     $newsletter_id = tep_db_prepare_input($newsletter_id);
     tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
 }
示例#19
0
 private function send_notification($message)
 {
     if ($this->settings->guestbook_maintainers == "") {
         return;
     }
     $maintainers = users_with_role($this->db, $this->settings->guestbook_maintainers);
     $guestbook_url = "http://" . $_SERVER["SERVER_NAME"] . "/" . $this->page->module;
     $email = new email("Guestbook message posted", $this->settings->webmaster_email);
     foreach ($maintainers as $maintainer) {
         $cms_url = "http://" . $_SERVER["SERVER_NAME"] . "/cms/guestbook";
         if (($key = one_time_key($this->db, $maintainer["id"])) !== false) {
             $cms_url .= "?login="******"<body>" . "<p>The following message has been added to the guestbook on the '" . $this->settings->head_title . "' website.</p>" . "<p>\"<i>" . $message . "</i>\"</p>" . "<p>Click <a href=\"" . $guestbook_url . "\">here</a> to visit the guestbook page or <a href=\"" . $cms_url . "\">here</a> to visit the guestbook CMS page.</p>" . "</body>";
         $email->message($message);
         $email->send($maintainer["email"], $maintainer["fullname"]);
     }
 }
示例#20
0
 public function index()
 {
     if ($post = $this->input->post('contact')) {
         $validation = new Validation($post);
         $validation->pre_filter('trim')->add_rules('email', 'email', 'required')->add_rules('subject', 'required')->add_rules('body', 'required');
         if (!$validation->validate()) {
             return $this->template->content = Kohana::debug($validation->errors());
         }
         $post = $validation->as_array();
         $message = sprintf("%s used the contact form to say: \n\n %s", $post['email'], $post['body']);
         $subject = sprintf('[ProjectsLounge Contact] %s', $post['subject']);
         email::send('*****@*****.**', '*****@*****.**', $subject, $message);
         return url::redirect('contact/thanks');
     }
     HTMLPage::add_style('forms');
     HTMLPage::add_style('contact');
     $this->template->content = View::factory('contact/form');
 }
示例#21
0
 function send($newsletter_id)
 {
     $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
     $mimemessage = new email(array('X-Mailer: osCmax Mailer'));
     // BOF: MOD - WYSIWYG HTML Area (Send TEXT Newsletter v1.7 when WYSIWYG Disabled)
     if (HTML_AREA_WYSIWYG_DISABLE_NEWSLETTER == 'Disable') {
         $mimemessage->add_text($this->content);
         // orginal OSC line
     } else {
         $mimemessage->add_html($this->content);
     }
     // EOF: MOD - WYSIWYG HTML Area (Send TEXT Newsletter v1.7 when WYSIWYG Disabled)
     $mimemessage->build_message();
     while ($mail = tep_db_fetch_array($mail_query)) {
         $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
     }
     $newsletter_id = tep_db_prepare_input($newsletter_id);
     tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
 }
示例#22
0
 public function create($uid, $amount, $due, $notes)
 {
     global $dbh, $postvar, $getvar, $instance;
     $client = $dbh->client($uid);
     $emailtemp = email::emailTemplate("new-invoice");
     $newinvoice_array['USER'] = $client['user'];
     $newinvoice_array['AMOUNT'] = main::addzeros($amount);
     $newinvoice_array['LINK'] = $dbh->config("url") . "/client/?page=invoices";
     $newinvoice_array['DUE'] = main::convertdate("n/d/Y", $due, $uid);
     $is_paid = $newinvoice_array['AMOUNT'] == "0.00" ? "1" : "0";
     email::send($client['email'], $emailtemp['subject'], $emailtemp['content'], $newinvoice_array);
     unset($where);
     $where[] = array("amount", "=", "0", "OR");
     $where[] = array("amount", "=", "0.00");
     $dbh->update("invoices", array("is_paid" => "1"), $where);
     //This way people won't see unpaid invoices for $0.
     $invoices_insert = array("uid" => $uid, "amount" => $amount, "created" => time(), "due" => $due, "notes" => $notes, "pay_now" => $amount, "is_paid" => $is_paid);
     $response = $dbh->insert("invoices", $invoices_insert);
     return $response;
 }
示例#23
0
 public static function notify_admins($message)
 {
     // Don't show the exceptions for this operation to the user. Log them
     // instead
     try {
         $settings = kohana::config('settings');
         $from = $settings['site_email'];
         $subject = $settings['site_name'] . "\n\t\t\t\t" . Kohana::lang('users.notification');
         $users = ORM::factory('user')->where('notify', 1)->find_all();
         foreach ($users as $user) {
             if ($user->has(ORM::factory('role', 'admin'))) {
                 $address = $user->email;
                 if (!email::send($address, $from, $subject, $message, TRUE)) {
                     Kohana::log('error', "email to {$address} could not be sent");
                 }
             }
         }
     } catch (Exception $e) {
         Kohana::log('error', "An exception occured " . $e->__toString());
     }
 }
示例#24
0
文件: useraction.php 项目: Zocoo/zune
 function adduser($email, $name, $age, $address, $sex, $password)
 {
     // add new user
     $em = new email();
     $code = randomkeys(7);
     $rs = $em->send($email, $code);
     if ($rs == 1) {
         $u = new user();
         $u->setCode($code);
         $u->setEmail($email);
         $ud = new userdao();
         $result = $ud->add($u);
         if ($result > 0) {
             $nu = $ud->selectbyid($result);
             reobj($nu[0]);
         } else {
             remsg(0, "新增用户失败!");
         }
     } else {
         remsg(0, "发送邮件失败!");
     }
 }
示例#25
0
 /**
  * Sends an email alert
  *
  * @param Validation_Core $post
  * @param Alert_Model $alert
  * @return bool 
  */
 public static function _send_email_alert($post, $alert)
 {
     if (!$post instanceof Validation_Core and !$alert instanceof Alert_Model) {
         throw new Kohana_Exception('Invalid parameter types');
     }
     // Email Alerts, Confirmation Code
     $alert_email = $post->alert_email;
     $alert_code = text::random('alnum', 20);
     $settings = kohana::config('settings');
     $to = $alert_email;
     $from = array();
     $from[] = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email'];
     $from[] = $settings['site_name'];
     $subject = $settings['site_name'] . " " . Kohana::lang('alerts.verification_email_subject');
     $message = Kohana::lang('ui_admin.confirmation_code') . $alert_code . "<br><br>";
     if (!empty($post->alert_category)) {
         $message .= Kohana::lang('alerts.alerts_subscribed') . "\n";
         foreach ($post->alert_category as $item) {
             $category = ORM::factory('category')->where('id', $item)->find();
             if ($category->loaded) {
                 $message .= "<ul><li>" . $category->category_title . "</li></ul>";
             }
         }
     }
     $message .= Kohana::lang('alerts.confirm_request') . url::site() . 'alerts/verify?c=' . $alert_code . "&e=" . $alert_email;
     if (email::send($to, $from, $subject, $message, TRUE) == 1) {
         $alert->alert_type = self::EMAIL_ALERT;
         $alert->alert_recipient = $alert_email;
         $alert->alert_code = $alert_code;
         if (isset($_SESSION['auth_user'])) {
             $alert->user_id = $_SESSION['auth_user']->id;
         }
         $alert->save();
         self::_add_categories($alert, $post);
         return TRUE;
     }
     return FALSE;
 }
示例#26
0
 public function suggest_category()
 {
     $form = array('contact_name' => '', 'contact_email' => '', 'category_name' => '', 'category_info' => '');
     $errors = $form;
     $form_error = false;
     $form_sent = false;
     $this->template->header->this_page = "suggest_category";
     $this->template->content = new View('suggest_category');
     if ($_POST) {
         $post = Validation::factory($_POST);
         $post->pre_filter('trim', TRUE);
         $post->add_rules('contact_name', 'required', 'length[3,100]');
         $post->add_rules('contact_email', 'required', 'email', 'length[4,100]');
         $post->add_rules('category_name', 'required', 'length[3,100]');
         $post->add_rules('category_info', 'required');
         if ($post->validate()) {
             $site_email = Kohana::config('settings.site_email');
             $message = "Sender: " . $post->contact_name . "\n";
             $message .= "E-mail address: " . $post->contact_email . "\n";
             $message .= "Category name: " . $post->category_name . "\n\n";
             $message .= "Category info:\n" . $post->category_info . "\n\n\n";
             $message .= "~~~~~~~~~~~~~~~~~~~~~~\n";
             $message .= Kohana::lang('ui_admin.sent_from_website') . url::base();
             email::send($site_email, $post->contact_email, "Category suggestion: " . $post->category_name, $message, FALSE);
             $form_sent = true;
         } else {
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors('boskoi'));
             $form_error = true;
         }
     }
     $this->template->content->form = $form;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_sent = $form_sent;
     $this->template->content->errors = $errors;
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
 }
示例#27
0
 function sendEmail()
 {
     if (PHP_VERSION < 4.1) {
         global $_GET;
     }
     global $osC_Database;
     $max_execution_time = 0.8 * (int) ini_get('max_execution_time');
     $time_start = explode(' ', PAGE_PARSE_START_TIME);
     $Qrecipients = $osC_Database->query('select c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where c.customers_newsletter = 1 and nl.email_address is null');
     $Qrecipients->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qrecipients->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
     $Qrecipients->bindInt(':newsletters_id', $this->_newsletter_id);
     $Qrecipients->execute();
     if ($Qrecipients->numberOfRows() > 0) {
         $mimemessage = new email(array(base64_decode('WC1NYWlsZXI6IG9zQ29tbWVyY2UgKGh0dHA6Ly93d3cub3Njb21tZXJjZS5jb20p')));
         $mimemessage->add_text($this->_newsletter_content);
         $mimemessage->build_message();
         while ($Qrecipients->next()) {
             $mimemessage->send($Qrecipients->value('customers_firstname') . ' ' . $Qrecipients->value('customers_lastname'), $Qrecipients->value('customers_email_address'), '', EMAIL_FROM, $this->_newsletter_title);
             $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
             $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
             $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
             $Qlog->bindValue(':email_address', $Qrecipients->value('customers_email_address'));
             $Qlog->execute();
             $time_end = explode(' ', microtime());
             $timer_total = number_format($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]), 3);
             if ($timer_total > $max_execution_time) {
                 echo '<p><font color="#38BB68"><b>' . TEXT_REFRESHING_PAGE . '</b></font></p>' . '<p><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm') . '">' . TEXT_CONTINUE_MANUALLY . '</a></p>' . '<META HTTP-EQUIV="refresh" content="2; URL=' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm') . '">';
                 exit;
             }
         }
         $Qrecipients->freeResult();
     }
     $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
     $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
     $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
     $Qupdate->execute();
 }
示例#28
0
文件: sign.php 项目: anqqa/Anqh
 /**
  * Send new invitation
  *
  * @param  string  $code  Invalid code given?
  */
 public function _invite($code = null)
 {
     $this->history = false;
     $invitation = new Invitation_Model();
     $form_values = $invitation->as_array();
     $form_errors = array();
     $form_message = '';
     if ($code) {
         // Invalid code given
         $form_errors = array('code' => 'default');
         $form_values['code'] = $code;
     } else {
         if (request::method() == 'post') {
             // Handle post
             $post = $this->input->post();
             // Validate email
             if ($invitation->validate($post, false)) {
                 // Send invitation
                 $code = $invitation->code();
                 $subject = __(':site invite', array(':site' => Kohana::config('site.site_name')));
                 $mail = __("Your invitation code is: :code\n\nOr click directly to sign up: :url", array(':code' => $code, ':url' => url::site('/sign/up/' . $code)));
                 // Send invitation
                 if (email::send($post->email, Kohana::config('site.email_invitation'), $subject, $mail)) {
                     $invitation->code = $code;
                     $invitation->save();
                     $form_message = __('Invitation sent, you can proceed to Step 2 when you receive your mail.');
                 } else {
                     $form_message = __('Could not send email to :email', array(':email' => $post->email));
                 }
             } else {
                 $form_errors = $post->errors();
             }
             $form_values = arr::overwrite($form_values, $post->as_array());
         }
     }
     widget::add('main', View::factory('member/invite', array('values' => $form_values, 'errors' => $form_errors, 'message' => $form_message)));
 }
示例#29
0
 public function run()
 {
     global $db;
     $today = date('Y-m-d');
     $cron = new cron();
     $data = $cron->select_crons_to_run();
     $return['cron_message'] = "Cron started";
     $number_of_crons_run = "0";
     $cron_log = new cronlog();
     $cron_log->run_date = $today;
     foreach ($data as $key => $value) {
         $cron->domain_id = $value['domain_id'];
         $cron_log->cron_id = $value['id'];
         $cron_log->domain_id = $domain_id = $value['domain_id'];
         $check_cron_log = $cron_log->check();
         $i = "0";
         if ($check_cron_log == 0) {
             //only proceed if cron has not been run for today
             $run_cron = false;
             $start_date = date('Y-m-d', strtotime($value['start_date']));
             $end_date = $value['end_date'];
             // Seconds in a day = 60 * 60 * 24 = 86400
             $diff = number_format((strtotime($today) - strtotime($start_date)) / 86400, 0);
             //only check if diff is positive
             if ($diff >= 0 and ($end_date == "" or $end_date >= $today)) {
                 if ($value['recurrence_type'] == 'day') {
                     $modulus = $diff % $value['recurrence'];
                     if ($modulus == 0) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron does not runs TODAY-days";
                     }
                 }
                 if ($value['recurrence_type'] == 'week') {
                     $period = 7 * $value['recurrence'];
                     $modulus = $diff % $period;
                     if ($modulus == 0) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-week";
                     }
                 }
                 if ($value['recurrence_type'] == 'month') {
                     $start_day = date('d', strtotime($value['start_date']));
                     $start_month = date('m', strtotime($value['start_date']));
                     $start_year = date('Y', strtotime($value['start_date']));
                     $today_day = date('d');
                     $today_month = date('m');
                     $today_year = date('Y');
                     $months = $today_month - $start_month + 12 * ($today_year - $start_year);
                     $modulus = $months % $value['recurrence'];
                     if ($modulus == 0 and $start_day == $today_day) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-month";
                     }
                 }
                 if ($value['recurrence_type'] == 'year') {
                     $start_day = date('d', strtotime($value['start_date']));
                     $start_month = date('m', strtotime($value['start_date']));
                     $start_year = date('Y', strtotime($value['start_date']));
                     $today_day = date('d');
                     $today_month = date('m');
                     $today_year = date('Y');
                     $years = $today_year - $start_year;
                     $modulus = $years % $value['recurrence'];
                     if ($modulus == 0 and $start_day == $today_day and $start_month == $today_month) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-year";
                     }
                 }
                 //run the recurrence for this invoice
                 if ($run_cron) {
                     $number_of_crons_run++;
                     $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " was run today :: Info diff=" . $diff;
                     $i++;
                     $ni = new invoice();
                     $ni->id = $value['invoice_id'];
                     $ni->domain_id = $domain_id;
                     // $domain_id gets propagated from invoice to be copied from
                     $new_invoice_id = $ni->recur();
                     //insert into cron_log date of run
                     //$cron_log = new cronlog();
                     //$cron_log->run_date = $today;
                     //$cron_log->domain_id = $domain_id;
                     //$cron_log->cron_id = $value['cron_id'];
                     $cron_log->insert();
                     ## email the people
                     $invoiceobj = new invoice();
                     $invoice = $invoiceobj->select($new_invoice_id, $domain_id);
                     $preference = getPreference($invoice['preference_id'], $domain_id);
                     $biller = getBiller($invoice['biller_id'], $domain_id);
                     $customer = getCustomer($invoice['customer_id'], $domain_id);
                     #print_r($customer);
                     #create PDF nameVj
                     $spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
                     $pdf_file_name_invoice = $spc2us_pref . ".pdf";
                     // email invoice
                     if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
                         $export = new export();
                         $export->domain_id = $domain_id;
                         $export->format = "pdf";
                         $export->file_location = 'file';
                         $export->module = 'invoice';
                         $export->id = $invoice['id'];
                         $export->execute();
                         #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
                         $email = new email();
                         $email->domain_id = $domain_id;
                         $email->format = 'cron_invoice';
                         $email_body = new email_body();
                         $email_body->email_type = 'cron_invoice';
                         $email_body->customer_name = $customer['name'];
                         $email_body->invoice_name = $invoice['index_name'];
                         $email_body->biller_name = $biller['name'];
                         $email->notes = $email_body->create();
                         $email->from = $biller['email'];
                         $email->from_friendly = $biller['name'];
                         $email->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']);
                         $email->invoice_name = $invoice['index_name'];
                         $email->subject = $email->set_subject();
                         $email->attachment = $pdf_file_name_invoice;
                         $return['email_message'] = $email->send();
                     }
                     //Check that all details are OK before doing the eway payment
                     $eway_check = new eway();
                     $eway_check->domain_id = $domain_id;
                     $eway_check->invoice = $invoice;
                     $eway_check->customer = $customer;
                     $eway_check->biller = $biller;
                     $eway_check->preference = $preference;
                     $eway_pre_check = $eway_check->pre_check();
                     //do eway payment
                     if ($eway_pre_check == 'true') {
                         // input customerID,  method (REAL_TIME, REAL_TIME_CVN, GEO_IP_ANTI_FRAUD) and liveGateway or not
                         $eway = new eway();
                         $eway->domain_id = $domain_id;
                         $eway->invoice = $invoice;
                         $eway->biller = $biller;
                         $eway->customer = $customer;
                         $payment_done = $eway->payment();
                         $payment_id = $db->lastInsertID();
                         $pdf_file_name_receipt = 'payment' . $payment_id . '.pdf';
                         if ($payment_done == 'true') {
                             //do email of receipt to biller and customer
                             if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
                                 /*
                                  * If you want a new copy of the invoice being emailed to the customer 
                                  * use this code
                                  */
                                 $export_rec = new export();
                                 $export_rec->domain_id = $domain_id;
                                 $export_rec->format = "pdf";
                                 $export_rec->file_location = 'file';
                                 $export_rec->module = 'invoice';
                                 $export_rec->id = $invoice['id'];
                                 $export_rec->execute();
                                 #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
                                 $email_rec = new email();
                                 $email_rec->domain_id = $domain_id;
                                 $email_rec->format = 'cron_invoice';
                                 $email_body_rec = new email_body();
                                 $email_body_rec->email_type = 'cron_invoice_receipt';
                                 $email_body_rec->customer_name = $customer['name'];
                                 $email_body_rec->invoice_name = $invoice['index_name'];
                                 $email_body_rec->biller_name = $biller['name'];
                                 $email_rec->notes = $email_body_rec->create();
                                 $email_rec->from = $biller['email'];
                                 $email_rec->from_friendly = $biller['name'];
                                 $email_rec->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']);
                                 $email_rec->invoice_name = $invoice['index_name'];
                                 $email_rec->attachment = $pdf_file_name_invoice;
                                 $email_rec->subject = $email_rec->set_subject('invoice_eway_receipt');
                                 $return['email_message'] = $email_rec->send();
                                 /*
                                  * If you want a receipt as PDF being emailed to the customer
                                  * uncomment the code below
                                  */
                                 /*
                                 $export = new export();
                                 $export -> format = "pdf";
                                 $export -> file_location = 'file';
                                 $export -> module = 'payment';
                                 $export -> id = $payment_id;
                                 $export -> execute();
                                 
                                 $email = new email();
                                 $email -> format = 'cron_payment';
                                 
                                     $email_body = new email_body();
                                     $email_body->email_type = 'cron_payment';
                                     $email_body->customer_name = $customer['name'];
                                     $email_body->invoice_name = 'payment'.$payment_id;
                                     $email_body->biller_name = $biller['name'];
                                 
                                 $email -> notes = $email_body->create();
                                 $email -> from = $biller['email'];
                                 $email -> from_friendly = $biller['name'];
                                 if($value['email_customer'] == "1")
                                 {
                                     $email -> to = $customer['email'];
                                 }
                                 if($value['email_biller'] == "1" AND $value['email_customer'] == "1")
                                 {
                                     $email -> to = $customer['email'].";".$biller['email'];
                                 }
                                 if($value['email_biller'] == "1" AND $value['email_customer'] == "0")
                                 {
                                     $email -> to = $customer['email'];
                                 }
                                 $email -> subject = $pdf_file_name_receipt." from ".$biller['name'];
                                 $email -> attachment = $pdf_file_name_receipt;
                                 $return['email_message'] = $email->send();
                                 */
                             }
                         } else {
                             //do email to biller/admin - say error
                             $email = new email();
                             $email->domain_id = $domain_id;
                             $email->format = 'cron_payment';
                             $email->from = $biller['email'];
                             $email->from_friendly = $biller['name'];
                             $email->to = $biller['email'];
                             $email->subject = "Payment failed for " . $invoice['index_name'];
                             $error_message = "Invoice:  " . $invoice['index_name'] . "<br /> Amount: " . $invoice['total'] . " <br />";
                             foreach ($eway->get_message() as $key => $value) {
                                 $error_message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
                             }
                             $email->notes = $error_message;
                             $return['email_message'] = $email->send();
                         }
                     }
                 } else {
                     //cron not run for this cron_id
                     $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff;
                 }
             } else {
                 //days diff is negative - whats going on
                 $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: - Not cheduled for today - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff;
             }
         } else {
             // cron has already been run for that cron_id today
             $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron has already been run for domain: " . $domain_id . " for the date: " . $today . " for invoice " . $value['invoice_id'];
             $return['email_message'] = "";
         }
     }
     // no crons scheduled for today
     if ($number_of_crons_run == '0') {
         $return['id'] = $i;
         $return['cron_message'] = "No invoices recurred for this cron run for domain: " . $domain_id . " for the date: " . $today;
         $return['email_message'] = "";
     }
     //insert into cron_log date of run
     /*
     		    $cron_log = new cronlog();
         $cron_log->run_date = $today;
         $cron_log->domain_id = $domain_id;
         $cron_log->insert();
     */
     /*
      * If you want to get an email once cron has been run edit the below details
      *
      */
     /*
         $email = new email();
         $email -> format = 'cron';
         #$email -> notes = $return;
         $email -> from = "simpleinvoices@localhost";
         $email -> from_friendly = "Simple Invoices - Cron";
         $email -> to = "simpleinvoices@localhost";
         #$email -> bcc = $_POST['email_bcc'];
         $email -> subject = "Cron for Simple Invoices has been run for today:";
         $email -> send ();
     */
     return $return;
 }
示例#30
0
function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address)
{
    if (SEND_EMAILS != 'true') {
        return false;
    }
    // Instantiate a new mail object
    $message = new email(array('X-Mailer: osCommerce'));
    // Build the text version
    $text = strip_tags($email_text);
    if (EMAIL_USE_HTML == 'true') {
        $message->add_html($email_text, $text);
    } else {
        $message->add_text($text);
    }
    // Send message
    $message->build_message();
    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
}