Gossamer Forum
Home : Products : DBMan : Customization :

Verify Accounts Question

Quote Reply
Verify Accounts Question
JPDeni had written the following code to allow me to search for accounts which had not yet added a record to the database.

Is there a way to print out both the UserID and Email address of the account?

Here is the code:

sub html_verify_accounts {
# --------------------------------------------------------

&html_print_headers;
$page_title = "Accounts Without Records";
&html_page_top;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;

foreach $line (@lines) {
if ($line =~ /^#/) { next; }
if ($line =~ /^\s*$/) { next; }
chomp ($line);
@values = &split_decode($line);
$user{$values[$auth_user_field]} = 1;
}
open (PASSWD, "<$auth_pw_file") or &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;
foreach $pass (@passwds) {
@data = split ":",$pass;
unless ($user{$data[0]}) {
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;
}

Thanks !
----------------
donm



Quote Reply
Re: Verify Accounts Question In reply to
This requires going about it quite differently.

Code:

foreach $pass (@passwds) {
chomp $pass;
@data = split ":",$pass;
unless ($user{$data[0]}) {
$email{$data[0]} = $data[7];
}
}
foreach $user (%email) { ++$number_of_users; }
if ($number_of_users) {
print "The following $number_of_users users do not have records in the database:<BR>";
foreach $user (sort keys %email) {
print "$user -- $email{$user}<BR>\n";
}
}
else {
print "All users have records in the database";
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Verify Accounts Question In reply to
I tried adding the code you provided however now I get syntax errors - is this the entire code? Or should it replace some of the code in the original?

I am getting the errors when I do the latter - this is a live database - and I can't leave it online as it displays the admin login and password.

Thanks!

----------------
donm

Quote Reply
Re: Verify Accounts Question In reply to
No. It was not the whole subroutine. Just what needed to be changed. This is the whole subroutine:

Code:

sub html_verify_accounts {
# --------------------------------------------------------

&html_print_headers;
$page_title = "Accounts Without Records";
&html_page_top;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;

foreach $line (@lines) {
if ($line =~ /^#/) { next; }
if ($line =~ /^\s*$/) { next; }
chomp ($line);
@values = &split_decode($line);
$user{$values[$auth_user_field]} = 1;
}
open (PASSWD, "<$auth_pw_file") or &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;
foreach $pass (@passwds) {
chomp $pass;
@data = split ":",$pass;
unless ($user{$data[0]}) {
$email{$data[0]} = $data[7];
}
}
foreach $user (%email) { ++$number_of_users; }
if ($number_of_users) {
print "The following $number_of_users users do not have records in the database:<BR>";
foreach $user (sort keys %email) {
print "$user -- $email{$user}<BR>\n";
}
}
else {
print "All users have records in the database";
}
&html_footer;
&html_page_bottom;
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Verify Accounts Question In reply to
Ok - now we have something returning - however it looks like this:

UserID -- 0
UserID2 -- 0
UserID3 -- 0

No email addresses - just numbers.

----------------
donm

Quote Reply
Re: Verify Accounts Question In reply to
I'd forgotten that you have added a permission.

Change $email{$data[0]} = $data[7]; to $email{$data[0]} = $data[8];.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Verify Accounts Question In reply to
DUH - I should have known that myself ! <g>

Thanks Carol - works great now !

----------------
donm

Quote Reply
Re: Verify Accounts Question In reply to
Hi,

nice mod, however I get the message, that 6 Users have no record, but only 3 are displayed.
What could that be?

Thank you

Jakob

Quote Reply
Re: Verify Accounts Question In reply to
Hi,

do you have nay idea why I only get 3 users listed how ever I'm told in the first line that 6 users have no recors?

Thanx

Jakob