public function index()
 {
     $mobile = strim($GLOBALS['request']['mobile']);
     if (app_conf("SMS_ON") == 0) {
         $root['status'] = 0;
         $root['info'] = '短信功能关闭';
         output($root);
     }
     if ($mobile == '') {
         $root['status'] = 0;
         $root['info'] = '手机号码不能为空';
         output($root);
     }
     if (!check_mobile($mobile)) {
         $root['status'] = 0;
         $root['info'] = "请输入正确的手机号码";
         output($root);
     }
     if (!check_ipop_limit(CLIENT_IP, "register_verify_phone", 60, 0)) {
         $root['status'] = 0;
         $root['info'] = '发送太快了';
         output($root);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "user WHERE mobile = " . $mobile;
     $user = $GLOBALS['db']->getRow($sql);
     if (empty($user)) {
         $root['status'] = 0;
         $root['info'] = "手机号未在本站注册过";
         output($root);
     }
     //删除超过5分钟的验证码
     $sql = "DELETE FROM " . DB_PREFIX . "sms_mobile_verify WHERE mobile_phone = '{$mobile}' and add_time <=" . (get_gmtime() - 300);
     $GLOBALS['db']->query($sql);
     $code = rand(100000, 999999);
     $message = "您正在找回密码,验证码:" . $code . ",如非本人操作,请忽略本短信【" . app_conf("SHOP_TITLE") . "】";
     require_once APP_ROOT_PATH . "system/utils/es_sms.php";
     $sms = new sms_sender();
     $send = $sms->sendSms($mobile, $message);
     if ($send['status']) {
         $add_time = get_gmtime();
         $GLOBALS['db']->query("insert into " . DB_PREFIX . "sms_mobile_verify(mobile_phone,code,add_time,send_count,ip) values('{$mobile}','{$code}','{$add_time}',1," . "'" . CLIENT_IP . "')");
         /* 插入一条发送成功记录到队列表中 */
         $msg_data['dest'] = $mobile;
         $msg_data['send_type'] = 0;
         $msg_data['content'] = addslashes($message);
         $msg_data['send_time'] = $add_time;
         $msg_data['is_send'] = 1;
         $msg_data['is_success'] = 1;
         $msg_data['create_time'] = $add_time;
         $msg_data['user_id'] = intval($user['id']);
         $msg_data['title'] = "密码找回验证";
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
         $root['info'] = "验证码发出,请注意查收";
         $root['status'] = 1;
     } else {
         $root['info'] = "发送失败" . $send['msg'];
         $root['status'] = 0;
     }
     output($root);
 }
 public function send()
 {
     $id = intval($_REQUEST['id']);
     $msg_item = M("PromoteMsgList")->getById($id);
     if ($msg_item) {
         if ($msg_item['send_type'] == 0) {
             //短信
             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
             $sms = new sms_sender();
             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
             $msg_item['result'] = $result['msg'];
             $msg_item['is_success'] = intval($result['status']);
             $msg_item['send_time'] = TIME_UTC;
             M("PromoteMsgList")->save($msg_item);
             if ($result['status']) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $result['msg'];
             }
         } else {
             //邮件
             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
             $mail = new mail_sender();
             $mail->AddAddress($msg_item['dest']);
             $mail->IsHTML($msg_item['is_html']);
             // 设置邮件格式为 HTML
             $mail->Subject = $msg_item['title'];
             // 标题
             if ($msg_item['is_html']) {
                 $mail_content = $msg_item['content'] . "<br />" . sprintf(app_conf("UNSUBSCRIBE_MAIL_TIP"), app_conf("SHOP_TITLE"), "<a href='" . SITE_DOMAIN . APP_ROOT . "/subscribe.php?act=unsubscribe&code=" . base64_encode($msg_item['dest']) . "'>" . $GLOBALS['lang']['CANCEN_EMAIL'] . "</a>");
             } else {
                 $mail_content = $msg_item['content'] . " \n " . sprintf(app_conf("UNSUBSCRIBE_MAIL_TIP"), app_conf("SHOP_TITLE"), $GLOBALS['lang']['CANCEN_EMAIL'] . SITE_DOMAIN . APP_ROOT . "/subscribe.php?act=unsubscribe&code=" . base64_encode($msg_item['dest']));
             }
             $mail->Body = $mail_content;
             // 内容
             $result = $mail->Send();
             $msg_item['result'] = $mail->ErrorInfo;
             $msg_item['is_success'] = intval($result);
             $msg_item['send_time'] = TIME_UTC;
             M("PromoteMsgList")->save($msg_item);
             if ($result) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $mail->ErrorInfo;
             }
         }
     } else {
         header("Content-Type:text/html; charset=utf-8");
         echo l("SEND_NOW") . l("FAILED");
     }
 }
 public function send()
 {
     $id = intval($_REQUEST['id']);
     $msg_item = M("PromoteMsgList")->getById($id);
     if ($msg_item) {
         if ($msg_item['send_type'] == 0) {
             //短信
             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
             $sms = new sms_sender();
             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
             $msg_item['result'] = $result['msg'];
             $msg_item['is_success'] = intval($result['status']);
             $msg_item['send_time'] = NOW_TIME;
             M("PromoteMsgList")->save($msg_item);
             if ($result['status']) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $result['msg'];
             }
         } else {
             //邮件
             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
             $mail = new mail_sender();
             $mail->AddAddress($msg_item['dest']);
             $mail->IsHTML($msg_item['is_html']);
             // 设置邮件格式为 HTML
             $mail->Subject = $msg_item['title'];
             // 标题
             $mail_content = $msg_item['content'];
             $mail->Body = $mail_content;
             // 内容
             $result = $mail->Send();
             $msg_item['result'] = $mail->ErrorInfo;
             $msg_item['is_success'] = intval($result);
             $msg_item['send_time'] = NOW_TIME;
             M("PromoteMsgList")->save($msg_item);
             if ($result) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $mail->ErrorInfo;
             }
         }
     } else {
         header("Content-Type:text/html; charset=utf-8");
         echo l("SEND_NOW") . l("FAILED");
     }
 }
 public function send_demo()
 {
     $test_mobile = $_REQUEST['test_mobile'];
     require_once APP_ROOT_PATH . "system/utils/es_sms.php";
     $sms = new sms_sender();
     $result = $sms->sendSms($test_mobile, l("DEMO_SMS"));
     if ($result['status']) {
         $this->success(l("SEND_SUCCESS"), 1);
     } else {
         $this->error(l("ERROR_INFO") . $result['msg'], 1);
     }
 }
Exemple #5
0
 $msg_data['is_send'] = 0;
 $msg_data['create_time'] = get_gmtime();
 $msg_data['user_id'] = 0;
 $msg_data['is_html'] = $promote_msg['is_html'];
 $msg_data['msg_id'] = $promote_msg['id'];
 $GLOBALS['db']->autoExecute(DB_PREFIX . "promote_msg_list", $msg_data);
 //插入
 if ($id = $GLOBALS['db']->insert_id()) {
     $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "promote_msg_list where id = " . $id);
     if ($msg_item) {
         //优先改变发送状态,不论有没有发送成功
         $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_send = 1,send_time='" . get_gmtime() . "' where id =" . intval($msg_item['id']));
         if ($msg_item['send_type'] == 0) {
             //短信
             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
             $sms = new sms_sender();
             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
             //发送结束,更新当前消息状态
             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_success = " . intval($result['status']) . ",result='" . $result['msg'] . "' where id =" . intval($msg_item['id']));
         }
         if ($msg_item['send_type'] == 1) {
             //邮件
             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
             $mail = new mail_sender();
             $mail->AddAddress($msg_item['dest']);
             $mail->IsHTML($msg_item['is_html']);
             // 设置邮件格式为 HTML
             $mail->Subject = $msg_item['title'];
             // 标题
             //发送推广邮件时加上退订的内容
             if ($msg_item['is_html']) {
function send_sms_email($msg_item)
{
    $re = array('status' => 0, 'msg' => '');
    if ($msg_item['send_type'] == 0) {
        //短信
        require_once APP_ROOT_PATH . "system/utils/es_sms.php";
        $sms = new sms_sender();
        $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
        //发送结束,更新当前消息状态
        //$GLOBALS['db']->query("update ".DB_PREFIX."deal_msg_list set is_success = ".intval($result['status']).",result='".$result['msg']."',send_time='".TIME_UTC."' where id =".intval($msg_item['id']));
        $re['status'] = intval($result['status']);
        $re['msg'] = $result['msg'];
    }
    if ($msg_item['send_type'] == 1) {
        //邮件
        require_once APP_ROOT_PATH . "system/utils/es_mail.php";
        $mail = new mail_sender();
        $mail->AddAddress($msg_item['dest']);
        $mail->IsHTML($msg_item['is_html']);
        // 设置邮件格式为 HTML
        $mail->Subject = $msg_item['title'];
        // 标题
        $mail->Body = $msg_item['content'];
        // 内容
        $is_success = $mail->Send();
        $result = $mail->ErrorInfo;
        //发送结束,更新当前消息状态
        //$GLOBALS['db']->query("update ".DB_PREFIX."deal_msg_list set is_success = ".intval($is_success).",result='".$result."',send_time='".TIME_UTC."' where id =".intval($msg_item['id']));
        $re['status'] = intval($is_success);
        $re['msg'] = $result;
    }
    return $re;
}
Exemple #7
0
 public function index()
 {
     $mobile_phone = trim($GLOBALS['request']['mobile']);
     //print_r($GLOBALS['request']);
     $root = array();
     $root['return'] = 1;
     if (app_conf("SMS_ON") == 0) {
         $root['status'] = 0;
         $root['info'] = '短信功能关闭';
         //$GLOBALS['lang']['SMS_OFF'];
         output($root);
     }
     if ($mobile_phone == '') {
         $root['status'] = 0;
         $root['info'] = '手机号码不能为空';
         output($root);
     }
     if (!check_mobile($mobile_phone)) {
         $root['status'] = 0;
         $root['info'] = "请输入正确的手机号码";
         output($root);
     }
     if (!check_ipop_limit(CLIENT_IP, "mobile_verify", 60, 0)) {
         $root['status'] = 0;
         $root['info'] = '发送太快了';
         output($root);
     }
     $have_user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where mobile = '{$mobile_phone}'");
     if ($have_user_id) {
         //已经验证的
         $root['info'] = '该手机号码已经注册过!';
         $root['status'] = 0;
         output($root);
     }
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //删除超过5分钟的验证码
         $sql = "DELETE FROM " . DB_PREFIX . "sms_mobile_verify WHERE mobile_phone = '{$mobile_phone}' and add_time <=" . (get_gmtime() - 300);
         //$root['sql']=$sql;
         $GLOBALS['db']->query($sql);
         $smsSubscribe = $GLOBALS['db']->getRow("select `id`,`mobile_phone`,`code`,`send_count`,`add_time` from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '{$mobile_phone}' and type=0 order by id desc");
         $new_time = get_gmtime();
         $difftime = $new_time - $smsSubscribe['add_time'];
         if ($smsSubscribe && intval($smsSubscribe['send_count']) <= 1 && $difftime < 61) {
             $root['info'] = "验证码已发出,请注意查收";
             $root['status'] = 1;
             output($root);
         } else {
             if (empty($smsSubscribe) || empty($smsSubscribe['code'])) {
                 //$tempcode = unpack('H4',str_shuffle(md5(uniqid())));
                 $code = rand(1111, 9999);
                 //$tempcode[1];
             } else {
                 //发送一样的,验证码;
                 $code = $smsSubscribe['code'];
             }
             $message = $code . "(" . app_conf("SHOP_TITLE") . "手机绑定验证码,请完成验证),如非本人操作,请勿略本短信";
             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
             $sms = new sms_sender();
             $send = $sms->sendSms($mobile_phone, $message);
             //$send['status']=1;
             if ($send['status']) {
                 $add_time = get_gmtime();
                 $re = $GLOBALS['db']->query("insert into " . DB_PREFIX . "sms_mobile_verify(mobile_phone,code,add_time,send_count,ip) values('{$mobile_phone}','{$code}','{$add_time}',1," . "'" . CLIENT_IP . "')");
                 /*插入一条发送成功记录到队列表中*/
                 $msg_data['dest'] = $mobile_phone;
                 $msg_data['send_type'] = 0;
                 $msg_data['content'] = addslashes($message);
                 $msg_data['send_time'] = $add_time;
                 $msg_data['is_send'] = 1;
                 $msg_data['is_success'] = 1;
                 $msg_data['create_time'] = $add_time;
                 $msg_data['user_id'] = intval($have_user_id);
                 $msg_data['title'] = "手机号绑定验证";
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                 $root['info'] = "验证码发出,请注意查收";
                 $root['status'] = 1;
             } else {
                 $root['info'] = "发送失败";
                 $root['status'] = 0;
             }
         }
     } else {
         $root['user_login_status'] = 0;
     }
     output($root);
 }
 public function index()
 {
     /*
     		//创建验证码表  ,如果表存在则不创建
     		$table=$GLOBALS['db_config']['DB_PREFIX']."sms_mobile_verify";
     		$create_table="CREATE TABLE IF NOT EXISTS `".$table."` (
     					  `id` int(11) NOT NULL auto_increment,
     					  `mobile_phone` varchar(50) NOT NULL default '',
     					  `code` varchar(20) NOT NULL default '',
     					  `status` tinyint(1) NOT NULL default '0',
     					  `add_time` int(10) default NULL,
     					  `send_count` int(11) NOT NULL default '0',
     					  `type` tinyint(1) NOT NULL default '0',
     					  PRIMARY KEY  (`id`)
     					) ENGINE=MyISAM DEFAULT CHARSET=utf8";
     	   $GLOBALS['db']->query($create_table,'SILENT');
     		//end
     */
     $mobile_phone = trim($GLOBALS['request']['mobile']);
     $is_login = intval($GLOBALS['request']['is_login']);
     //is_login 0:仅注册,会判断手机号码,是否存在; 1:可登陆,可注册 不判断手机号码是否存在;
     $root = array();
     //$root['return'] = 1;
     /*
     $isMobile = preg_match("/^(13\d{9}|14\d{9}|18\d{9}|15\d{9})|(0\d{9}|9\d{8})$/",$mobile_phone);
     if(!$isMobile)
     {
     	$root['info']="请输入正确的手机号码";
     	$root['status']=0;
     	output($root);
     }	
     */
     if (app_conf("SMS_ON") == 0) {
         $root['status'] = 0;
         $root['info'] = '短信功能关闭';
         //$GLOBALS['lang']['SMS_OFF'];
         output($root);
     }
     if ($mobile_phone == '') {
         $root['status'] = 0;
         $root['info'] = '手机号码不能为空';
         output($root);
     }
     if (!check_mobile($mobile_phone)) {
         $root['status'] = 0;
         $root['info'] = "请输入正确的手机号码";
         output($root);
     }
     if (!check_ipop_limit(CLIENT_IP, "register_verify_phone", 60, 0)) {
         $root['status'] = 0;
         $root['info'] = '发送太快了';
         output($root);
     }
     $have_user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where mobile = '{$mobile_phone}'");
     //is_login 0:仅注册,会判断手机号码,是否存在; 1:可登陆,可注册 不判断手机号码是否存在;
     if ($is_login == 0 && $have_user_id) {
         //已经验证的
         $root['info'] = '该手机号码已经注册过!';
         $root['status'] = 0;
         output($root);
     }
     //删除超过5分钟的验证码
     $sql = "DELETE FROM " . DB_PREFIX . "sms_mobile_verify WHERE mobile_phone = '{$mobile_phone}' and add_time <=" . (get_gmtime() - 300);
     //$root['sql']=$sql;
     $GLOBALS['db']->query($sql);
     $smsSubscribe = $GLOBALS['db']->getRow("select `id`,`mobile_phone`,`code`,`send_count`,`add_time` from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '{$mobile_phone}' and type=0 order by id desc");
     $new_time = get_gmtime();
     $difftime = $new_time - $smsSubscribe['add_time'];
     if ($smsSubscribe && intval($smsSubscribe['send_count']) <= 1 && $difftime < 61) {
         $root['info'] = "验证码已发出,请注意查收";
         $root['status'] = 1;
         output($root);
     } else {
         if (empty($smsSubscribe) || empty($smsSubscribe['code'])) {
             //$tempcode = unpack('H4',str_shuffle(md5(uniqid())));
             $code = rand(1111, 9999);
             //$tempcode[1];
         } else {
             //发送一样的,验证码;
             $code = $smsSubscribe['code'];
         }
         $message = $code . "(" . app_conf("SHOP_TITLE") . "手机绑定验证码,请完成验证),如非本人操作,请勿略本短信";
         require_once APP_ROOT_PATH . "system/utils/es_sms.php";
         $sms = new sms_sender();
         $send = $sms->sendSms($mobile_phone, $message);
         //$send['status']=1;
         if ($send['status']) {
             $add_time = get_gmtime();
             $re = $GLOBALS['db']->query("insert into " . DB_PREFIX . "sms_mobile_verify(mobile_phone,code,add_time,send_count,ip) values('{$mobile_phone}','{$code}','{$add_time}',1," . "'" . CLIENT_IP . "')");
             /*插入一条发送成功记录到队列表中*/
             $msg_data['dest'] = $mobile_phone;
             $msg_data['send_type'] = 0;
             $msg_data['content'] = addslashes($message);
             $msg_data['send_time'] = $add_time;
             $msg_data['is_send'] = 1;
             $msg_data['is_success'] = 1;
             $msg_data['create_time'] = $add_time;
             $msg_data['user_id'] = intval($have_user_id);
             $msg_data['title'] = "手机号绑定验证";
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
             $root['info'] = "验证码发出,请注意查收";
             $root['status'] = 1;
         } else {
             $root['info'] = "发送失败" . $send['msg'];
             $root['status'] = 0;
         }
     }
     output($root);
 }
Exemple #9
0
 public function promote_msg_list()
 {
     set_time_limit(0);
     //推广队列的群发
     $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 1 where name = 'PROMOTE_MSG_LOCK' and `value` = 0");
     $rs = $GLOBALS['db']->affected_rows();
     if ($rs) {
         $promote_msg = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "promote_msg where send_status <> 2 and send_time <= " . NOW_TIME . " order by id asc limit 1");
         if ($promote_msg) {
             $last_id = intval($GLOBALS['db']->getOne("select value from " . DB_PREFIX . "conf where name = 'PROMOTE_MSG_PAGE'"));
             //开始更新为发送中
             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg set send_status = 1 where id = " . intval($promote_msg['id']) . " and send_status <> 2");
             switch (intval($promote_msg['send_type'])) {
                 case 0:
                     //会员组
                     $group_id = intval($promote_msg['send_type_id']);
                     if ($promote_msg['type'] == 0) {
                         //短信
                         $sql = "select u.id,u.mobile from " . DB_PREFIX . "user as u where u.mobile <> '' ";
                         if ($group_id > 0) {
                             $sql .= " and u.group_id = " . $group_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['mobile'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     if ($promote_msg['type'] == 1) {
                         //邮件
                         $sql = "select u.id,u.email from " . DB_PREFIX . "user as u where u.email <> '' ";
                         if ($group_id > 0) {
                             $sql .= " and u.group_id = " . $group_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['email'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     break;
                 case 1:
                     //会员等级
                     $level_id = intval($promote_msg['send_type_id']);
                     if ($promote_msg['type'] == 0) {
                         //短信
                         $sql = "select u.id,u.mobile from " . DB_PREFIX . "user as u where u.mobile <> '' ";
                         if ($level_id > 0) {
                             $sql .= " and u.level_id = " . $level_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['mobile'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     if ($promote_msg['type'] == 1) {
                         //邮件
                         $sql = "select u.id,u.email from " . DB_PREFIX . "user as u where u.email <> '' ";
                         if ($level_id > 0) {
                             $sql .= " and u.level_id = " . $level_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['email'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     break;
                 case 2:
                     //自定义
                     $send_define_data = trim($promote_msg['send_define_data']);
                     //自定义的内容
                     $dest_array = preg_split("/[ ,]/i", $send_define_data);
                     foreach ($dest_array as $k => $v) {
                         $rs = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "promote_msg_list where msg_id = " . intval($promote_msg['id']) . " and dest = '" . $v . "'");
                         if ($rs == 0) {
                             $dest = $v;
                             break;
                         }
                     }
                     $last_id = 0;
                     break;
             }
             if ($dest) {
                 //开始创建一个新的发送队列
                 $msg_data['dest'] = $dest;
                 $msg_data['send_type'] = $promote_msg['type'];
                 $msg_data['content'] = addslashes($promote_msg['content']);
                 $msg_data['title'] = $promote_msg['title'];
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = NOW_TIME;
                 $msg_data['user_id'] = intval($uid);
                 $msg_data['is_html'] = $promote_msg['is_html'];
                 $msg_data['msg_id'] = $promote_msg['id'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "promote_msg_list", $msg_data);
                 //插入
                 if ($id = $GLOBALS['db']->insert_id()) {
                     $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "promote_msg_list where id = " . $id);
                     if ($msg_item) {
                         //优先改变发送状态,不论有没有发送成功
                         $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_send = 1,send_time='" . NOW_TIME . "' where id =" . intval($msg_item['id']));
                         if ($msg_item['send_type'] == 0) {
                             //短信
                             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
                             $sms = new sms_sender();
                             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
                             //发送结束,更新当前消息状态
                             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_success = " . intval($result['status']) . ",result='" . $result['msg'] . "' where id =" . intval($msg_item['id']));
                         }
                         if ($msg_item['send_type'] == 1) {
                             //邮件
                             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
                             $mail = new mail_sender();
                             $mail->AddAddress($msg_item['dest']);
                             $mail->IsHTML($msg_item['is_html']);
                             // 设置邮件格式为 HTML
                             $mail->Subject = $msg_item['title'];
                             // 标题
                             $mail->Body = $msg_item['content'];
                             // 内容
                             $is_success = $mail->Send();
                             $result = $mail->ErrorInfo;
                             //发送结束,更新当前消息状态
                             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_success = " . intval($is_success) . ",result='" . $result . "' where id =" . intval($msg_item['id']));
                         }
                     }
                 }
                 $GLOBALS['db']->query("update " . DB_PREFIX . "conf set value = " . intval($last_id) . " where name='PROMOTE_MSG_PAGE'");
             } else {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg set send_status = 2 where id = " . intval($promote_msg['id']));
                 $GLOBALS['db']->query("update " . DB_PREFIX . "conf set value = 0 where name='PROMOTE_MSG_PAGE'");
             }
         }
         $count = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "promote_msg where send_status <> 2 and send_time <=" . get_gmtime()));
         $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 0 where name = 'PROMOTE_MSG_LOCK'");
     } else {
         $count = 0;
     }
     $data['count'] = $count;
     ajax_return($data, true);
 }
 public function sms_demo($tel)
 {
     $test_mobile = $tel;
     require_once APP_ROOT_PATH . "system/utils/es_sms.php";
     $sms = new sms_sender();
     $result = $sms->sendSms($test_mobile, l("DEMO_SMS"));
     return $result;
 }