From: ivan Date: Wed, 1 Mar 2000 08:15:10 +0000 (+0000) Subject: queuing webdemo registration X-Git-Tag: freeside_1_3_0~176 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=9634d838efee4b155c89c36f524eca98d73d1868;ds=inline queuing webdemo registration --- diff --git a/fs_webdemo/register.cgi b/fs_webdemo/register.cgi index 4332958f6..45b5d6aeb 100755 --- a/fs_webdemo/register.cgi +++ b/fs_webdemo/register.cgi @@ -1,18 +1,22 @@ #!/usr/bin/perl -Tw +# +# $Id: register.cgi,v 1.2 2000-03-01 08:15:10 ivan Exp $ use strict; -use vars qw( $freeside_bin $freeside_test $freeside_conf +use vars qw( #$freeside_bin $freeside_test $freeside_conf $datasrc $user $pass $x - @pw_set @saltset - $cgi $username $name $email $user_pw $crypt_pw $dbh $sth - $header $msg + #@pw_set @saltset + $cgi $username $email + #$user_pw $crypt_pw + $dbh $sth + #$header $msg ); use CGI; #use CGI::Carp qw(fatalsToBrowser); use DBI; -use Mail::Internet; -use Mail::Header; -use Date::Format; +#use Mail::Internet; +#use Mail::Header; +#use Date::Format; $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; @@ -21,18 +25,18 @@ $ENV{'CDPATH'} = ''; $ENV{'ENV'} = ''; $ENV{'BASH_ENV'} = ''; -$freeside_bin = '/home/freeside/bin/'; -$freeside_test = '/home/freeside/test/'; -$freeside_conf = '/usr/local/etc/freeside/'; +#$freeside_bin = '/home/freeside/bin/'; +#$freeside_test = '/home/freeside/test/'; +#$freeside_conf = '/usr/local/etc/freeside/'; $datasrc = 'DBI:mysql:http_auth'; $user = "freeside"; $pass = "maelcolm"; -#my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' ); -#my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9' ); -@pw_set = ( 'a'..'z', '0'..'9' ); -@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); +##my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' ); +##my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9' ); +#@pw_set = ( 'a'..'z', '0'..'9' ); +#@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); ### @@ -43,12 +47,6 @@ $username =~ /^\s*([a-z][\w]{0,15})\s*$/i or &idiot("Illegal username. Please use 1-16 alphanumeric characters, and start your username with a letter."); $username = lc($1); -$name = $cgi->param('name'); -$name =~ /^([\w\-\,\. ]*)$/ - or &idiot("Illegal name. ". - "Only alphanumerics, the dash, comma and period are legal."); -$name = $1; - $email = $cgi->param('email'); $email =~ /^([\w\-\.\+]+\@[\w\-\.]+)$/ or &idiot("Illegal email address."); @@ -56,8 +54,8 @@ $email = $1; ### -$user_pw = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) ); -$crypt_pw = crypt($user_pw,$saltset[int(rand(64))].$saltset[int(rand(64))]); +#$user_pw = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) ); +#$crypt_pw = crypt($user_pw,$saltset[int(rand(64))].$saltset[int(rand(64))]); ### @@ -77,11 +75,13 @@ $x = $DBI::errstr; #silly; to avoid "used only once" warning $sth = $dbh->prepare("INSERT INTO mysql_auth VALUES (". join(", ", $dbh->quote($username), - $dbh->quote($crypt_pw), + $dbh->quote("X"), +# $dbh->quote($crypt_pw), $dbh->quote('freeside'), + $dbh->quote('unconfigured'), ). ")" ); -$sth->execute or &idiot($sth->errstr); +$sth->execute or &idiot("Username in use: ". $sth->errstr); $dbh->disconnect or die $dbh->errstr; @@ -103,152 +103,14 @@ print <freeside demo registration successful -

Your sample database has been setup. Your username, password, and URL - have been emailed to you. +

Your sample database has been setup. Your password and the URL for the + Freeside demo have been emailed to you. END ### -system("/usr/bin/mysqladmin --user=$user --password=$pass ". - "create $username >/dev/null"); - -open(MAPSECRETS, ">>${freeside_conf}mapsecrets") - or die "Can\'t open ${freeside_conf}mapsecrets: $!"; -print MAPSECRETS "$username secrets.$username\n"; -close MAPSECRETS; - -open(SECRETS, ">${freeside_conf}secrets.$username") - or die "Can\'t open ${freeside_conf}secrets.$username: $!"; -chmod 0600, "${freeside_conf}secrets.$username"; -print SECRETS "DBI:mysql:$username\nfreeside\nmaelcolm\n"; -close SECRETS; - -mkdir "${freeside_conf}conf.DBI:mysql:$username", 0755; - -open(ADDRESS, ">${freeside_conf}conf.DBI:mysql:$username/address") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/address: $!"; -print ADDRESS <${freeside_conf}conf.DBI:mysql:$username/domain") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/domain: $!"; -print DOMAIN "this-is-an-example-domain.tld\n"; -close DOMAIN; - -open(HOME, ">${freeside_conf}conf.DBI:mysql:$username/home") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/home: $!"; -print HOME "/home\n"; -close HOME; - -open(INVOICE_FROM, ">${freeside_conf}conf.DBI:mysql:$username/invoice_from") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/invoice_from: $!"; -print INVOICE_FROM "$email\n"; -close INVOICE_FROM; - -open(LPR, ">${freeside_conf}conf.DBI:mysql:$username/lpr") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/lpr: $!"; -print LPR "cat >/dev/null\n"; -close LPR; - -mkdir "${freeside_conf}conf.DBI:mysql:$username/registries", 0755; -mkdir "${freeside_conf}conf.DBI:mysql:$username/registries/internic", 0755; -open(FROM, ">${freeside_conf}conf.DBI:mysql:$username/registries/internic/from") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/from: $!"; -print FROM "$email\n"; -close FROM; -open(NAMESERVERS, ">${freeside_conf}conf.DBI:mysql:$username/registries/internic/nameservers") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/nameservers: $!"; -print NAMESERVERS <${freeside_conf}conf.DBI:mysql:$username/registries/internic/tech_contact") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/tech_contact: $!"; -print TECH_CONTACT "EXAMPLE-INTERNIC-HANDLE\n"; -close TECH_CONTACT; -system ("cp", "${freeside_conf}.domain-template.txt", - "${freeside_conf}conf.DBI:mysql:$username/registries/internic/template" - ); -open(TO, ">${freeside_conf}conf.DBI:mysql:$username/registries/internic/to") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/to: $!"; -print TO "$email\n"; -close TO; - -open(SHELLS, ">${freeside_conf}conf.DBI:mysql:$username/shells") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/shells: $!"; -print SHELLS <${freeside_conf}conf.DBI:mysql:$username/smtpmachine") - or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/smtpmachine: $!"; -print SMTPMACHINE "localhost\n"; -close SMTPMACHINE; - -#make counter dir -mkdir("/usr/local/etc/freeside/counters.DBI:mysql:$username",0755) - or die "Can't create counter spooldir: $!"; - -system("${freeside_bin}fs-setup.webdemo", "$username"); -system("${freeside_test}cgi-test", - "http://freeside.sisd.com/", $username, $user_pw); - -### - -$ENV{SMTPHOSTS} = "localhost"; -$ENV{MAILADDRESS} = 'ivan@sisd.com'; -$header = Mail::Header->new( [ - 'From: ivan@sisd.com', - "To: $email", - 'Cc: ivan-fsreg@sisd.com', - 'Sender: ivan@sisd.com', - 'Reply-To: ivan@sisd.com', - 'Date: '. time2str("%a, %d %b %Y %X %z", time), - 'Subject: Freeside demo information', -] ); -$msg = Mail::Internet->new( - 'Header' => $header, - 'Body' => [ -"Hello $name <$email>,\n", -"\n", -"Your sample Freeside database has been setup.\n", -"\n", -"Point your web browswer at http://freeside.sisd.com/ and use the following\n", -"authentication information:\n", -"\n", -"Username: $username\n", -"Password: $user_pw\n", -"\n", -"You may wish to subscribe to the Freeside mailing list - send a blank\n", -"message to ivan-freeside-subscribe\@sisd.com.\n", -"\n", -"-- \n", -"Ivan Kohler \n", -"20 4,16 \* \* \* saytime\n", - ] -); -$msg->smtpsend or die "Can\'t send registration email!"; - -### - sub idiot { my($error)=@_; print $cgi->header, < + + + Freeside - Billing and account administration software for ISPs + + + + + +
+ + + + +
freeside demo registration
+
+

You will need to choose a username for access to the Freeside web demo. + Also enter your email address and (optionally) your name. + +

A password + and the URL for your demo will be emailed to you, so don't waste your + time with non-deliverable addresses. +We will not give your name or email address to any third party, + nor will we send you any unsolicited email. +

+
+Freeside username: 
+
+Email address:     
+
+
+
+ + diff --git a/fs_webdemo/registerd b/fs_webdemo/registerd new file mode 100755 index 000000000..91dd8df29 --- /dev/null +++ b/fs_webdemo/registerd @@ -0,0 +1,285 @@ +#!/usr/bin/perl -Tw +# +# $Id: registerd,v 1.1 2000-03-01 08:15:10 ivan Exp $ + +use strict; +use vars qw(# $freeside_bin $freeside_test + $freeside_conf + $mysql_data + $datasrc $user $pass $x + @pw_set @saltset + # $cgi $username $name $email $user_pw $crypt_pw $dbh $sth + # $header $msg + ); +#use CGI; +#use CGI::Carp qw(fatalsToBrowser); +use DBI; +use Mail::Internet; +use Mail::Header; +use Date::Format; + +#$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; +#$ENV{'SHELL'} = '/bin/sh'; +#$ENV{'IFS'} = " \t\n"; +#$ENV{'CDPATH'} = ''; +#$ENV{'ENV'} = ''; +#$ENV{'BASH_ENV'} = ''; + +#$freeside_bin = '/home/freeside/bin/'; +#$freeside_test = '/home/freeside/test/'; +$freeside_conf = '/usr/local/etc/freeside/'; + +$mysql_data = "/var/lib/mysql"; + +$datasrc = 'DBI:mysql:http_auth'; +$user = "freeside"; +$pass = "maelcolm"; + +#my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' ); +#my(@pw_set)= ( 'a'..'z', 'A'..'Z', '0'..'9' ); +@pw_set = ( 'a'..'z', '0'..'9' ); +@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); + +die "not running as system user freeside" + unless $> == scalar(getpwnam('freeside')) + +$dbh = DBI->connect( $datasrc, $user, $pass, { + 'AutoCommit' => 'true', +} ) or die "DBI->connect error: $DBI::errstr\n"; +$x = $DBI::errstr; #silly; to avoid "used only once" warning + +while ( 1 ) { + + $SIG{HUP} = 'IGNORE'; + $SIG{INT} = 'IGNORE'; + $SIG{QUIT} = 'IGNORE'; + $SIG{TERM} = 'IGNORE'; + $SIG{TSTP} = 'IGNORE'; + $SIG{PIPE} = 'IGNORE'; + + $sth = $dbh->prepare("LOCK TABLES mysql_auth WRITE"); + $sth->execute or die $sth->errstr; + + $sth = $dbh->prepare( + 'SELECT * FROM mysql_auth WHERE status = "unconfigured"' + ); + $sth->execute or die $sth->errstr; + my $pending = $sth->fetchall_arrayref( {} ); + + $sth = $dbh->prepare( + 'UPDATE mysql_auth SET status = "locked" WHERE status = "unconfigured"' + ); + $sth->execute or die $sth->errstr; + + $sth = $dbh->prepare("UNLOCK TABLES"); + $sth->execute or die $sth->errstr; + + # + + foreach my $row ( @{$pending} ) { + + my $username = $row->{'username'}; + + my $user_pw = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) ); + my $crypt_pw = + crypt($user_pw,$saltset[int(rand(64))].$saltset[int(rand(64))]); + + system("/usr/bin/mysqladmin --user=$user --password=$pass ". + "create demo_$username >/dev/null"); + + system "cp $mysql_data/demo_template/* $mysql_data/demo_$username"; + + mkdir "${freeside_conf}conf.DBI:mysql:demo_$username", 0755; + system "cp -r ${freeside_conf}conf.DBI:mysql:demo_template/* ". + "${freeside_conf}conf.DBI:mysql:demo_$username"; + + mkdir "${freeside_conf}counters.DBI:mysql:demo_$username", 0755; + system "cp ${freeside_conf}counters.DBI:mysql:demo_template/* ". + "${freeside_conf}counters.DBI:mysql:demo_$username"; + + + open(SECRETS, ">${freeside_conf}secrets.$username") + or die "Can\'t open ${freeside_conf}secrets.demo_$username: $!"; + chmod 0600, "${freeside_conf}secrets.$username"; + print SECRETS "DBI:mysql:demo_$username\nfreeside\nmaelcolm\n"; + close SECRETS; + + open(MAPSECRETS, ">>${freeside_conf}mapsecrets") + or die "Can\'t open ${freeside_conf}mapsecrets: $!"; + print MAPSECRETS "$username secrets.demo_$username\n"; + close MAPSECRETS; + + + + + } + + + $SIG{HUP} = 'DEFAULT'; + $SIG{INT} = 'DEFAULT'; + $SIG{QUIT} = 'DEFAULT'; + $SIG{TERM} = 'DEFAULT'; + $SIG{TSTP} = 'DEFAULT'; + $SIG{PIPE} = 'DEFAULT'; + + sleep 5; + +} + +$sth = $dbh->prepare("INSERT INTO mysql_auth VALUES (". join(", ", + $dbh->quote($username), + $dbh->quote($crypt_pw), + $dbh->quote('freeside'), +). ")" ); + +$sth->execute or &idiot("Username in use: ". $sth->errstr); + +$dbh->disconnect or die $dbh->errstr; + +### + + + +open(ADDRESS, ">${freeside_conf}conf.DBI:mysql:$username/address") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/address: $!"; +print ADDRESS <${freeside_conf}conf.DBI:mysql:$username/domain") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/domain: $!"; +print DOMAIN "this-is-an-example-domain.tld\n"; +close DOMAIN; + +open(HOME, ">${freeside_conf}conf.DBI:mysql:$username/home") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/home: $!"; +print HOME "/home\n"; +close HOME; + +open(INVOICE_FROM, ">${freeside_conf}conf.DBI:mysql:$username/invoice_from") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/invoice_from: $!"; +print INVOICE_FROM "$email\n"; +close INVOICE_FROM; + +open(LPR, ">${freeside_conf}conf.DBI:mysql:$username/lpr") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/lpr: $!"; +print LPR "cat >/dev/null\n"; +close LPR; + +mkdir "${freeside_conf}conf.DBI:mysql:$username/registries", 0755; +mkdir "${freeside_conf}conf.DBI:mysql:$username/registries/internic", 0755; +open(FROM, ">${freeside_conf}conf.DBI:mysql:$username/registries/internic/from") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/from: $!"; +print FROM "$email\n"; +close FROM; +open(NAMESERVERS, ">${freeside_conf}conf.DBI:mysql:$username/registries/internic/nameservers") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/nameservers: $!"; +print NAMESERVERS <${freeside_conf}conf.DBI:mysql:$username/registries/internic/tech_contact") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/tech_contact: $!"; +print TECH_CONTACT "EXAMPLE-INTERNIC-HANDLE\n"; +close TECH_CONTACT; +system ("cp", "${freeside_conf}.domain-template.txt", + "${freeside_conf}conf.DBI:mysql:$username/registries/internic/template" + ); +open(TO, ">${freeside_conf}conf.DBI:mysql:$username/registries/internic/to") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/registries/internic/to: $!"; +print TO "$email\n"; +close TO; + +open(SHELLS, ">${freeside_conf}conf.DBI:mysql:$username/shells") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/shells: $!"; +print SHELLS <${freeside_conf}conf.DBI:mysql:$username/smtpmachine") + or die "Can\'t open ${freeside_conf}conf.DBI:mysql:$username/smtpmachine: $!"; +print SMTPMACHINE "localhost\n"; +close SMTPMACHINE; + +#make counter dir +mkdir("/usr/local/etc/freeside/counters.DBI:mysql:$username",0755) + or die "Can't create counter spooldir: $!"; + +system("${freeside_bin}fs-setup.webdemo", "$username"); +system("${freeside_test}cgi-test", + "http://freeside.sisd.com/", $username, $user_pw); + +### + +$ENV{SMTPHOSTS} = "localhost"; +$ENV{MAILADDRESS} = 'ivan@sisd.com'; +$header = Mail::Header->new( [ + 'From: ivan@sisd.com', + "To: $email", + 'Cc: ivan-fsreg@sisd.com', + 'Sender: ivan@sisd.com', + 'Reply-To: ivan@sisd.com', + 'Date: '. time2str("%a, %d %b %Y %X %z", time), + 'Subject: Freeside demo information', +] ); +$msg = Mail::Internet->new( + 'Header' => $header, + 'Body' => [ +"Hello $name <$email>,\n", +"\n", +"Your sample Freeside database has been setup.\n", +"\n", +"Point your web browswer at http://freeside.sisd.com/ and use the following\n", +"authentication information:\n", +"\n", +"Username: $username\n", +"Password: $user_pw\n", +"\n", +"You may wish to subscribe to the Freeside mailing list - send a blank\n", +"message to ivan-freeside-subscribe\@sisd.com.\n", +"\n", +"-- \n", +"Ivan Kohler \n", +"20 4,16 \* \* \* saytime\n", + ] +); +$msg->smtpsend or die "Can\'t send registration email!"; + +### + +sub idiot { + my($error)=@_; + print $cgi->header, < + + Registration error + + +
+

Registration error

+
+

$error +

Hit the Back button in your web browser, correct this mistake, + and submit the form again. + + +END + + exit; + +}