本文整理匯總了PHP中response::redirect方法的典型用法代碼示例。如果您正苦於以下問題:PHP response::redirect方法的具體用法?PHP response::redirect怎麽用?PHP response::redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類response
的用法示例。
在下文中一共展示了response::redirect方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Constructor
*
* @param string $uri The URI to route
* @param string $domain The domain to route
* @param bool $secure True if connection made via SSL
*/
public function __construct($buri = '/')
{
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
} else {
$uri = $buri;
}
if (isset($_SERVER['HTTP_HOST'])) {
$domain = strtolower($_SERVER['HTTP_HOST']);
} else {
if (isset($_SERVER['SERVER_NAME'])) {
$domain = strtolower($_SERVER['SERVER_NAME']);
} else {
$domain = 'localhost';
}
}
$secure = true;
// Parse query string
if (strpos($uri, '?')) {
$base = substr($uri, 0, strpos($uri, '?'));
$rest = substr($uri, strpos($uri, '?') + 1);
// Apache mod_rewrite workaround for existing folders - requests
// are routed as /uri/?/uri if the folder exists.
if ($base != '/' && file_exists('.' . $base) && substr($rest, 0, strlen($base) - 1) . '/' == $base) {
// folder match, reroute the $rest.
// TODO: Query string arguments should be passed on
if (strpos($rest, '&') > 0) {
$params = substr($rest, strpos($rest, '&') + 1);
}
response::redirect($base . '?' . $params);
} else {
// Parse the querystring
$qsl = explode('&', $rest);
foreach ($qsl as $qsi) {
if (preg_match('/^(.*)=(.*)$/', $qsi, $keys)) {
$_GET[$keys[1]] = urldecode($keys[2]);
$_REQUEST[$keys[1]] = urldecode($keys[2]);
}
}
$uri = $base;
}
}
// Quick fix for first index being '/index_php' when invoked via
// apache - hopefully sorts bug with php oauth.
if (arr::hasKey($_GET, '/index_php')) {
array_shift($_GET);
array_shift($_GET);
}
// Assign the URI and start parsing
$this->_uri = $uri;
$this->_domain = $domain;
$this->_secure = request::isSecure();
foreach (explode('/', $this->_uri) as $segment) {
if ($segment != '') {
$this->_urisegments[] = $segment;
}
}
}
示例2: login
function login()
{
$user = request::post('username')->toString();
$pass = request::post('password')->toString();
if (User::authenticate(new PasswordAuthentication($user, $pass))) {
session::set('username', $user);
response::redirect('/ppp/confirm');
}
}
示例3: admin
/**
* Форма фхода в админку
* @access protected
*/
public function admin()
{
$args = request::get(array('user', 'secret'));
$data = array('LC' => LC::get());
try {
if (!empty($args)) {
authenticate::login();
}
} catch (Exception $e) {
dbg::write($e->getMessage(), LOG_PATH . 'adm_access.log');
$data['errors'] = $e->getMessage();
}
if (!authenticate::is_logged()) {
$tmpl = new tmpl($this->pwd() . 'login.html');
response::send($tmpl->parse($data), 'html');
} else {
response::redirect('/xxx/');
}
}
示例4: redirect
/**
* Redirect with HTTP 303 "See Other" code
* This is a recommended method to redirect after POST
* @param string $message
*/
public function redirect($url)
{
response::redirect($url);
}
示例5: run
public function run()
{
//echo 'Filename: '.$this->_filename.'<br />';
// echo 'Base path: '.$this->_basePath.'<br />';
// echo 'Base url: '.$this->_baseUrl.'<br />';
// echo 'Relative: '.$this->_rel.'<br />';
//var_dump($this);
$tmFilename = $this->_basePath . '/' . dirname($this->_rel) . '/.thumb/' . $this->_filename;
if (is_file($tmFilename)) {
/*
* IMPORTANT: Workaround for open_file_cache of nginx
*/
$this->readFile($tmFilename);
}
if (strpos($this->_filename, '_') !== false) {
if (basename($this->_rel) == '.thumb') {
if (($filename = $this->getSourcePath()) || ($filename = $this->getSourcePath('l_'))) {
// Check path
$path = $this->_basePath . '/' . $this->_rel;
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
if (is_dir($path)) {
if ($thumb = $this->makeThumbnail($filename)) {
// FOUND
$this->prepareShutdown($path);
if (is_file($tmFilename)) {
//response::notFound();
$this->optimizePng($tmFilename);
// Finally, throw away redirects
$this->readFile($tmFilename);
response::redirect($_SERVER['REQUEST_URI']);
} else {
//echo $tmFilename;
throw new Exception('thumbnail was created but not found 0_o');
//response::notFound();
}
}
} else {
throw new Exception('can\'t create directory');
}
} else {
throw new Exception('source file not found in directory');
}
} else {
var_dump($this);
throw new Exception('basename is not correct (' . $this->_rel . ')');
}
}
$this->notFound();
}
示例6: doRenderGet
function doRenderGet($chart)
{
$url = $this->getPooledUrl($chart);
response::redirect($url);
}
示例7: empty
/**
* Public site initialization
*
* @author Litvinenko S. Anthon <crazyfluger@gmail.com>
* @access public
* @package SBIN DIESEL
*/
try {
$uri = empty($_SERVER['REDIRECT_URL']) ? '/' : $_SERVER['REDIRECT_URL'];
$diStrc = data_interface::get_instance(SITE_DI);
$page = $diStrc->get_page_by_uri($uri);
define(PAGE_URI, $page['uri']);
define(SRCH_URI, str_replace($page['uri'], "", $uri));
define(PAGE_ID, $page['id']);
if (!empty($page['redirect'])) {
response::redirect($page['redirect']);
} else {
$uiStrc = user_interface::get_instance(SITE_UI);
$uiStrc->set_args(request::get());
$uiStrc->process_page($page);
}
} catch (Exception $e) {
dbg::write('Error: ' . $e->getMessage());
//response::header('404');
//9* 28102010
try {
$out = user_interface::get_instance('action_page');
$out->set_args(array('action_msg' => $e->getMessage()));
return $out->render();
} catch (Exception $e) {
dbg::write('Error: ' . $e->getMessage());
示例8: catch
<?php
// NOTE: Инициализация базовой части административного интерфейса.
include_once 'adm_base.php';
try {
if (request::get('cll') == 'logout') {
authenticate::logout();
response::redirect('/xxx/');
} else {
$ui = user_interface::get_instance('login');
$ui->admin();
}
} catch (Exception $e) {
dbg::write($e->getMessage(), LOG_PATH . 'ui_errors.log');
response::header('404');
}
示例9: catch
<?php
/**
* The user interface initialization code
*
* @author Litvinenko S. Anthon <crazyfluger@gmail.com>
* @version 2.0
* @access public
* @package CFsCMS2(PE)
*/
try {
// NOTE: If defined authentication data interface and user not logged in
if (defined('AUTH_DI') && !authenticate::is_logged()) {
// Then redicrect to login form
response::redirect('login/');
}
// Call user interface
$ui = user_interface::get_instance(request::get('ui', UI_DEFAULT));
if (($content = $ui->call(request::get('cll', UI_CLL_DEFAULT), request::get())) === FALSE) {
response::header('404');
} else {
response::send($content, 'html');
}
} catch (Exception $e) {
dbg::write($e->getMessage() . "\n" . $e->getTraceAsString(), LOG_PATH . 'ui_errors.log');
response::header('404');
}