Beispiel #1
0
 public function sendEmail()
 {
     global $mysql, $langArray, $user, $config;
     if (!isset($_POST['message']) || trim($_POST['message']) == '') {
         return $langArray['error_not_set_message'];
     }
     $mysql->query("\n\t\t\tINSERT INTO `users_emails` (\n\t\t\t\t`from_id`,\n\t\t\t\t`from_email`,\n\t\t\t\t`to_id`,\n\t\t\t\t`message`,\n\t\t\t\t`datetime`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . intval($_SESSION['user']['user_id']) . "',\n\t\t\t\t'" . sql_quote($_SESSION['user']['email']) . "',\n\t\t\t\t'" . intval($user['user_id']) . "',\n\t\t\t\t'" . sql_quote($_POST['message']) . "',\n\t\t\t\tNOW()\n\t\t\t)\n\t\t");
     #发送邮件
     require_once ENGINE_PATH . '/classes/email.class.php';
     $emailClass = new email();
     $emailClass->fromEmail = 'no-reply@' . $config['domain'];
     $emailClass->subject = '[' . $config['domain'] . '] ' . $langArray['email_profile_subject'];
     $emailClass->message = langMessageReplace($langArray['email_profile_text'], array('USERNAME' => $_SESSION['user']['username'], 'EMAIL' => $_SESSION['user']['email'], 'MESSAGE' => $_POST['message']));
     $emailClass->to($user['email']);
     $emailClass->send();
     unset($emailClass);
     return true;
 }
Beispiel #2
0
 public function add()
 {
     global $mysql, $langArray, $config;
     if (!isset($_POST['name']) || trim($_POST['name']) == '') {
         $error['name'] = $langArray['error_fill_this_field'];
     }
     if (!isset($_POST['text']) || trim($_POST['text']) == '') {
         $error['text'] = $langArray['error_fill_this_field'];
     }
     if (!isset($_POST['send_to']) || trim($_POST['send_to']) == '') {
         $error['send_to'] = $langArray['error_fill_this_field'];
     }
     if (isset($_POST['send_to']) && $_POST['send_to'] == 'city' && (!isset($_POST['city_id']) || !is_numeric($_POST['city_id']))) {
         $error['city'] = $langArray['error_fill_this_field'];
     }
     if (isset($_POST['send_to']) && $_POST['send_to'] == 'group' && (!isset($_POST['bgroup_id']) || !is_numeric($_POST['bgroup_id']))) {
         $error['group'] = $langArray['error_fill_this_field'];
     }
     if (isset($error)) {
         return $error;
     }
     $sendID = 0;
     if ($_POST['send_to'] == 'city') {
         $sendID = $_POST['city_id'];
     } elseif ($_POST['send_to'] == 'group') {
         $sendID = $_POST['bgroup_id'];
     }
     $mysql->query("\n\t\t\tINSERT INTO `bulletin` (\n\t\t\t\t`name`,\n\t\t\t\t`text`,\n\t\t\t\t`datetime`,\n\t\t\t\t`send_to`,\n\t\t\t\t`send_id`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . sql_quote($_POST['name']) . "',\n\t\t\t\t'" . sql_quote($_POST['text']) . "',\n\t\t\t\tNOW(),\n\t\t\t\t'" . sql_quote($_POST['send_to']) . "',\n\t\t\t\t'" . intval($sendID) . "'\n\t\t\t)\n\t\t", __FUNCTION__);
     $bulletinID = $mysql->insert_id();
     #加载订阅列表
     if ($_POST['send_to'] == 'city') {
         $mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `users`\n\t\t\t\tWHERE `city_id` = '" . intval($_POST['city_id']) . "' AND `bulletin_subscribe` = 'true'\n\t\t\t");
         if ($mysql->num_rows() > 0) {
             while ($d = $mysql->fetch_array()) {
                 $emails[] = $d['email'];
             }
         }
     }
     #加载分组
     if ($_POST['send_to'] == 'group') {
         $mysql->query("\n\t\t\t\tSELECT u.*\n\t\t\t\tFROM `bulletin_users` AS bg\t\t\t\t\n\t\t\t\tJOIN `users` AS u\n\t\t\t\tON u.`user_id` = bg.`user_id` AND u.`bulletin_subscribe` = 'true'\n\t\t\t\tWHERE bg.`bulletingroup_id` = '" . intval($_POST['bgroup_id']) . "'\n\t\t\t");
         if ($mysql->num_rows() > 0) {
             while ($d = $mysql->fetch_array()) {
                 $emails[] = $d['email'];
             }
         }
     }
     #加载全部
     if ($_POST['send_to'] == 'active') {
         $mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `users`\n\t\t\t\tWHERE `bulletin_subscribe` = 'true'\n\t\t\t");
         if ($mysql->num_rows() > 0) {
             while ($d = $mysql->fetch_array()) {
                 $emails[] = $d['email'];
             }
         }
     }
     #加载全部
     if ($_POST['send_to'] == 'admins') {
         $mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `admins`\n\t\t\t\tWHERE `bulletin_subscribe` = 'true'\n\t\t\t");
         if ($mysql->num_rows() > 0) {
             while ($d = $mysql->fetch_array()) {
                 $emails[] = $d['email'];
             }
         }
     }
     #加载全部
     if ($_POST['send_to'] == 'site') {
         $mysql->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `bulletin_emails`\n\t\t\t\tWHERE `bulletin_subscribe` = 'true'\n\t\t\t");
         if ($mysql->num_rows() > 0) {
             while ($d = $mysql->fetch_array()) {
                 $emails[] = $d['email'];
             }
         }
     }
     #获取模板
     $mysql->query("\n\t\t\tSELECT *\n\t\t\tFROM `bulletin_template`\n\t\t\tORDER BY `id` DESC\n\t\t\tLIMIT 1\n\t\t");
     if ($mysql->num_rows() > 0) {
         $template = $mysql->fetch_array();
         $template = $template['template'];
     } else {
         $template = '{$CONTENT}';
     }
     if (isset($emails)) {
         require_once $config['system_core'] . 'classes/email.class.php';
         foreach ($emails as $email) {
             $mail = new email();
             $mail->fromEmail = 'no-reply@' . $config['domain'];
             $mail->to($email);
             $mail->subject = '[' . $config['domain'] . '] ' . $_POST['name'];
             $mail->contentType = 'text/html';
             $mail->message = langMessageReplace($template, array('DOMAIN' => $config['domain'], 'BULLETINID' => $bulletinID, 'EMAIL' => $email, 'CONTENT' => $_POST['text']));
             require_once ROOT_PATH . '/apps/system/models/system.class.php';
             $system = new system();
             $smtp = $system->is_smtp();
             $smtpconf = $system->getAllKeyValue();
             if ($smtp) {
                 $mail->email_sock($smtpconf["smtp_host"], $smtpconf["smtp_port"], 0, 'error', 10, 1, $smtpconf["smtp_user"], $smtpconf["smtp_pass"], $smtpconf["smtp_from"]);
                 $mail->send_mail_sock($mail->subject, $mail->message, $email, $smtpconf["smtp_from_name"]);
                 unset($emailClass);
             } else {
                 $mail->send();
             }
             unset($mail);
         }
     }
     return true;
 }
Beispiel #3
0
 public function report($id)
 {
     global $mysql, $langArray;
     $mysql->query("\n\t\t\tUPDATE `items_comments`\n\t\t\tSET `report_by` = '" . intval($_SESSION['user']['user_id']) . "'\n\t\t\tWHERE `id` = '" . intval($id) . "'\n\t\t\tLIMIT 1\n\t\t");
     #给管理员发送电子邮件
     $mysql->query("\n\t\t\tSELECT *\n\t\t\tFROM `system`\n\t\t\tWHERE `key` = 'admin_mail' OR `key` = 'report_mail'\n\t\t");
     while ($d = $mysql->fetch_array()) {
         if ($d['key'] == 'report_mail') {
             $sendTo = $d['value'];
             break;
         }
         $sendTo = $d['value'];
     }
     $emailClass = new email();
     $emailClass->to($sendTo);
     $emailClass->fromEmail = 'no-reply@' . DOMAIN;
     $emailClass->contentType = 'text/html';
     $emailClass->subject = "[" . DOMAIN . "] " . $langArray['email_report_comment_subject'];
     $emailClass->message = $_SESSION['user']['username'] . $langArray['email_report_comment_text'];
     $emailClass->send();
     unset($emailClass);
     return true;
 }
Beispiel #4
0
    public function sendAnswer()
    {
        global $mysql, $langArray, $data;
        if (!isset($_POST['answer']) || trim($_POST['answer']) == '') {
            $error['answer'] = $langArray['error_not_set_name'];
        }
        if (isset($error)) {
            return $error;
        }
        $mysql->query("\n\t\t\tUPDATE `contacts`\n\t\t\tSET `answer` = '" . sql_quote($_POST['answer']) . "',\n\t\t\t\t\t`answer_datetime` = NOW()\n\t\t\tWHERE `id` = '" . intval($data['id']) . "'\n\t\t\tLIMIT 1\n\t\t", __FUNCTION__);
        #发送邮件
        $emailClass = new email();
        $emailClass->to($data['email']);
        $emailClass->fromEmail = 'no-reply@' . DOMAIN;
        $emailClass->contentType = 'text/plain';
        $emailClass->subject = "[" . DOMAIN . "] 联系表单";
        $emailClass->message = $_POST['answer'] . '
		
' . $data['name'] . ' ' . $langArray['wrote'] . ' =============
' . $data['short_text'];
        $emailClass->send();
        unset($emailClass);
        return true;
    }