<?php
include("connect.php");
include("login_cookies.php");

while($admin = mysql_fetch_array($db_admin)) {

if ($_COOKIE["pass"] == $admin["kode"]) {

 if ($admin["admin"] == "1" || $admin["crew"] == "1") {

	if ($admin["exist"] == "1") {

print "<strong>OBS:</strong> Kun til uploading af filer, der skal bruges til avisen!!!<br /><br />";

if ($_POST["submit"] == "Upload!" && isset($_POST["FileToUpload"])) {

////////////////////////////////////////////////////////////////////////////////////////////////////


//upload.php
function upload_form() {
global $PHP_SELF;
?>
<form method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>">
<input type="hidden" name="action" value="upload">
Upload file!
<input type="file" name="userfile">
<input type="submit" name="submit" value="Upload">
</form>
<?php
}

function upload_file() {
global $userfile, $userfile_name, $userfile_size, $userfile_type, $archive_dir, $max_filesize, $WINDIR;

$archive_dir="/uploaded";

if(isset($WINDIR)) { $userfile = str_replace("\\\\","\\", $userfile); }

$filename = basename($userfile_name);
$max_filesize = 20000;

if($userfile_size <= 0) die ("$filename is empty");
if($userfile_size > $max_filesize) die ("$filename is too big! Only $max_filesize bytes allowed!");
if(!@copy($userfile, "$archive_dir/$filename")) die ("Can't copy $userfile_name to $filename.");
if(isset($WINDIR) && !@unlink($userfile)) die ("Can't delete the file $userfile_name.");

echo "<img src=\"$filename\"><br>";
echo "$filename has been successfully uploaded.<br>";
echo "Filesize: " . number_format($userfile_size) . "<br>";
echo "Filetype: $userfile_type<br>";
}
?>
<html>
<head><title>File upload</title></head>
<body>
<?php
if($action == 'upload') {
upload_file();
} else {
upload_form();
}

////////////////////////////////////////////////////////////////////////////////////////////////////

}

 } else {
print "Du skal være medlem af crewet for at kunne se denne side!";
}

}
}
}
?>