wiki.techinc.nl/thumb_handler.php
Aaron Schulz dcbe8e7dd3 FU r101117: removed cURL thumb handler code and made thumb_handler.php a thin wrapper around thumb.php
* Moved original URL fetching code and parameter extraction code to thumb.php
* Made use of local repo URL and hash settings to avoid extra config code
* This makes it easy to add hooks for extensions/config to alter behavoir (ExtractThumbParameters hook added)
* Added FileRepo::getHashLevels()
2011-12-08 03:43:07 +00:00

43 lines
1.2 KiB
PHP

<?php
# Valid web server entry point
define( 'THUMB_HANDLER', true );
if ( $_SERVER['REQUEST_URI'] === $_SERVER['SCRIPT_NAME'] ) {
# Directly requesting this script is not a use case.
# Instead of giving a thumbnail error, give a generic 404.
wfDisplay404Error(); // go away, nothing to see here
} else {
# Execute thumb.php, having set THUMB_HANDLER so that
# it knows to extract params from a thumbnail file URL.
require( dirname( __FILE__ ) . '/thumb.php' );
}
/**
* Print out a generic 404 error message
*
* @return void
*/
function wfDisplay404Error() {
header( 'HTTP/1.1 404 Not Found' );
header( 'Content-Type: text/html;charset=utf-8' );
$prot = isset( $_SERVER['HTTPS'] ) ? "https://" : "http://";
$serv = strlen( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
$loc = $_SERVER["REQUEST_URI"];
$encUrl = htmlspecialchars( $prot . $serv . $loc );
// Looks like a typical apache2 error
$standard_404 = <<<ENDTEXT
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL $encUrl was not found on this server.</p>
</body></html>
ENDTEXT;
print $standard_404;
}