Example #1
0
 protected function _getCode($email = '')
 {
     $email = htmlspecialchars($email);
     $results = User::getUserInfoByEmail($email);
     if ($results) {
         $code = md5(uniqid());
         $data = array();
         $data['code'] = $code;
         $data['email'] = $email;
         $data['expire'] = time() + self::_expireTime();
         $rs = Code::insertCodeInfo($data);
         if ($rs) {
             return $code;
         } else {
             return false;
         }
     } else {
         $msg['msg'] = '不存在这个注册邮箱,请重新输入!';
         $msg['result'] = '-3';
         echo json_encode($msg);
         throw new Exception('exit');
     }
 }