Hi,
I just joined the board and have been slooooowly learning perl. I installed smartsearch.cgi on my site at The platform is Windows NT. It is basically just a pay per click search engine program. Well it works great but in the admin section there is a option to delete a user. When an account is created, a directory is created name after their username, and inside that a directory is created called "logs". Here is the code inside admin.pl, the admin script, that is apparent supposted to be deleting the files and folders. The files inside the "username" directory are all deleted correctly when i hit 'delete' but the directories (username,logs) aren't deleted. I would appreciate any help and would be glad to give you ftp info if you want to look deeper into the script.
Thanks,
John
Here is the code:
------------------------------------------------
sub deleteuser {
open(DATA,"$add_ntpath\\accounts\\$delete\\balance.data"
$balance = <DATA>;
close(DATA);
if($balance > 0.01) {
open(DATA,"$add_ntpath\\accounts\\$delete\\bids.data"
@bids = <DATA>;
close(DATA);
foreach $bid(@bids) {
@biddata = split(/&&/, $bid);
@newlist_b = "";
open(DATA,">$add_ntpath\\keywords\\$biddata[0]"
flock (DATA,2);
@keydata_b = <DATA>;
flock (DATA,8);
close(DATA);
foreach $key(@keydata_b) {
@kdata_b = split(/&&/, $key);
if($kdata_b[2] ne $delete) { push(@newlist_b,$key); }
}
open(DATA,">$add_ntpath\\keywords\\$biddata[0]"
flock (DATA,2);
print DATA @newlist_b;
flock (DATA,8);
close(DATA);
}
}
unlink("$add_ntpath\\accounts\\$delete\\bids.data"
unlink("$add_ntpath\\accounts\\$delete\\balance.data"
unlink("$add_ntpath\\accounts\\$delete\\info.data"
unlink("$add_ntpath\\accounts\\$delete\\lowsent"
opendir (DIR, "$add_ntpath\\accounts\\$delete\\logs\\aff"
@afiles = grep { /.aff/ } readdir(DIR);
close (DIR);
foreach $files(@afiles) { unlink("$add_ntpath\\accounts\\$delete\\logs\\aff\\$files" }
rmdir("$add_ntpath\\accounts\\$delete\\logs\\aff"
opendir (DIR, "$add_ntpath\\accounts\\$delete\\logs"
@files = grep { /.log/ } readdir(DIR);
close (DIR);
foreach $files(@files) { unlink("$add_ntpath\\accounts\\$delete\\logs\\$files" }
rmdir("$add_ntpath\\accounts\\$delete\\logs"
rmdir("$add_ntpath\\accounts\\$delete"
print <<EOF;
<title>Account Deleted</title>
The account <b>$delete</b> has been completely deleted.<br>
<META HTTP-EQUIV=REFRESH CONTENT="1; URL=admin.pl?pass=$pass">
<a href="admin.pl?pass=$pass">Back to main...</a>
EOF
exit;
}
I just joined the board and have been slooooowly learning perl. I installed smartsearch.cgi on my site at The platform is Windows NT. It is basically just a pay per click search engine program. Well it works great but in the admin section there is a option to delete a user. When an account is created, a directory is created name after their username, and inside that a directory is created called "logs". Here is the code inside admin.pl, the admin script, that is apparent supposted to be deleting the files and folders. The files inside the "username" directory are all deleted correctly when i hit 'delete' but the directories (username,logs) aren't deleted. I would appreciate any help and would be glad to give you ftp info if you want to look deeper into the script.
Thanks,
John
Here is the code:
------------------------------------------------
sub deleteuser {
open(DATA,"$add_ntpath\\accounts\\$delete\\balance.data"
$balance = <DATA>;
close(DATA);
if($balance > 0.01) {
open(DATA,"$add_ntpath\\accounts\\$delete\\bids.data"
@bids = <DATA>;
close(DATA);
foreach $bid(@bids) {
@biddata = split(/&&/, $bid);
@newlist_b = "";
open(DATA,">$add_ntpath\\keywords\\$biddata[0]"
flock (DATA,2);
@keydata_b = <DATA>;
flock (DATA,8);
close(DATA);
foreach $key(@keydata_b) {
@kdata_b = split(/&&/, $key);
if($kdata_b[2] ne $delete) { push(@newlist_b,$key); }
}
open(DATA,">$add_ntpath\\keywords\\$biddata[0]"
flock (DATA,2);
print DATA @newlist_b;
flock (DATA,8);
close(DATA);
}
}
unlink("$add_ntpath\\accounts\\$delete\\bids.data"
unlink("$add_ntpath\\accounts\\$delete\\balance.data"
unlink("$add_ntpath\\accounts\\$delete\\info.data"
unlink("$add_ntpath\\accounts\\$delete\\lowsent"
opendir (DIR, "$add_ntpath\\accounts\\$delete\\logs\\aff"
@afiles = grep { /.aff/ } readdir(DIR);
close (DIR);
foreach $files(@afiles) { unlink("$add_ntpath\\accounts\\$delete\\logs\\aff\\$files" }
rmdir("$add_ntpath\\accounts\\$delete\\logs\\aff"
opendir (DIR, "$add_ntpath\\accounts\\$delete\\logs"
@files = grep { /.log/ } readdir(DIR);
close (DIR);
foreach $files(@files) { unlink("$add_ntpath\\accounts\\$delete\\logs\\$files" }
rmdir("$add_ntpath\\accounts\\$delete\\logs"
rmdir("$add_ntpath\\accounts\\$delete"
print <<EOF;
<title>Account Deleted</title>
The account <b>$delete</b> has been completely deleted.<br>
<META HTTP-EQUIV=REFRESH CONTENT="1; URL=admin.pl?pass=$pass">
<a href="admin.pl?pass=$pass">Back to main...</a>
EOF
exit;
}