require("include/top.php");
$logos_path = 'gfx/logos/';
unset($submitok);
// check the submitted data
//if($sshotfile&&($sshotfile!="none"))
if(is_uploaded_file($logofile))
{
// check user account
if(!$_SESSION["SESSION"]||!$_SESSION["SCENEID"])
$errormessage[]="you need to be logged in first.";
// check if the logo filename is already taken
if(file_exists($logos_path.$logofile_name)) {
$errormessage[]="this filename already exists on the server";
}
if(!preg_match("/^[a-z0-9_-]*\.[a-zA-Z]{3,4}$/",$logofile_name)) {
$errormessage[]="please give a senseful filename devoid of dumb characters, kthx? (nothing but alphanumerics, dash and underscore is allowed)";
}
$fileinfo = GetImageSize($logofile);
switch($fileinfo[2]) {
case 1:$mytype=".gif";break;
case 2:$mytype=".jpg";break;
case 3:$mytype=".png";break;
default: $errormessage[]="the logo is not a valid .gif/jpg or .png file"; break;
}
if($fileinfo[0]>700) {
$errormessage[]="the width of the logo must not be greater than 700 pixels";
}
if($fileinfo[1]>200) {
$errormessage[]="the height of the logo must not be greater than 200 pixels";
}
if(filesize($logofile) > 256 * 1024) {
$errormessage[]="the size of the logo must not be greater than 256KB";
}
// if everything is ok
if(!$errormessage)
$submitok=true;
}
// move the submitted sshot to the appropriate location
if(!$submitok && file_exists($logofile)){
unlink($logofile);
// move_uploaded_file($sshotfile,"screenshots/".$which.$mytype);
// copy($sshotfile, "screenshots/".$which.$mytype);
// unlink($sshotfile);
}
if($submitok) {
$ext = strrchr($logofile_name, '.');
if($ext !== false)
{
$custom_name = substr($logofile_name, 0, -strlen($ext));
}
else
{
$custom_name = $logofile_name;
}
if(strlen($custom_name) > 250)
{
$custom_name = substr($custom_name, 0, 250);
}
$custom_name .= $mytype;
copy($logofile, $logos_path.$custom_name);
unlink($logofile);
// reward the user
$query ="INSERT INTO logos SET ";
$query.="file='".$custom_name."', ";
$query.="author1=".$_SESSION["SCENEID_ID"];
mysql_query($query);
}
?>