***********************************************
config_mfuploaderII.php
***** PLEASE USE
Code: Select all
AND OTHER TAGS FOR CODE *****[/color]Code: Select all
<?
/*
Multifile Uploader Script -
Author :
Contact :
Last Modified : May 8, 2005
*/
$basePATH = "/home/tdpearce/public_html/uploaded/"; // Full PATH to script dir
$baseURL = "http://www.digitaltributedesign.com/uploaded/"; // Full URL to script dir
$stylesheet = "style_mfuploaderII.css"; // relative path to stylesheet
// images
$foldericon = "images/folder.gif";
$imageicon = "images/image.gif";
$othericon = "images/text.gif";
$showstatusDir = "yes"; // confirms directory on status report
$numUploads = "15"; // 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%";
$showCopyright = "yes"; // not required
// Security
$reqSecure = "yes"; // Passcode control?
$profile = array(
// add as many profiles as you like or change any permissions for the following profiles
"admin" => array(
"allowFileDelete" => true, // delete Files
"allowDirDelete" => true, // delete Directories
"allowChangeDir" => true, // create Files
"allowCreateDir" => true, // create Directories
"allowViewGraphic" => true // view images
),
"trusteduser" => array(
"allowFileDelete" => true,
"allowDirDelete" => true,
"allowChangeDir" => true,
"allowCreateDir" => false,
"allowViewGraphic" => true
),
"regularuser" => array(
"allowFileDelete" => false,
"allowDirDelete" => false,
"allowChangeDir" => true,
"allowCreateDir" => false,
"allowViewGraphic" => true
),
"restricteduser" => array(
"allowFileDelete" => false,
"allowDirDelete" => false,
"allowChangeDir" => false,
"allowCreateDir" => false,
"allowViewGraphic" => true
),
// "nosecurityuser" is profile used if you have $reqSecure = no
"nosecurityuser" => array(
"allowFileDelete" => false,
"allowDirDelete" => false,
"allowChangeDir" => true,
"allowCreateDir" => false,
"allowViewGraphic" => true
)
);
$user = array(
// add as many users as you need
// format : "username" =>array("password" =>"password assigned by admin","profile" =>"assign profile from above")
"****" => array("password" => "****","profile" => "admin"),
);
$notsecureprofile = "nosecurityuser"; // profile if no password security on script
// Screen Text & Error Messages - can be changed to any language
$caption = "DIGITAL TRIBUTE DESIGN MULTIFILE UPLOADER/MANAGER";
$loginpageMsg = "Please Enter Your Username and Passcode";
$usernameText = "Username";
$passwordText = "Passcode :";
$loggedonText = "Logged On";
$loginButtonText = "Go To Upload Section";
$logoutText = "logout now";
$directorysectionTitle = "DIRECTORY & FILE LIST ";
$deleteMsg = "Are you sure you want to delete....";
$yesMsg = "YES";
$noMsg = "NO";
$diddeleteMsg = "Deleted....";
$cannotdeleteMsg_1 = "The directory";
$cannotdeleteMsg_2 = "could not be deleted. It must be empty before you can delete it.";
$changeddirMsg = "Moved to directory....";
$makedirectoryTitle = "CREATE A NEW DIRECTORY";
$makedirText = "Directory Name";
$makedirButtonText = "Create Now!";
$existsMsg_1 = "The directory";
$existsMsg_2 = "already exists";
$createddirMsg = "Created the new directory....";
$backlinkText = "ROOT [back]";
$viewText = "View";
$deletelinkText = "DELETE";
$typeText = "Type";
$nameText = "Name";
$sizeText = "Size";
$modifiedText = "Modified";
$uploadsectionTitle = "SELECT FILES TO UPLOAD";
$directorywarningMsg = "- Be Sure You Are At The Correct Directory";
$allowedfiletypesText = "Allowed Filetypes";
$lineText = "File";
$uploadButtonText = "Upload Files";
$statusMsg = "Upload Status :";
$nofileMsg = "No file selected for upload";
$notallowedMsg = "NOT ALLOWED";
$existsMsg = "ALREADY EXISTS";
$successMsg = "has been uploaded";
$linkSpacer = " <b> : </b> ";
?>
***************************************
[u]mfuploaderII.php[/u]
<?
/*
Multifile Uploader Script
Author :
Contact :
Last Modified : May 8, 2005
*/
include("config_mfuploaderII.php");
if(!$wkgdir) $wkgdir="/";
// table framing whole page
$pageTop = "<html><head><title>$caption</title><link href=$stylesheet rel=stylesheet type=text/css></head><body><div align=\"center\" class=caption><a href=\"index.php\">$caption</a></div><div align=\"center\"><table width=$mainTableWidth border=0><tr><td>";
$pageBottom = "</td></tr></table></div></html></body>";
if($showCopyright == "yes") {
$pre = "Please name the photos with the funeral home name, the client's last name and then sequentially in the order you would like them to appear (e.g. funeralhome-smith001.jpg)";
$version = "1.0";
$startdate = "2003";
$copyright =" <p><div align=center class=copybar>$pre";
}
// session management
if($reqSecure == "yes") {
session_start();
if (!session_is_registered("mfupload")) {
if (isset($_POST["username"]) && isset($_POST["password"]) && isset($user[$_POST["username"]]) && ($_POST["password"] == $user[$_POST["username"]]["password"])) {
session_register("mfupload");
$_SESSION["mfupload"] = $_POST["username"];
header("Location: $PHP_SELF");
exit;
}
else {
// login page
echo $pageTop;
echo " <p><div align=\"center\" class=sitetag>$loginpageMsg</div>";
echo " <p><div align=\"center\"><table border=0>";
echo "<form name=loginform method=post action=$PHP_SELF>";
echo "<tr><th>$usernameText</th><td><input type=text name=username style=\"width: 135px;\"></td></tr>";
echo "<tr><th>$passwordText</th><td><input type=password name=password style=\"width: 135px;\"></td></tr>";
echo "<tr><th> </th><td><input type=submit class=button value=\"$loginButtonText\" style=\"width: 135px;\"></td></tr>";
echo "</form></table></div>";
echo "<script language=javascript>document.loginform.username.select();document.loginform.username.focus();</script>";
echo $copyright;
echo $pageBottom;
exit;
}
}
else {
$username = $_SESSION["mfupload"];
}
}//end of if $reqSecure
// kill session
if($_GET["action"]=="logout") {
session_unset("mfupload");
header("Location: $PHP_SELF");
exit;
}
// User Permission Settings
if(!session_is_registered("mfupload")) {
$userprofile = $notsecureprofile;
}
else {
$userprofile = $user[$username]["profile"];
}
$allowFileDelete = $profile[$userprofile]["allowFileDelete"];
$allowDirDelete = $profile[$userprofile]["allowDirDelete"];
$allowChangeDir = $profile[$userprofile]["allowChangeDir"];
$allowCreateDir = $profile[$userprofile]["allowCreateDir"];
$allowViewGraphic = $profile[$userprofile]["allowViewGraphic"];
function page_detail(){
include("config_mfuploaderII.php");
global $userprofile,$allowFileDelete,$allowChangeDir,$allowCreateDir,$allowViewGraphic;
global $basePATH,$wkgdir,$msg2,$msg_upload,$action,$file,$image,$fileurl;
if($allowCreateDir) {
$makenewdir = " <br><div align=\"left\"><li><b>$makedirectoryTitle</b></div><div align=\"center\"><table border=\"0\" width=\"100%\" class=bodytable><form method=\"post\" action=\"$PHP_SELF\"><input type=\"HIDDEN\" name=\"action\" value=\"mkdir\"><input type=\"HIDDEN\" name=\"wkgdir\" value=\"$wkgdir\"><tr><th style=\"width: 20%;\"> $makedirText </td><td><input type=\"text\" name=\"mkdirfile\" style=\"width: 100%;\"></td><td style=\"width: 20%;\"><input type=\"submit\" name=\"mkdir\" value=\"$makedirButtonText\" class=button></td></tr></form></table></div>";
}
$backlink = "<div align=\"center\"><table border=\"0\" width=\"100%\"><tr><td><div align=\"left\"><A HREF=\"$PHP_SELF?action=root\">«$backlinkText</a></div></td></tr></table></div";
if($action == "" || $action == "root") {
echo $makenewdir;
}
else {
echo $backlink;
}
echo "<div align=\"center\"><table border=\"0\" width=\"100%\">";
if($msg2 !="") {
echo " <tr><td colspan=\"2\" class=msg_table>$msg2</td></tr>";
}
echo "</table>";
// Upload Files
echo " <br><div align=\"left\"><li><b>$uploadsectionTitle</b>";
if($allowChangeDir) {
echo $directorywarningMsg;
}
echo "</div>";
echo "<div align=\"center\"><table width=100% 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\">";
echo "<input type=\"hidden\" name=\"wkgdir\" value=\"$wkgdir\">";
$num = 0;
while($num < $numUploads) {
$num++;
echo "<tr><th style=\"width: 20%;\">$lineText $num:</td><td><input name=\"dofile$num\" type=\"file\" style=\"width: 50%;\"></td></tr> ";
}
echo "<tr><td style=\"width: 20%;\"> </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\">$statusMsg ";
if($showstatusDir == "yes") {
echo $wkgdir;
}
echo "</div></td></tr>";
echo $msg_upload;
}
echo "</table></div></td></tr></table></div>";
}
// File size calculations
function display_size($file){
$file_size = filesize($file);
if($file_size >= 1073741824) {
$file_size = round($file_size / 1073741824 * 100) / 100 . "g";
}
elseif($file_size >= 1048576) {
$file_size = round($file_size / 1048576 * 100) / 100 . "m";
}
elseif($file_size >= 1024) {
$file_size = round($file_size / 1024 * 100) / 100 . "k";
}
else{
$file_size = $file_size . "b";
}
return $file_size;
}
// List the files function
function list_files() {
include("config_mfuploaderII.php");
global $userprofile,$allowFileDelete,$allowViewGraphic;
global $allowedFiles,$basePATH,$wkgdir,$key;
// Load directory into array
$handle=opendir(".");
while ($file = readdir($handle)) {
if(is_file($file)) $filelist[] = $file;
}
closedir($handle);
// List files
if($filelist) {
asort($filelist);
while (list ($key, $file) = each ($filelist)) {
$ext = substr(strrchr( $file , "." ), 1);
$ext = str_replace("jpeg", "jpg", $ext);
// Image
if(in_array($ext,$allowedFiles)) {
$icon = "<img src=\"$imageicon\" alt=\"Image\" border=\"0\" width=\"16\" height=\"16\">";
}
// Not an image
else {
$icon = "<img src=\"$othericon\" alt=\"Not An Image\" border=\"0\" width=\"15\" height=\"15\">";
}
$filename=$basePATH.$wkgdir.$file;
$fileurl=rawurlencode($wkgdir.$file);
$lastchanged = filectime($filename);
$changeddate = date("d-m-Y H:i:s", $lastchanged);
// List the file(s)
echo "<tr><td align=\"center\">$icon</td><td>".htmlspecialchars($file)."</td><td align=\"right\">".display_size($filename)."</td><td align=\"right\">".$changeddate."</td><td>";
if($allowViewGraphic && in_array($ext,$allowedFiles)) {
echo "<a href=$baseURL$wkgdir$file target=_new>$viewText</a>";
} else { echo " "; }
echo "</td><td>";
if($allowFileDelete) {
echo "<a href=\"$PHP_SELF?action=del&wkgdir=$wkgdir&file=$file\">$deletelinkText</a>";
} else { echo " "; }
echo "</td></tr>";
}
}
}
// List the directories
function displaydir() {
include("config_mfuploaderII.php");
global $userprofile,$allowDirDelete,$allowChangeDir;
global $username,$file,$basePATH,$wkgdir;
// logout link
if (session_is_registered("mfupload")) {
echo "<div align=\"right\">$loggedonText - $username $linkSpacer<a href=$PHP_SELF?action=logout>$logoutText</a>$linkSpacer</div>";
}
if($allowChangeDir) {
// Draw the main table for directories and files
echo " <br><div align=\"left\"><li><b>$directorysectionTitle $wkgdir</b></div>";
echo "<div align=\"center\"><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\" class=bodytable>";
echo "<tr><th>$typeText</th><th style=\"width: 40%;\">$nameText</th><th style=\"width: 10%;\">$sizeText</th><th>$modifiedText</th><th> </th><th> </th></tr>";
// Load directory into array
chdir($basePATH . $wkgdir);
$handle=opendir(".");
while (false !== ($file = readdir($handle))) {
if(is_dir($file)) $dirlist[] = $file;
}
closedir($handle);
// List directories first
if($dirlist) {
asort($dirlist);
while (list ($key, $file) = each ($dirlist)) {
if($file != "." && $file != "..") {
$fileurl=rawurlencode($wkgdir.$file);
echo "<tr><td align=\"center\"><img src=\"$foldericon\" border=\"0\" width=\"15\" height=\"13\"></td><td><A HREF=\"$PHP_SELF?action=chdr&file=$fileurl\">".htmlspecialchars($file)."</a></td><td align=\"right\"></td><td align=\"right\"> </td><td> </td><td>";
if($allowDirDelete) {
echo "<A HREF=\"$PHP_SELF?action=del&wkgdir=$wkgdir&file=$file\">$deletelinkText</A></td></tr>";
}
}
}
list_files();
echo "</table></div>";
}
}
}
// User has entered .. as directory. Potential security breach. Deny access.
$regexp="\\.\\.";
if (ereg( $regexp, $file, $regs )| ereg( $regexp, $wkgdir,$regs ))
{
$msg2 = "ERROR: Directories may not contain the character \"..\"";
echo $pageTop;
page_detail();
killit();
echo $copyright;
echo $pageBottom;
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>$nofileMsg</td></tr>";
}
elseif($limitFiles == "yes" && !in_array($ext,$allowedFiles)) {
$msg_upload .= "<tr><td>$lineText $num :</td><td><b>$upFile1</b></td><td>$notallowedMsg</td></tr>";
}
elseif(file_exists("$basePATH.$wkgdir$upFile1")) {
$msg_upload .="<tr><td>$lineText $num :</td><td><b>$upFile1</b></td><td>$existsMsg</td></tr>";
}
else {
// everything OK
move_uploaded_file ($upFile3, "$basePATH.$wkgdir$upFile1");
$msg_upload .="<tr><td>$lineText $num :</td><td><b>$upFile1</b> ($size)</td><td>$successMsg</td></tr>";
}
}
echo $pageTop;
displaydir();
page_detail();
echo $copyright;
echo $pageBottom;
exit;
}
// Begin actions code
switch ($action){
// No $action variable? Display initial page
case "":
echo $pageTop;
displaydir();
page_detail();
echo $copyright;
echo $pageBottom;
break;
// Change to root dir
case "root":
$wkgdir="/";
echo $pageTop;
displaydir();
page_detail();
echo $copyright;
echo $pageBottom;
break;
// Change directory
case "chdr":
$wkgdir=$file."/";
$msg2 = "$changeddirMsg $wkgdir";
echo $pageTop;
displaydir();
page_detail();
echo $copyright;
echo $pageBottom;
break;
// Delete file or directory
case "del":
if ($confirm=="yes") {
if(is_dir($basePATH.$file)) {
$result = @rmdir($basePATH.$file);
if($result == 0) {
$msg2 = "$cannotdeleteMsg_1 '$file' $cannotdeleteMsg_2";
}
}
else {
unlink($basePATH.$wkgdir.$file);
$msg2 = "$diddeleteMsg $file";
}
}
else {
$msg2 = "$deleteMsg $wkgdir$file ? <a href=\"$PHP_SELF?action=del&confirm=yes&wkgdir=$wkgdir&file=$file\">$yesMsg</a> | <a href=\"$PHP_SELF\">$noMsg</a>";
}
echo $pageTop;
displaydir();
page_detail();
echo $copyright;
echo $pageBottom;
break;
// Create directory
case "mkdir":
// The directory already exists.
if(file_exists($basePATH.$wkgdir.$mkdirfile)) {
$msg2 = "$existsMsg_1 $wkgdir$mkdirfile $existsMsg_2";
}
else {
$msg2 = "$createddirMsg $wkgdir$mkdirfile";
mkdir($basePATH.$wkgdir.$mkdirfile,0750);
}
echo $pageTop;
displaydir();
page_detail();
echo $copyright;
echo $pageBottom;
break;
}
?>
****************************
[u]style_mfuploaderII.css[/u]
/* author: */
/* Creation date: 4/23/2005 */
body {
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
background: #4e68a2 url(images/bg_top.jpg) top left no-repeat;
font-family: Trebuchet MS, Helvetica, sans-serif;
font-size: 9pt;
font-style: normal;
text-decoration: none;
text-align: justify;
color: #3E588F;
}
a {color: #505a49; font-size: 7.5pt; font-weight: bold; text-decoration: none; }
a:hover { color: #8090A3; font-size: 7.5pt; font-weight: bold; text-decoration: none; }
.caption {
background: #ffffff;
height: 15px;
width: 100%;
border-bottom: 1px solid #95A5AD;
margin: 0px;
color : #3E588F;
text-align: center;
padding-top: 2px;
padding-right: 0px;
padding-bottom: 2px;
padding-left: 0px;
font-family: tahoma, arial, verdana, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
}
.sitetag {
font-size: 19pt;
font-weight: bold;
font-family: Trebuchet MS, Helvetica, sans-serif;
color: #3E588F;
}
table, td{
font: normal 7.5pt verdana, tahoma, arial, helvetica, sans-serif;
color:#2F497F;
padding: 0px, 0px, 0px, 0px;
text-align:left;
}
.bodytable {
background-color: #D1DBEF;
padding-bottom: 8px;
padding-left: 8px;
padding-right: 8px;
padding-top: 8px;
font: normal 7.5pt verdana, tahoma, arial, helvetica, sans-serif;
color: #000000;
border: 1px solid #2F497F;
}
.msg_table {
background: #ffffff;
font-style: normal;
font-variant: normal;
font-weight: bold;
font-size: 8pt;
font-family: sans-serif;
color: #2F497F;
text-indent : 2px;
text-align: center;
}
input, text, textarea, select {
font: 8.5pt verdana,arial,helvetica,sans-serif;
color: #2F497F;
border: 1px solid #4E68A2;
background-color: #fff;
text-indent:2px;
}
.button{
background-color: #fff;
font: bold 8.5pt Trebuchet MS, verdana,arial,helvetica,sans-serif;
color: #4E68A2;
border-left-color: #fff;
border-bottom-color: #545454;
border-top-color: #fff;
border-right-color: #545454;
}
.copybar {
white-space: nowrap;
font-family: Trebuchet MS, Helvetica, sans-serif;
font-size: 6.5pt;
font-weight: normal;
color: #fff;
}
.copybar a { font-weight: bold; text-decoration: none; color: #505a49; font-size: 7.5pt; }
.copybar a:hover { font-weight: bold; text-decoration: underline; color: #ff9900; font-size: 7.5pt; }
.copybar a:visited { font-weight: bold; color: #505a49; font-size: 7.5pt; }