|
Posted by Geoff Berrow on 02/05/07 01:02
Message-ID: <eq5sfs$rfj$1@aioe.org> from Andy contained the following:
>I tried to follow your message but I get a parse error.
>I am a new to PHP and do not know how to modify my script.
>In order to test it place it in any directory on your site. It is really
>nice deleter, but I need multiple file deleter with check boxes.
Cheap and cheerful. Save this lot as deleter.php and run it from the
directory you want to control
<?php
$notify="";
?>
<HTML>
<HEAD>
<TITLE>File management</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<?php
if(isset($_POST['del'])){
$notify="<br> ".count($_POST['delete'])." file(s) deleted";}
echo "<center><em style = \"font-weight:
bold;\">".$message.$notify."</em></center>";
?>
<FORM style="border 1px solid black; background-color:#9999ff;
padding:20px;" ENCTYPE="multipart/form-data" name="form" ACTION="<?php
echo $_SERVER['PHP_SELF']?>" METHOD="POST">
<table align="center"width="100%" border="0" cellspacing="0"
cellpadding="0">
<?php
if(isset($_POST['del']))
{$j=0;
$error="";
for($i=0;$i<count($_POST['delete']);$i++){
if(!@unlink($path.$_POST['delete'][$i])){
$j++;
$error="<b><p>$j file(s) could not be deleted</b></p>";}
}
print $error;
}
?>
</P>
</td>
</tr>
</table>
<table align="center" border="1" cellspacing="0" cellpadding="2">
<?php
if(empty($_POST['cdir'])){
//$dir = $path."";
$path=$_SERVER['PATH_TRANSLATED'];
//print "$path<br>";
$i= strlen($path);
//print"$i<br>";
do{$i--;}
while(strpos($path,"/",$i)===false);
//print"$i<br>";
//print substr($path,0,$i);
$path=substr($path,0,$i+1);
$dir=$path;
}
else{
$dir=$_SERVER['DOCUMENT_ROOT'].$_POST['cdir'];
}
// Open a known directory, and proceed to read its contents
//if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
//print $dir . $file;
if(($file!="."&&$file!="..")){
echo "<tr><td>filename: </td><td><b> <a
href=\"$file\">$file</a></b></td><td>Type: </td><td>". filetype($dir
.. $file)."</td><td align=\"center\"><input
type=\"checkbox\"name=\"delete[]\" value=\"$file\"><td></tr>\n";
}
}
closedir($dh);
}
//}
?>
<tr>
<td colspan=5 align="right"><input type="submit" value ="Delete
selected" name="del"><td></tr>
<tr><td colspan="5" align="left">
<!--<input type="textbox"name="cdir"> <input type="submit" value
="change dir" name="cd">-->
<td></tr>
</table>
</form>
</BODY>
</HTML>
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
[Back to original message]
|