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

Last change on this file since 32396 was 32396, checked in by fil@…, 12 years ago

plugin hash_documents, cf. http://www.spip-contrib.net/Le-plugin-hash_documents

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