source: spip-zone/_plugins_/hash_documents/action/hash_404.php @ 53428

Last change on this file since 53428 was 53428, checked in by yffic@…, 10 years ago

if (!defined("_ECRIRE_INC_VERSION")) return; sur tout fichier PHP pour sécurité future principalement

File size: 1.5 KB
Line 
1<?php
2if (!defined("_ECRIRE_INC_VERSION")) return;
3
4## fichier appele par le .htaccess de IMG/ ; lequel doit contenir :
5
6/*
7
8RewriteEngine On
9RewriteCond %{REQUEST_FILENAME} !-f
10# Si spip est range a la racine du domaine ou pour un mutualise
11RewriteRule .* /ecrire/?action=hash_404 [L]
12# Si spip est range dans un sous dossier spip
13#RewriteRule .* /spip/ecrire/?action=hash_404 [L]
14
15*/
16
17include_spip("hash_fonctions");
18$doc = preg_replace(',^.*?IMG/,', '', $_SERVER['REQUEST_URI']);
19
20if (($dest = hasher_adresser_document($doc)
21AND file_exists('../'.$GLOBALS['meta']['dir_img'].$dest))
22OR ($dest1 = hasher_adresser_document($doc, true)
23AND file_exists('../'.$GLOBALS['meta']['dir_img'].$dest))
24) {
25        $url = 'http://'.$_SERVER['HTTP_HOST'].preg_replace(',^(.*?IMG/).*,', '\1', $_SERVER['REQUEST_URI']).$dest;
26        header('HTTP/1.1 301 Moved Permanently');
27        header('Location: '.$url);
28        echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
29<html><head>
30<title>301 Moved Permanently</title>
31</head><body>
32<h1>Moved Permanently</h1>
33<p>The requested URL '.htmlspecialchars($_SERVER['REQUEST_URI']).' has moved to <a href="'.$url.'">'.$url.'</a>.</p>
34<hr>
35'.$_SERVER['SERVER_SIGNATURE'].'
36</body></html>
37';
38}
39else {
40        echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
41<html><head>
42<title>404 Not Found</title>
43</head><body>
44<h1>Not Found</h1>
45<p>The requested URL '.htmlspecialchars($_SERVER['REQUEST_URI']).' was not found on this server.</p>
46<hr>
47'.$_SERVER['SERVER_SIGNATURE'].'
48</body></html>
49';
50}
51
52?>
Note: See TracBrowser for help on using the repository browser.