本文整理汇总了PHP中_redirect函数的典型用法代码示例。如果您正苦于以下问题:PHP _redirect函数的具体用法?PHP _redirect怎么用?PHP _redirect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_redirect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
function callback($ctx)
{
$jump = htmlspecialchars(trim($_GET['jump']));
self::validate_url($jump);
if (!$this->appid || !$this->secret) {
_redirect($jump);
}
$code = urlencode(htmlspecialchars(trim($_GET['code'])));
if (!$code) {
_redirect($jump);
}
$wx_url = 'https://api.weixin.qq.com/sns/oauth2/access_token';
$wx_url = "{$wx_url}?appid={$this->appid}&secret={$this->secret}&code={$code}&grant_type=authorization_code";
$resp = Http::get($wx_url);
$ret = @json_decode($resp, true);
if (is_array($ret) && $ret['openid']) {
$connect = WxConnect::get_by('wx_openid', $ret['openid']);
if ($connect) {
Logger::info("wx_openid[{$ret['openid']}] oauth login, uid: {$connect->user_id}");
$profile = Profile::get($connect->user_id);
if ($profile && $profile->status != Profile::STATUS_LOCK) {
UC::force_login($profile);
}
} else {
// 兼容 /weixin/bind, 因为它依赖 session 中的 openid, 所以这里设置
session_start();
$_SESSION['wx_openid'] = $ret['openid'];
}
} else {
Logger::info("weixin oauth, code: {$code}, resp: {$resp}, " . Http::$error);
}
_redirect($jump);
}
示例2: edit
function edit($ctx)
{
_render('form');
try {
$channel_id = (string) $_GET['id'] !== '' ? intval($_GET['id']) : '';
$m = Channel::get($channel_id);
if (!$m) {
_redirect($this->_list_url());
return;
}
$wx_info = WxChannelInfo::get($channel_id);
if ($_POST) {
$f = $_POST['f'];
// 生成二维码 每次保存都更新一次 但是如果已经发放了 其实不能更新的 因为会过期 所以,永久的不能更新 临时的更新可以处理
$expire_type = intval($f['expire_type']);
$expire_seconds = intval($f['expire_seconds']);
$expire_seconds = max(0, $expire_seconds);
$status = intval($f['status']);
$wx_info = WxChannelInfo::qrcode_create($channel_id, $expire_type, $expire_seconds, $status);
_redirect($this->_list_url());
}
$ctx->wx_info = $wx_info;
$ctx->m = $m;
} catch (Exception $e) {
$msg = $e->getMessage();
$ctx->errmsg = $msg;
$ctx->m = $m;
$ctx->wx_info = $wx_info;
}
}
示例3: index
function index($ctx)
{
$conf = App::$config['login'];
if (strlen($conf['password']) < 6 || $conf['password'] == '12345678') {
$ctx->errmsg = 'Password is not configured strong enough, you can not login';
return;
}
if ($_POST) {
session_start();
$vcode = strtolower(htmlspecialchars($_POST['verify_code']));
if (!$vcode || $vcode !== strtolower($_SESSION['verify_code'])) {
$ctx->errmsg = 'Wrong captcha code';
return;
}
$name = htmlspecialchars(trim($_POST['name']));
$password = htmlspecialchars(trim($_POST['password']));
if ($name === $conf['name'] && $password === $conf['password']) {
$_SESSION['login_user'] = 1;
_redirect('/');
return;
} else {
$ctx->errmsg = "Wrong username or password!";
}
}
}
示例4: refresh_js_token
function refresh_js_token($ctx)
{
$id = intval($_GET['id']);
$account = WxAccount::get($id);
$account->refresh_js_token();
_redirect(_list_url());
}
示例5: init
function init($ctx)
{
session_start();
$user = $_SESSION['admin_user'];
if (!$user) {
_redirect('admin/login');
}
}
示例6: del
function del($ctx)
{
$id = intval($_GET['id']);
$contract = Contract::get($id);
if ($contract) {
$contract->set_del();
}
_redirect(_list_url());
}
示例7: set_new
function set_new($ctx)
{
$id = intval($_GET['id']);
$tactics = Tactics::get($id);
if ($tactics) {
$tactics->set_new();
}
_redirect(_list_url());
}
示例8: init
function init($ctx)
{
parent::init($ctx);
$ctx->user = UC::auth();
if (!$ctx->user) {
$url = $_SERVER['REQUEST_URI'];
_redirect('login', array('jump' => $url));
return;
}
}
示例9: success
function success($ctx)
{
$ctx->title = '绑定成功';
$prj_subscribe_status = $_COOKIE['no_subscribe_prj'] ? WxConnect::PRJ_UNSUBSCRIBED : WxConnect::PRJ_SUBSCRIBED;
setcookie('no_subscribe_prj', '', time() + 3600);
if (!$ctx->user) {
_redirect(_action('/'));
}
$uid = $ctx->user['id'];
$wx_openid = $this->openid;
if ($uid && $wx_openid) {
WxConnect::bind($uid, $wx_openid);
}
setcookie(WxTmpLogin::COOKIE_KEY_AUTO_BIND_WX, '', time() - 1, '/');
unset($_SESSION['wx_openid']);
}
示例10: index
function index($ctx)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!SafeUtil::verify_captcha($_POST['verify_code'])) {
$ctx->errmsg = '验证码错误!';
return;
}
$name = htmlspecialchars(trim($_POST['name']));
$password = htmlspecialchars(trim($_POST['password']));
if ($name === 'admin' && $password === 'yuhun666') {
$_SESSION['admin_user'] = 1;
$url = _url('admin');
_redirect($url);
return;
} else {
$ctx->errmsg = "用户名或密码错误!";
}
}
}
示例11: index
function index($ctx)
{
$conf = App::$config['login'];
if (strlen($conf['password']) < 6) {
$ctx->errmsg = 'Password is not configured strong enough, you can not login';
return;
}
if ($_POST) {
$name = htmlspecialchars(trim($_POST['name']));
$password = htmlspecialchars(trim($_POST['password']));
if ($name === $conf['name'] && $password === $conf['password']) {
$_SESSION['login_user'] = 1;
_redirect('/');
return;
} else {
$ctx->errmsg = "Wrong username or password!";
}
}
}
示例12: index
function index($ctx)
{
$jump = htmlspecialchars(trim($_GET['jump']));
$host = Html::host();
if (!preg_match("/http(s)?:\\/\\/[^\\/]*{$host}\\//", $jump)) {
$jump = '';
}
// 验证 token
$token = htmlspecialchars(trim($_GET['token']));
if (strlen($token) == 32) {
$sess = WxTmpLogin::get_session($token);
if ($sess) {
WxTmpLogin::del_session($token);
}
}
if (!$sess) {
#if($token && !$_SESSION['wx_openid']){
# _throw("链接已经过期, 请重新获取微信消息!", 200);
#}
_redirect($jump);
}
session_start();
$_SESSION['wx_openid'] = $sess['openid'];
$connect = WxConnect::get_by('wx_openid', $sess['openid']);
if (!$connect) {
setcookie(WxTmpLogin::COOKIE_KEY_AUTO_BIND_WX, 1, time() + 3600 * 24, '/');
Logger::info("not connected wx_openid: {$sess['openid']}");
UC::logout();
} else {
$uid = $connect->user_id;
$profile = Profile::get($uid);
setcookie('ltz_wx_binded', 1, time() + 3600 * 24 * 365, "/");
// 已经绑定了,直接删除该cookie
if (isset($_COOKIE[WxTmpLogin::COOKIE_KEY_AUTO_BIND_WX])) {
setcookie(WxTmpLogin::COOKIE_KEY_AUTO_BIND_WX, '', time() - 1, '/');
}
Logger::info("wx_openid[{$sess['openid']}] login, uid: {$uid}, {$profile->name}");
UC::force_login($profile);
}
_redirect($jump);
}
示例13: index
function index($ctx)
{
$aid = $_GET['aid'] ? intval($_GET['aid']) : 0;
$account = WxAccount::get($aid);
if (count($account) <= 0) {
_redirect('/admin/weixin/account');
return;
}
$str_menu = $account->menu;
$arr_menu = $this->format_wx_menu($str_menu);
if (empty($arr_menu) || !isset($arr_menu['button'])) {
$arr_menu = array();
} else {
$arr_menu = $arr_menu['button'];
}
// 需要对sub_button 进行特殊处理,javascript对object和array的处理不一致
$ctx->aid = $aid;
$ctx->menus = json_encode($arr_menu);
$ctx->count = count($arr_menu);
$ctx->account = $account;
}
示例14: on_submit
private function on_submit($ctx)
{
$conf = App::$config['login'];
$req = array('name' => $_POST['name'], 'password' => $_POST['password']);
$req = SafeUtil::safe_decrypt($req);
if (!$req) {
_throw("decrypt failed");
}
$name = htmlspecialchars(trim($req['name']));
$password = htmlspecialchars(trim($req['password']));
$ctx->name = $name;
$vcode = strtolower(htmlspecialchars($_POST['verify_code']));
if (!$vcode || $vcode !== strtolower($_SESSION['verify_code'])) {
$ctx->errmsg = 'Wrong captcha code';
return;
}
if ($name === $conf['name'] && $password === $conf['password']) {
$_SESSION['login_user'] = 1;
_redirect('/');
return;
} else {
$ctx->errmsg = "Wrong username or password!";
}
}
示例15: del
function del($ctx)
{
if ($_POST) {
$k = $_POST['k'];
if (is_array($k)) {
$this->ssdb->multi_del($k);
} else {
$this->ssdb->del($k);
}
_redirect($_POST['jump']);
return;
}
$k = $_GET['k'];
if (!is_array($k)) {
$k = array($k);
}
$ctx->ks = $k;
$ctx->jump = $_SERVER['HTTP_REFERER'];
if (!$ctx->jump) {
$ctx->jump = _url('kv');
}
}