FU r101117: removed cURL thumb handler code and made thumb_handler.php a thin wrapper...
[lhc/web/wiklou.git] / thumb_handler.php
1 <?php
2
3 # Valid web server entry point
4 define( 'THUMB_HANDLER', true );
5
6 if ( $_SERVER['REQUEST_URI'] === $_SERVER['SCRIPT_NAME'] ) {
7 # Directly requesting this script is not a use case.
8 # Instead of giving a thumbnail error, give a generic 404.
9 wfDisplay404Error(); // go away, nothing to see here
10 } else {
11 # Execute thumb.php, having set THUMB_HANDLER so that
12 # it knows to extract params from a thumbnail file URL.
13 require( dirname( __FILE__ ) . '/thumb.php' );
14 }
15
16 /**
17 * Print out a generic 404 error message
18 *
19 * @return void
20 */
21 function wfDisplay404Error() {
22 header( 'HTTP/1.1 404 Not Found' );
23 header( 'Content-Type: text/html;charset=utf-8' );
24
25 $prot = isset( $_SERVER['HTTPS'] ) ? "https://" : "http://";
26 $serv = strlen( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
27 $loc = $_SERVER["REQUEST_URI"];
28
29 $encUrl = htmlspecialchars( $prot . $serv . $loc );
30
31 // Looks like a typical apache2 error
32 $standard_404 = <<<ENDTEXT
33 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
34 <html><head>
35 <title>404 Not Found</title>
36 </head><body>
37 <h1>Not Found</h1>
38 <p>The requested URL $encUrl was not found on this server.</p>
39 </body></html>
40 ENDTEXT;
41
42 print $standard_404;
43 }