require("include/top.php");
unset($submitok);
if(is_uploaded_file($userfile))
{
//$tmpfile=tempnam("tmp","avatar");
//rename($userfile,$tmpfile);
$size=GetImageSize($userfile);
if($size[0]!=16) {
$errormessage[]="the width must be equal to 16 pixels";
}
if($size[1]!=16) {
$errormessage[]="the height must be equal to 16 pixels";
}
if($size[2]!=1) {
$errormessage[]="the file must be a .gif file";
}
if(filesize($userfile)>4096) {
$errormessage[]="the file size must be lower than 4Kb";
}
$ext = strrchr($userfile_name, '.');
if($ext !== false)
{
$custom_name = substr($userfile_name, 0, -strlen($ext));
}
else
{
$custom_name = $userfile_name;
}
$custom_name = strtolower($custom_name);
if(strlen($custom_name) > 250)
{
$custom_name = substr($custom_name, 0, 250);
}
$custom_name .= '.gif';
if(!preg_match("/^[a-z0-9_-]*\.gif$/",$custom_name)) {
$errormessage[]="please give a senseful filename devoid of dumb characters, kthx? (nothing but alphanumerics, dash and underscore is allowed)";
}
if(file_exists("avatars/".$custom_name)) {
$errormessage[]="this filename already exists on the server";
}
// if everything is ok
if(!$errormessage)
$submitok=true;
}
if(!$submitok&&file_exists($userfile)){
unlink($userfile);
}
if($submitok) {
copy($userfile,"avatars/".$custom_name);
unlink($userfile);
/*
// reward the user
$query ="INSERT INTO avatars SET ";
$query.="avatar='".$userfile_name."',";
$query.="user=".$user["id"].",";
$query.="added=NOW()";
mysql_query($query);
*/
}
if($errormessage) { ?>
for($i=0;$ierror: | ".$errormessage[$i]."
| \n");
}
?>
} ?>
some of the currently available avatars |
$d = glob("avatars/*.gif");
$grid = 16;
$keyz = array_rand($d,$grid*$grid);
for ($i=0; $i<$grid*$grid; $i++) {
$entry = $d[$keyz[$i]];
print(" | \n");
if(($i%$grid)==$grid-1) {
print(" \n");
}
}
/*
while($entry=$d->read()) {
$i++;
print("
| \n");
if(!($i%8)) {
print(" \n");
}
}
$d->close();
while($i%8) {
$i++;
print("
| \n");
}
*/
?>
|
|
|
require("include/bottom.php"); ?>