コード例 #1
0
 public function add_auth($data, $file_name = '')
 {
     global $kekezu, $user_info, $_lang;
     $moblie_obj = new Keke_witkey_auth_mobile_class();
     $fdata = $this->format_auth_apply($data);
     $valid_code = kekezu::randomkeys(4);
     $fdata['valid_code'] = $valid_code;
     $fdata[auth_time] = time();
     $msg_obj = new keke_msg_class();
     $content = $_lang['dear'] . $user_info['username'] . $_lang['hello'] . $_lang['mobile_auth_code'] . " {$fdata['valid_code']}   " . $_lang['from'] . "[{$kekezu->_sys_config[website_url]}]";
     $msg_res = $msg_obj->send_phone_sms($fdata['mobile'], $content);
     if ($msg_res == "操作成功") {
         $auth_info = db_factory::get_one(sprintf("select * from %switkey_auth_mobile where uid='%d'", TABLEPRE, $user_info['uid']));
         if ($auth_info) {
             $moblie_obj->setWhere('uid=' . $fdata['uid']);
             $moblie_obj->setMobile($fdata[mobile]);
             $moblie_obj->setValid_code($fdata['valid_code']);
             $moblie_obj->setAuth_status(0);
             $moblie_obj->edit_keke_witkey_auth_mobile();
         } else {
             $moblie_obj->setUid($fdata[uid]);
             $moblie_obj->setMobile($fdata[mobile]);
             $moblie_obj->setValid_code($fdata['valid_code']);
             $moblie_obj->setUsername($fdata[username]);
             $moblie_obj->setCash($fdata[cash]);
             $moblie_obj->setAuth_time($fdata[auth_time]);
             $moblie_obj->setAuth_status(0);
             $moblie_obj->create_keke_witkey_auth_mobile();
         }
         $fdata['start_time'] == $fdata['end_time'] and $end_time = $fdata['end_time'] or $end_time = 0;
         $res = $this->add_auth_record($fdata['uid'], $fdata['username'], $this->_auth_code, $end_time, 0);
         parse_str($_SERVER['QUERY_STRING'], $arr);
         $arr[auth_step] = "step2";
         unset($arr['inajax']);
         return true;
     }
     return false;
 }