Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Script Delete Problem

Status
Not open for further replies.

jonance

Technical User
Nov 8, 2001
4
0
0
US
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,&quot;$add_ntpath\\accounts\\$delete\\bids.data&quot;);
@bids = <DATA>;
close(DATA);
foreach $bid(@bids) {
@biddata = split(/&&/, $bid);
@newlist_b = &quot;&quot;;
open(DATA,&quot;>$add_ntpath\\keywords\\$biddata[0]&quot;);
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,&quot;>$add_ntpath\\keywords\\$biddata[0]&quot;);
flock (DATA,2);
print DATA @newlist_b;
flock (DATA,8);
close(DATA);
}
}

unlink(&quot;$add_ntpath\\accounts\\$delete\\bids.data&quot;);
unlink(&quot;$add_ntpath\\accounts\\$delete\\balance.data&quot;);
unlink(&quot;$add_ntpath\\accounts\\$delete\\info.data&quot;);
unlink(&quot;$add_ntpath\\accounts\\$delete\\lowsent&quot;);

opendir (DIR, &quot;$add_ntpath\\accounts\\$delete\\logs\\aff&quot;);
@afiles = grep { /.aff/ } readdir(DIR);
close (DIR);
foreach $files(@afiles) { unlink(&quot;$add_ntpath\\accounts\\$delete\\logs\\aff\\$files&quot;); }
rmdir(&quot;$add_ntpath\\accounts\\$delete\\logs\\aff&quot;);

opendir (DIR, &quot;$add_ntpath\\accounts\\$delete\\logs&quot;);
@files = grep { /.log/ } readdir(DIR);
close (DIR);
foreach $files(@files) { unlink(&quot;$add_ntpath\\accounts\\$delete\\logs\\$files&quot;); }
rmdir(&quot;$add_ntpath\\accounts\\$delete\\logs&quot;);
rmdir(&quot;$add_ntpath\\accounts\\$delete&quot;);

print <<EOF;
<title>Account Deleted</title>
The account <b>$delete</b> has been completely deleted.<br>
<META HTTP-EQUIV=REFRESH CONTENT=&quot;1; URL=admin.pl?pass=$pass&quot;>
<a href=&quot;admin.pl?pass=$pass&quot;>Back to main...</a>
EOF

exit;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top