本文整理汇总了PHP中Server::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::redirect方法的具体用法?PHP Server::redirect怎么用?PHP Server::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::redirect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
/**
* request to load controller
*/
static function action()
{
// benchmark
$benchmark = new Benchmark();
$benchmark->start();
$request = new Request();
$request->setBaseUri(Application::getBaseUrl());
// auth checkc
if (self::$auth) {
foreach (self::$auth as $auth) {
$auth->check($request->getUri());
}
}
$routing = new Routing();
if (!($data = $routing::getRouleClass($request->getUri()))) {
if ($data = $routing::getRouleClass($request->getUri() . '/')) {
Server::redirect(Application::getBaseUrl() . $request->getUri() . '/');
}
}
if (empty($data)) {
$data = array('class' => 'core:default:error_404');
} else {
if ($data['class'] == '') {
$data = array('class' => 'core:default:index');
}
}
// pearse class method
if (preg_match("/^([0-9a-zA-Z\\-_]+):([0-9a-zA-Z\\-_]+):?([0-9a-zA-Z\\-_]*)\$/", $data['class'], $matchs)) {
$project = $matchs[1];
$class = $matchs[2];
$method = $matchs[3];
$method = !empty($method) ? $method : "index";
} else {
throw new PMPException('Error Class Method or Class Name(`' . $data['class'] . '` is not routing find).');
}
$benchmark->setMark("routing");
try {
$path = self::$source_dir . '/' . $project;
$filename = $path . '/conf';
dir_include_all($filename);
$filename = $path . '/class';
dir_include_all($filename);
$filename = $path . '/controller/' . $class . '.php';
if (file_exists($filename)) {
include_once $filename;
} else {
$path = dirname(__FILE__) . '/../../component';
$filename = $path . '/controller/' . $class . '.php';
if (file_exists($filename)) {
include_once $filename;
}
}
$classname = $class . 'Controller';
$controller = new $classname($path, $class, $method, $project);
$controller->addDefaultTemplatefiles(dirname(__FILE__) . '/../../component/view/form.tpl');
$benchmark->setMark('included');
if (isset($data['param'])) {
$reflection = new \ReflectionClass($controller);
$reflection_method = $reflection->getMethod($method);
$params = array();
foreach ($reflection_method->getParameters() as $key => $p) {
if (array_key_exists($p->getName(), $data['param'])) {
$params[$key] = $data['param'][$p->getName()];
} else {
if ($p->isDefaultValueAvailable()) {
$params[$key] = $p->getDefaultValue();
} else {
throw new PMPException(sprintf('Not Found Controller Paramater %s In %s', get_class($controller) . ':' . $method, $p->getName()));
}
}
}
call_user_func_array(array($controller, $method), $params);
} else {
$controller->{$method}();
}
$benchmark->setMark("action");
$benchmark->stop();
//$benchmark->display(false);
} catch (\Exception $e) {
throw new PMPException($e);
}
}
示例2: failedAuth
/**
*
*/
public function failedAuth()
{
if ($this->failed_url) {
Server::redirect($this->failed_url);
}
}
示例3: showContent
/**
* Returns the content, or, if streaming, shows what content we have added
* and saves the footer for later.
* @return unknown_type
*/
public function showContent()
{
if (isset($this->authRequired) && $this->authRequired == true) {
if (AuthUser::hasAuth()) {
echo $this->content;
} else {
Server::redirect('/Home/login?r=' . $_SERVER['REQUEST_URI']);
}
} else {
echo $this->content;
}
if ($this->stream_depth > 0) {
ob_flush();
flush();
// Record the footer
ob_start();
}
}