CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: Throw Down The Gauntlet:
how do I make this script automatically add the user to the htpasswd file

 



daniel_2000_au
Deleted

Mar 9, 2000, 10:37 AM

Post #1 of 2 (3583 views)
how do I make this script automatically add the user to the htpasswd file Can't Post

Does anyone know how to make this script automatically a users to the htpasswd?

#!/usr/bin/perl

############################################
## ##
## Account Manager LITE User Signup ##
## by CGI Script Center ##
## (e-mail cgi@elitehost.com) ##
## ##
## version: 1.05 ##
## last modified: 08/27/98 ##
## copyright (c) 1998 ##
## ##
## latest version is available from ##
## http://cgi.elitehost.com ##
## ##
############################################
##############################################################
# EDIT THE VARIABLES BELOW ###################################
##############################################################

require "/full/directory/path/to/config.pl";

##############################################################
##############################################################
#
# Copyright 1998 Elite Host. All Rights Reserved.
#
# TERMS OF USE
# 1. Account Manager LITE is offered as shareware. In exchange
# for its use, the CGI Script Center requires the following:
#
# Customer/User may use/install Account Manager LITE as many
# times as customer wishes, as long as customer owns th web
# site that Account Manager LITE is installed on. Account
# Manager LITE may not under any circumstances be sold
# or redistributed without the written consent of CGI Script Center and # its owner Diran Alemshah.
#
# 2. CGI Script Center, at its own discresion, will decide if any terms
# of the this agreement have been violated by customer. Upon written e- # mailed notification to Customer of Terms of Use violations, CGI
# Script Center may revoke customer's license to use Account Manager
# LITE.
#
# In that event, Customer agrees to any and all of the following:
#
# a) Customers found in violation of this agreement, found reselling or
# redistributing Account Manager LITE, will no longer be licensed to
# use Account Manager LITE and agrees to either immediately cease
# the use/distribution of Account Manager LITE or pay the CGI
# Script Center the full price of our Professional Series Account
# Manager for each copy used and/or distributed.
#
# b). Customer will no longer be licensed to run any version of
# Account Manager.
#
# Indemnification
# 1. Customer agrees that it shall defend, indemnify, save and hold
# CGI Script Center, Elite Web Design and marketing, and any
# persons affiliated with either company, harmless from any and all
# demands, liabilities, losses, costs and claims, including reasonable
# attorney's fees asserted against CGI Script Center, its agents, its
# customers, officers and employees, that may arise or result from any
# service provided or performed or agreed to be performed or any product # sold by customer, its agents, employees or assigns. Customer agrees to # defend, indemnify and hold harmless CGI Script Center, its # agents, # its cusomters, officers, and employes,against
# liabilities arising out of; a) any injury to person or property caused # by an products sold or otherwise distributed in connection with CGI
# Script Center products; (b) any material supplied by customer
# infringing or allegedly infringing on the proprietary rights of a
# third party; c) copyright infringement and (d) any defective products # sold to customer from CGI Script Center products.
#
# This program may not be distributed in whole or part, freely, for pay, # or any other form of compensation. This program may not be offered
# by Internet Service and/or other providers to their customers, whether
# for free or compensation. Contanct the CGI Script Center for
# commercial licensing information.
#
#################################################################
# This version designed for UNIX web servers. If you require
# an Win32(NT/WIN95) version, please contact cgi@elitehost.com
#################################################################
##############################################################
# DO NOT EDIT BELOW THIS LINE
##############################################################

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; }
$value =~ s/<!--(.|\n)*-->//g;
}

$version = "1.05";

$cgiurl = $ENV{'SCRIPT_NAME'};

if ($INPUT{'find'}) { &find; } ######### Will search for member info.
if ($INPUT{'process'}) { &sorder; }
#elsif ($INPUT{'order'}) { &order; }
#elsif ($INPUT{'sorder'}) {&sorder; }
else {&sorder;}############# IF no button was pressed, run just as
exit;


sub sorder {

unless ($INPUT{'agree'}) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><CENTER><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account Manager</FONT> Status:<BR>You Must Agree.</FONT></B></P></CENTER>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">In order for us to process your request, you must check the box marked <B>"I agree to the above"</B> on our order form.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">If you need further
assistance, please contact <A HREF="mailto:$orgmail">$orgname Support</A>.</FONT></P>
<CENTER><TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD COLSTART="1"><HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica">$orgname
maintained with <B><A HREF="http://cgi.elitehost.com/">Account Manager $version</A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}


unless ($INPUT{'fname'}) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><CENTER><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account Manager</FONT> Status:<BR>Please Enter Your First Name.</FONT></B></P></CENTER>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please don't forget to enter <B>your first name</B> in our service request form.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">If you need further
assistance, please contact <A HREF="mailto:$orgmail">$orgname Support</A>.</FONT></P>
<CENTER><TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD COLSTART="1"><HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica">$orgname
maintained with <B><A HREF="http://cgi.elitehost.com/">Account Manager $version</A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}

unless ($INPUT{'lname'}) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><CENTER><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account Manager</FONT> Status:<BR>Please Enter Your Last Name.</FONT></B></P></CENTER>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please don't forget to enter <B>your last name</B> in our service request form.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">If you need further
assistance, please contact <A HREF="mailto:$orgmail">$orgname Support</A>.</FONT></P>
<CENTER><TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD COLSTART="1"><HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica">$orgname
maintained with <B><A HREF="http://cgi.elitehost.com/">Account Manager $version</A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}

$INPUT{'email'} =~ s/\s//g;

unless ($INPUT{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(,)/
&#0124; &#0124; $INPUT{'email'} !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
$legalemail = 1;
} else {
$legalemail = 0;
}


if ($legalemail !~ 1) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><CENTER><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account Manager</FONT> Status:<BR>Please Enter Your E-Mail Address.</FONT></B></P></CENTER>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please don't forget to enter <B>your E-mail address</B> in our service request form.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">If you need further
assistance, please contact <A HREF="mailto:$orgmail">$orgname Support</A>.</FONT></P>
<CENTER><TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD COLSTART="1"><HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica">$orgname
maintained with <B><A HREF="http://cgi.elitehost.com/">Account Manager $version</A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}


&add;
}

sub close {

open (FILE,"$closing/email.txt"); #### Full path name from root.
@closing = <FILE>;
close(FILE);

open (MAIL, "|$mailprog -t")
&#0124; &#0124; print "Can't start mail program";
print MAIL "To: $INPUT{'email'}\n";
print MAIL "From: $orgmail ($orgname)\n";
print MAIL "Subject: $response_subject\n";
print MAIL "-" x 75 . "\n\n";




foreach $line(@closing) {
print MAIL "$line";
}

print MAIL"\n\n";
close (MAIL);


#################################################################
## MAIL BACK TO ADMIN ###########################################
#################################################################

$firstname = $INPUT{'fname'};
$lastname = $INPUT{'lname'};

open (MAIL, "|$mailprog -t")
&#0124; &#0124; print "Can't start mail program";

print MAIL "To: $orgmail\n";
print MAIL "From: $INPUT{'email'} ($firstname $lastname)\n";
print MAIL "Subject: $signupresponse\n";
print MAIL "-" x 75 . "\n\n";

print MAIL "Customer Information\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Name: $INPUT{'fname'} $INPUT{'lname'}\n";
print MAIL "Email: $INPUT{'email'}\n\n";

close (MAIL);




print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account
Manager</FONT> Status: Success!</FONT></B></P>
<P><FONT SIZE="-1" FACE="verdana, arial, helvetica">Your $orgname account information has been sent to the site administrators. You should receive a response shortly. Thank you for your interest.</FONT></P>
<P><FONT SIZE="-1" FACE="verdana, arial, helvetica">Please contact
<A HREF="mailto:$orgmail">$orgname Support</A> if you
need any further assistance.</FONT></P>
<HR SIZE="1">
<CENTER><FONT SIZE=\"-2\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER>
</TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}

#}

sub checkaddress {

$INPUT{'email'} =~ s/\s//g;

unless ($INPUT{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(,)/
&#0124; &#0124; $INPUT{'email'} !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
$legalemail = 1;
} else {
$legalemail = 0;
}


if ($legalemail !~ 1) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><CENTER><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account Manager</FONT> Status:<BR>Please Enter Your E-Mail Address.</FONT></B></P></CENTER>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please don't forget to enter <B>your E-mail address</B> in our service request form.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">If you need further
assistance, please contact <A HREF="mailto:$orgmail">$orgname Support</A>.</FONT></P>
<CENTER><TABLE BORDER="0" WIDTH="400"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD COLSTART="1"><HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica">$orgname
maintained with <B><A HREF="http://cgi.elitehost.com/">Account Manager $version</A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}
}

sub find {

&checkaddress;

# Open member database, read info
open (DAT,"<$memberinfo/amdata.db");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
@database_array = <DAT>;
close (DAT);

foreach $lines(@database_array) {
@edit_array = split(/\:/,$lines);

&parseemail;
# if ($edit_array[2] =~ /$INPUT{'email'}/i) {last; }

if ($edit_array[2] eq $email) {last; }

}

# unless ($edit_array[2] =~ /$INPUT{'email'}/i) {

unless ($edit_array[2] eq $email) {

print "Content-type: text/html\n\n";
&header;
print "<CENTER><BR><TABLE
BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART=\"1\"><P><B><FONT FACE=\"verdana, arial, helvetica\"><FONT
COLOR=\"#FF0000\">Account Manager</FONT> Status: Not Found!</FONT></B></P><P><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Your $orgname account information was not found in our database. Please make sure that you used the same email address that you created your account with.</FONT></P><P><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Please contact <A
HREF=\"mailto:$orgmail\">$orgname Support</A> for your account information.</FONT></P><HR
SIZE=\"1\"><CENTER><FONT SIZE=\"-2\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;
exit;
}

print "Content-type: text/html\n\n";
&header;
print "<CENTER><BR><TABLE
BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART=\"1\"><P><B><FONT FACE=\"verdana, arial, helvetica\"><FONT
COLOR=\"#FF0000\">Account Manager</FONT> Status: Success!</FONT></B></P><P><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Your $orgname account information has been emailed to you at: $INPUT{'email'}.</FONT></P><P><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Please contact <A
HREF=\"mailto:$orgmail\">$orgname Support</A> if you need any further assistance.</FONT></P><HR
SIZE=\"1\"><CENTER><FONT SIZE=\"-2\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;

open (MAIL, "|$mailprog -t")
&#0124; &#0124; print "Can't start mail program";

print MAIL "To: $edit_array[2]\n";
print MAIL "From: $orgmail ($orgname Support)\n";
print MAIL "Subject: $orgname Account Information\n\n";
#Date
print MAIL "$date\n";

# Check for Message Subject

print MAIL "-" x 75 . "\n\n";

print MAIL "You requested your $orgname account information:\n\n";

print MAIL "Your $orgname User ID is: $edit_array[0]\n";
print MAIL "Your $orgname password is: $edit_array[1]\n\n";

print MAIL "please contact $orgname support at: $orgmail\n";
print MAIL "if you have any questions.\n\n";

print MAIL "$orgname Support Team\n";

close (MAIL);


exit;

}

sub add {


unless ($INPUT{'username'}) {
print "Content-type: text/html\n\n";
&header;
print "<CENTER><TABLE BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD ALIGN=\"CENTER\" COLSTART=\"1\">
<FONT SIZE=\"+1\" FACE=\"verdana, arial, helvetica\"><FONT COLOR=\"#FF0000\">Account
Manager:</FONT><BR>Account Information Input Form</FONT><BR><BR>
<TABLE BORDER=\"0\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
ALIGN=\"LEFT\" COLSTART=\"1\"><FONT SIZE=\"+1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\"><B>Username
Error! No Username</B></FONT><BR><BR><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Please go back and a Username.</FONT></TD></TR><TR><TD COLSTART=\"1\"><HR SIZE=\"1\">
<CENTER><FONT SIZE=\"-2\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER> </TD></TR></ROWS></TBODY></TABLE></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;
exit;
}

if ($INPUT{'username'} =~ /\s/) {
print "Content-type: text/html\n\n";
&header;
print "<CENTER><TABLE BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD ALIGN=\"CENTER\" COLSTART=\"1\">
<FONT SIZE=\"+1\" FACE=\"verdana, arial, helvetica\"><FONT COLOR=\"#FF0000\">Account
Manager:</FONT><BR>Account Information Input Form</FONT><BR><BR>
<TABLE BORDER=\"0\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
ALIGN=\"LEFT\" COLSTART=\"1\"><FONT SIZE=\"+1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\"><B>Username
Error! Username Contains a Space</B></FONT><BR><BR><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Please go back and enter a Username without spaces. If you would like to use a multi-word Username, be sure to use an underscore ( _ ).</FONT></TD></TR><TR><TD COLSTART=\"1\"><HR SIZE=\"1\">
<CENTER><FONT SIZE=\"-2\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER> </TD></TR></ROWS></TBODY></TABLE></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;
exit;
}

if ($INPUT{'username'} eq $INPUT{'pwd'}) {

print "Content-type: text/html\n\n";
&header;
print "<CENTER><TABLE BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD ALIGN=\"CENTER\" COLSTART=\"1\">
<FONT SIZE=\"+1\" FACE=\"verdana, arial, helvetica\"><FONT COLOR=\"#FF0000\">Account Manager:</FONT><BR> Account Information Input Form</FONT><BR><BR>
<TABLE BORDER=\"0\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
ALIGN=\"LEFT\" COLSTART=\"1\"><FONT SIZE=\"+1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\"><B>Password Error! Same as Username</B></FONT><BR><BR><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">You must chose a Password other than your Username, for security considerations. Please return and enter another password.</FONT></TD></TR>

</ROWS></TBODY></TABLE></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;
exit;
}

unless ($INPUT{'pwd'} eq $INPUT{'pwd2'} && $INPUT{'pwd'} && $INPUT{'pwd2'} ){

print "Content-type: text/html\n\n";
&header;
print "<CENTER><TABLE BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD ALIGN=\"CENTER\" COLSTART=\"1\">
<FONT SIZE=\"+1\" FACE=\"verdana, arial, helvetica\"><FONT COLOR=\"#FF0000\">Account
Manager:</FONT><BR>Account Information Input Form</FONT><BR><BR>
<TABLE BORDER=\"0\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
ALIGN=\"LEFT\" COLSTART=\"1\"><FONT SIZE=\"+1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\"><B>Password
Error! Password Mismatch</B></FONT><BR><BR><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">Please go back and re-enter your
password choice.</FONT></TD></TR><TR><TD COLSTART=\"1\"><HR SIZE=\"1\">
<CENTER><FONT SIZE=\"-2\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER> </TD></TR></ROWS></TBODY></TABLE></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;
exit;
}


if (-e "$memberinfo/amdata.db") {

open (MEMBER, "<$memberinfo/amdata.db");
if ($LOCK_EX){
flock(MEMBER, $LOCK_EX); #Locks the file
}
@database_array = <MEMBER>;
close (MEMBER);

foreach $lines(@database_array) {
@edit_array = split(/\:/,$lines);

&parseusername2;

# if ($edit_array[0] eq $INPUT{'username'}) {last; }

if (($edit_array[0]) && ($edit_array[0] eq $desiredname)) {last; }

}

$INPUT{'username'} =~ s/\W.*//;
# if ($edit_array[0] eq $INPUT{'username'}) {

if (($edit_array[0]) && ($edit_array[0] eq $desiredname)) {

print "Content-type: text/html\n\n";
&header;
print "<CENTER><TABLE BORDER=\"0\" WIDTH=\"450\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR
><TD ALIGN=\"CENTER\" COLSTART=\"1\">
<FONT SIZE=\"+1\" FACE=\"verdana, arial, helvetica\"><FONT COLOR=\"#FF0000\">Account Manager:</FONT><BR>User Name Taken</FONT><BR><BR>
<TABLE BORDER=\"0\"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
ALIGN=\"LEFT\" COLSTART=\"1\"><FONT SIZE=\"+1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\"><B>User Name Error! User Name Taken</B></FONT><BR><BR><FONT
SIZE=\"-1\" COLOR=\"$fontcolor\" FACE=\"verdana, arial, helvetica\">The User Name you have selected is already in use by another user. Please return and enter another user name.</FONT></TD></TR>
<TR><TD COLSTART=\"1\"><HR SIZE=\"1\">
<CENTER><FONT SIZE=\"-2\" FACE=\"verdana, arial, helvetica\"> $orgname is maintained with <A
HREF=\"http://cgi.elitehost.com\"><B>Account Manager $version</B></A></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></TD></TR></ROWS></TBODY></TABLE></CENTER>";
&footer;
exit;
}

}
&dupeaddress;
&dupeaddress2;
&usertemp;
#&dupepwd;
&temp;
exit;
}

sub usertemp {


opendir (DIR, "$memberinfo");
@file = grep { /.infotmp/} readdir(DIR);
foreach $lines(@file) {
$lines =~ s/\W.*//;

&parseusername;

if ($lines eq $desiredname) {

# if ($lines =~ /$INPUT{'username'}\b/i) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="450"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account
Manager</FONT> Status: Username Taken!</FONT></B></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">The Username: $INPUT{'username'} has already been reserved by someone awaiting membership</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please choose another Username.</FONT></P>
<HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica"><B>$orgname maintained with
<A HREF="http://cgi.elitehost.com/"><B>Account Manager $version</B></A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;

}
}
}

sub dupeaddress {
#print "Content-type: text/html\n\n";
open (EMAIL, "<$memberinfo/amdata.db");
if ($LOCK_EX){
flock(EMAIL, $LOCK_EX); #Locks the file
}
@database_array = <EMAIL>;
close (EMAIL);

foreach $lines(@database_array) {
@edit_array = split(/\:/,$lines);
&parseemail;

if ($edit_array[2] eq $email) {

# if ($edit_array[2] =~ /$INPUT{'email'}/i) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="450"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account
Manager</FONT> Status: Address Taken!</FONT></B></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">The E-mail address: $INPUT{'email'} is already in our database. </FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please contact
<A HREF="mailto:$orgmail"><B>$orgname Support</B></A> if you
need any further assistance.</FONT></P>
<HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica"><B>$orgname maintained with
<A HREF="http://cgi.elitehost.com/"><B>Account Manager $version</B></A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
exit;
}
}
}

sub dupeaddress2 {


opendir (DIR, "$memberinfo");
close (DIR);
@file = grep { /.infotmp/} readdir(DIR);
foreach $lines(@file) {

open (DAT, "<$memberinfo/$lines");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
@approval = <DAT>;
foreach $item(@approval) {
@edit_approval = split(/\:/,$item);

&parseemail;

if ($edit_approval[2] eq $email) {last; }

# if ($edit_approval[2] =~ /$INPUT{'email'}/i) {last; }
}

if ($edit_approval[2] eq $email) {

# if ($edit_approval[2] =~ /$INPUT{'email'}/i) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="450"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account
Manager</FONT> Status: Address Taken!</FONT></B></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">The E-mail address:
$INPUT{'email'} was found in use by someone awaiting membership.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please contact
<A HREF="mailto:$orgmail"><B>$orgname Support</B></A> if you need any further
assistance.</FONT></P>
<HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica"><B>$orgname
maintained with
<A HREF="http://cgi.elitehost.com/"><B>Account Manager $version</B></A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
#close (DIR);
exit;

}
}
}

sub dupepwd {


opendir (DIR, "$memberinfo");
close (DIR);
@file = grep { /.infotmp/} readdir(DIR);
foreach $lines(@file) {

open (DAT, "<$memberinfo/$lines");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
@approval = <DAT>;
foreach $item(@approval) {
@edit_approval = split(/\:/,$item);

if ($edit_approval[1] =~ /$INPUT{'pwd'}\b/i) {last; }
}

if ($edit_approval[1] =~ /$INPUT{'pwd'}\b/i) {
print "Content-type: text/html\n\n";
&header;
print<<EOF;
<CENTER><BR>
<TABLE BORDER="0" WIDTH="450"><TBODY><COLDEFS><COLDEF></COLDEFS><ROWS><TR><TD
COLSTART="1"><P><B><FONT FACE="verdana, arial, helvetica"><FONT
COLOR="#FF0000">Account
Manager</FONT> Status: Address Taken!</FONT></B></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">The Password you chose has already been requested by a new prospective user. Please choose another.</FONT></P>
<P><FONT SIZE="-1" COLOR="$fontcolor" FACE="verdana, arial, helvetica">Please contact
<A HREF="mailto:$orgmail"><B>$orgname Support</B></A> if you need any further
assistance.</FONT></P>
<HR SIZE="1">
<CENTER><FONT SIZE="-2" FACE="verdana, arial, helvetica"><B>$orgname
maintained with
<A HREF="http://cgi.elitehost.com/"><B>Account Manager $version</B></A></B></FONT>
</CENTER></TD></TR></ROWS></TBODY></TABLE></CENTER>
EOF
&footer;
#close (DIR);
exit;

}
}
}


######################################
# Create temp files for Admin approval
######################################

sub temp {

$INPUT{'fname'} =~ s/\s+$//;
$INPUT{'lname'} =~ s/\s+$//;


$newline2 = join
("\:",$INPUT{'username'},$INPUT{'pwd'},$INPUT{'email'},$INPUT{'fname'},$INPUT{'lname'},$setup,$monthly,$INPUT{'payment'},$INPUT{'creditcards'},$INPUT{'nameoncard'},$INPUT{'cardnumb er'},$INPUT{'exp'},$INPUT{'billingaddress'},$INPUT{'billingaddress2'},$INPUT{'city'},$INPUT{'state'},$INPUT{'zip'},$INPUT{'lbill'},$INPUT{'papplied'},$INPUT{'aapplied'},$INPUT{'tba lance'},$INPUT{'tnew'},$INPUT{'tcharges'},$INPUT{'nnew'},$INPUT{'linvoice'},$INPUT{'taxes'},$INPUT{'ccity'},$INPUT{'cstate'},$INPUT{'czip'},0);
$newline2 .= "\n";

open(TEMP2, ">$memberinfo/$INPUT{'username'}.infotmp") or print "unable to create user info temp file. Check your directory permission settings";
if ($LOCK_EX){
flock(TEMP2, $LOCK_EX); #Locks the file
}
print TEMP2 $newline2;
close (TEMP2);

#unlink ("$memberinfo/$INPUT{'username'}.infotmp");


#}

if ($INPUT{$lines}) {
unlink ("$memberinfo/$lines");

}

#}
&close;

exit;

}


sub parseusername {
$desiredname = $INPUT{'username'};
$lines =~ tr/A-Z/a-z/;
$desiredname =~ tr/A-Z/a-z/;
}

sub parseusername2 {
$desiredname = $INPUT{'username'};
$edit_array[0] =~ tr/A-Z/a-z/;
$desiredname =~ tr/A-Z/a-z/;
}


sub parseemail {
$email = $INPUT{'email'};
$edit_array[2] =~ tr/A-Z/a-z/;
$email =~ tr/A-Z/a-z/;
}


sub header {
open (FILE,"<$header/header.txt"); #### Full path name from root.
@headerfile = <FILE>;
close(FILE);
print "<HTML><HEAD><TITLE></TITLE></HEAD><BODY $bodyspec>\n";
foreach $line(@headerfile) {
print "$line";
}
}


sub footer {
open (FILE,"<$footer/footer.txt"); #### Full path name from root.
@footerfile = <FILE>;
close(FILE);
foreach $line(@footerfile) {
print "$line";
}
print "</BODY></HTML>";
}



perlkid
stranger

Mar 9, 2000, 3:13 AM

Post #2 of 2 (3583 views)
Re: how do I make this script automatically add the user to the htpasswd file [In reply to] Can't Post

 
Daniel,

I can't say that I completly understand what you want but I think that you are trying to write a user name and a password to a file when someone signs up with an account.

If I'm right you can use this
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$username = $INPUT{'new_user'};
$password = $INPUT{'new_pass'};
$username =~ tr/A-Z/a-z/;
$password = crypt($password, "MM");
$users = "users.dat";
open (PEOPLE, ">>$users");
print PEOPLE "$username $password \n";
close (PEOPLE);
print "Content-type: text/html\n\n";
print "<h1>You user name and password were added</h1>\n";
</pre><HR></BLOCKQUOTE>

If you need somthing different let me know and I'll se if I can help you any further.

perlkid

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives