<?

// SETTINGS //
// Config
$dirUploads "/home/gpcons2/public_html/control/pimages";  // The directory the files will be uploaded to
$showDir "yes";
$numUploads "10"// Number of upload blanks to be shown on page
$limitFiles "yes"// Allow only certain filetypes?
$showAllowedFiles "yes"// 
$allowedFiles = array("jpg""gif""png""bmp"); // Allowed filetypes
$mainTableWidth "75%";
$stylesheet "uploader_style.css";
// Security
$reqSecure "no"// Passcode control?
$userPassword "2355";
// Screen Text & Error Messages - can be changed to any language
$caption "MULTIFILE UPLOADER";
$loginpageMsg "A Passcode Is Required";
$uploadpageMsg "Select The Files To Upload";
$passwordText "Passcode :";
$loginButtonText "Go To Upload Page";
$logoutText "logout now";
$allowedfiletypesText "Allowed Filetypes";
$lineText    =    "File";
$uploadButtonText "Upload Files";
$statusText "Upload Status :";
$nofileText "No file selected for upload";
$notallowedText "NOT ALLOWED";
$existsText "ALREADY EXISTS";
$successText "has been uploaded";
// END OF SETTINGS //

$pageTop "<html><head><title>$caption</title><link href=$stylesheet rel=stylesheet type=text/css></head><body><div align=\"center\" class=caption>$caption</div>";

        
$pre "Multifile Uploader";
        
$version "2.0";
        
$startdate "2003";

$pageBottom "</body></html>";

// session management
if($reqSecure == "yes")    {
    
session_start();
if (!
session_is_registered("mfupload")) {
    if (isset(
$_POST["password"]) && $_POST["password"] == $userPassword) {
            
session_register("mfupload");
            
$_SESSION["mfupload"] = $_POST["password"];
            
header("Location: $PHP_SELF");
            exit;
        } 
      else {
// login page
         
echo $pageTop;
         echo 
"&nbsp;<p><div align=\"center\" class=sitetag>$loginpageMsg</div>";
         echo 
"&nbsp;<p><div align=\"center\"><table border=0>";
         echo 
"<form name=loginform method=post action=$PHP_SELF>";
         echo 
"<tr><th>$passwordText</th><td><input type=password name=password style=\"width: 135px;\"></td>";
         echo 
"<th>&nbsp;</th><td><input type=submit class=button value=\"$loginButtonText\" style=\"width: 135px;\"></td></tr>";
         echo 
"</form></table></div>";
         echo 
"<script language=javascript>document.loginform.password.select();document.loginform.password.focus();</script>";
            echo 
$pageBottom;
         exit;
        }
    }
}

// kill session
if($_GET["action"]=="logout")    {
     
session_unset("mfupload");
         
header("Location: $PHP_SELF");
         exit;


if(
$doupload) {
global 
$allowedFiles;
$num 0;
while(
$num $numUploads) {
    
$num++;

    
$upFile "dofile$num"."_name";
    
$upFile1 = $$upFile;
    
$upFile2 "dofile$num";
    
$upFile3 = $$upFile2;

    
$ext substr(strrchr$upFile1 "." ), 1);
    
$ext str_replace("jpeg""jpg"$ext);
    
    
$size filesize($upFile3)/1024;
    
$size round($size,1);
    
    
// error messages
    
if($upFile3 == "") {
        
$msg_upload .= "<tr><td>$lineText $num :</td><td colspan=2>$nofileText</td></tr>";
        }
    elseif(
$limitFiles == "yes" && !in_array($ext,$allowedFiles))    {
        
$msg_upload .= "<tr><td>$lineText $num :</td><td><b>$upFile1</b></td><td>$notallowedText</td></tr>";
        }
    elseif(
file_exists("$dirUploads/$upFile1")) {
        
$msg_upload .="<tr><td>$lineText $num :</td><td><b>$upFile1</b></td><td>$existsText</td></tr>";
        } 
    else {
    
// everything OK
        
move_uploaded_file ($upFile3"$dirUploads/$upFile1");
        
$msg_upload .="<tr><td>$lineText $num :</td><td><b>$upFile1</b> ($size)</td><td>$successText</td></tr>";
        }
    }


// upload page
echo $pageTop;
if (
$reqSecure == "yes" && session_is_registered("mfupload")) {
    echo 
"<div align=\"right\"><a href=$PHP_SELF?action=logout>$logoutText</a>&nbsp;&nbsp;&nbsp;</div>";
}
    echo 
"<div align=\"center\" class=sitetag>$uploadpageMsg</div>";
    echo 
"&nbsp;<p><div align=\"center\"><table width=$mainTableWidth border=\"0\" class=bodytable>";
    if(
$showAllowedFiles == "yes")    {
        echo 
"<tr><th colspan=2><div align=\"center\">$allowedfiletypesText : ";
            for(
$i=0;$i<count($allowedFiles);$i++)    {
                if ((
$i<>count($allowedFiles)-1))$commas=", "; else $commas="";
                list(
$key,$value)=each($allowedFiles);
                echo 
$value.$commas;
                }
    }
    echo 
"</div></td></tr>";
    echo 
"<tr><td width=50%><table width=100% border=0>";
    echo 
"<form enctype=\"multipart/form-data\" action=\"$PHP_SELF\" method=\"post\">";
        
$num 0;
        while(
$num $numUploads) {
        
$num++;
        echo 
"<tr><th style=\"width: 20%;\">$lineText $num:</td><td><input name=\"dofile$num\" type=\"file\" style=\"width: 100%;\"></td></tr> ";
        }
    echo 
"<tr><td style=\"width: 20%;\">&nbsp;</td><td><input name=\"doupload\" type=\"submit\" value=\"$uploadButtonText\" class=button style=\"width: 100%;\"></td></tr>";
    echo 
"</form>";
    echo 
"</table></td>";
    echo 
"<td width=50%><div align=\"center\"><table width=95% border=0 class=msg_table>";
        if(
$msg_upload)    {
            echo 
"<tr><th colspan=3><div align=\"center\">$statusText ";
            if(
$showDir == "yes")    {
            echo 
$dirUploads;
            }
            echo 
"</div></td></tr>";
            echo 
$msg_upload;
            }
    echo 
"</table></div></td></tr></table></div>";

    echo 
$pageBottom;
?>