function sendsms($mobile, $send_txt, $tplid = 1, $id_code = '', $siteid = 1) { pc_base::load_app_class('smsapi', 'sms', 0); //引入smsapi类 $sms_setting = getcache('sms', 'sms'); $sms_uid = $sms_setting[$siteid]['userid']; //短信接口用户ID $sms_pid = $sms_setting[$siteid]['productid']; //产品ID $sms_passwd = $sms_setting[$siteid]['sms_key']; //32位密码 $smsapi = new smsapi($sms_uid, $sms_pid, $sms_passwd); //初始化接口类 $mobile = explode(',', $mobile); $code = $smsapi->send_sms($mobile, $send_txt, 0, CHARSET, $id_code, $tplid, 1); //发送短信 if ($code == 0) { return 0; } else { return sms_status($code, 1); } }
} //短信功能关闭 $sms_uid = $sms_setting[$siteid]['userid']; //短信接口用户ID $sms_pid = $sms_setting[$siteid]['productid']; //产品ID $sms_passwd = $sms_setting[$siteid]['sms_key']; //32位密码 $posttime = SYS_TIME - 600; $rs = $sms_report_db->get_one("`mobile`='{$mobile}' AND `posttime`>'{$posttime}'"); if ($rs['id_code']) { $id_code = $rs['id_code']; } else { $id_code = random(6); //唯一吗,用于扩展验证 } //$send_txt = '尊敬的用户您好,您在'.$sitename.'的注册验证码为:'.$id_code.',验证码有效期为5分钟。'; $send_txt = $id_code; $send_userid = intval($_GET['send_userid']); //操作者id pc_base::load_app_class('smsapi', 'sms', 0); //引入smsapi类 $smsapi = new smsapi($sms_uid, $sms_pid, $sms_passwd); //初始化接口类 //$smsapi->get_price(); //获取短信剩余条数和限制短信发送的ip地址 $mobile = explode(',', $mobile); $tplid = 1; $sent_time = intval($_POST['sendtype']) == 2 && !empty($_POST['sendtime']) ? trim($_POST['sendtime']) : date('Y-m-d H:i:s', SYS_TIME); $smsapi->send_sms($mobile, $send_txt, $sent_time, CHARSET, $id_code, $tplid); //发送短信 echo 0;
if (!preg_match('/^1([0-9]{9})/', $mobile)) { exit('mobile phone error'); } if (intval($sms_setting[$siteid]['sms_enable']) == 0) { exit(1); } //短信功能关闭 //检查一个小时内发短信次数是还超过3次 $posttime = SYS_TIME - 3600; $where = "`mobile`='{$mobile}' AND `posttime`>'{$posttime}'"; $num = $sms_report_db->count($where); if ($num > 2) { exit(1); //一小时内发送短信数量超过限制 3 条 } $sms_uid = $sms_setting[$siteid]['userid']; //短信接口用户ID $sms_pid = $sms_setting[$siteid]['productid']; //产品ID $sms_passwd = $sms_setting[$siteid]['sms_key']; //32位密码 $smsapi = new smsapi($sms_uid, $sms_pid, $sms_passwd); //初始化接口类 $id_code = random(6); //唯一吗,用于扩展验证 $send_txt = '尊敬的用户您好,您在' . $sitename . '的注册验证码为:' . $id_code . ',验证码有效期为5分钟。'; $content = safe_replace($send_txt); $sent_time = intval($_POST['sendtype']) == 2 && !empty($_POST['sendtime']) ? trim($_POST['sendtime']) : date('Y-m-d H:i:s', SYS_TIME); $smsapi->send_sms($mobile, $content, $sent_time, CHARSET, $id_code); //发送短信 exit(1);
exit('-3'); //当日单IP 发送短信数量超过 $allow_max_ip } if (intval($sms_setting[$siteid]['sms_enable']) == 0) { exit('-99'); } //短信功能关闭 $sms_uid = $sms_setting[$siteid]['userid']; //短信接口用户ID $sms_pid = $sms_setting[$siteid]['productid']; //产品ID $sms_passwd = $sms_setting[$siteid]['sms_key']; //32位密码 $id_code = random(6); //唯一吗,用于扩展验证 //$send_txt = '尊敬的用户您好,您在'.$sitename.'的注册验证码为:'.$id_code.',验证码有效期为5分钟。'; $send_txt = $sitename . '||' . $id_code; $send_userid = intval($_GET['send_userid']); //操作者id $smsapi = new smsapi($sms_uid, $sms_pid, $sms_passwd); //初始化接口类 $smsapi->get_price(); //获取短信剩余条数和限制短信发送的ip地址 $mobile = explode(',', $mobile); $content = safe_replace($send_txt); $tplid = 13; $sent_time = intval($_POST['sendtype']) == 2 && !empty($_POST['sendtime']) ? trim($_POST['sendtime']) : date('Y-m-d H:i:s', SYS_TIME); $smsapi->send_sms($mobile, $content, $sent_time, CHARSET, $id_code, $tplid); //发送短信 //echo $smsapi->statuscode; 由于服务器延迟的问题,先返回发送成功的提示,以免页面等待时候过长,体验不好 echo 0;