本文整理匯總了PHP中Core\Helper\Utility\Route::jumpBack方法的典型用法代碼示例。如果您正苦於以下問題:PHP Route::jumpBack方法的具體用法?PHP Route::jumpBack怎麽用?PHP Route::jumpBack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core\Helper\Utility\Route
的用法示例。
在下文中一共展示了Route::jumpBack方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->minLength(2, '用戶名最短為2個字符')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->minLength(6, '密碼最短為6個非空字符')->validate('password');
$input['email'] = $validator->validate('email');
$input['mobile_phone'] = $validator->digits('手機號格式不對')->validate('mobile_phone');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
// 手機輸入,輸入法經常無故添加空格,我們需要去除所有的空額,防止出錯
$p_captcha = Utils::filterAlnumStr($p_captcha);
// 需要跳轉回去的地址
$returnUrl = $validator->validate('returnUrl');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage('驗證碼錯誤[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']');
goto out_fail;
}
$userService = new UserService();
// 檢查用戶是否已經注冊
$isUserExist = $userService->isUserExist($input['user_name'], $input['email']);
if ($isUserExist) {
$this->addFlashMessage($isUserExist . '已經存在');
goto out_fail;
}
// 注冊用戶
$user = $userService->registerUser($input);
if (!$user) {
$this->addFlashMessage('用戶注冊失敗,請稍後刷新頁麵重試');
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
$this->addFlashMessage("注冊成功");
if ($returnUrl) {
header('Location:' . $returnUrl);
return;
} else {
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}
return;
// 這裏正常返回
out_fail:
// 失敗,從這裏出口
$smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time())));
$smarty->display('user_register.tpl', 'User|Register|post');
}
示例2: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->validate('password');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage("驗證碼錯誤");
goto out_fail;
}
$adminService = new AdminUserService();
// 驗證用戶登陸
$admin = $adminService->doAuthAdmin($input['user_name'], $input['user_name'], $input['password']);
if (!$admin) {
$this->addFlashMessage("登陸失敗,用戶名、密碼錯誤");
goto out_fail;
}
// 記錄用戶的登陸信息
$adminUserInfo = $admin->toArray();
unset($adminUserInfo['password']);
// 不要記錄密碼
// 取得用戶的角色權限
$adminUserInfo['role_action_list'] = '';
if ($adminUserInfo['role_id'] > 0) {
$metaRoleService = new MetaRoleService();
$role = $metaRoleService->loadRoleById($adminUserInfo['role_id']);
if (!$role->isEmpty()) {
// 賦值角色權限
$adminUserInfo['role_action_list'] = $role['meta_data'];
}
}
AuthHelper::saveAuthUser($adminUserInfo);
try {
// 記錄用戶登錄日誌
AdminLog::logAdminOperate('user.login', '用戶登錄', 'IP:' . $f3->get('IP'));
} catch (\Exception $e) {
// do nothing
}
$this->addFlashMessage("登陸成功");
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
return;
// 這裏正常返回
out_fail:
// 失敗從這裏入口
$smarty->display('user_login.tpl', 'User|Login|post');
}
示例3: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->minLength(2, '用戶名最短為2個字符')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->minLength(6, '密碼最短為6個非空字符')->validate('password');
$input['email'] = $validator->validate('email');
$input['mobile_phone'] = $validator->digits('手機號格式不對')->validate('mobile_phone');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage("驗證碼錯誤");
goto out_fail;
}
$userService = new UserService();
// 檢查用戶是否已經注冊
$isUserExist = $userService->isUserExist($input['user_name'], $input['email']);
if ($isUserExist) {
$this->addFlashMessage($isUserExist . '已經存在');
goto out_fail;
}
// 注冊用戶
$user = $userService->registerUser($input);
if (!$user) {
$this->addFlashMessage('用戶注冊失敗,請稍後刷新頁麵重試');
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
// 設置用戶名在網頁顯示
ClientData::saveClientData(Login::$clientDataIsUserLoginKey, true);
ClientData::saveClientData(Login::$clientDataUserNameDisplayKey, $user->user_name);
$this->addFlashMessage("注冊成功");
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
return;
// 這裏正常返回
out_fail:
// 失敗,從這裏出口
$smarty->display('user_login.tpl', 'User|Register|post');
}
示例4: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->validate('password');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
// 手機輸入,輸入法經常無故添加空格,我們需要去除所有的空額,防止出錯
$p_captcha = Utils::filterAlnumStr($p_captcha);
// 需要跳轉回去的地址
$returnUrl = $validator->validate('returnUrl');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage('驗證碼錯誤[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']');
goto out_fail;
}
$userService = new UserService();
// 驗證用戶登陸
$user = $userService->doAuthUser($input['user_name'], $input['user_name'], $input['password']);
if (!$user) {
$this->addFlashMessage("登陸失敗,用戶名、密碼錯誤");
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
$this->addFlashMessage("登陸成功");
if ($returnUrl) {
header('Location:' . $returnUrl);
return;
} else {
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}
return;
// 這裏正常返回
out_fail:
// 失敗從這裏出口
$smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time())));
$smarty->display('user_login.tpl', 'User|Login|post');
}
示例5: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->validate('password');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage("驗證碼錯誤");
goto out_fail;
}
$userService = new UserService();
// 驗證用戶登陸
$user = $userService->doAuthUser($input['user_name'], $input['user_name'], $input['password']);
if (!$user) {
$this->addFlashMessage("登陸失敗,用戶名、密碼錯誤");
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
// 設置用戶名在網頁顯示
ClientData::saveClientData(Login::$clientDataIsUserLoginKey, true);
ClientData::saveClientData(Login::$clientDataUserNameDisplayKey, $user->user_name);
$this->addFlashMessage("登陸成功");
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
return;
// 這裏正常返回
out_fail:
// 失敗從這裏入口
$smarty->display('user_login.tpl', 'User|Login|post');
}
示例6: get
/**
* QQ 登陸
*/
public function get($f3)
{
global $logger;
global $smarty;
// 驗證 state 參數,防止 csrf 攻擊
if ($_REQUEST['state'] != $f3->get('SESSION[qq_login_state]')) {
$errorMessage = 'qq login state doest not match, GET[' . $f3->get('GET[state]') . '] SESSION[' . $f3->get('SESSION[qq_login_state]') . ']';
$logger->addLogInfo(\Core\Log\Base::NOTICE, 'QQLOGIN', $errorMessage);
goto out;
}
// 獲取 access_token
$callback = RouteHelper::makeUrl('/Thirdpart/QQAuth/Callback', null, false, true);
$tokenUrl = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&" . "client_id=" . QQAuthPlugin::getOptionValue('qqauth_appid') . "&redirect_uri=" . urlencode($callback) . "&client_secret=" . QQAuthPlugin::getOptionValue('qqauth_appkey') . "&code=" . $_REQUEST["code"];
$response = $this->get_url_contents($tokenUrl);
if (strpos($response, "callback") !== false) {
$lpos = strpos($response, "(");
$rpos = strrpos($response, ")");
$response = substr($response, $lpos + 1, $rpos - $lpos - 1);
$msg = json_decode($response);
if (isset($msg->error)) {
$errorMessage = 'error [' . $msg->error . '] msg [' . $msg->error_description . ']';
$logger->addLogInfo(\Core\Log\Base::NOTICE, 'QQLOGIN', $errorMessage);
goto out;
}
}
$params = array();
parse_str($response, $params);
$logger->addLogInfo(\Core\Log\Base::DEBUG, 'QQLOGIN', print_r($params, true));
$accessToken = $params["access_token"];
// 取得 OpenID
$graphUrl = "https://graph.qq.com/oauth2.0/me?access_token=" . $accessToken;
$response = $this->get_url_contents($graphUrl);
if (strpos($response, "callback") !== false) {
$lpos = strpos($response, "(");
$rpos = strrpos($response, ")");
$response = substr($response, $lpos + 1, $rpos - $lpos - 1);
}
$user = json_decode($response);
if (isset($user->error)) {
$errorMessage = 'error [' . $msg->error . '] msg [' . $msg->error_description . ']';
goto out;
}
$openId = $user->openid;
// 取得 userInfo
$get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $accessToken . "&oauth_consumer_key=" . QQAuthPlugin::getOptionValue('qqauth_appid') . "&openid=" . $openId . "&format=json";
$response = $this->get_url_contents($get_user_info);
$qqUserInfo = json_decode($response, true);
$sns_login = "qq:{$openId}";
// 用戶登陸操作
$userBasicService = new UserBasicService();
$authUser = $userBasicService->doAuthSnsUser($sns_login, null, null, false);
if ($authUser) {
goto out_login_user;
}
// 之前沒有登陸過,自動注冊用戶
$authUser = $userBasicService->doAuthSnsUser($sns_login, $openId . '@qq.com', $openId . '@qq.com', true);
$logger->addLogInfo(\Core\Log\Base::INFO, 'QQLOGIN', '注冊QQ用戶:' . print_r($qqUserInfo, true));
out_login_user:
AuthHelper::saveAuthUser($authUser->toArray(), 'qqlogin');
// 設置用戶名在網頁顯示
ClientData::saveClientData(\Controller\User\Login::$clientDataIsUserLoginKey, true);
ClientData::saveClientData(\Controller\User\Login::$clientDataUserNameDisplayKey, 'QQ用戶:' . $qqUserInfo['nickname']);
out:
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}
示例7: get
/**
* 360 登陸
*/
public function get($f3)
{
global $logger;
if (empty($_GET['code'])) {
$this->addFlashMessage('360聯合登陸失敗,Code 不存在');
goto out;
}
require_once 'sdk/QClient.php';
// 獲取access token
$callback = RouteHelper::makeUrl('/Thirdpart/Dev360Auth/Callback', null, false, true);
$oauth = new \QOAuth2(Dev360AuthPlugin::getOptionValue(self::$optionKeyPrefix . 'dev360auth_app_key'), Dev360AuthPlugin::getOptionValue(self::$optionKeyPrefix . 'dev360auth_app_secrect'), '');
$token = $oauth->getAccessTokenByCode($_GET['code'], $callback);
if (empty($token['access_token'])) {
$this->addFlashMessage('360聯合登陸失敗,獲取 access_token 失敗');
goto out;
}
// 調用API,獲取用戶信息
$client = new \QClient(Dev360AuthPlugin::getOptionValue(self::$optionKeyPrefix . 'dev360auth_app_key'), Dev360AuthPlugin::getOptionValue(self::$optionKeyPrefix . 'dev360auth_app_secrect'), $token['access_token']);
$user = $client->userMe();
if (empty($user)) {
$this->addFlashMessage('360聯合登陸失敗,用戶信息為空');
goto out;
}
$param = array('user_id' => $user['id'], 'username' => !empty($user['name']) ? (string) $user['name'] : '網友', 'token' => $token['access_token']);
// put all values into $_POST[]
$qid = $param['user_id'];
$qname = urldecode($param['username']);
$qmail = '';
if (empty($qid)) {
// 沒有 qid 沒法登陸
$this->addFlashMessage('360聯合登陸失敗,沒有 qid');
goto out;
}
$sns_login = "hao360:{$qid}";
// 用戶登陸操作
$userBasicService = new UserBasicService();
$authUser = $userBasicService->doAuthSnsUser($sns_login, null, null, false);
if ($authUser) {
goto out_login_user;
}
// 用戶不存在,自動注冊一個用戶
if (empty($qmail)) {
$qmail = '' . $qid . '@360.cn';
}
if (empty($qname)) {
$qname = $qmail;
}
$retry = 10;
// 重試 10 次
$regUserName = $qname;
while ($userBasicService->isUserExist($regUserName, null) && $retry-- > 0) {
$regUserName = $qname . '_' . rand(10000, 99999);
}
if ($retry <= 0) {
$this->addFlashMessage('360聯合登陸失敗,用戶名已經存在,無法自動注冊');
goto out;
}
$authUser = $userBasicService->doAuthSnsUser($sns_login, $qname, $qmail, true);
$logger->addLogInfo(\Core\Log\Base::INFO, 'DEV360AUTH', '注冊360用戶' . print_r(array('sns_login' => $sns_login, 'qname' => $qname, 'qmail' => $qmail), true));
out_login_user:
AuthHelper::saveAuthUser($authUser->toArray(), 'dev360auth');
// 設置用戶名在網頁顯示
ClientData::saveClientData(\Controller\User\Login::$clientDataIsUserLoginKey, true);
ClientData::saveClientData(\Controller\User\Login::$clientDataUserNameDisplayKey, '360用戶:' . $authUser['user_name']);
out:
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}