I'm trying to convert this over to CGI.pm so that I can enable the ability to delete multiple files (Node 263147) instead of just one at a time...anyone have any suggestions? I have attempted multiple times but keep getting an error 500.
$password="some-password";
$operate=1;
$location= "/home/sites/www.some-domain.com/web/folder/";
exit if $operate==0;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
foreach $pair (@pairs) {
($name, $value)=split(/=/,$pair);
$value =~ tr/+/ /;
$value=~s/%(..)/pack("c",hex($1))/ge;
$f{$name}=$value;
chomp($f{$name});
}
print "Content-type:text/html\n\n$head $pageadmin $mid\n";
print " <table border=0 width=100% cellspacing=0 cellpadding=1>\n";
print "<tr><td bgcolor=#CCCCCC><b> File Removal System</b></td></
+tr></table>";
if(($f{'action'} eq "delete")&&(open(FILE,$f{'file'}))){
unlink($f{'file'})||print "<h1>Could Not Delete: ".$f{'file'}."</h
+1>";
}
$dir=$f{'dir'} if $f{'password'} eq $password;
opendir(DIR,$dir);
@dirfiles=readdir(DIR);
closedir(DIR);
@dirfiles=sort(@dirfiles);
print "<p><center><table border=0 cellpadding=5 cellspacing=0><tr><td>
+";
print "<p><center><table border=0><tr><form action=".$ENV{'REQUEST_URI
+'}." method=post><td>\n";
print "<input type=hidden name=dir value=\"".$location."\" size=40>\n"
+;
print "<input type=hidden name=password value=orianphoto size=40></td>
+\n";
print "<td rowspan=2><input type=submit value=\"Click Here To View Con
+tents Of Directory\"></td></tr>\n";
print "<tr><td><input type=hidden name=password value=orianphoto size=
+40></td></form></tr></table></center></p>\n\n";
print "</td></tr><tr><td>\n\n\n";
print "<p><center><table border=1><tr>\n";
print "<form action=".$ENV{'REQUEST_URI'}." method=post>\n";
print "<input type=hidden name=action value=delete>\n";
print "<td bgcolor=navy><font color=white><B>Files in The Photo Direct
+ory: </td></tr><tr><td>\n";
$i=0;
foreach $file(@dirfiles){
if((!opendir(TEST,$dir."/".$file))&&($f{'password'} eq $password)&
+&($file ne ".")&&($file ne "..")){
$i++;
print "<input type=checkbox name=file value=\"".$dir."/".$file
+;
if($i==1){
print "\" checked>";
}else{
print "\">";
}
print $file."<BR>\n";
}
}
print "<input type=hidden name=dir value=\"".$location."\">\n";
print "<input type=hidden name=password value=orianphoto>\n";
print "<input type=submit value=\"Delete Selected File\"></td>\n";
print "</form></tr></table></center></p>";
print "</td></tr></table></center></p>\n";
|