File: /home/awaldron/www/archive/demo/upload/showUploadFiles.php
<?php
/*##################################################################################
| |
| upload script by http://www.reducedcomplexity.com |
| if you use the script please send an email to scripts@reducedcomplexity.com |
| found a bug? please send me an email so i can fix it. |
| |
| use at your own risk! reducedcomplexity.com gives absolutely no warranties. |
| copyright http://www.reducedcomplexity.com | Rudi Bieller |
| |
*/##################################################################################
require("uplConfig.php"); // KEEP THIS HERE!!
include("functions.php");
$type_text = array("txt", "log");
$type_image = array("jpg", "jpeg", "gif", "png", "bmp");
// download a selected file --------------------------------------------------------------------
if (isset($_GET["file2dl"])) {
$filename0 = $_GET["file2dl"]; // single filename
$filename1 = BASEFOLDER . $filename0; // filename with path
$path = pathinfo($filename1);
foreach ($type_text as $single_type) {
if ($single_type == @$path["extension"]) {
header ("Content-Type: text/plain");
$done = 1;
}
}
if (!isset($done)) {
foreach ($type_image as $single_type) {
if ($single_type == @$path["extension"]) {
header ("Content-Type: image/" . $path["extension"]);
$done = 1;
}
}
}
if (!isset($done)) {
header ("Content-Type: application/octet-stream");
}
header("Content-Disposition: attachment; filename=$filename0");
readfile($filename1);
die;
}
// ---------------------------------------------------------------------------------------------
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1">
<style type="text/css">
body {
scrollbar-face-color: #EEF4EC;
scrollbar-shadow-color: #000000;
scrollbar-highlight-color: #000000;
scrollbar-3dlight-color: #EEF4EC;
scrollbar-darkshadow-color: #EEF4EC;
scrollbar-track-color: #FFFFFF;
scrollbar-arrow-color: #3E3E3E;
color: #000000;
background : url(001.gif) repeat fixed;
font-family: Tahoma, Verdana, Arial;
font-size: 08pt;
height: 100%;
}
table {
color: #000000;
font-family: Tahoma, Verdana, Arial;
font-size: 10pt;
border-style: groove;
border-width:1pt;
border-color:#000000;
background : #979797;
}
td {
color: #000000;
font-family: Tahoma, Verdana, Arial;
font-size: 08pt;
border-style: solid;
border-width:1pt;
border-color:#000000;
background-color:#FFFFFF;
}
th {
color: #000000;
font-family: Tahoma, Verdana, Arial, sans-serif;
font-size: 08pt;
text-align: left;
font-weight: normal;
border-style: solid;
border-width: 1pt;
border-color: #000000;
background-color: #CCCCCC;
padding: 10px;
}
b {
color: #000000;
font-family: Tahoma, Verdana, Arial;
font-size: 08pt;
}
dt {
color: #000000;
font-family: Tahoma, Verdana, Arial;
font-size: 08pt;
font-weight:bold;
}
.form {
color: #000000;
background-color:#ffffff;
BORDER-BOTTOM: #000000 1px solid;
BORDER-LEFT: #000000 1px solid;
BORDER-RIGHT: #000000 1px solid;
BORDER-TOP: #000000 1px solid;
FONT-FAMILY: Tahoma, Verdana, Arial;
FONT-SIZE: 10px;
}
a:active {
color: #000000;
text-decoration: underline;
font-weight:normal;
}
a:link {
color: #000000;
text-decoration: underline;
font-weight:normal;
}
a:visited {
color: #000000;
text-decoration: underline;
font-weight:normal;
}
a:hover {
color: #606060;
text-decoration: none;
font-weight:normal;
}
</style>
<title>reducedcomplexity.com scripts - uploader admin uploaded files | quality php scripts for personal and commercial use.</title>
<META NAME="keywords" CONTENT="php, script, scripts, php script, php scripts, upload, uploader, php upload, php uploader, upload script, php upload script, news, php news, news script, php news script, news php script, newsscript">
<META HTTP-EQUIV="title" CONTENT="reducedcomplexity.com scripts - main site | quality php scripts for personal and commercial use.">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<META NAME="description" CONTENT="reducedcomplexity.com scripts offers selected quality php scripts. currently available is a sophisticated upload script and a filebased newsscript.">
<META NAME="ROBOTS" CONTENT="ALL">
<script language="JavaScript">
<!--
function popup(url, winName, features) /* function to open a popup window */
{
window.open(url, winName, features);
}
function AllMessages() /* function to make all selectboxes selected by one click */
{
for (var x = 0; x < document.upf.elements.length; x++)
{
var y = document.upf.elements[x];
if (y.name != 'selectall') y.checked = document.upf.selectall.checked;
}
}
//-->
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td>
<br>
<b>uploaded files.</b>
<?php
if (!isset($_GET["file2rename"]) && !isset($_POST["adminRename"])) {
print "<br>
<small>order by <a href=\"".$_SERVER["PHP_SELF"]."?sortby=date\">date of upload</a> | <a href=\"".$_SERVER["PHP_SELF"]."?sortby=name\">filename</a></small>
<br><br>\n";
}
?>
</td>
</tr>
<tr>
<td>
<?php
// case rename of a file is clicked
if (isset($_GET["file2rename"])) {
print "<br>";
print "<form action=" . $_SERVER["PHP_SELF"] . " method=\"post\">\n";
print "rename file from "" . $_GET["file2rename"] . "" to:<br>\n";
print "<input type=\"text\" name=\"renameFile\" size=\"36\" class=\"form\"><br>\n";
print "password:<br>\n";
print "<input type=\"password\" name=\"pwd\" class=\"form\"><br>\n";
print "<input type=\"hidden\" name=\"origName\" value=\"" . $_GET["file2rename"] . "\">\n";
print "<input type=\"submit\" name=\"adminRename\" value=\"go!\" class=\"form\">\n";
print "</form>\n";
print "<a href=\"JavaScript:window.close();\">close window</a>\n";
die("</td></tr></table></body></html>");
}
// ---------------------------------------------------------------------------------------------
// rename a file in the list -------------------------------------------------------------------
if (isset($_POST["adminRename"]) && $_POST["adminRename"] == "go!") {
renFiles($_POST["origName"], $_POST["renameFile"]);
print "<br><br><a href=\"JavaScript:window.close();\">close window</a>\n";
die("</td></tr></table></body></html>");
}
// ---------------------------------------------------------------------------------------------
// delete one or more file(s) in the list ------------------------------------------------------
if (isset($_POST["adminSubmit"]) && $_POST["adminSubmit"] == "go!") {
delFiles($_POST["deleteFile"]);
}
// ---------------------------------------------------------------------------------------------
// show all files of the upload-folder ---------------------------------------------------------
$handle = @opendir(BASEFOLDER);
if ($handle) {
while ($file = readdir($handle)) {
if (($file != ".") && ($file != "..")) {
if (!is_dir(BASEFOLDER . $file)) $filelist[] = $file; // folders are not displayed (yet)
}
}
closedir($handle);
}
if (!empty($filelist)) {
natcasesort($filelist);
foreach ($filelist as $singleFile) {
$f_size = filesize(BASEFOLDER . $singleFile); // size in bytes of file
$f_size = niceFilesize($f_size); // so it's ok to view... ;)
$f_atime = date("Y-m-d, H:i:s", fileatime(BASEFOLDER . $singleFile)); // last access/saving of file
$f_mtime = date("Y-m-d, H:i:s", filemtime(BASEFOLDER . $singleFile)); // last modification of file
$path = @pathinfo(BASEFOLDER . $singleFile);
foreach ($type_image as $single_type) {
if ($single_type == @$path["extension"]) $is_pic = 1;
}
if (isset($is_pic)) $pic_prop = getimagesize(BASEFOLDER . $singleFile); // image properties
$blub[] = $f_mtime."RCSEP".$singleFile."RCSEP".$f_size."RCSEP".$pic_prop[0]."RCSEP".$pic_prop[1];
clearstatcache();
unset ($is_pic);
unset ($pic_prop);
}
if (!isset($_GET["sortby"])) {
$_GET["sortby"] = "name";
}
if ($_GET["sortby"] == "date") {
arsort($blub);
}
print "<br> entries sorted by ".$_GET["sortby"].".<p></p>\n";
print "<form action=\"" . $_SERVER["PHP_SELF"] . "?sortby=".$_GET["sortby"]."\" method=\"post\" name=\"upf\">\n";
print "<table><tr><th><b>filename</b></th><th width=\"20\"> </th><th width=\"65\"><b>delete file?</b></th>
<th width=\"20\"> </th><th width=\"100\"><b>action</b></th><th width=\"20\"> </th><th width=\"300\"><b>additional infos</b></th></tr>\n";
foreach ($blub as $zeile) {
$all = explode("RCSEP", $zeile);
print "<tr>\n";
print "<td><b>$all[1]</b></td>\n";
print "<td width=\"20\"> </td>\n";
print "<td align=\"center\"><input type=\"checkbox\" name=\"deleteFile[]\" value=\"$all[1]\"></td>\n";
print "<td width=\"20\"> </td>";
print "<td><a href=\"" . $_SERVER["PHP_SELF"] . "?file2dl=$all[1]\">download</a> -
<a href=\"JavaScript:popup('" . $_SERVER["PHP_SELF"] . "?file2rename=" . $all[1] . "', 'rename_file', 'width=300,height=220,resizable=YES,scrollbars=NO,menubar=NO,toolbar=NO,directories=NO,location=NO,status=NO,screenX=0,screenY=0')\">rename</a></td>\n";
print "<td width=\"20\"> </td>";
print "<td>filesize: $all[2]<br>
date of upload: $all[0]<br>";
if (!empty($all[3]) || !empty($all[4])) print "pic-props (width x height): $all[3] x $all[4]<br>";
print "</td>\n";
print "</tr>\n";
}
print "<tr><td colspan=\"7\"><br><b>delete all?</b> <input type=\"checkbox\" name=\"selectall\" value=\"selectall\" onClick=\"AllMessages(this.form);\"><br><br></td></tr>\n";
print "</table>\n";
print "<br>\n";
print "to delete selected files enter password:<br>\n";
print "<input type=\"password\" name=\"pwd\" size=\"34\" class=\"form\"><br>\n";
print "<input type=\"submit\" name=\"adminSubmit\" value=\"go!\" class=\"form\">\n";
print "</form>\n";
} else {
print "<br>there are no files in the upload folder<br>";
}
// ----------------------------------------------------------------------------------------------
?>
</td>
</tr>
</table>
</body>
</html>