<? if(!$allow_upload){ Header("Location: index.php"); } ?>
<? include_once("inc/header.php"); ?>
<?
$my_max_file_size = "102400000000";
$the_path = $upload_dir;
$registered_types = array(
"application/x-gzip-compressed" => ".tar.gz, .tgz",
"application/x-zip-compressed" => ".zip",
"application/x-tar" => ".tar",
"text/plain" => ".html, .php, .txt, .inc (etc)",
"image/bmp" => ".bmp, .ico",
"image/gif" => ".gif",
"image/pjpeg" => ".jpg, .jpeg",
"image/jpeg" => ".jpg, .jpeg",
"application/x-shockwave-flash" => ".swf",
"application/msword" => ".doc",
"application/vnd.ms-excel" => ".xls",
"application/octet-stream" => ".exe, .fla (etc)",
"audio/mpeg" => ".mp3, .mp2"
);
$allowed_types = array("audio/mpeg");
switch($task)
{
case 'upload':
upload($the_file);
break;
default:
form();
}
function form($error=false)
{
global $PHP_SELF,$my_max_file_size, $the_path;
if ($error) print $error . "<br><br>";
print "<center>";
print "\n<form ENCTYPE=\"multipart/form-data\" action=\"" . $PHP_SELF . "\" method=\"post\">";
print "\n<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . $my_max_file_size . "\">";
print "\n<INPUT TYPE=\"hidden\" name=\"task\" value=\"upload\">";
print "\n<br><INPUT NAME=\"the_file\" TYPE=\"file\" SIZE=\"35\"><br>";
print "\n<input type=\"submit\" Value=\"Upload\">";
print "\n</form>";
print "</center>";
}
function upload($the_file)
{
global $the_path, $the_file_name, $the_file_type, $upload_dir, $upload_ftpaccess;
$error = validate_upload($the_file);
if($error)
{
form($error);
}
else
{
if(!@copy($the_file, $the_path . "/" . $the_file_name))
{
form("\n<center><font face=\"Verdana\">Error uploading your file. Please email: $admin_email with the error.</font></center>");
}
else
{
Header("Location: addnew?dir_name=$upload_dir&ftp_access=$upload_ftpaccess&action=Add+MP3s");
//form("\n<center><font face=\"Verdana\">File uploaded!</font></center>");
}
}
}
function validate_upload($the_file)
{
global $my_max_file_size, $allowed_types, $the_file_type, $registered_types;
$start_error = "\n<br><center>";
if($the_file == "none")
{
$error .= "\n<li>You did not upload anything!</li>";
}
else
{
if (!in_array($the_file_type,$allowed_types))
{
$error .= "\n<center><font face=\"Verdana\">You are not allowed to upload files of this type ( <font color=\"red\">$the_file_type</font> ).<br>You are only allowed to upload these types of files:</font></center><br>\n";
while ($type = current($allowed_types))
{
$error .= "<center><font face=\"Verdana\">\n" . $registered_types[$type] . " (" . $type . ")";
next($allowed_types);
}
}
if($error)
{
$error = $start_error . $error . "\n</font></center>";
return $error;
}
else
{
return false;
}
}
}
?>
<? include_once("inc/footer.php"); ?>