File: /home/awaldron/www/archive/demo/admin/files.php
<?php
session_start();
include("../_functions.php");
dbconnect();
if (!is_logged()) auto_login();
echo "<html>\n";
echo "<head>\n";
echo "<title>".COMPANY_NAME." : Uploaded Files Manager</title>\n";
echo "<script language=\"JavaScript\" type=\"text/javascript\">\n";
echo "<!--\n";
echo "function openWindow(theURL,winName,features) { //v2.0\n";
echo " window.open(theURL,winName,features);\n";
echo "}\n";
echo "function confirm_delete(fn) {\n";
echo " input_box=confirm(\"Are you sure you want to delete this file from the server?\");\n";
echo " if (input_box==true) {\n";
echo " self.location='files.php?del='+fn;\n";
echo " }\n";
echo "}\n";
echo "-->\n";
echo "</script>\n";
echo "</head>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../default.css\">\n";
echo "<body style=\"margin:15px;\">\n";
if (!admin_panel($_SESSION["auth_user"])) {
echo "<br><br><br><br>".error("You must be logged in to access the administration panel!");
} else {
echo "<P><img src=\"/gui/icons/cog.gif\" align=\"left\">\n";
echo "<div class=\"headline\">Uploaded Files Manager</div>\n";
echo "<P>From this control panel, you can review and delete files uploaded to the server by intranet users.\n";
if (isset($_GET["del"])) {
if (@unlink("/home/intranet/files/".$_GET["del"])) echo notice("File Deletion Successful");
else echo "<P>".error("The file could not be deleted.");
}
echo "<br><br><br><center><table class=\"textdn\" border=0 cellspacing=1 cellpadding=3 bgcolor=\"#".COLOR_TBAR."\">\n";
echo "<tr class=\"header\"><td>Filename</td><td align=\"center\">#Ref</td><td align=\"center\"> Actions </td></tr>\n";
$ctr = 0;
if ($handle = opendir("/home/intranet/files")) {
while (false !== ($file = readdir($handle))) {
if (!is_dir("/home/intranet/files/".$file)) {
$pages = quickSQL("SELECT COUNT(page_id) FROM tbl_pages WHERE page_active=1 AND (page_body LIKE '%".$file."%' OR page_linkto LIKE '%".$file."%')");
$notices = quickSQL("SELECT COUNT(notice_id) FROM tbl_notices WHERE notice_active=1 AND notice_body LIKE '%".$file."%'");
$threads = quickSQL("SELECT COUNT(thread_id) FROM tbl_threads WHERE thread_active=1 AND thread_body LIKE '%".$file."%'");
echo "<tr bgcolor=\"".($ctr%2==0?"#FFFFFF":"#EEEEEE")."\">";
echo "<td>".$file." </td>";
echo "<td align=\"center\">".($pages+$notices+$threads)."</td>";
echo "<td align=\"center\"> <a href=\"/files/".$file."\" target=\"file\">View</a> | <a href=\"JavaScript:confirm_delete('".$file."')\">Delete</a> </td></tr>\n";
$ctr++;
}
}
closedir($handle);
}
echo "</table>\n";
echo "<br><br><br><br>\n";
echo "<center>Powered by <a href=\"http://www.intrabreeze.com\">IntraBreeze</a> © 2005 IntraBreeze, LLC</center>\n";
}
echo "</body>\n</html>\n";
?>