本文整理汇总了PHP中http_redirect函数的典型用法代码示例。如果您正苦于以下问题:PHP http_redirect函数的具体用法?PHP http_redirect怎么用?PHP http_redirect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了http_redirect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: httpRedirect
/**
* Perform HTTP redirect with saving POST params in session.
*
* @param string $url URL redirect to.
* @param array<mixed> $postData List of post params to save.
*/
public static function httpRedirect($url = "", $postData = [])
{
if (preg_match("#^http[s]?://.+#", $url)) {
// absolute url
if (function_exists("http_redirect")) {
http_redirect($url);
} else {
self::http_redirect($url);
}
} else {
// same domain (relative url)
if (!empty($postData)) {
if (is_array($postData)) {
if (!Session::exists('_post') || !is_array($_SESSION['_post'])) {
Session::set('_post', []);
}
foreach ($postData as $fieldName => $fieldValue) {
Session::set("_post[{$fieldName}]", serialize($fieldValue));
}
} else {
throw new HttpException("Wrong POST data.");
}
}
if (function_exists("http_redirect")) {
http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url);
} else {
self::http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url);
}
}
}
示例2: force_login
public function force_login(PlPage $page)
{
$redirect = S::v('loginX');
if (!$redirect) {
$page->trigError('Impossible de s\'authentifier. Problème de configuration de plat/al.');
return;
}
http_redirect($redirect);
}
示例3: handler_set_skin
function handler_set_skin($page)
{
S::assert_xsrf_token();
S::set('skin', Post::s('change_skin'));
if (!empty($_SERVER['HTTP_REFERER'])) {
http_redirect($_SERVER['HTTP_REFERER']);
} else {
pl_redirect('/');
}
}
示例4: handler_exit
function handler_exit($page, $level = null)
{
global $globals;
if (S::has('suid')) {
Platal::session()->stopSUID();
pl_redirect('/');
}
Platal::session()->destroy();
http_redirect($globals->baseurl_http);
$page->changeTpl('exit.tpl');
}
示例5: index
function index()
{
$error = $this->codeError($_GET['code']);
if ($error == '/') {
session_start();
session_destroy();
http_redirect('/');
exit;
}
$this->template->vars('error', $error);
$this->template->view('index');
exit;
}
示例6: handler_sso
function handler_sso($page)
{
$this->load('sso.inc.php');
// First, perform security checks.
if (!wats4u_sso_check()) {
return PL_BAD_REQUEST;
}
global $globals;
if (!S::logged()) {
// Request auth.
$page->assign('external_auth', true);
$page->assign('ext_url', $globals->wats4u->public_url);
$page->setTitle('Authentification');
$page->setDefaultSkin('group_login');
$page->assign('group', null);
return PL_DO_AUTH;
}
if (!S::user()->checkPerms(PERMS_USER)) {
// External (X.net) account
return PL_FORBIDDEN;
}
// Update the last login information (unless the user is in SUID).
$uid = S::i('uid');
if (!S::suid()) {
global $platal;
S::logger($uid)->log('connexion_wats4u', $platal->path . ' ' . urldecode($_GET['url']));
}
// If we logged in specifically for this 'external_auth' request
// and didn't want to "keep access to services", we kill the session
// just before returning.
// See classes/xorgsession.php:startSessionAs
if (S::b('external_auth_exit')) {
S::logger()->log('deconnexion', @$_SERVER['HTTP_REFERER']);
Platal::session()->killAccessCookie();
Platal::session()->destroy();
}
// Compute return URL
$full_return = wats4u_sso_build_return_url(S::user());
if ($full_return === "") {
// Something went wrong
$page->kill("Erreur dans le traitement de la requête Wats4U.");
}
http_redirect($full_return);
}
示例7: userEvent
function userEvent()
{
$active = $this->isActive();
if ($active < 2) {
http_redirect('/');
exit;
}
session_start();
$id = $_SESSION['user'][0];
$model = new Model_profileEvent();
$modelCor = new Model_correspondence();
$event = $model->allEvents($id, 1);
$result = $modelCor->ajaxMessage(0, $event[0]['id']);
$modelUser = new Model_profileUser();
$event_user = $model->userByEvent($event[0]['id']);
$maxId = $modelCor->maxId();
foreach ($result as $key => $value) {
$user = $modelUser->result_by(array("id" => $value['user_id']));
$ava = explode('static', $user[0]['ava']);
if (!empty($event_user) && $value['user_id'] == $event_user) {
$result[$key]['user'] = true;
} else {
$result[$key]['user'] = false;
if ($value['user_id'] == $id) {
$result[$key]['us'] = true;
} else {
$result[$key]['us'] = false;
}
}
$result[$key]['ava'] = $ava[count($ava) - 1];
$result[$key]['login'] = $user[0]['login'];
}
$this->template->vars('menu', array('Назад' => 'onclick="goHref()"'));
$this->template->vars('event', $event[0]['id']);
$this->template->vars('maxId', $maxId[0]['last_value']);
$this->template->vars('message', $result);
$this->template->vars('events', $event);
$this->template->view('event_mes');
}
示例8: httpRedirect
/**
* Perform HTTP redirect with saving POST params in session.
*
* @param string $url URL redirect to.
* @param array<mixed> $postData List of post params to save.
*/
public static function httpRedirect($url = "", $postData = array())
{
if (preg_match("#^http[s]?://.+#", $url)) {
// absolute url
http_redirect($url);
} else {
// same domain (relative url)
if (!empty($postData)) {
if (is_array($postData)) {
if (!isset($_SESSION['_post']) || !is_array($_SESSION['_post'])) {
$_SESSION['_post'] = array();
}
foreach ($postData as $fieldName => $fieldValue) {
$_SESSION['_post'][$fieldName] = serialize($fieldValue);
}
} else {
throw new \Exception("Wrong POST data.");
}
}
http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url);
}
}
示例9: check
public function check($printErr = true)
{
global $AUTH;
$err = null;
try {
$data = $this->handleResponseAuth();
if ($data !== null) {
// Set credentials to authenticate
$AUTH->setTrustUsername(false);
$AUTH->setLogoutPossible(true);
$AUTH->passCredentials($data);
// Try to authenticate the user
$result = $AUTH->isAuthenticated();
if ($result === true) {
if (!isset($data['onetime'])) {
// Success: Store in session
$AUTH->storeInSession();
}
// In case of success do an redirect, to prevent the browser from
// showing up bad warning messages upon page reload about resending
// the logins POST request
http_redirect();
} else {
throw new FieldInputError(null, l('Authentication failed.'));
}
}
} catch (FieldInputError $e) {
$err = $e;
}
// Authentication failed. Show the login dialog with the error message to
// the user again. In case of an ajax request, simply raise an exception
if (!CONST_AJAX) {
return array('LogonDialog', 'view', $err);
} else {
throw new NagVisException(l('You are not authenticated'), null, l('Access denied'));
}
}
示例10: mysqli
echo "Rellena todos los campos";
} else {
// verificamos que el usuario exista en la BDD
$conexion = new mysqli('localhost', 'root', '', 'sistema');
if ($conexion->connect_error) {
die($conexion->connect_error);
}
$existe_email = "SELECT email FROM usuario WHERE email='{$email}'";
$respuesta = $conexion->query($existe_email);
$rows = $respuesta->num_rows;
if ($rows > 0) {
// si el usuario existe en la BDD traemos la contrasena
$get_pass = "SELECT contrasena FROM usuario WHERE email='{$email}'";
$resp = $conexion->query($get_pass);
$row2 = mysqli_fetch_assoc($resp);
//echo $row2['contrasena'];
//echo "in pass: ".$pass;
// verificar que la contrasena ingresada coincida con la almacenada en la BDD
if ($row2['contrasena'] == $pass) {
// Si las contrasenas coinciden podemos iniciar sesion
$_SESSION['email'] = $email;
if (isset($_SESSION['email'])) {
http_redirect('inicio.php');
}
} else {
echo "las contrasenas no coiciden";
}
}
}
}
$msg = isset($_GET['exito']) ? $_GET['exito'] : '';
示例11: md5
$error = '';
if ($_POST) {
$email = $_POST['email'];
$contrasena = md5($_POST['password']);
$verificar_contrasena = md5($_POST['verif_password']);
if ($email == "" || $contrasena == "" || $verificar_contrasena == "") {
echo '<h2>Ingrese sus datos</h2>';
} else {
if ($contrasena !== $verificar_contrasena) {
$error .= htmlentities('Las contraseñas no coinciden');
echo '<h2>Las contraseñas no coinciden</h2>';
}
if ($error == '') {
$conn = new mysqli('localhost', 'root', '', 'bdd');
if ($conn->connect_error) {
$error .= '<br>No se pudo conectar a la base de datos';
}
//die($conn ->connect_error);
$query = "INSERT INTO usuario \n (\n email, \n password)\n VALUES (\n '{$email}',\n '{$contrasena}'\n )";
$result = $conn->query($query);
if (!$result) {
$error .= '<br>No se pudo guardar los registros en la bdd. Vuelva a intentarlo.';
//die($conn ->error);
}
if ($error == '') {
http_redirect('index.php?exito=' . urlencode('Datos guardados con exito'));
}
}
}
}
示例12: execute
//.........这里部分代码省略.........
$db->begin();
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadXML($order->DataText1);
$shop_account_element = $doc->getElementsByTagName('shop_account');
$shop_account_element = $shop_account_element->item(0);
//handle and store the TXID
//remove first if exists
$txid_elements = $doc->getElementsByTagName('txid');
if ($txid_elements->length >= 1) {
$txid_element = $txid_elements->item(0);
$txid_element->parentNode->removeChild($txid_element);
}
//then create
$txidNode = $doc->createElement("txid", $txid);
$shop_account_element->appendChild($txidNode);
//handle and store the userid
//remove first if exists
$userid_elements = $doc->getElementsByTagName('userid');
if ($userid_elements->length >= 1) {
$userid_element = $userid_elements->item(0);
$userid_element->parentNode->removeChild($userid_element);
}
//then create
$useridNode = $doc->createElement("userid", $userid);
$shop_account_element->appendChild($useridNode);
//handle and store the pseudocardpan
if ($http->hasPostVariable('truncatedcardpan')) {
//remove first if exists
$tpan_elements = $doc->getElementsByTagName('truncatedcardpan');
if ($tpan_elements->length >= 1) {
$tpan_element = $tpan_elements->item(0);
$tpan_element->parentNode->removeChild($tpan_element);
}
//then create
$truncatedcardpan_node = $doc->createElement("truncatedcardpan", $http->postVariable('truncatedcardpan'));
$shop_account_element->appendChild($truncatedcardpan_node);
}
if ($json_response->status === "REDIRECT") {
//remove first if exists
$cc3d_sec_elements = $doc->getElementsByTagName('cc3d_reserved');
if ($cc3d_sec_elements->length >= 1) {
$cc3d_sec_element = $cc3d_sec_elements->item(0);
$cc3d_sec_element->parentNode->removeChild($cc3d_sec_element);
}
//save reserved flag false for now
$reservedFlag = $doc->createElement("cc3d_reserved", "false");
$shop_account_element->appendChild($reservedFlag);
} else {
//remove cc3d_reserved if exists. this case could occure if someone changed from 3d CC to normal CC.
$cc3d_sec_elements = $doc->getElementsByTagName('cc3d_reserved');
if ($cc3d_sec_elements->length >= 1) {
$cc3d_sec_element = $cc3d_sec_elements->item(0);
$cc3d_sec_element->parentNode->removeChild($cc3d_sec_element);
}
}
//i must store here redundant otherwise the order will not be stored since its stuck in a transaction
$db->commit();
//store it
$order->setAttribute('data_text_1', $doc->saveXML());
$order->store();
$db->commit();
if ($json_response->status === "REDIRECT") {
eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card detected - REDIRECTING to creditcard institute check :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
//do redirect to 3d secure password confirm page
http_redirect($json_response->redirecturl);
exit;
} else {
xrowPayoneCreditCardGateway::setPaymentMethod($order);
eZLog::write("SUCCESS in step 2 ('preauthorisation') for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
return eZWorkflowType::STATUS_ACCEPTED;
}
} else {
eZLog::write("FAILED in step 2 ('preauthorisation') for order ID " . $order_id . " with ERRORCODE " . $json_response->errorcode . " Message: " . $json_response->errormessage, $logName = 'xrowpayone.log', $dir = 'var/log');
if ($payoneINI->variable('GeneralSettings', 'CustomErrorNode') === "disabled") {
//use default error of payone
$errors = array($json_response->customermessage);
} else {
//use customized errors
$response["errorcode"] = $json_response->errorcode;
$response["errormessage"] = $json_response->errormessage;
$errors = array(xrowPayoneHelper::generateCustomErrorString($order, $response));
}
}
} else {
eZLog::write("ERROR: Remote content not found in file " . __FILE__ . " on line " . __LINE__, $logName = 'xrowpayone.log', $dir = 'var/log');
}
} else {
if (is_object($paymentObj)) {
//that means, that we have a paymentobject which is not approved. its not approved because the payment has failed so we return a array
$errors = array(ezpI18n::tr('extension/xrowpayone', 'Error occured during payment process. Please choose your payment option again.'));
$paymentObj->remove();
}
}
$process->Template = array();
$process->Template['templateName'] = xrowPayoneCreditCardGateway::TEMPLATE;
$process->Template['path'] = array(array('url' => false, 'text' => ezpI18n::tr('extension/xrowpayone', 'Payment Information')));
$process->Template['templateVars'] = array('errors' => $errors, 'order' => $order, 'event' => $event);
// return eZWorkflowType::STATUS_REJECTED;
return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT;
}
示例13: cerrar_sesion
<?php
cerrar_sesion();
http_redirect('index.php');
示例14: session_start
<?php
require_once "../include/pictures.php";
require_once "../include/comments.php";
require_once "../include/cart.php";
require_once "../include/html_functions.php";
require_once "../include/functions.php";
session_start();
if (!isset($_GET['query'])) {
http_redirect("/error.php?msg=Error, need to provide a query to search");
}
$pictures = Pictures::get_all_pictures_by_tag($_GET['query']);
?>
<?php
our_header("", $_GET['query']);
?>
<div class="column prepend-1 span-24 first last">
<h2>Pictures that are tagged as '<?php
echo $_GET['query'];
?>
'</h2>
<?php
thumbnail_pic_list($pictures);
?>
</div>
示例15: session_start
<?php
require_once "../include/users.php";
require_once "../include/functions.php";
session_start();
require_login();
Users::logout();
http_redirect("/");