<?
// avatar gallery (index.php)
// Copyright 2005 Thad Ward
// This code is released under the GPL license VERSION 2 ONLY.
// (see http://www.gnu.org/licenses/gpl.txt or the COPYING file in this directory.)


// check to see if the "zlib" extension is available, and if so, enable zlib output compression.

if(extension_loaded("zlib"))
{
    
ini_set('zlib.output_compression_level''9');
    
ob_start("ob_gzhandler");
}

// this code currently depends on the mimetype php extension, which is deprecated.

define("AVATAR_VERSION"0.13);

// config items
$images_per_line 10;
$show_names false;

// TODO: error checking on opendir(), check for the mimetype extension.
?>
<html><head><title>Avatar Images</title></head><body>
<p>Welcome to my avatar images collection. Please feel free to save any of these images for your own use.
If you wish to use them, please <b>do NOT</b> link directly to them here. Instead, save a copy and upload it to
your own server. Alternately, if your forum has a spot to upload an avatar image from a URL, you may use the
image here directly. I have written a <a href="avatar.phps">PHP script</a> which randomly selects one of
these images and returns it. The script can be easilly adapted to do other stuff, such as selecting the
proper avatar image for the proper season. This index page was generated by <a href="index.phps">this
PHP script</a>. (<a href="COPYING">COPYING</a> file) Enjoy.</p>
<table>
<tr>
<?

$i 
0;
$d opendir(".");
while((
$file readdir($d)) !== false)
{
    if(
is_dir($file))
        continue;

    
$mtype = @mime_content_type($file);
    
    if(
!= strcasecmp("image"substr($mtype05)))
        continue;
    
    print 
'  <td align="center" valign="middle">';
    
    if(
$show_names === true)
        print 
'<table><tr><td align="center" valign="middle">';
        
    print 
'<img src="' $file '">';

    if(
$show_names === true)
        print 
'</td></tr><tr><td align="center" valign="middle">' $file '</td></tr></table>';

    print 
"</td>\n";

    
$i++;

    if((
$i $images_per_line) == 0)
        print 
"</tr>\n<tr>\n";
}
closedir($d);

?></tr>
</table>
</body>
</html>