cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Stefan_Krueger
Level 9

User authentification in Perl?

Are there any samples for user authentification except the ASP sample in the docs? Something in Perl for instance?
I don't need the actual authentification process, just a template that handles the communication (receiving parameters and returning success or failure).
Stefan Krueger
InstallSite.org
0 Kudos
(2) Replies
Sunny_s
Level 6

I am not a PERL guru, here is a sample PERL script which

1) Recieve serialnum as CGI param
2) Checks serialnum in a flat file database (subscribe.dat)
3) syntax of subscribe.dat is simple
SerialNum, PAID or UNPAID
4) Based on serialnum, appropiate response is sent to Update Service
5) Each query is logged for future records.

Here is sample subscribe.dat
1111,PAID
2222,UNPAID

Here is PERL script

#!/usr/local/bin/perl
use CGI qw(:standard);
use CGI qw/:standard :html3/;

print ("Content-Type: text/html\n\n");
ReadUserInputs ();
CheckUsersValidity ();
AddUserInputsToDB ();

sub CheckUsersValidity
{
open (CUSTOMERDB, "
while ($dbrow=)
{
@dbcol = split (/,/, $dbrow);

if ($serialnum eq $dbcol[0])
{
if ($dbcol[1] eq "PAID\n")
{
print("OK");
return;
}
else
{
print("FAILED");
print("Your Subscription is : UNPAID, please contact ISV");
return;
}
}
}
close (CUSTOMERDB);
print("FAILED");
print("Your Serial Number is not present in our database, please contact ISV");
}

sub ReadUserInputs
{
$serialnum=param('serialnum');
}

sub AddUserInputsToDB()
{
open (CUSTOMERDB, ">>queries.dat");
select (CUSTOMERDB);
print ("$serialnum\n");
close(CUSTOMERDB);
}
0 Kudos
Stefan_Krueger
Level 9

Thanks a lot.
Stefan Krueger
InstallSite.org
0 Kudos