<?
########################################################
####### IMAGE PROTECTOR
########################################################
####### Date Released: 28th August 2006
####### Author: Nino Skopac
####### Developed At: http://www.recgr.com
####### Initial Release: http://dev.recgr.com
####### Support: http://www.forum-grounds.com
####### Contact Author: http://www.pmgrounds.com ['Nino']
########################################################
#######    H    O    W        T    O        U    S    E
/*

IMAGE PROTECTOR is a Applicaton which is used to
prevent your visitors to see the default
contents of your image folder.

- RENAME this file to index.php.
- PUT it in your image folder.

THAT'S IT !

*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<?
$path 
explode('/'$_SERVER['PHP_SELF']);

$folderTitle $path[count($path)-2];

?>
<title>Folder &raquo;<?=$folderTitle?>&laquo; Contents</title>
</head>

<body>
<?

$folder 
'.';
if (
$handle opendir($folder)) {
    while ( (
$file readdir($handle)) !== false) {
        if (
$file != "." && $file != "..") {
            
// getting the file extension
            
$is_img explode("."$file);
            
$ext end($is_img);
            
// allowed extensions
            
$allowed = array('png''jpg''jpeg''gif''bmp''tiff''wbmp');
            
// in_array() is case sensitive
            
$allowedUppercased $allowed;
            
$allowedUppercased array_flip($allowedUppercased);
            
$allowedUppercased array_change_key_case($allowedUppercasedCASE_UPPER);
            
$allowedUppercased array_flip($allowedUppercased);
            
$allowedUcfirst = array();
            
            for (
$i 0$i count($allowed); $i++) {
                
$allowedUcfirst[$i] = ucfirst($allowed[$i]);
            }
            
            if (
in_array($ext$allowed) || in_array($ext$allowedUppercased)  || in_array($ext$allowedUcfirst)) {
                
// Main Part
                
@list($w$h) = @getimagesize($file);
                
                if (empty(
$w) || empty($h)) {
                
$w "";
                
$h "";
                }
                
                echo 
'<p style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; border-bottom: 1px dotted #999999;">';
                echo 
"\n";
                
                echo 
"<font size=\"+2\"><em>$file</em></font> \n";
                echo 
"<br /> \n";
                echo 
"<a href=\"$file\"> \n";
                echo 
"<img src=\"$file\" alt=\"$file\" title=\"$file\" width=\"$w\" height=\"$h\" style=\"padding-top: 5px; padding-bottom: 3px;\" border=\"0\" />";
                echo 
"\n</a> \n";
                echo 
"\n";
                echo 
"<br /> \n";
                if (!empty(
$w)) {
                echo 
"<strong>Width:</strong> $w px";
                echo 
"\n";
                echo 
" | ";
                echo 
"\n";
                }
                if (!empty(
$h)) {
                echo 
"<strong>Height:</strong> $h px";
                echo 
"\n";
                echo 
" | ";
                echo 
"\n";
                }
                echo 
"<strong>Type:</strong> image/$ext";
                
                echo 
"\n";
                echo 
"<br /> <br /> \n";
                echo 
'</p>';
                echo 
"\n \n";
                                
            }
        }
    }
    
closedir($handle);
}
?>
<p>
<address style="margin-left: 10px;"><?=$_SERVER['HTTP_HOST']?></address>
<address style="margin-left: 10px;"><?=date("H:i T");?></address>
</p>
</body>
</html>
1