当前位置: 首页>>代码示例>>PHP>>正文


PHP WebApp::forceRedirect方法代码示例

本文整理汇总了PHP中WebApp::forceRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP WebApp::forceRedirect方法的具体用法?PHP WebApp::forceRedirect怎么用?PHP WebApp::forceRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebApp的用法示例。


在下文中一共展示了WebApp::forceRedirect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check

 public function check()
 {
     $this->parent->parent->debug($this::name_space . ': Checking for login token...');
     if (!$this->parent->parent->config->config['core']['database']) {
         return false;
     }
     // Check for token cookie
     if (Cookie::get('ltkn') === NULL) {
         $this->parent->parent->debug($this::name_space . ': Login token not found!');
         return false;
     }
     $this->parent->parent->debug($this::name_space . ': Found token');
     $token = Cookie::get('ltkn');
     $sessID = Session::getID();
     $userID = Session::get('WebApp.User', 'userID');
     // It does exist so...
     // Find token in database where userID = the userID in the token
     $this->parent->parent->debug($this::name_space . ': Checking sessions table for:');
     $this->parent->parent->debug('T: ' . $token . '/ S: ' . $sessID . '/ U: ' . $userID);
     $token_query = $this->mySQL_r->prepare("SELECT INET_NTOA(`IP`), `auth` FROM `core_sessions` WHERE `token`=? AND `session`=? AND `user`=?");
     $token_query->bind_param('ssi', $token, $sessID, $userID);
     $token_query->execute();
     $token_query->store_result();
     if ($token_query->num_rows != 1) {
         $this->parent->parent->debug($this::name_space . ': Failed to find session.');
         return false;
     }
     $token_query->bind_result($ip, $auth);
     $token_query->fetch();
     if (Server::get('remote_addr') != $ip || $auth) {
         $update_query = $this->mySQL_w->prepare("UPDATE `core_sessions` SET `auth`=1 WHERE `token`=?");
         $update_query->bind_param('s', $token);
         $update_query->execute();
         WebApp::forceRedirect('/user/auth?r=' . urlencode(Server::get('request_uri')));
     }
     $this->parent->parent->debug($this::name_space . ': Found session. Token Check successful!');
     return true;
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:38,代码来源:class.sessiontokeniser.php

示例2: __construct

 function __construct($parent)
 {
     $this->parent = $parent;
     $this->mySQL_r = $parent->mySQL_r;
     $this->mySQL_w = $parent->mySQL_w;
     $this->parent->debug('***** ' . $this::name_space . ' *****');
     $this->parent->debug($this::name_space . ': Version ' . $this::version);
     $this->session = new SessionTokeniser($this);
     // Is a user logged in?
     if (Session::get($this::name_space, 'loggedIn') !== true) {
         $this->parent->debug($this::name_space . ': No user logged in, using anoymous');
         $this->_fetchDetails();
         return;
     }
     if ($this->session->check()) {
         $this->parent->debug($this::name_space . ': User logged in');
         $this->loggedIn = true;
         $this->username = Session::get($this::name_space, 'username');
         $this->userID = Session::get($this::name_space, 'userID');
         $this->session->update();
     } else {
         Session::del($this::name_space, 'loggedIn');
         Session::del($this::name_space, 'username');
         Session::del($this::name_space, 'userID');
     }
     // Create user data
     $this->_fetchDetails();
     if ($this->enabled == false) {
         $this->parent->debug($this::name_space . ': User disabled... logging out');
         $this->logout();
         header("Location: /user/login");
         exit;
     } elseif (Server::get('request_uri') != "/user/profile/password" && $this->changePwd == 1) {
         $this->parent->debug($this::name_space . ': User must change password');
         WebApp::forceRedirect('/user/profile/password');
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:37,代码来源:class.usercontroller.php


注:本文中的WebApp::forceRedirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。