//校验用户或者编号是否存在 $check_user_info = array(); $check_user_info = DB::fetch_first("SELECT user_id,user_password FROM " . DB::table('users') . " WHERE user_name ='" . $user_name . "' AND isdelete = 0 LIMIT 1"); if (empty($check_user_info)) { $check_user_info = DB::fetch_first("SELECT user_id,user_password FROM " . DB::table('users') . " WHERE user_id ='" . $user_name . "' AND isdelete = 0 LIMIT 1"); } //校验密码 if ($check_user_info['user_id']) { $user_encode_password = encode_password($user_password); if ($user_encode_password == $check_user_info['user_password']) { if ($api_client) { allow_crossdomain(); $userinfo = DB::fetch_first("SELECT * FROM " . DB::table('users') . " WHERE user_id ='" . $check_user_info['user_id'] . "' LIMIT 1"); //并返回用户信息 $return = array('errcode' => 'e_1000', 'errmsg' => lang('error', 'e_1000'), 'data' => $userinfo); } elseif ($location_url) { $user['user_id'] = $check_user_info['user_id']; ext::synlogin($user, $user); header('location:' . $location_url . ''); die; } else { $user['user_id'] = $check_user_info['user_id']; ext::synlogin($user, $user); $return = array('errcode' => 'e_1000', 'errmsg' => lang('error', 'e_1000'), 'data' => ''); } } } } echo format_data($return, $data_format_type); break; }
function url_login() { //DEBUG 模拟登录 $user_name = isset($_GET['user_name']) ? $_GET['user_name'] : ''; $user_password = isset($_GET['user_password']) ? $_GET['user_password'] : ''; $url = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; $replace_pram = 'user_name=' . $user_name . '&user_password='******'', $url); if (!empty($user_name) && !empty($user_password)) { /* * url pram add user_name=teacher1&user_password=e10adc3949ba59abbe56e057f20f883e * eg: home.php?user_name=teacher1&user_password=e10adc3949ba59abbe56e057f20f883e */ $member = DB::fetch_first("SELECT user_id,user_password from " . DB::table('users') . " WHERE user_name='" . $user_name . "' LIMIT 1"); if (empty($member)) { $member = DB::fetch_first("SELECT user_id,user_password from " . DB::table('users') . " WHERE user_id='" . $user_name . "' LIMIT 1"); } if ($member['user_password'] && $member['user_id']) { $user_id = $member['user_id']; //校验密码 是否正确 $uc_password = sha1($user_password); if ($uc_password == $member['user_password']) { //loaducenter(); //$ucsynlogin = uc_user_synlogin($uid); $user['user_id'] = $user_id; ext::synlogin($user, $user); header('location:' . $location_url . ''); die; } } } }