本文整理匯總了PHP中URI::string方法的典型用法代碼示例。如果您正苦於以下問題:PHP URI::string方法的具體用法?PHP URI::string怎麽用?PHP URI::string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類URI
的用法示例。
在下文中一共展示了URI::string方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
/**
* When visiting any page on the site, check if the user is already logged in,
* or they are visiting a page that is allowed when logged out. Otherwise,
* redirect to the login page. If visiting the login page, check the browser
* supports cookies.
*/
public function check()
{
$uri = new URI();
// Skip check when accessing the data services, as it is redundant but would slow the services down.
// Also no need to login when running the scheduled tasks.
if ($uri->segment(1) == 'services' || $uri->segment(1) == 'scheduled_tasks') {
return;
}
// check for setup request
//
if ($uri->segment(1) == 'setup_check') {
// get kohana paths
//
$ipaths = Kohana::include_paths();
// check if indicia_setup module folder exists
//
clearstatcache();
foreach ($ipaths as $path) {
if (preg_match("/indicia_setup/", $path) && file_exists($path)) {
return;
}
}
}
// Always logged in
$auth = new Auth();
if (!$auth->logged_in() and !$auth->auto_login() and $uri->segment(1) != 'login' and $uri->segment(1) != 'logout' and $uri->segment(1) != 'new_password' and $uri->segment(1) != 'forgotten_password') {
$_SESSION['requested_page'] = $uri->string();
url::redirect('login');
} else {
if ($auth->logged_in() and is_null($_SESSION['auth_user']->password) and $uri->segment(1) != 'new_password' and $uri->segment(1) != 'logout' and $uri->segment(1) != 'setup_check') {
$_SESSION['requested_page'] = $uri->string();
url::redirect('new_password');
}
}
}
示例2: login
/**
* Show invite only page if enabled
*/
public function login()
{
$uri = new URI();
// Redirect to invite page if not logged or signing in
if (!in_array($uri->string(), array('invite', 'sign/in')) && strpos($uri->string(), 'sign/up') !== 0 && !Visitor::instance()->logged_in()) {
// Stop execution if ajax, ie. expired session and trying to do ajax call
if (request::is_ajax()) {
exit;
}
url::redirect('invite');
}
}