Viewing file: 13.php (1.02 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// Include the Session class
require_once('Session/Session.php');
// Instantiate the Session class
$session=new Session();
// Check to see if $viewImages is registered
if ( $session->get('viewImages') ) {
// An array of available images
$images=array(
'sitepoint_logo.jpg',
'php-big.png'
);
// If $_GET['img'] is set and in available...
if ( isset ($_GET['img']) && in_array($_GET['img'],$images) ) {
// Get the image information
$dims=getimagesize('sample_images/'.$_GET['img']);
// Send the correct HTTP headers
header('content-disposition: inline; filename=' . $_GET['img']);
header('content-type: '.$dims['mime']); # PHP 4.3.x +
header('content-length: ' . filesize('sample_images/'.$_GET['img']));
// Display the image
readfile('sample_images/'.$_GET['img']);
} else {
die ('Invalid image specified');
}
} else {
die ('This image is protected from hotlinking');
}
?>
|