3 # $Id: register.cgi,v 1.5 2000-03-03 18:22:42 ivan Exp $
7 $datasrc $user $pass $x
11 #$freeside_bin $freeside_test $freeside_conf
16 use CGI::Carp qw(fatalsToBrowser);
22 $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
23 $ENV{'SHELL'} = '/bin/sh';
24 $ENV{'IFS'} = " \t\n";
27 $ENV{'BASH_ENV'} = '';
29 #$freeside_bin = '/home/freeside/bin/';
30 #$freeside_test = '/home/freeside/test/';
31 #$freeside_conf = '/usr/local/etc/freeside/';
33 $datasrc = 'DBI:mysql:http_auth';
37 ##my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' );
38 ##my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9' );
39 #@pw_set = ( 'a'..'z', '0'..'9' );
40 #@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
46 $username = $cgi->param('username');
47 $username =~ /^\s*([a-z][\w]{0,15})\s*$/i
48 or &idiot("Illegal username. Please use 1-16 alphanumeric characters, and start your username with a letter.");
51 $email = $cgi->param('email');
52 $email =~ /^([\w\-\.\+]+\@[\w\-\.]+)$/
53 or &idiot("Illegal email address.");
58 #$user_pw = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) );
59 #$crypt_pw = crypt($user_pw,$saltset[int(rand(64))].$saltset[int(rand(64))]);
63 local $SIG{HUP} = 'IGNORE';
64 local $SIG{INT} = 'IGNORE';
65 local $SIG{QUIT} = 'IGNORE';
66 local $SIG{TERM} = 'IGNORE';
67 local $SIG{TSTP} = 'IGNORE';
68 local $SIG{PIPE} = 'IGNORE';
72 $dbh = DBI->connect( $datasrc, $user, $pass, {
73 'AutoCommit' => 'true',
74 } ) or die "DBI->connect error: $DBI::errstr\n";
75 $x = $DBI::errstr; #silly; to avoid "used only once" warning
77 $sth = $dbh->prepare("INSERT INTO mysql_auth VALUES (". join(", ",
78 $dbh->quote($username),
80 # $dbh->quote($crypt_pw),
82 $dbh->quote('freeside'),
83 $dbh->quote('unconfigured'),
86 $sth->execute or &idiot("Username in use: ". $sth->errstr);
88 $dbh->disconnect or die $dbh->errstr;
97 <TITLE>Freeside demo registration successful</TITLE>
99 <BODY BGCOLOR="#FFFFFF">
103 <img border=0 alt="Silicon Interactive Software Design" src="http://www.sisd.com/freeside/small-logo.gif">
105 <center><font color="#ff0000" size=7>freeside demo registration successful</font></center>
108 <P>Your sample database has been setup. Your password and the URL for the
109 Freeside demo have been emailed to you.
118 print $cgi->header, <<END;
121 <TITLE>Registration error</TITLE>
123 <BODY BGCOLOR="#FFFFFF">
125 <H4>Registration error</H4>
128 <P>Hit the <I>Back</I> button in your web browser, correct this mistake,
129 and submit the form again.