Viewing file: upload_dir.php (3.47 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/***************************************************************************
upload_dir.php -
Allow deletion of uploaded files.
-------------------
begin : Thu May 03 2001
copyright : (C) 2001 by Steve Shimp
email : steve@forcefed4.com
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/***************************************************************************
Thanks to Eric Persson for giving me a start on listing a directory with
links.
Copyleft(L) 1999 Eric Persson, eric@persson.tm, http://www.persson.tm/scripts/
****************************************************************************/
include('extention.inc');
include('functions.'.$phpEx);
include('config.'.$phpEx);
require('auth.'.$phpEx);
$pagetitle = "Delete Uploads";
function list_files($basedir)
{
if(is_dir($basedir))
{
$thisdir = dir($basedir);
while ($entry=$thisdir->read())
{
if(($entry!='.') && ($entry!='..'))
{
// $result.="<a href=\"$basedir/$entry\">$entry</a><br>";
$result.="<a href=\"$PHP_SELF?remove=$basedir/$entry\">$entry</a><br>";
}
}
}
return $result;
}
// authentication stuff
if ($user_logged_in) {
// valid session.. just check it's the right user.
if($userdata[user_level] == 2 && !is_moderator($forum_id, $userdata[user_id], $db)) {
include('page_header.'.$phpEx);
error_die($l_notedit);
}
} else {
$userdata = get_userdata($username, $db);
if($userdata[user_level] == 2 && is_moderator($forum_id, $userdata[user_id], $db)) {
if($md_passwd != $userdata[user_password]) {
$die = 1;
}
}
else if($userdata[user_level] > 2) {
if($md_passwd != $userdata[user_password]) {
$die = 1;
}
}
else {
$die = 1;
}
if($die != 1) {
// You've entered your username and password, and no problems have been found, log you in!
$sessid = new_session($userdata[user_id], $REMOTE_ADDR, $sesscookietime, $db);
set_session_cookie($sessid, $sesscookietime, $sesscookiename, $cookiepath, $cookiedomain, $cookiesecure);
}
}
if($die == 1) {
include('page_header.' . $phpEx);
error_die($l_permdeny);
}
// end authentication
include('page_header.'.$phpEx);
if($remove) { // delete a file
if(unlink("$remove"))
{
echo "$remove deleted successfully<BR><BR>";
} else {
echo "$remove NOT deleted<BR><BR>";
}
} // go ahead and show the new listing
echo "<P ALIGN=\"CENTER\">Simply click on a file to delete it.</P>";
$filelist = list_files($url_uploads);
echo "<TABLE ALIGN=\"CENTER\" BGCOLOR=\"$table_bgcolor\"><TR><TD BGCOLOR=\"$color1\">";
echo "<FONT COLOR=\"$textcolor\" FACE=\"$FontFace\">";
echo "$filelist";
echo "</FONT>";
echo "</TD></TR>"; //echos the second value in the array
echo "</TABLE>";
echo "<P ALIGN=\"CENTER\"><A HREF=\"javascript:history.back();\">[BACK]</A></P>";
require('page_tail.'.$phpEx);
?>
|