I implemented the following code to verify all accounts had a corresponding record in the database. However when I try to use it - it does not complete. It gets as far as "The following users do not have records in the database:" and stops - the footer does not even load to complete the page.
Any ideas? Here is the code:
# --------------------------------------------------------
&html_print_headers;
$page_title = "Accounts Without Records";
&html_page_top;
open (PASSWD, "<$auth_pw_file") or &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;
foreach $pass (@passwds) {
@data = split ":",$pass;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;
$found = 0;
foreach $line (@lines) {
if ($line =~ /^#/) { next; }
if ($line =~ /^\s*$/) { next; }
chomp ($line);
@values = &split_decode($line);
if ($values[$auth_user_field] eq $data[0]) {
$found = 1;
last;
}
}
unless ($found == 1) {
push (@list,$data[0]);
}
}
unless ($list[0]) {
print "All users have records in the database";
}
else {
print "The following users do not have records in the database:<BR>";
foreach $user (@list) {
print "$user<BR>";
}
}
&html_footer;
&html_page_bottom;
}--------------------
donm
Any ideas? Here is the code:
Code:
sub html_verify_accounts { # --------------------------------------------------------
&html_print_headers;
$page_title = "Accounts Without Records";
&html_page_top;
open (PASSWD, "<$auth_pw_file") or &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;
foreach $pass (@passwds) {
@data = split ":",$pass;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;
$found = 0;
foreach $line (@lines) {
if ($line =~ /^#/) { next; }
if ($line =~ /^\s*$/) { next; }
chomp ($line);
@values = &split_decode($line);
if ($values[$auth_user_field] eq $data[0]) {
$found = 1;
last;
}
}
unless ($found == 1) {
push (@list,$data[0]);
}
}
unless ($list[0]) {
print "All users have records in the database";
}
else {
print "The following users do not have records in the database:<BR>";
foreach $user (@list) {
print "$user<BR>";
}
}
&html_footer;
&html_page_bottom;
}
donm