本文整理汇总了PHP中Error::httpError方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::httpError方法的具体用法?PHP Error::httpError怎么用?PHP Error::httpError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::httpError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: navigate
public function navigate()
{
$url = trim($_SERVER['REQUEST_URI'], "/");
$result = $this->findUrl($url);
$urlParts = explode("/", $url);
$args = array();
if ($result) {
// Если URL записан.
$parts = explode("/", $result);
} else {
$parts = $urlParts;
}
$controller = ucfirst(array_shift($parts)) . "Controller";
if (!class_exists($controller)) {
Error::httpError(404);
}
$controller = new $controller();
$action = "action" . ucfirst(array_shift($parts));
if (!method_exists($controller, $action)) {
Error::httpError(404);
}
if (method_exists($controller, "access")) {
$controller->access();
}
for ($i = 0; $i < count($parts); $i++) {
$args[] = array_pop($urlParts);
}
call_user_func_array(array(new $controller(), $action), $args);
exit;
}
示例2: access
public function access()
{
if (!Auth::isLogged()) {
$this->redirect("/login");
}
if (!Auth::isAdmin()) {
Error::httpError(403);
}
}
示例3: actionIndex
public function actionIndex($seo)
{
$cat = CatsModel::model()->where("`seo_url`='{$seo}'")->findRow();
if (!$cat) {
Error::httpError(404);
}
$movies = MoviesModel::model()->where("`cat_id`='{$cat->id}'")->findAll();
$this->view("category/list", array("movies" => $movies, "cat" => $cat), false);
}
示例4: haveGlobal
$_SESSION['error_' . $name] = $text;
}
/*
* Проверяем, есть ли в сессии глобальная ошибка.
*/
public static function haveGlobal($name)
{
return isset($_SESSION['error_' . $name]);
}
/*
* Получаем глобальную ошибку и стираем её.
*/
public static function showGlobal($name)
{
$error = isset($_SESSION['error_' . $name]) ? $_SESSION['error_' . $name] : false;
unset($_SESSION['error_' . $name]);
return $error;
}
/*
* Отображаем страницу ошибки.
*/
public static function httpError($name, $isShow = true)
{
if ($isShow === true) {
include "views/errors/" . $name . ".php";
exit;
}
}
}
Error::httpError("error", false);
示例5: actionActivate
public function actionActivate($hash)
{
$model = UsersModel::model()->where("`hash`='{$hash}'")->findRow();
if (!$model || $model->status != 0) {
Error::httpError(404);
}
$model->status = 1;
$model->save();
$this->view("user_registered", array("message" => Lang::get("account_activated")), false);
}
示例6: actionShowSerial
public function actionShowSerial($seoUrl)
{
if ($_SESSION['user']['id'] != "") {
$movie = MoviesModel::model()->where("`seo_url` = '{$seoUrl}'")->findRow();
$seasons = SeasonModel::model()->where("`serial_id` = '{$movie->id}'")->order("sort asc")->findAll();
$rating = RatingsModel::getRating($movie->id);
$rating_count = RatingsModel::getRatingCount($movie->id);
$user = UsersModel::model()->where(" `id` = '{$_SESSION['user']['id']}' ")->findRow();
$user_major = UsersModel::isPackageActive();
switch ($movie->in_roles) {
case 1:
$difficulty = "Легкий";
break;
case 2:
$difficulty = "Легкий-средний";
break;
case 3:
$difficulty = "Средний";
break;
case 4:
$difficulty = "Средний-сложный";
break;
case 5:
$difficulty = "Сложный";
break;
default:
$difficulty = $movie->in_roles;
}
if (!$movie) {
Error::httpError(404);
}
$this->view("movies/serial_show", array("movie" => $movie, "seasons" => $seasons, "rating" => $rating, "rating_count" => $rating_count, "difficulty" => $difficulty, "user" => $user, "user_major" => $user_major), false);
} else {
$this->redirect("/");
}
}