本文整理汇总了PHP中Safe::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::redirect方法的具体用法?PHP Safe::redirect怎么用?PHP Safe::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Safe
的用法示例。
在下文中一共展示了Safe::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sprintf
}
// attempt to delete
if (Sections::delete($item['id'])) {
// log item deletion
$label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['title']));
$description = Sections::get_permalink($item);
Logger::remember('sections/delete.php: ' . $label, $description);
// this can appear anywhere
Cache::clear();
// back to the anchor page or to the index page
if (is_object($overlay) && ($back_url = $overlay->get_url_after_deleting())) {
Safe::redirect($back_url);
} elseif (is_object($anchor)) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url());
} else {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'sections/');
}
}
// deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
Logger::error(i18n::s('The action has not been confirmed.'));
} else {
// all sub-sections have not been deleted
if (($stats = Sections::stat_for_anchor('section:' . $item['id'])) && $stats['count']) {
Logger::error(i18n::s('Warning: related content will be deleted as well.'));
}
// all articles have not been deleted
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
Logger::error(i18n::s('Warning: related content will be deleted as well.'));
}
// commands
示例2: str_replace
$overlay->attributes[$name][$sub_name] = str_replace('\\', '\\\\', $sub_value);
}
} else {
$overlay->attributes[$name] = str_replace('\\', '\\\\', $value);
}
}
// update the record
$item['overlay'] = serialize($overlay->attributes);
// touch the related anchor
if ($article = Anchors::get('article:' . $item['id'])) {
$article->touch('vote', $item['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
}
// update the database
if (!Articles::put($item)) {
} elseif ($next && !headers_sent()) {
Safe::redirect($next);
// ask for manual click
} else {
$context['text'] .= '<p>' . i18n::s('Thank you for your contribution') . "</p>\n";
// link to the poll, depending on access rights
$menu = array();
if ($permitted) {
$menu = array_merge($menu, array(Articles::get_permalink($item) => i18n::s('View poll results')));
}
// back to the front page
$menu = array_merge($menu, array($context['url_to_root'] => i18n::s('Front page')));
$context['text'] .= Skin::build_list($menu, 'menu_bar');
}
}
// render the skin
render_skin();
示例3: load_skin
$anchor = Anchors::get($id);
}
// load localized strings
i18n::bind('behaviors');
// load the skin, maybe with a variant
load_skin('agreements', $anchor);
// no subject
if (!is_object($anchor)) {
Logger::error(i18n::s('No item has the provided id.'));
} else {
// initialize the list of agreements
if (!isset($_SESSION['agreements']) || !is_array($_SESSION['agreements'])) {
$_SESSION['agreements'] = array();
}
// append the new agreement
$_SESSION['agreements'][] = $anchor->get_reference();
// revisit referer
if (isset($_SERVER['HTTP_REFERER'])) {
Safe::redirect($_SERVER['HTTP_REFERER']);
}
}
// the path to this page
if (is_object($anchor)) {
$context['path_bar'] = $anchor->get_path_bar();
}
// the title of the page
if (is_object($anchor)) {
$context['page_title'] = $anchor->get_title();
}
// render the skin
render_skin();
示例4: send_body
// we only consider php scripts, of course
if (strlen($item) < 5 || substr($item, -4) != '.php') {
continue;
}
// do not execute twins, to ensure that scripts are ran only once
if (file_exists($context['path_to_root'] . 'scripts/run_once/' . $item . '.done')) {
continue;
}
// ok, we have to execute this one
$scripts[] = $item;
}
// close the directory
Safe::closedir($dir);
// no script has been found; if the server has been switched off, go silently to the control panel
if (!@count($scripts) && file_exists('../parameters/switch.off')) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'control/');
}
}
/**
* dynamically generate the page
*
* @see skins/index.php
*/
function send_body()
{
global $context, $local;
// $local is required to localize included scripts
// include every script that has to be run once
global $scripts, $scripts_count;
if (@count($scripts)) {
// the alphabetical order may be used to control script execution order
示例5: load_skin
}
// load the skin
load_skin('users');
// the path to this page
$context['path_bar'] = array('users/' => i18n::s('People'));
// the title of the page
if (isset($item['nick_name'])) {
$context['page_title'] = sprintf(i18n::s('Select a picture for %s'), $item['nick_name']);
}
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// anonymous users are invited to log in or to register
} elseif (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('users/select_avatar.php'));
} elseif (!isset($item['id'])) {
include '../error.php';
// permission denied
} elseif (!$permitted) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// the avatar has been changed
} elseif (isset($_REQUEST['avatar'])) {
// change the avatar in the profile
$item['avatar_url'] = $_REQUEST['avatar'];
// no password change
unset($item['password']);
if (Users::put($item)) {
Users::clear($item);
}
示例6: elseif
} elseif (!$permitted) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
// touch the related anchor before actual deletion, since the location has to be accessible at that time
if (is_object($anchor)) {
$anchor->touch('location:delete', $item['id']);
}
// if no error, back to the anchor or to the index page
if (Locations::delete($item['id'])) {
Locations::clear($item);
if (is_object($anchor)) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url());
} else {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/');
}
}
// deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('The action has not been confirmed.'));
// ask for confirmation
} else {
// commands
$menu = array();
$menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this location'), NULL, NULL, 'confirmed');
if (is_object($anchor)) {
$menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), 'span');
}
// the submit button
示例7: load_skin
include_once 'servers.php';
include_once '../services/call.php';
// ping
// load the skin
load_skin('servers');
// the path to this page
$context['path_bar'] = array('servers/' => i18n::s('Servers'));
// the title of the page
$context['page_title'] = i18n::s('Ping the cloud');
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// anonymous users are invited to log in or to register
} elseif (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('servers/ping.php'));
} elseif (!Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// do the ping
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ping') {
// list servers to be advertised
if ($servers = Servers::list_for_ping(0, 20, 'ping')) {
$context['text'] .= '<p>' . i18n::s('Servers that have been notified') . '</p><ul>';
// ping each server
foreach ($servers as $server_url => $attributes) {
list($server_ping, $server_label) = $attributes;
$milestone = get_micro_time();
$result = @Call::invoke($server_ping, 'weblogUpdates.ping', array(strip_tags($context['site_name']), $context['url_to_home'] . $context['url_to_root']), 'XML-RPC');
if ($result[0]) {
$label = round(get_micro_time() - $milestone, 2) . ' sec.';
示例8: urlencode
<?php
/*
* Redirect automaticaly a user to its profile
* or invite him to log in (and then redirect)
* can be a usefull target for a link in email for example.
*
* @author Alexis Raimbault
* @reference
* @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
*/
include_once '../shared/global.php';
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode($context['url_to_home'] . $context['url_to_root'] . 'users/profile.php'));
} else {
Safe::redirect(Surfer::get_permalink());
}
示例9: sprintf
$context['text'] .= '<p><a href="../skins/configure.php">' . sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Page factory')) . "</a></p>\n";
// end of verifications
} else {
// the title of the page
$context['page_title'] = i18n::s('Control Panel');
// server is closed
if (file_exists($context['path_to_root'] . 'parameters/switch.off')) {
// title
Logger::error(i18n::s('The server is currently switched off. All users are redirected to the closed page.'));
// link to the switch page
if (Surfer::is_associate()) {
$context['text'] = '<p style="text-decoration: blink;"><a href="switch.php?action=on">' . i18n::s('Switch the server on again') . '</a></p>';
}
// there is no switch file, redirect to the setup assistant
} elseif (!file_exists($context['path_to_root'] . 'parameters/switch.on')) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'setup.php');
}
// server is running on demonstration mode
if (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
Logger::error(i18n::s('The server is running in demonstration mode, and restrictions apply, even to associates.'));
}
// this is a tabbed page
$all_tabs = array();
//
// the Configuration Panels tab is reserved to associates
//
if (Surfer::is_associate()) {
$text = '<p>' . i18n::s('Click on following links to review or change parameters of this server.') . '</p>';
$commands = array();
// configuration scripts that are part of the core -- some complex commands
if (Surfer::has_all()) {
示例10: elseif
// page language, if any
if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
$context['page_language'] = $item['language'];
}
// page canonical link
$context['page_link'] = Articles::get_permalink($item);
// not found -- help web crawlers
if (!isset($item['id'])) {
include '../error.php';
// permission denied
} elseif (!$permitted) {
// make it clear to crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
} elseif (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_permalink($item)));
} elseif (isset($_REQUEST['requested']) && ($requested = Users::get($_REQUEST['requested'])) && $requested['email']) {
// prepare the mail message
$to = Mailer::encode_recipient($requested['email'], $requested['full_name']);
$subject = sprintf(i18n::c('%s: %s'), i18n::c('Request'), strip_tags($item['title']));
$message = Articles::build_notification('apply', $item, $overlay);
$headers = Mailer::set_thread('article:' . $item['id']);
// allow for skinnable template
$message = Skin::build_mail_message($message);
// build multiple parts, for HTML rendering
$message = Mailer::build_multipart($message);
// send the message to requested user
if (Mailer::post(Surfer::from(), $to, $subject, $message, NULL, $headers)) {
$text = sprintf(i18n::s('Your request has been transmitted to %s. Check your mailbox for feed-back.'), Skin::build_link(Users::get_permalink($requested), Codes::beautify_title($requested['full_name']), 'user'));
$context['text'] .= Skin::build_block($text, 'note');
}
示例11: isset
// forward to the updated page
} else {
// touch the related anchor
$anchor->touch('file:update', $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
// clear cache
Files::clear($_REQUEST);
// increment the post counter of the surfer
Users::increment_posts(Surfer::get_id());
// record surfer activity
Activities::post('file:' . $_REQUEST['id'], 'upload');
if ($render_overlaid) {
echo 'post done';
die;
}
// forward to the anchor page
Safe::redirect($anchor->get_url('files'));
}
// display the form on GET
} else {
$with_form = TRUE;
}
// display the form
if ($with_form) {
// prevent updates from section owner or associate
if (isset($item['assign_id']) && $item['assign_id'] && !Surfer::is($item['assign_id'])) {
$context['text'] .= Skin::build_block(sprintf(i18n::s('This file has been reserved by %s %s, and it is likely that an updated version will be made available soon.'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date'])), 'caution');
}
// the form to edit a file
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form" enctype="multipart/form-data"><div>';
$fields = array();
//
示例12: elseif
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// not found
} elseif (!isset($item['id'])) {
include '../error.php';
// an anchor is mandatory
} elseif (!is_object($anchor)) {
Safe::header('Status: 404 Not Found', TRUE, 404);
Logger::error(i18n::s('No anchor has been found.'));
// permission denied
} elseif (!$permitted) {
// surfer has to be authenticated
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Versions::get_url($item['id'], 'restore')));
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// restoration
} else {
// update the database
if (Versions::restore($item['id'])) {
// provide some feed-back
$context['text'] .= '<p>' . i18n::s('The page has been successfully restored.') . '</p>';
// follow-up commands
$context['text'] .= Skin::build_link($anchor->get_url(), i18n::s('Done'), 'button');
// clear the cache; the article may be listed at many places
Cache::clear();
}
示例13: load_skin
* @author GnapZ
* @reference
* @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
*/
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'files.php';
// load the skin
load_skin('files');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Files'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('files/configure.php'));
} elseif (!Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
// load current parameters, if any
Safe::load('parameters/files.include.php');
// the form
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
//
// supported extensions
//
$extensions = '';
// supported extensions
$label = i18n::s('Supported extensions');
示例14: elseif
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// passwords have to be confirmed
} elseif (!isset($_REQUEST['password']) || !$_REQUEST['password'] || strcmp($_REQUEST['confirm'], $_REQUEST['password'])) {
Logger::error(i18n::s('Please confirm your new password.'));
$with_form = TRUE;
// stop robots and replay attacks
} elseif (Surfer::may_be_a_robot()) {
Logger::error(i18n::s('Please prove you are not a robot.'));
$with_form = TRUE;
// display the form on error
} elseif (!Users::put($_REQUEST)) {
$with_form = TRUE;
// save one click to associates
} elseif (Surfer::is_associate()) {
Safe::redirect(Users::get_permalink($item));
} else {
// splash message
$context['text'] .= '<p>' . i18n::s('Password has been changed.') . '</p>';
// back to the anchor page
$links = array();
$links[] = Skin::build_link(Users::get_permalink($item), i18n::s('Done'), 'button');
$context['text'] .= Skin::finalize_list($links, 'assistant_bar');
}
// display the form on GET
} else {
$with_form = TRUE;
}
// display the form
if ($with_form) {
// splash message
示例15: elseif
// the title of the page
if (isset($item['title'])) {
$context['page_title'] = $item['title'];
}
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// not found
} elseif (!isset($item['id'])) {
include '../error.php';
// permission denied
} elseif (!$permitted) {
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Categories::get_url($item['id'], 'print')));
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// display the category
} else {
// the introduction text
$context['text'] .= Skin::build_block($item['introduction'], 'introduction');
// the beautified description, which is the actual page body
$context['text'] .= Skin::build_block($item['description'], 'description');
// // date of last update
// $context['text'] .= i18n::s('Last update').' '.Skin::build_date($item['edit_date']);
//
// the section of sub-categories
//