#!/bin/perl
# sample.cgi
# Written By David S. Choi, dc@sitedeveloper.com
# 15 June 1998
#
# Sample cgi script utilizing dcprotect.pl
#
#------------------------------------------------------------------

# $path is directory path to the location of this program
# Try using relative path

$path = ".";

# require all library files

require "$path/dclib.cgi";
require "$path/dcprotect.cgi";
require "$path/cgi-lib.cgi";

# Print HTTP header but note it doesn't end here

print "Content-type: text/html\n";

# Read in all the input data

&ReadParse;

# $thisurl is the URL of this script

$thisurl = "http://www.nrdp.net/uuflorida/member/member.cgi";

# $password_file_dir is the directory where all
# authentication files will be created and kept
# This directory must be set to 777

$password_file_dir = "$path/data";

# Path to the template file used by dcprotect.pl

$templatefile = "$path/dcprotect.htmlt";

# Platform "NT" or "UNIX"

$platform = "UNIX";

# setup file name

$in{'auth_setup_file'} = "auth_setup_file.txt";

# password file name

$in{'password_file'} = "auth_user_file.txt";

# cookie expriation date if 'Remember My Password' is used

$in{'expires'} = "Fri, 31-Dec-2010 12:00:00 GMT";

# Cookie name

$in{'cookie_name'} = "DCProtectSessionID";

# Username, Password, and Group are always required
# They are appended at the very beginning of @login_fields
# and %field_input_type in dcprotect subroutine
# Also, Status is appended at the end of @login_fields

@login_fields = qw(Firstname Lastname EMail);

%field_form_type = (
		Firstname => 'text|40|required',
		Lastname => 'text|40|required',
		EMail => 'text|40|required'
);

# Following line adds authentication

$r_userdata = dcprotect($thisurl,$password_file_dir,\%in,
			\@login_fields,\%field_form_type);

# Be sure to print the end of HTTP Header

print "\n";

# Below here you place your CGI code


# Following links allow you and your users to
# Login/Logout, etc...  If you are 'Registering Via EMail'
# You should have 'User Menu' available so that
# your users can change their passwords

	print qq~
		<p>
		[ <a href="$thisurl?az=login">Login/Logout</a> ]
		[ <a href="$thisurl">Refresh</a> ]
		[ <a href="$thisurl?dc_action=usermanage">Manage Users</a> ]
		[ <a href="$thisurl?dc_action=configure">Change Configuration Setting</a> ]
		[ <a href="$thisurl?dc_action=user_mod">User Menu</a> ]<BR><BR><BR><BR>
  		<CENTER>[ <a href="http://www.nrdp.net/uuflorida/pass/">SPEAKER DATABASE AREA</a> ]</CENTER>
		<p>
	~;

#
# If you need to use users' information, here's how
#

print "Username : $r_userdata->{'Username'}<br>\n";
print "Firstname : $r_userdata->{'Firstname'}<br>\n";
print "Lastname : $r_userdata->{'Lastname'}<br>\n";
print "EMail : $r_userdata->{'EMail'}<br>\n";
print "Group : $r_userdata->{'Group'}<br>\n";
