21,7 → 21,7 |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: erreur_404.php,v 1.2 2005-05-26 08:51:55 jpm Exp $ |
// CVS : $Id: erreur_404.php,v 1.3 2006-10-06 14:23:12 alexandre_tb Exp $ |
/** |
* Redirection de page |
* |
33,7 → 33,7 |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2005 |
*@version $Revision: 1.2 $ $Date: 2005-05-26 08:51:55 $ |
*@version $Revision: 1.3 $ $Date: 2006-10-06 14:23:12 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
54,9 → 54,9 |
/** Chemin et nom du fichier affichant une erreur 404.*/ |
define('PAP_FICHIER_ERREUR_404', 'sites/commun/%s/http_erreurs/erreur404.php'); |
/** Chemin et nom du fichier affichant une erreur 404.*/ |
define('PAP_URL_ERREUR_404', 'sites/commun/%s/http_erreurs/erreur404.php?url=%s'); |
define('PAP_URL_ERREUR_404', '%ssites/commun/%s/http_erreurs/erreur404.php?url=%s'); |
/** Url où rediriger une page.*/ |
define('PAP_URL_REDIRECTION', '/papyrus.php?menu=%s'); |
define('PAP_URL_REDIRECTION', '%spapyrus.php?menu=%s'); |
|
if (file_exists(PAP_FICHIER_CONFIG) && file_exists(PAP_FICHIER_FONCTION_MENU) && file_exists(PAP_FICHIER_CONFIG_AVANCEE) && |
file_exists(PAP_FICHIER_PEAR_DB) && file_exists(PAP_FICHIER_PEAR_HTTP)) { |
83,12 → 83,15 |
if (DB::isError($bdd) || empty($_SERVER['REQUEST_URI'])) { |
gererErreur404(); |
} |
preg_match('/^\/(.*?)(?:\?(.*)|)$/', $_SERVER['REQUEST_URI'], $tab_raccourci); |
$raccourci = $tab_raccourci[1]; |
//preg_match('/^\/(.*?)(?:\?(.*)|)$/', $_SERVER['REQUEST_URI'], $tab_raccourci); |
preg_match('/^(\/.*?)([^\/]+?)(?:\?(.*)|)$/', $_SERVER['REQUEST_URI'], $tab_raccourci); |
$raccourci = $tab_raccourci[2]; |
$chemin_papyrus = $tab_raccourci[1]; |
$parametres = ''; |
if (isset($tab_raccourci[2])) { |
$parametres = $tab_raccourci[2]; |
} |
//echo $raccourci; |
// Nous cherchons à savoir si le raccourci est entièrement numérique ou pas. |
if (preg_match('/^[0-9]+$/', $raccourci)) { |
// Nous vérifions si nous utilisons les codes numériques ou alphanumérique dans les url |
108,25 → 111,25 |
if ($code != '') { |
// Nous effectuons la redirection: |
if (!empty($parametres)) { |
header ('Location: '.sprintf(PAP_URL_REDIRECTION, $code).'&'.$parametres); |
header ('Location: '.sprintf(PAP_URL_REDIRECTION, $chemin_papyrus, $code).'&'.$parametres); |
} else { |
header ('Location: '.sprintf(PAP_URL_REDIRECTION, $code)); |
header ('Location: '.sprintf(PAP_URL_REDIRECTION, $chemin_papyrus, $code)); |
} |
header('Status: 303'); |
exit(0); |
} else { |
gererErreur404(); |
gererErreur404($chemin_papyrus); |
} |
|
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
function gererErreur404() { |
function gererErreur404($chemin_papyrus = '') { |
// Utilisation de la fonction statique de Pear HTTP pour négocier l'i18n. |
$aso_i18n_possible = array(GEN_I18N_ID_DEFAUT => true); |
$i18n = HTTP::negotiateLanguage($aso_i18n_possible, GEN_I18N_ID_DEFAUT); |
if (file_exists(sprintf(PAP_FICHIER_ERREUR_404, $i18n))) { |
header ('Location: /'.sprintf(PAP_URL_ERREUR_404, $i18n, $_SERVER['REQUEST_URI'])); |
header ('Location: '.sprintf(PAP_URL_ERREUR_404, $chemin_papyrus, $i18n, $_SERVER['REQUEST_URI'])); |
} else { |
header('Location: /'); |
} |
136,6 → 139,9 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.2 2005/05/26 08:51:55 jpm |
* Correction bogue du à la gestion des paramêtres. |
* |
* Revision 1.1 2005/03/30 08:58:32 jpm |
* Ajout du fichier gérant les erreurs 404 et les redirections. |
* |