public function check_phone() { //获取验证码 import('Class.SendMsg', APP_PATH); // $phonenum="13017148493"; // $phonecode="{\"param1\":\"1000\"}"; if (!IS_AJAX) { halt('页面不存在!'); } //电话号码 $phonenum = I('phone_num', '', 'htmlspecialchars'); $dm_phone["repay_id"] = I("fund_repay_id"); //项目id $dm_phone["phone_number"] = $phonenum; if ($phone = M("dm_phone")->where($dm_phone)->find()) { //该号码已经支持过该项目 $this->ajaxReturn(array('Code' => 2)); return 0; } M("dm_phone")->add($dm_phone); $count = M("dm_phone")->where('repay_id=' . I("fund_repay_id"))->count(); //这个项目的基金支持数 $limits = M("dm_repay")->where("id=" . I("fund_repay_id"))->getField("limits"); //回报的限定人数 if ($count > $limits && $limits != 0) { //删除 M("dm_phone")->where($dm_phone)->delete(); $this->ajaxReturn(array('Code' => 3)); return 0; } M("dm_phone")->where($dm_phone)->delete(); // $phonenum=I('phone_num','','htmlspecialchars'); //电话号码 // $dm_phone["repay_id"]=I("fund_repay_id");//项目id // session('fund_phone',I('phone_num','','htmlspecialchars')); // //设置验证码session // $_SESSION["code_time"]=time();//验证码过期时间 // session('send_phone_code',1);//验证码 // $this->ajaxReturn(array( // 'Code'=>1, // 'dm_phone'=>$dm_phone, // )); // return 0; $this->security_code = rand(10000, 99999); $phonecode = "{\"param1\":\"{$this->security_code}\"}"; $msg = new SendMsg($phonenum, $phonecode); $msg->init(); // $this->security_code=10000; // $code=session('security_code'); //设置手机号码session session('fund_phone', I('phone_num', '', 'htmlspecialchars')); //设置验证码session $_SESSION["code_time"] = time(); //验证码过期时间 session('send_phone_code', $this->security_code); //验证码 $this->ajaxReturn(array('Code' => 1)); return 0; }
public function phonenum() { import('Class.SendMsg', APP_PATH); // $phonenum="13017148493"; // $phonecode="{\"param1\":\"1000\"}"; if (!IS_POST) { halt('页面不存在!'); } $phonenum = I('post.phone_num', '', 'htmlspecialchars'); $this->security_code = rand(10000, 99999); $phonecode = "{\"param1\":\"{$this->security_code}\"}"; $msg = new SendMsg($phonenum, $phonecode); $msg->init(); // $this->security_code=10000; $code = session('security_code'); if (isset($code)) { session('security_code', null); } session('security_code', $this->security_code); $data = 1; $this->ajaxReturn($data); }