本文整理汇总了PHP中Router::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::redirect方法的具体用法?PHP Router::redirect怎么用?PHP Router::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
public function view()
{
config::set('heading', 'БЛОГ');
$params = $this->getParams();
if (isset($params[0])) {
$alias = strtolower($params[0]);
$this->data['one_blog'] = $this->model->getOneBlogWithComment($alias);
}
if ($_POST and isset($_POST['id_comm'])) {
if (clearData($_POST['id_comm'])) {
$id = clearData($_POST['id_comm']);
} else {
throw new Exception('Введены некорректные данные');
}
if (clearData($_POST['text-comm'])) {
$text = clearData($_POST['text-comm'], true);
} else {
throw new Exception('Введены некорректные данные');
}
if (clearData($_POST['n_comm'])) {
$name = clearData($_POST['n_comm']);
} else {
throw new Exception('Введены некорректные данные');
}
$tableUserId = Session::getSession('id') ? Session::getSession('id') : NULL;
$this->model->addComment($id, $text, $name, $tableUserId);
Router::redirect($_SERVER['REQUEST_URI']);
}
}
示例2: run
public static function run($uri)
{
self::$router = new Router($uri);
self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
Lang::load(self::$router->getLanguage());
$controller_class = ucfirst(self::$router->getController()) . "Controller";
$controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
$layout = self::$router->getRoute();
if ($layout == "admin" && Session::get("role") != "admin") {
if ($controller_method != "admin_login") {
Router::redirect("/admin/users/login");
}
}
//Calling controller's method
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$view_path = $controller_object->{$controller_method}();
$view_object = new View($controller_object->getData(), $view_path);
$content = $view_object->render();
} else {
throw new Exception("Method {$controller_method} does not exist in {$controller_class}");
}
$layout_path = VIEWS_PATH . DS . $layout . ".html";
$layout_view_object = new View(compact('content'), $layout_path);
echo $layout_view_object->render();
}
示例3: home
/**
* Displays a view
*
* @return void
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
public function home()
{
// Redirect to tasks page
Router::redirect('*', array('controller' => 'tasks', 'action' => 'index'));
$path = func_get_args();
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
示例4: p_signup
public function p_signup()
{
# Check if data was entered
if ($_POST['first_name'] == "" || $_POST['last_name'] == "" || $_POST['password'] == "") {
# Send back to signup with appropriate error
Router::redirect("/users/signup/Please enter all requested information");
}
# Check if email address is of the right form
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
# Send back to signup with appropriate error
Router::redirect("/users/signup/Please enter a valid email address");
}
# Check if passwords match
if ($_POST['password'] != $_POST['password_check']) {
# Send back to signup with appropriate error
Router::redirect("/users/signup/Passwords do not match");
}
# Remove the password check from the array
unset($_POST['password_check']);
# Encrypt the password
$_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
# More data we want stored with the user
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
$_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
# Insert this user into the database
$user_id = DB::instance(DB_NAME)->insert("users", $_POST);
# Send the user to the signup success page
$this->template->content = View::instance('v_users_signup_success');
$this->template->title = "Success!";
echo $this->template;
}
示例5: logout
public function logout()
{
Load::lib('SdAuth');
SdAuth::logout();
View::template('login2');
Router::redirect('');
}
示例6: cerrar
function cerrar()
{
Auth::destroy_identity();
Session::delete("usuario_id");
Session::delete("usuario_nombrecompleto");
Router::redirect("login/index");
}
示例7: run
public static function run($uri)
{
self::$router = new Router($uri);
self::$db = DB::getInstance(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
Lang::load(self::$router->getLanguage());
$controller_class = ucfirst(self::$router->getController()) . 'controller';
$controller_method = strtolower(self::$router->getMethod_prefix() . self::$router->getAction());
$controller_parametr = self::$router->getParams();
$layout = self::$router->getRoute();
if ($layout == 'admin' && Session::get('role') != 'admin') {
if ($controller_method != 'admin_login') {
Router::redirect('/admin/users/login');
}
}
//Calling conrollers method
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$view_path = $controller_object->{$controller_method}();
$view_object = new View($controller_object->getData(), $view_path);
$content = $view_object->render();
} else {
throw new Exception('Метод ' . $controller_method . ' в классе ' . $controller_class . 'не найден');
}
$layout_path = VIEW_PATH . DS . $layout . '.html';
$layout_view_object = new View(compact('content'), $layout_path);
// основной рендер вывода страниц
echo $layout_view_object->render();
}
示例8: creerCommentaire
public function creerCommentaire($disc)
{
if (!empty($_POST)) {
$this->executerRequete("INSERT INTO message (id_utilisateur, id_discussion, texte, date) VALUES (?,?,?,NOW())", [$_SESSION['auth']->id, $disc, $_POST['commentaire']]);
Router::redirect("forumDiscussion", ['id' => $disc]);
}
}
示例9: initialize
protected final function initialize()
{
$controller = Router::get("controller");
$action = Router::get("action");
$ruta = $controller . "/" . $action;
$tipousuario = Auth::get("tipousuario");
if (Auth::is_valid()) {
if ($tipousuario == "alumno") {
if ($ruta != "perfil/index" and $ruta != "perfil/logout" and $ruta != "asistencia/alumno") {
Flash::warning("Acceso Denegado");
Router::redirect("perfil/");
}
}
if ($tipousuario == "docente") {
$permisos = array("perfil/actualizar", "perfil/cambiarpass", "perfil/index", "perfil/programarevaluaciones", "calificar/grupo", "perfil/logout", "asistencia/index", "asistencia/agregar_asistencia");
if (!in_array($ruta, $permisos)) {
Flash::warning("Acceso Denegado");
Router::redirect("perfil/");
}
}
} else {
if ($ruta != 'index/index' and $ruta != 'perfil/logout') {
Flash::warning("Acceso Denegado");
Router::redirect("index/index");
}
}
}
示例10: run
public static function run($uri)
{
self::$router = new Router($uri);
# создаем обект базы данных и передаем параметры подключения
self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
Lang::load(self::$router->getLanguage());
$controller_class = ucfirst(self::$router->getController()) . 'Controller';
$controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
# при каждом запросе к руту admin выполняется проверка, имеет ли пользователь на это права
$layout = self::$router->getRoute();
if ($layout == 'admin' && Session::get('role') != 'admin') {
if ($controller_method != 'admin_login') {
Router::redirect('/admin/users/login');
}
}
// Calling controller's method
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$view_path = $controller_object->{$controller_method}();
$view_object = new View($controller_object->getData(), $view_path);
$content = $view_object->render();
} else {
throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
}
# код віполняющий рендеринг
$layout_path = VIEWS_PATH . DS . $layout . '.html';
$layout_view_object = new View(compact('content'), $layout_path);
echo $layout_view_object->render();
}
示例11: sala
public function sala()
{
// http://gravatar.com/avatar/
$this->title = 'Sala de Asistencia';
if (Input::post("nombre") and Input::post("email") and Input::post("ayuda")) {
$usuario = new Usuario();
$usuario->nombre = Input::post("nombre");
$usuario->email = Input::post("email");
$usuario->online = 1;
if ($usuario->save()) {
$id = $usuario->find('columns: id', 'limit: 1', 'order: id desc');
$canal = new Canal();
$this->imagen = $this->get_gravatar($usuario->email);
$imagen = "<img style='float:left;padding:4px;' src='" . $this->imagen . "' width=\"50\" alt=\"Tu Imagen\">";
$canal->mensaje = "<span style='float:left;padding-top:10px;'>" . $imagen . "<b>" . $usuario->nombre . "(" . $usuario->email . ")</b>: <br>" . Input::post("ayuda") . "</span> <div class='clearfix'></div>";
$canal->identificador_canal = md5(Input::post("email") . date("Y-m-d") . $id[0]->id);
$canal->usuario_id = $id[0]->id;
if ($canal->save()) {
$this->nombre = Input::post("nombre");
$this->email = Input::post("email");
$this->identificador_canal = $canal->identificador_canal;
$this->usuario_id = $canal->usuario_id;
} else {
Flash::error("No se pudo abrir un canal de asistencia, Vuelva a intentarlo por favor!");
Router::redirect("index/chat");
}
} else {
Flash::error("No pudo ingresar a una sala de asistencia, por favor intentelo de nuevo");
}
} else {
Flash::error("El nombre, email y la consulta de como podemos ayudarte, son obligatorios");
Router::redirect("index/chat");
}
}
示例12: p_ticket
public function p_ticket()
{
# Sanitize the user input
$_POST = DB::instance(DB_NAME)->sanitize($_POST);
# Backup validation in case of javascript failure
# Not recommended as the page looks terrible without js
# Check if data was entered
if ($_POST['name'] == "" || $_POST['phone'] == "" || $_POST['serial'] == "") {
# Send back to signup with appropriate error
Router::redirect("/tickets");
}
# Check if email address is of the right form
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
# Send back to signup with appropriate error
Router::redirect("/tickets");
}
# Unix timestamp of when this post was created / modified
$_POST['ticket_id'] = date('Ymd\\-his');
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
# Add the location
$_POST['location'] = 'Helpdesk';
# Create ticket and computer arrays
$ticket = $_POST;
$computer = $_POST;
# Add ticket status
$ticket['status'] = 'New';
# Remove the unneeded data before submit
unset($ticket['model'], $ticket['serial']);
unset($computer['email'], $computer['phone'], $computer['notes']);
# Insert
DB::instance(DB_NAME)->insert('tickets', $ticket);
DB::instance(DB_NAME)->insert('computers', $computer);
# Build a multi-dimension array of recipients of this email
$to[] = array("name" => $_POST["name"], "email" => $_POST["email"]);
# Build a single-dimension array of who this email is coming from
# note it's using the constants we set in the configuration above)
$from = array("name" => "HSPH Helpdesk", "email" => APP_EMAIL);
# Subject
$subject = "Helpdesk Computer Drop Off: " . $_POST["subject"];
# Generate Time
# You can set the body as just a string of text
$body = "This is confirmation that you have delivered your " . $_POST['model'] . " with the serial number " . $_POST['serial'] . " to the helpdesk at " . date('g\\:i a \\o\\n F d\\, Y') . " with the following notes: <br>" . $_POST['notes'] . "<br><br>Thank you and have a great day!" . "<br>The Helpdesk<br>(617) 432-4357<br>helpdesk@hsph.harvard.edu";
# OR, if your email is complex and involves HTML/CSS, you can build the body via a View just like we do in our controllers
# $body = View::instance('e_users_welcome');
# Why not send an email to the test account as well
# Build multi-dimension arrays of name / email pairs for cc / bcc if you want to
$cc = "";
$bcc = "nathanielvarney.com@gmail.com";
# With everything set, send the email
if (!($email = Email::send($to, $from, $subject, $body, true, $cc, $bcc))) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
# Load the success page
$this->template->content = View::instance('v_tickets_p_ticket_success');
$this->template->title = "Success!";
echo $this->template;
}
}
示例13: markread
public function markread()
{
Container::get('hooks')->fire('controller.index.markread');
Auth::set_last_visit(User::get()->id, User::get()->logged);
// Reset tracked topics
Track::set_tracked_topics(null);
return Router::redirect(Router::pathFor('home'), __('Mark read redirect'));
}
示例14: borrar
/**
* Borra un Registro
*/
public function borrar($id)
{
if (!Load::model($this->model)->delete((int) $id)) {
Flash::error('Falló Operación');
}
//enrutando al index para listar los articulos
Router::redirect();
}
示例15: unfollow
public function unfollow($user_id_followed)
{
# Delete this connection
$where_condition = 'WHERE user_id = ' . $this->user->user_id . ' AND user_id_followed = ' . $user_id_followed;
DB::instance(DB_NAME)->delete('users_users', $where_condition);
# Send them back
Router::redirect("/posts/users");
}