
marco
Novice
Jan 25, 2003, 10:40 AM
Post #1 of 15
(999 views)
|
|
My small script is not working. Can you help me ?
|
Can't Post
|
|
Hello, Here is what I need: When I click on this link: http://www.mydomain.com/cgi-bin/noswemanagem.pl?anny74@hotmail.com I want this ( only this one) username ( Wich is the same as the email adress) and password to be delete from my password file. Here is how the passcodes, wich I want to delete, looks like in the .htpasswd file: anny74@hotmail.com:yaGO2D9I2Zw2U Here is the script I'm using but it doesn't work, I get this message: User not found. But I'm sure the user is in my password file. #!/usr/bin/perl $passfile="/usr/home/marco/www.mydomain.com/cgi-bin/.htpasswd"; $flock="y"; #________________________________________________________________ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; } else { $INPUT{$name} = $value; } } unless ($INPUT{'username'}) { print "Content-type: text/html \n\n"; } $temp=0; $temp=$ENV{'QUERY_STRING'}; if ($temp) { $INPUT{'username'} = $temp; &remove; } exit; #______________________________________________________________________ sub remove { open (data, "<$passfile") or &error("Unable to open the password file"); if ($flock eq "y") { flock data, 2; } @data=<data>; close(data); $count=0; foreach $data(@data) { $count++; @datax=split(/:/, $data); if ($input{'username'} eq "@datax[0]" and $input{'username'}== "@datax[0]") { $count--; splice (@data, $count, 1); open (wdata, ">$passfile") or &error("Unable to write to the data file"); if ($flock eq "y") { flock wdata, 2; } print wdata @data; close(wdata); print "User \"$input{'username'}\" is deleted form the data base.\n"; exit; } } print "User not found\n"; exit; } #####error sub error { print "An error has occured. <br> The error is $_[0]<br>\n"; print "$!\n"; exit; } Can someone tell me what is wrong ? Thank you, Marco
|