本文整理汇总了PHP中url::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP url::redirect方法的具体用法?PHP url::redirect怎么用?PHP url::redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url
的用法示例。
在下文中一共展示了url::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
public function upgrade()
{
if (php_sapi_name() == "cli") {
// @todo this may screw up some module installers, but we don't have a better answer at
// this time.
$_SERVER["HTTP_HOST"] = "example.com";
} else {
if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
access::forbidden();
}
}
// Upgrade gallery and user first
module::install("gallery");
module::install("user");
// Then upgrade the rest
foreach (module::available() as $id => $module) {
if ($id == "gallery") {
continue;
}
if ($module->active && $module->code_version != $module->version) {
module::install($id);
}
}
if (php_sapi_name() == "cli") {
print "Upgrade complete\n";
} else {
url::redirect("upgrader?done=1");
}
}
示例2: envoyer
/**
* Methode : page envoyer le mailing
*/
public function envoyer()
{
if ($_POST) {
$texte = $this->input->post('texte');
$format = $this->input->post('format');
$sujet = $this->input->post('sujet');
$format = $format == 1 ? TRUE : FALSE;
$users = $this->user->select();
$nbr_envois = 0;
foreach ($users as $user) {
if ($format) {
$view = new View('mailing/template');
$view->name = ucfirst(mb_strtolower($user->username));
$view->content = $texte;
$message = $view->render();
} else {
$message = $texte;
}
if (email::send($user->email, Kohana::config('email.from'), $sujet, $message, $format)) {
$nbr_envois++;
}
}
return url::redirect('mailing?msg=' . urlencode(Kohana::lang('mailing.send_valide', number_format($nbr_envois))));
} else {
return parent::redirect_erreur('mailing');
}
}
示例3: handler
public function handler()
{
access::verify_csrf();
$form = $this->_get_form();
if ($form->validate()) {
module::set_var("sitemap_xtra", "path", $form->sitemap->sitemap_path->value);
module::set_var("sitemap_xtra", "base_url", $form->sitemap->sitemap_base_url->value);
module::set_var("sitemap_xtra", "zip", $form->sitemap->sitemap_zip->value);
module::set_var("sitemap_xtra", "ping_yandex", $form->sitemap->sitemap_ping_yandex->value);
module::set_var("sitemap_xtra", "ping_google", $form->sitemap->sitemap_ping_google->value);
module::set_var("sitemap_xtra", "ping_bing", $form->sitemap->sitemap_ping_bing->value);
module::set_var("sitemap_xtra", "ping_ask", $form->sitemap->sitemap_ping_ask->value);
module::set_var("sitemap_xtra", "robots_txt", $form->sitemap->sitemap_robots_txt->value);
module::set_var("sitemap_xtra", "albums", $form->albums->sitemap_albums->value);
module::set_var("sitemap_xtra", "albums_freq", $form->albums->sitemap_albums_freq->value);
module::set_var("sitemap_xtra", "albums_prio", $form->albums->sitemap_albums_prio->value);
module::set_var("sitemap_xtra", "photos", $form->photos->sitemap_photos->value);
module::set_var("sitemap_xtra", "photos_freq", $form->photos->sitemap_photos_freq->value);
module::set_var("sitemap_xtra", "photos_prio", $form->photos->sitemap_photos_prio->value);
module::set_var("sitemap_xtra", "movies", $form->movies->sitemap_movies->value);
module::set_var("sitemap_xtra", "movies_freq", $form->movies->sitemap_movies_freq->value);
module::set_var("sitemap_xtra", "movies_prio", $form->movies->sitemap_movies_prio->value);
module::set_var("sitemap_xtra", "pages", $form->pages->sitemap_pages->value);
module::set_var("sitemap_xtra", "pages_freq", $form->pages->sitemap_pages_freq->value);
module::set_var("sitemap_xtra", "pages_prio", $form->pages->sitemap_pages_prio->value);
if ($form->build_sitemap->sitemap_build->value) {
if ($status = $this->_build_sitemap()) {
message::info($status);
}
}
message::success(t("Settings have been saved"));
url::redirect("admin/sitemap_xtra");
}
print $this->_get_view($form);
}
示例4: index
public function index()
{
$view = new Admin_View("admin.html");
$view->page_title = t("Users and groups");
$view->page_type = "collection";
$view->page_subtype = "admin_users";
$view->content = new View("admin_users.html");
// @todo: add this as a config option
$page_size = module::get_var("user", "page_size", 10);
$page = Input::instance()->get("page", "1");
$builder = db::build();
$user_count = $builder->from("users")->count_records();
// Pagination info
$view->page = $page;
$view->page_size = $page_size;
$view->children_count = $user_count;
$view->max_pages = ceil($view->children_count / $view->page_size);
$view->content->pager = new Pagination();
$view->content->pager->initialize(array("query_string" => "page", "total_items" => $user_count, "items_per_page" => $page_size, "style" => "classic"));
// Make sure that the page references a valid offset
if ($page < 1) {
url::redirect(url::merge(array("page" => 1)));
} else {
if ($page > $view->content->pager->total_pages) {
url::redirect(url::merge(array("page" => $view->content->pager->total_pages)));
}
}
// Join our users against the items table so that we can get a count of their items
// in the same query.
$view->content->users = ORM::factory("user")->order_by("users.name", "ASC")->find_all($page_size, $view->content->pager->sql_offset);
$view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all();
print $view;
}
示例5: handler
public function handler()
{
access::verify_csrf();
$form = $this->_get_form();
if ($form->validate()) {
module::set_var("social_share", "general_impage_only", $form->general_settings->general_impage_only->value);
module::set_var("social_share", "facebook_share_enabled", $form->facebook_share_settings->facebook_share_enabled->value);
module::set_var("social_share", "facebook_share_layout", $form->facebook_share_settings->facebook_share_layout->value);
module::set_var("social_share", "facebook_share_link_text", $form->facebook_share_settings->facebook_share_link_text->value);
module::set_var("social_share", "facebook_like_enabled", $form->facebook_like_settings->facebook_like_enabled->value);
module::set_var("social_share", "facebook_like_appId", $form->facebook_like_settings->facebook_like_appId->value);
module::set_var("social_share", "facebook_like_adminId", $form->facebook_like_settings->facebook_like_adminId->value);
module::set_var("social_share", "facebook_like_site_name", $form->facebook_like_settings->facebook_like_site_name->value);
module::set_var("social_share", "facebook_like_code_type", $form->facebook_like_settings->facebook_like_code_type->value);
module::set_var("social_share", "facebook_like_show_faces", $form->facebook_like_settings->facebook_like_show_faces->value, true);
module::set_var("social_share", "facebook_like_send", $form->facebook_like_settings->facebook_like_send->value, true);
module::set_var("social_share", "facebook_like_action", $form->facebook_like_settings->facebook_like_action->value);
module::set_var("social_share", "facebook_like_layout", $form->facebook_like_settings->facebook_like_layout->value);
module::set_var("social_share", "google_enabled", $form->google_settings->google_enabled->value);
module::set_var("social_share", "google_size", $form->google_settings->google_size->value);
module::set_var("social_share", "google_annotation", $form->google_settings->google_annotation->value);
module::set_var("social_share", "pinterest_enabled", $form->pinterest_settings->pinterest_enabled->value);
module::set_var("social_share", "pinterest_count_location", $form->pinterest_settings->pinterest_count_location->value);
module::set_var("social_share", "twitter_enabled", $form->twitter_settings->twitter_enabled->value);
module::set_var("social_share", "twitter_count_location", $form->twitter_settings->twitter_count_location->value);
module::set_var("social_share", "twitter_size", $form->twitter_settings->twitter_size->value);
message::success(t("Your settings have been saved."));
url::redirect("admin/social_share");
}
print $this->_get_view($form);
}
示例6: show
public function show($tag_id)
{
$tag = ORM::factory("tag", $tag_id);
$page_size = module::get_var("gallery", "page_size", 9);
$page = (int) Input::instance()->get("page", "1");
$children_count = $tag->items_count();
$offset = ($page - 1) * $page_size;
$max_pages = max(ceil($children_count / $page_size), 1);
// Make sure that the page references a valid offset
if ($page < 1) {
url::redirect($album->abs_url());
} else {
if ($page > $max_pages) {
url::redirect($album->abs_url("page={$max_pages}"));
}
}
$template = new Theme_View("page.html", "collection", "tag");
$template->set_global("page", $page);
$template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->set_global("tag", $tag);
$template->set_global("children", $tag->items($page_size, $offset));
$template->set_global("children_count", $children_count);
$template->content = new View("dynamic.html");
$template->content->title = $tag->name;
print $template;
}
示例7: saveprefs
public function saveprefs()
{
// Prevent Cross Site Request Forgery
access::verify_csrf();
$form = $this->_get_admin_form();
if ($form->validate()) {
Kohana_Log::add("error", print_r($form, 1));
module::set_var("tag_albums", "tag_page_title", $form->Tag_Albums_Tag_Sort->tag_page_title->value);
module::set_var("tag_albums", "tag_index", $form->Tag_Albums_Tag_Sort->tag_index->value);
module::set_var("tag_albums", "tag_index_scope", count($form->Tag_Albums_Tag_Sort->tag_index_scope->value));
module::set_var("tag_albums", "tag_index_filter_top", count($form->Tag_Albums_Tag_Sort->tag_index_filter_top->value));
module::set_var("tag_albums", "tag_index_filter_bottom", count($form->Tag_Albums_Tag_Sort->tag_index_filter_bottom->value));
module::set_var("tag_albums", "tag_sort_by", $form->Tag_Albums_Tag_Sort->tag_sort_by->value);
module::set_var("tag_albums", "tag_sort_direction", $form->Tag_Albums_Tag_Sort->tag_sort_direction->value);
module::set_var("tag_albums", "subalbum_sort_by", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_by->value);
module::set_var("tag_albums", "subalbum_sort_direction", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_direction->value);
message::success(t("Your settings have been saved."));
url::redirect("admin/tag_albums");
}
// Else show the page with errors
$view = new Admin_View("admin.html");
$view->content = new View("admin_tag_albums.html");
$view->content->tag_albums_form = $form;
print $view;
}
示例8: index
public function index()
{
// Create new session
$this->session->create();
$this->template->header->this_page = 'alerts';
$this->template->content = new View('alerts');
// Display news feeds?
$this->template->content->allow_feed = Kohana::config('settings.allow_feed');
// Retrieve default country, latitude, longitude
$default_country = Kohana::config('settings.default_country');
// Retrieve Country Cities
$this->template->content->cities = $this->_get_cities($default_country);
// Setup and initialize form field names
$form = array('alert_mobile' => '', 'alert_mobile_yes' => '', 'alert_email' => '', 'alert_email_yes' => '', 'alert_lat' => '', 'alert_lon' => '', 'alert_radius' => '');
// Copy the form as errors, so the errors will be stored with keys
// corresponding to the form field names
$errors = $form;
$form_error = FALSE;
$form_saved = FALSE;
// If there is a post and $_POST is not empty
if ($post = $this->input->post()) {
// Create a new alert
$alert = ORM::factory('alert');
// Test to see if things passed the rule checks
if ($alert->validate($post)) {
// Yes! everything is valid
// Save alert and send out confirmation code
if (!empty($post->alert_mobile)) {
$this->_send_mobile_alert($post->alert_mobile, $post->alert_lon, $post->alert_lat, $post->alert_radius);
}
if (!empty($post->alert_email)) {
$this->_send_email_alert($post->alert_email, $post->alert_lon, $post->alert_lat, $post->alert_radius);
}
$this->session->set('alert_mobile', $post->alert_mobile);
$this->session->set('alert_email', $post->alert_email);
url::redirect('alerts/confirm');
} else {
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('alerts'));
$form_error = TRUE;
}
} else {
$form['alert_lat'] = Kohana::config('settings.default_lat');
$form['alert_lon'] = Kohana::config('settings.default_lon');
$form['alert_radius'] = 20;
}
$this->template->content->form = $form;
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->form_saved = $form_saved;
// Javascript Header
$this->template->header->map_enabled = TRUE;
$this->template->header->js = new View('alerts_js');
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = $form['alert_lat'];
$this->template->header->js->longitude = $form['alert_lon'];
}
示例9: saveprefs
public function saveprefs()
{
// Save user preferences to the database.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Make sure the user filled out the form properly.
$form = $this->_get_admin_form();
if ($form->validate()) {
Kohana_Log::add("error", print_r($form, 1));
// Save settings to Gallery's database.
foreach (iptc::keys() as $keyword => $iptcvar) {
$checkbox = false;
for ($i = 0; $i < count($form->Global->{$keyword}); $i++) {
if ($form->Global->{$keyword}->value[$i] == $keyword) {
$checkbox = true;
}
}
module::set_var("iptc", "show_" . $keyword, $checkbox);
}
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your settings have been saved."));
url::redirect("admin/iptc");
}
// Else show the page with errors
$view = new Admin_View("admin.html");
$view->content = new View("admin_iptc.html");
$view->content->iptc_form = $form;
print $view;
}
示例10: __construct
public function __construct()
{
parent::__construct();
// Load profiler
if (Kohana::config('config.enable_profiler')) {
$this->profiler = new Profiler();
}
$this->auth = Auth::instance();
$this->db = Database::instance();
// Are we logged in? if not, do we have an auto-login cookie?
if (!$this->auth->logged_in()) {
// Try to login with 'remember me' token
if (!$this->auth->auto_login()) {
// Login user in via HTTP AUTH
$this->auth->http_auth_login();
}
}
// Get session information
$this->user = Auth::instance()->get_user();
// Check private deployment access
$controller_whitelist = array('login', 'riverid', 'api', 'frontlinesms', 'smssync', 'nexmo');
if (Kohana::config('settings.private_deployment')) {
if (!$this->auth->logged_in('login') and !in_array(Router::$controller, $controller_whitelist)) {
// Redirect to login form
url::redirect('login');
}
}
// Set default content-type header
header('Content-type: text/html; charset=UTF-8');
}
示例11: update
public function update()
{
//Get the ordered list of modules
$modulerawlist = explode("&", trim($_POST['modulelist'], "&"));
//Make sure that gallery and user modules are first in the list
$current_weight = 2;
$identity_provider = module::get_var("gallery", "identity_provider");
foreach ($modulerawlist as $row) {
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
if ($currentry[0] == "gallery") {
$modulelist[0] = $row;
} elseif ($currentry[0] == $identity_provider) {
$modulelist[1] = $row;
} else {
$modulelist[$current_weight] = $row;
$current_weight++;
}
}
ksort($modulelist);
//Write the correct weight values
$current_weight = 0;
foreach ($modulelist as $row) {
$current_weight++;
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
db::build()->update("modules")->set("weight", $current_weight)->where("id", "=", $currentry[1])->execute();
}
message::success(t("Your settings have been saved."));
url::redirect("admin/moduleorder");
print $this->_get_view();
}
示例12: redirect
public function redirect()
{
$uri = URI::instance()->string();
$routed_uri = false;
$bounces = Kohana::config('redirect_301');
if (is_null(Router::$controller) and is_array($bounces)) {
foreach ($bounces as $key => $val) {
// Trim slashes
$key = trim($key, '/');
$val = trim($val, '/');
if (preg_match('#^' . $key . '$#u', $uri)) {
if (strpos($val, '$') !== FALSE) {
// Use regex routing
$routed_uri = preg_replace('#^' . $key . '$#u', $val, $uri);
} else {
// Standard routing
$routed_uri = $val;
}
// A valid route has been found
break;
}
}
}
if ($routed_uri !== false) {
url::redirect($routed_uri, '301');
}
}
示例13: ttstyle
public function ttstyle()
{
if (!IN_PRODUCTION) {
$profiler = new Profiler();
}
url::redirect('/style/overview');
}
示例14: tagitems
public function tagitems()
{
// Tag all non-album items in the current album with the specified tags.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Generate an array of all non-album items in the current album.
$children = ORM::factory("item")->where("parent_id", $this->input->post("item_id"))->where("type !=", "album")->find_all();
// Loop through each item in the album and make sure the user has
// access to view and edit it.
foreach ($children as $child) {
if (access::can("view", $child) && access::can("edit", $child)) {
// Assuming the user can view/edit the current item, loop
// through each tag that was submitted and apply it to
// the current item.
foreach (split(",", $this->input->post("name")) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
tag::add($child, $tag_name);
}
}
}
}
// Redirect back to the album.
$item = ORM::factory("item", $this->input->post("item_id"));
url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
}
示例15: logout
public function logout()
{
// Load auth and log out
$this->auth->logout(true);
// Redirect back to the login page
url::redirect('auth_demo/login');
}