#!/usr/bin/perl use strict; use CGI qw/:standard :html3 *table/; use CGI::Carp 'fatalsToBrowser'; use DBI; require "functions.pl"; our ($dbh,@states,@services,@industry,@professions,@cards,$base_dir); our ($owneremail,$ownerdesc,$sendmail,@templates,$url_base); our ($TMDBName,$TMDBUser,$TMDBPass,$DBHost,$tmuploaddir); our ($tmownerdesc,$tmowneremail); my ($action,$username,$password,$i,$j,$uid,$xx,$prn,$adate,$sdate); my ($rc,$sth,$ufh,$query,@buff,@content,@tmp,$q); my (%CookieData,$Cookie); my ($firm_name,$services,$industry,$profession,$day_phone,$evening_phone,$suite_no,$street); my ($city,$postal_code,$state,$addr_location,$description,$news,$file,$col,$bgcol); my ($to,$subject,$body); my ($salutation,$surname,$middle,$name,$email); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); my ($dbh2,$sth2,$rc2); my @colors=('#006644','#AF3060','#A38121'); my @bgcols=('#E9EBEF','#FFFFFF'); my $myname='engine.cgi'; # # # # # # # # # # # # # # # # # # # # # # # # Start. # # # # # # # # # # # # # # # # # # # # # # # # Get Action ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year=1900+$year; %CookieData=cookie("BizInc USA"); db_connect(); $action=(param('action'))?param('action'):""; if ($action eq "login"){ $username=(param('username'))?param('username'):""; $password=(param('password'))?param('password'):""; if($username eq "" || $password eq ""){ print_error('Invalid username or password!'); db_disconnect(); exit(100); } @buff=auth($username,$password,$sth); if($buff[0] eq '0'){ print_header('Biz Inc USA - Login incorrect.'); print_login(); print "
Login incorrect!
\n"; print_footer(); } else { if($buff[1] eq "Y"){ # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # getting users from database. $query="SELECT id,username,surname,middle,name,status,validated,create_date,activation_date,prn FROM basic_auth WHERE superuser='N' ORDER BY surname"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); undef(@buff); print<<"HTML";
HTML $i=0; while (@buff=$sth->fetchrow_array){ $bgcol=$bgcols[$i%2]; $i++; $col=$colors[0]; if ($buff[5] eq "inactive"){ $col=$colors[1]; } if ($buff[6] eq "N"){ $col=$colors[2]; } print<<"HTML"; HTML } print<<"HTML";
 #   Actions   Username   Full Name   Status   Valid   Signup Date   Activate On   PRN 
 $i  HTML if($buff[6] eq "Y"){ if ($buff[5] eq "inactive"){ print "\t\t\t\n"; } else { print "\t\t\t\n"; } print "\t\t\t\n"; } print<<"HTML";  $buff[1]   $buff[2] $buff[3]. $buff[4]   $buff[5]   $buff[6]   $buff[7]   $buff[8]   $buff[9] 
HTML print_footer(); } else { # non-superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # getting user's Settings. $uid=$buff[0]; $prn=$buff[9]; $sdate=$buff[10]; $adate=$buff[11]; $query="SELECT * from personal_info WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } @content=$sth->fetchrow_array; if (!defined(@content) || $content[0] eq ""){ $buff[0]=" Unavailable "; $buff[3]="false"; } else { $buff[0]=" Available "; } $query="SELECT template from web_temp WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } @content=$sth->fetchrow_array; if (!defined(@content) || $content[0] eq ""){ $buff[1]=" default "; } else { $buff[1]=" $content[0] "; } $tmp[0]=0; if (-f "$username/counter.dat"){ open (DAT,"$username/counter.dat"); @tmp=; close(DAT); } if ($tmp[0] =~ /[^0-9]\n/) { $tmp[0] = 0; } $buff[2]=$tmp[0]; print "Set-Cookie: $Cookie\n"; print_header("Welcome $buff[5] - BizInc USA"); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print<<"HTML";

 Site Status 
 Personal Information:  $buff[0]
 Current Template:  $buff[1]
 Visitors so far:   $buff[2] 
 Signup Date:   $sdate 
 Activation Date:   $adate 
 Your PRN:   $prn 


HTML if($buff[3] eq "false"){ print "
Please go and submit your personal information!
\n"; } print_footer(); } } } ############################################# ### End of action=login ############################################# ### Action Logout ############################################# elsif ($action eq "Logout"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Logout.'); print_login(); print "
User logout successful.
\n"; print_footer(); } elsif ($action eq "Personal Info"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $query="SELECT firm_name,services,industry,profession,day_phone,evening_phone,suite_no,street,city, postal_code,state,addr_location,description,news FROM personal_info WHERE id='$buff[0]'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } undef(@buff); @buff=$sth->fetchrow_array; $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Personal Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); if(!defined(@buff) || $buff[0] eq ""){ print_pers_info('','','','','','','','','','','','','','','Insert'); } else { print_pers_info(@buff,'Update'); } print_footer(); } } # # Web Template Form ###################### elsif ($action eq "Web Template"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=$buff[0]; $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user templates. $query="SELECT template FROM web_temp where id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } @buff=$sth->fetchrow_array(); $buff[1]="update"; if (!defined(@buff)){ $buff[0]='default'; $buff[1]='insert'; } if ($buff[0] eq ""){ $buff[0]='default'; $buff[1]='insert'; } print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Web Templates'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_web($buff[0],$uid,$buff[1]); print_footer(); } } #### Web Template Chosen ####################### elsif ($action eq "web_template"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); $uid=$buff[0]; $buff[0]=(param('t_style'))?param('t_style'):""; $buff[1]=(param('oper'))?param('oper'):""; if(!$buff[0] || $buff[0] eq "" || $buff[1] eq "" || !$buff[1]){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Web Template'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_web('',$uid); print "
Please choose a template!
\n"; $sth->finiesh(); db_disconnect(); print_footer(); exit(123); } else { if ($buff[1] eq "update"){ $query="UPDATE web_temp SET template='$buff[0]' WHERE id='$uid'"; } else { $query="INSERT INTO web_temp VALUES ('$uid','$buff[0]')"; } $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Web Template.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print "

Your option was successful stored into our database.
\n"; } print_footer(); } } #### Payment Info Form ####################### elsif ($action eq "Payment Info"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); $query="SELECT surname,middle,name,cc1,cc2,cc_type,expire_mon,expire_year,address, city,zip,state,tel,cvvs FROM payment_info WHERE id='$buff[0]'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } @buff=$sth->fetchrow_array(); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Payment Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_payment(@buff); print_footer(); } } #### Payment Info Update ####################### elsif ($action eq "do_payment"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); $uid=$buff[0]; $buff[0]=(param('ch_surname'))?param('ch_surname'):""; $buff[1]=(param('ch_middle'))?param('ch_middle'):""; $buff[2]=(param('ch_name'))?param('ch_name'):""; $buff[3]=(param('cc1'))?param('cc1'):""; $buff[4]=(param('cc2'))?param('cc2'):""; $buff[5]=(param('cc_type'))?param('cc_type'):""; $buff[6]=(param('expire_mon'))?param('expire_mon'):""; $buff[7]=(param('expire_year'))?param('expire_year'):""; $buff[8]=(param('address'))?param('address'):""; $buff[9]=(param('city'))?param('city'):""; $buff[10]=(param('zip'))?param('zip'):""; $buff[11]=(param('state'))?param('state'):""; $buff[12]=(param('tel'))?param('tel'):""; $buff[13]=(param('cvvs'))?param('cvvs'):""; if($buff[0] eq "" || $buff[1] eq "" || $buff[2] eq "" || $buff[3] eq "" || $buff[4] eq "" || $buff[5] eq "" || $buff[6] eq "" || $buff[7] eq "" || $buff[8] eq "" || $buff[9] eq "" || $buff[10] eq "" || $buff[11] eq "" || $buff[12] eq "" || $buff[13] eq ""){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Payment Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_payment(@buff); print "
One of the fields is empty!
\n"; } else { $buff[0]=quotemeta($buff[0]); $buff[1]=quotemeta($buff[1]); $buff[2]=quotemeta($buff[2]); $buff[3]=quotemeta($buff[3]); $buff[4]=quotemeta($buff[4]); $buff[8]=quotemeta($buff[8]); $buff[9]=quotemeta($buff[9]); $buff[10]=quotemeta($buff[10]); $buff[12]=quotemeta($buff[12]); $buff[13]=quotemeta($buff[13]); $query="UPDATE payment_info SET surname='$buff[0]',middle='$buff[1]',name='$buff[2]',cc1='$buff[3]', cc2='$buff[4]',cc_type='$buff[5]',expire_mon='$buff[6]',expire_year='$buff[7]', address='$buff[8]',city='$buff[9]',zip='$buff[10]',state='$buff[11]',tel='$buff[12]', cvvs='$buff[13]' WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Payment Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print "

The data was successful stored into our database.
\n"; } print_footer(); } } #### Basic Info Form #################### elsif ($action eq "Basic Info"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_basic($buff[4],$buff[5],$buff[6],$buff[7],$buff[8]); print_footer(); } } #### Basic Info Update ####################### elsif ($action eq "do_basic"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $surname=(param('surname'))?param('surname'):""; $salutation=(param('salutation'))?param('salutation'):""; $middle=(param('middle'))?param('middle'):""; $name=(param('name'))?param('name'):""; $email=(param('email'))?param('email'):""; $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); if ($salutation eq ""){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_basic($salutation,$surname,$middle,$name,$email); print "
Salutation field is empty!
\n"; print_footer(); } elsif ($surname eq ""){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_basic($salutation,$surname,$middle,$name,$email); print "
First name field is empty!
\n"; print_footer(); } elsif ($middle eq ""){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_basic($salutation,$surname,$middle,$name,$email); print "
Middle initial field is empty!
\n"; print_footer(); } elsif ($name eq ""){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_basic($salutation,$surname,$middle,$name,$email); print "
Last name field is empty!
\n"; print_footer(); } elsif ($email eq ""){ print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print_basic($salutation,$surname,$middle,$name,$email); print "
Email field is empty!
\n"; print_footer(); } else { $surname=quotemeta($surname); $middle=quotemeta($middle); $name=quotemeta($name); $email=quotemeta($email); $query="UPDATE basic_auth SET salutation='$salutation',surname='$surname',middle='$middle', name='$name',email='$email' WHERE id='$buff[0]'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Basic Info Change'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print "

Basic information successfuly changed.
\n"; print_footer(); } } } # New Password form elsif ($action eq "New Password"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); print "Set-Cookie: $Cookie\n"; if ($buff[1] eq "Y") { print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); } else { print_header('Biz Inc USA - Change Password.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); } print<<"HTML";
 Change Password 
 Old Password:    
 New Password:    
 Confirm Password:    
  
HTML print_footer(); } } # Change Password ################## elsif ($action eq "Change"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { my $oldpass=(param('old'))?param('old'):""; my $npass=(param('password'))?param('password'):""; my $cpass=(param('confirm'))?param('confirm'):""; my $err=""; if ($password ne $oldpass){ $err="Old password is incorrect!"; } if ($npass eq "" || $cpass eq ""){ $err="New password, or password confirmation is invalid!"; } if ($npass ne $cpass){ $err="Passwords do not match!"; } if ($err eq ""){ $cpass=quotemeta($npass); $query="UPDATE basic_auth SET password='$cpass' WHERE id='$buff[0]'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } $password=$npass; } $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); print "Set-Cookie: $Cookie\n"; if ($buff[1] eq "Y") { print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); } else { print_header('Biz Inc USA - Password Change'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); } if ($err eq ""){ print "

Password successfuly changed.
\n"; } else { print "

$err
\n"; } print_footer(); } } ### Main ######################################## elsif ($action eq "Main"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # getting users from database. $query="SELECT id,username,surname,middle,name,status,validated,create_date,activation_date,prn FROM basic_auth WHERE superuser='N' ORDER BY surname"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); undef(@buff); print<<"HTML";
HTML $i=0; while (@buff=$sth->fetchrow_array){ $bgcol=$bgcols[$i%2]; $i++; $col=$colors[0]; if ($buff[5] eq "inactive"){ $col=$colors[1]; } if ($buff[6] eq "N"){ $col=$colors[2]; } print<<"HTML"; HTML } print<<"HTML";
 #   Actions   Username   Full Name   Status   Valid   Signup Date   Activate On   PRN 
 $i  HTML if($buff[6] eq "Y"){ if ($buff[5] eq "inactive"){ print "\t\t\t\n"; } else { print "\t\t\t\n"; } print "\t\t\t\n"; } print<<"HTML";  $buff[1]   $buff[2] $buff[3]. $buff[4]   $buff[5]   $buff[6]   $buff[7]   $buff[8]   $buff[9] 
HTML print_footer(); } } ### View payment info. elsif ($action eq "View"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # getting users from database. $query="SELECT a.surname,a.middle,a.name,a.cc1,a.cc2,a.cc_type,a.expire_mon,a.expire_year, a.address,a.city,a.zip,a.state,a.tel,a.cvvs,b.username,b.status FROM payment_info a, basic_auth b WHERE a.id='$uid' AND a.id=b.id"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } undef(@buff); @buff=$sth->fetchrow_array; print "Set-Cookie: $Cookie\n"; print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print<<"HTML";
 $buff[14]'s payment info:  HTML if ($buff[15] eq "inactive"){ print "\t\t\t\n"; }else { print "\t\t\t\n"; } print<<"HTML";
 Card Holder Full Name:   $buff[0] $buff[1]. $buff[2] 
 Credit Card No.:   $buff[3]-$buff[4] 
 Credit Card Type:   $buff[5] 
 Card Expiration Date:   $buff[6]/$buff[7] 
 Statement Address:   $buff[8] 
 Statement City:   $buff[9] 
 Statement Zip Code:   $buff[10] 
 Statement State:   $buff[11] 
 Card Holder Tel#:   $buff[12] 
 CVVS Code:   $buff[13] 
HTML print_footer(); } } ### Activate an account elsif ($action eq "Activate"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $query="SELECT username,salutation,surname,middle,name,email,prn FROM basic_auth WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } undef(@buff); @buff=$sth->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find user in the database! Exit!'); $sth->finish(); db_disconnect(); exit(433); } # Create directory if necessary and adding index. if (!-d $buff[0]){ mkdir $buff[0]; if (!open(DAT,"user.dat")) { $sth->finish(); db_disconnect(); print_error ("Cannont create user.dat file!","Activation impossible!"); exit(213); } else { @tmp=; close(DAT); } if (!open(CGIFILE,">","$buff[0]/index.cgi")){ $sth->finish(); db_disconnect(); print_error ("Cannont create user's index.cgi file!","Exit!"); exit(211); } else { foreach $xx (@tmp){ $xx =~ s/_ID_/$uid/g; print CGIFILE "$xx"; } close(CGIFILE); chmod 0755,"$buff[0]/index.cgi"; } } # Updating status into database $query="UPDATE basic_auth SET status='active',activation_date=now() WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } # We send a mail to the customer. open (TEXT,"text/activation.txt"); @content=; close(TEXT); open (MAIL,"|$sendmail"); print MAIL "From: $ownerdesc <$owneremail>\n"; print MAIL "To: $buff[2] $buff[3]. $buff[4] <$buff[5]>\n"; print MAIL "Subject: [BizIncUSA] Your account was activated.\n\n"; foreach $xx (@content){ $xx=~ s/var\_salutation/$buff[1]/g; $xx=~ s/var\_firstname/$buff[2]/g; $xx=~ s/var\_middle/$buff[3]/g; $xx=~ s/var\_lastname/$buff[4]/g; $xx=~ s/var\_prn/$buff[6]/g; $xx=~ s/var\_username/$buff[0]/g; print MAIL "$xx"; } close(MAIL); # print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Account \"$buff[0]\" was successful activated.
\n"; print_footer(); } } ### DE-Activate an account elsif ($action eq "Deactivate"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $query="SELECT username,salutation,surname,middle,name,email,prn FROM basic_auth WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } undef(@buff); @buff=$sth->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find user in the database! Exit!'); $sth->finish(); db_disconnect(); exit(433); } # Updating status into database $query="UPDATE basic_auth SET status='inactive' WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } # We send a mail to the customer. open (TEXT,"text/deactivation.txt"); @content=; close(TEXT); open (MAIL,"|$sendmail"); print MAIL "From: $ownerdesc <$owneremail>\n"; print MAIL "To: $buff[2] $buff[3]. $buff[4] <$buff[5]>\n"; print MAIL "Subject: [BizIncUSA] Your account was deactivated.\n\n"; foreach $xx (@content){ $xx=~ s/var\_salutation/$buff[1]/g; $xx=~ s/var\_firstname/$buff[2]/g; $xx=~ s/var\_middle/$buff[3]/g; $xx=~ s/var\_lastname/$buff[4]/g; $xx=~ s/var\_prn/$buff[6]/g; $xx=~ s/var\_username/$buff[0]/g; print MAIL "$xx"; } close(MAIL); # print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Account \"$buff[0]\" was successful deactivated.
\n"; print_footer(); } } ### DELETE action, will require confirmation elsif ($action eq "Delete"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $query="SELECT username,salutation,surname,middle,name,email,prn FROM basic_auth WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } undef(@buff); @buff=$sth->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find user in the database! Exit!'); $sth->finish(); db_disconnect(); exit(433); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print<<"HTML";

Are you sure you want to delete user $buff[0] [$buff[2] $buff[3]. $buff[4]]?


  Yes     No   
HTML print_footer(); } } ### DELETE an account (confirmed) elsif ($action eq "Confirm"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $query="SELECT username,salutation,surname,middle,name,email,prn FROM basic_auth WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } undef(@buff); @buff=$sth->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find user in the database! Exit!'); $sth->finish(); db_disconnect(); exit(433); } #cleaning the directory! if (-d $buff[0]){ opendir(DIR, $buff[0]); @content=readdir(DIR); closedir DIR; foreach(@content){ unlink "$buff[0]/$_"; } rmdir $buff[0]; } # Delete User from all tables. $query="DELETE FROM basic_auth WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } $query="DELETE FROM web_temp WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } $query="DELETE FROM payment_info WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } $query="DELETE FROM personal_info WHERE id='$uid'"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Account \"$buff[0]\" was successful deleted.
\n"; print_footer(); } } ### Send Emails Form elsif ($action eq "Email"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting userlist from database $query="SELECT surname,name,email,username FROM basic_auth WHERE superuser='N' ORDER BY username"; $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print<<"HTML";

 Send email to users 
 To:    
 Subject:    
 Message:   
  
HTML print_footer(); } } ### Execute Send Email elsif ($action eq "Send"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $to=(param('target'))?param('target'):""; $subject=(param('subject'))?param('subject'):""; $body=(param('body'))?param('body'):""; if ($to eq "" || $subject eq "" || $body eq ""){ print_error('One of the params are missing. '); $sth->finish(); db_disconnect(); exit(400); } if($to eq "All"){ $query="SELECT surname,name,email FROM basic_auth WHERE superuser='N' ORDER BY surname"; } elsif ( $to eq "All Subscribed") { $query="SELECT a.surname,a.name,a.email FROM basic_auth a, personal_info b, WHERE a.superuser='N' AND a.id=b.id AND b.news='Y' AND a.status='active' ORDER BY surname"; } elsif ( $to eq "All Active") { $query="SELECT surname,name,email FROM basic_auth WHERE superuser='N' AND status='active' ORDER BY surname"; } elsif ( $to eq "All Inactive") { $query="SELECT surname,name,email FROM basic_auth, WHERE superuser='N' AND status='inactive' ORDER BY surname"; } else { $query=""; } $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); if ($query eq ""){ open (MAIL,"|$sendmail"); print MAIL "From: $ownerdesc <$owneremail>\n"; print MAIL "To: $to\n"; print MAIL "Subject: [BizIncUSA] $subject.\n\n"; print MAIL "$body"; close(MAIL); print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Mail successfuly sent to $to.
\n"; print_footer(); } else { # Getting userlist from database $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Please wait. Sending emails...
\n"; print_footer(); while (@buff=$sth->fetchrow_array){ open (MAIL,"|$sendmail"); print MAIL "From: $ownerdesc <$owneremail>\n"; print MAIL "To: $buff[0] $buff[1] <$buff[2]>\n"; print MAIL "Subject: [BizIncUSA] $subject.\n\n"; print MAIL "$body"; close(MAIL); print "
To: $buff[0] $buff[1] ($buff[2])
\n"; } print "
Task Completed!

\n"; print_footer(); } } } ### TRADEMARK MAIN ######################################## elsif ($action eq "Trademark"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # getting trademarks from database. $dbh2 = DBI->connect("dbi:mysql:dbname=$TMDBName;host=$DBHost","$TMDBUser","$TMDBPass", { PrintError => 0, RaiseError => 0, AutoCommit => 1 }); if (!defined($dbh2)){ print_error("Database Error:","$DBI::errstr"); $sth->finish(); db_disconnect(); exit(1); } $query="SELECT id,firstname,middle,lastname,trdmk_type,tgs,status,date,req_serv,amount FROM trademark ORDER BY status"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc2) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); undef(@buff); print<<"HTML";
HTML $i=0; while (@buff=$sth2->fetchrow_array){ $bgcol=$bgcols[$i%2]; $i++; if ($buff[6] eq "waiting"){ $col=$colors[0]; } else { $col="#003366"; } print<<"HTML"; HTML } print<<"HTML";
 #   Actions   Full Name   Service Requested   Trademark Type   T.o.G   Status   Request ID   Date 
 $i   $buff[1] $buff[2]. $buff[3]   (\$$buff[9]) $buff[8]   $buff[4]   $buff[5]   $buff[6]   #$buff[0]   $buff[7] 
HTML print_footer(); $sth2->finish(); $dbh2->disconnect(); } } ### View trademark request details ################################### elsif ($action eq "tmview"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # getting informations from database. $dbh2 = DBI->connect("dbi:mysql:dbname=$TMDBName;host=$DBHost","$TMDBUser","$TMDBPass", { PrintError => 0, RaiseError => 0, AutoCommit => 1 }); if (!defined($dbh2)){ print_error("Database Error:","$DBI::errstr"); $sth->finish(); db_disconnect(); exit(1); } $query="SELECT req_serv,amount,firstname,middle,lastname,dayphone,eveningphone, companyname,statecountry,appaddress,appcity,appstate,appzip,cpfirstname,cplastname, cemail,trdmk_type,tgs,bizaddress,bizcity,bizstate,bizzip,cvvs,logo,text,cctype,ccno, ccexpdate,ccaddress,cccity,ccstate,cczip,randstr,status FROM trademark WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc2) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(1); } undef(@buff); @buff=$sth2->fetchrow_array; print "Set-Cookie: $Cookie\n"; print_header("Welcome to BizInc USA administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); if ($buff[23] ne ""){ $buff[23]="Click here..."; } else { $buff[23]="-"; } if ($buff[24] eq ""){ $buff[24]="-"; } else { $buff[24]="".$buff[24].""; } print<<"HTML";
 Registration Details 
 Services Requested:   $buff[0] (\$$buff[1])
 Full Name:   $buff[2] $buff[3]. $buff[4]
 Daytime Phone:   $buff[5]
 Evening Phone:   $buff[6]
 Company Name:   $buff[7]
 State/Country of Incorporation:   $buff[8]
 Applicant's Address:   $buff[9]
 Applicant's City:   $buff[10]
 Applicant's State:   $buff[11]
 Applicant's Zip:   $buff[12]
 Contact Person Full Name:   $buff[13] $buff[14]
 Contact Email Address:   $buff[15]
 Type of Trademark:   $buff[16]
 Type of Goods or Services:   $buff[17]
 Business Address:   $buff[18]
 Business City:   $buff[19]
 Business State:   $buff[20]
 Business Zip:   $buff[21]
 CVVS Code:   $buff[22]
 Logo Image:   $buff[23]
 Words/Phrase:   $buff[24]
 Credit Card Type:   $buff[25]
 Credit Card No.:   $buff[26]
 Credit Card Expiration Date:   $buff[27]
 Credit Card Address:   $buff[28]
 Credit Card City:   $buff[29]
 Credit Card State:   $buff[30]
 Credit Card Zip:   $buff[31]
 Status:   $buff[33]
HTML print_footer(); $sth2->finish(); $dbh2->disconnect(); } } ### TRADEMARK DELETE action, will require confirmation elsif ($action eq "tmdel"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $dbh2 = DBI->connect("dbi:mysql:dbname=$TMDBName;host=$DBHost","$TMDBUser","$TMDBPass", { PrintError => 0, RaiseError => 0, AutoCommit => 1 }); if (!defined($dbh2)){ print_error("Database Error:","$DBI::errstr"); $sth->finish(); db_disconnect(); exit(1); } $query="SELECT firstname,middle,lastname FROM trademark WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); $sth->finish(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc2) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconeect(); exit(1); } undef(@buff); @buff=$sth2->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find this request in the database! Exit!'); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(433); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print<<"HTML";

Are you sure you want to delete request #$uid [$buff[0] $buff[1]. $buff[2]]?


  Yes     No   
HTML print_footer(); $sth2->finish(); $dbh2->disconnect(); } } ### DELETE a TRADEMARK Request (confirmed) elsif ($action eq "tmdelconf"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $dbh2 = DBI->connect("dbi:mysql:dbname=$TMDBName;host=$DBHost","$TMDBUser","$TMDBPass", { PrintError => 0, RaiseError => 0, AutoCommit => 1 }); if (!defined($dbh2)){ print_error("Database Error:","$DBI::errstr"); $sth->finish(); db_disconnect(); exit(1); } # Looking for files $query="SELECT logo,result FROM trademark WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(1); } undef(@buff); @buff=$sth2->fetchrow_array; if ($buff[0] && $buff[0] ne ""){ unlink "$tmuploaddir/$buff[0]"; } if ($buff[1] && $buff[1] ne ""){ unlink "$tmuploaddir/$buff[1]"; } # Delete User from all tables. $query="DELETE FROM trademark WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(1); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Request #$uid was successful deleted.
\n"; print_footer(); $sth2->finish(); $dbh2->disconnect(); } } ### TRADEMARK Upload Form elsif ($action eq "tmupdate"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $dbh2 = DBI->connect("dbi:mysql:dbname=$TMDBName;host=$DBHost","$TMDBUser","$TMDBPass", { PrintError => 0, RaiseError => 0, AutoCommit => 1 }); if (!defined($dbh2)){ print_error("Database Error:","$DBI::errstr"); $sth->finish(); db_disconnect(); exit(1); } $query="SELECT firstname,middle,lastname,randstr FROM trademark WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); $sth->finish(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc2) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconeect(); exit(1); } undef(@buff); @buff=$sth2->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find this request in the database! Exit!'); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(433); } print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print<<"HTML";

 Results for $buff[0] $buff[1]. $buff[2] 
 Results File:  
  
HTML print_footer(); $sth2->finish(); $dbh2->disconnect(); } } ### TRADEMARK Upload and Notify user. elsif ($action eq "tmupfile"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0' || $buff[1] ne "Y"){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $uid=(param('id'))?param('id'):""; $file=(param('resfile'))?param('resfile'):""; if ($uid eq ""){ print_error('Parameter id not defined. EXIT!'); $sth->finish(); db_disconnect(); exit(400); } # Superusers. $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); # Getting user from database $dbh2 = DBI->connect("dbi:mysql:dbname=$TMDBName;host=$DBHost","$TMDBUser","$TMDBPass", { PrintError => 0, RaiseError => 0, AutoCommit => 1 }); if (!defined($dbh2)){ print_error("Database Error:","$DBI::errstr"); $sth->finish(); db_disconnect(); exit(1); } $query="SELECT firstname,middle,lastname,randstr,cpfirstname,cplastname,cemail FROM trademark WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); $sth->finish(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc2) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconeect(); exit(1); } undef(@buff); @buff=$sth2->fetchrow_array; if (!defined(@buff) || $buff[0] eq ""){ print_error('Cannot find this request in the database! Exit!'); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconnect(); exit(433); } #### Receiving file if ($file ne ""){ $q = new CGI; $file=~ /.*\.(.*)$/; my $ufh = $q->upload('resfile'); $file="res-".$buff[3].".".$1; if(open(UPLOADFILE, ">$tmuploaddir/$file")){ while ( <$ufh> ) { print UPLOADFILE; } close UPLOADFILE; } else { print_error('Error uploading file!'); exit(12); } } # Database update $query="UPDATE trademark SET status='checked',result='$file' WHERE id='$uid'"; $sth2 = $dbh2->prepare($query); if (!$sth2) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); $sth->finish(); $dbh2->disconnect(); exit(1); } $rc2=$sth2->execute; if (!$rc2) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); $sth2->finish(); $dbh2->disconeect(); exit(1); } ### Send e-mail to the customer . open (MAIL,"|$sendmail"); print MAIL "From: $tmownerdesc <$tmowneremail>\n"; print MAIL "To: $buff[4] $buff[5] <$buff[6]>\n"; print MAIL "Subject: Trademark Search Results Ready!\n\n"; print MAIL "\n\n\t\tDear $buff[4],\n\n"; print MAIL "Your trademark Search results are available for viewing. Please click \n"; print MAIL "on the link below to download your results. If your email program \n"; print MAIL "does not allow for direct connect to the link, copy and past the link \n"; print MAIL "in your browser.\n\n"; print MAIL "$url_base/tmkview.cgi?id=$uid&str=$buff[3]\n\n"; print MAIL "If you have any questions regarding your search results, or would like \n"; print MAIL "to apply for the trademark based on the results and our comments, \n"; print MAIL "please email trademarks\@bizincusa.com .\n\n"; print MAIL "Also, If you need any of the following services, do not hesitate to \n"; print MAIL "contact us for a quote:\n\n"; print MAIL "Incorporate a Business\n"; print MAIL "Form an LLC\n"; print MAIL "Domain Registration\n"; print MAIL "Website Design (from \$399)\n"; print MAIL "Website Hosting ( \$6.99 / mo)\n"; print MAIL "Merchant Account (Accept Credit Cards)\n"; print MAIL "Need a CPA (Discounts Apply)\n"; print MAIL "Need an Attorney (Referral Discounts in network)\n\n"; print MAIL "401(k) Pension Plan Rollover\n"; print MAIL "Annuities\n"; print MAIL "Life Insurance\n"; print MAIL "Health Insurance\n"; print MAIL "Group Health Insurance\n"; print MAIL "Disability Income Insurance\n"; print MAIL "Homeowners Insurance\n"; print MAIL "Automobile Insurance\n\n\n\n"; print MAIL "Let us know what your needs are, we will be more than happy to assist you!\n\n"; print MAIL "Bizincusa.com\n888-INC-9995\n\n"; close(MAIL); ### end e-mail print "Set-Cookie: $Cookie\n"; print_header("BizInc USA - Administration page"); print_menu('Main','Email','New Password','Trademark','Logout'); print "

Results for request no. $uid was successful updated.
\n"; print_footer(); $sth2->finish(); $dbh2->disconnect(); } } ### Update/Insert Personal Information. # # # # # # # # # # # # # # # # # # # # elsif ($action eq "Update" || $action eq "Insert"){ $username=$CookieData{'username'}; $password=$CookieData{'password'}; @buff=auth($username,$password,$sth); if ($buff[0] eq '0'){ $CookieData{'username'}=""; $CookieData{'password'}=""; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => 'now' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Session Expired.'); print_login(); print "
Your session has expired. Please re-login.
\n"; print_footer(); } else { $firm_name=(param('firm_name'))?param('firm_name'):""; $firm_name=quotemeta($firm_name); $services=(param('services'))?param('services'):""; $industry=(param('industry'))?param('industry'):""; $profession=(param('profession'))?param('profession'):""; $day_phone=(param('day_phone'))?param('day_phone'):""; $day_phone=quotemeta($day_phone); $evening_phone=(param('evening_phone'))?param('evening_phone'):""; $evening_phone=quotemeta($evening_phone); $suite_no=(param('suite_no'))?param('suite_no'):""; $suite_no=quotemeta($suite_no); $street=(param('street'))?param('street'):""; $street=quotemeta($street); $city=(param('city'))?param('city'):""; $city=quotemeta($city); $postal_code=(param('postal_code'))?param('postal_code'):""; $postal_code=quotemeta($postal_code); $state=(param('state'))?param('state'):""; $addr_location=(param('addr_location'))?param('addr_location'):"Office"; $description=(param('description'))?param('description'):""; $description=quotemeta($description); $news=(param('news'))?param('news'):"N"; $file=(param('file'))?param('file'):""; # File upload part. if($file ne "" ){ $q = new CGI; if ($file =~ /\.jpg/i){ $file="jpg"; } elsif ($file =~ /\.gif/i){ $file="gif"; } else { print_error('Your file is not an .jpg or .gif file.'); $sth->finish(); db_disconnect(); exit(11); } unlink 'image.gif'; unlink 'image.jpg'; $ufh = $q->upload('file'); if(open(UPLOADFILE, ">$base_dir/$username/image.$file")){ while ( <$ufh> ) { print UPLOADFILE; } close UPLOADFILE; } else { print_error('Error uploading file!'); $sth->finish(); db_disconnect(); exit(12); } } # End of file upload. if ($action eq "Insert"){ $query="INSERT INTO personal_info VALUES ('$buff[0]','$firm_name','$services','$industry','$profession', '$day_phone','$evening_phone','$suite_no','$street','$city','$postal_code','$state','$addr_location','$description','$news')"; } else { $query="UPDATE personal_info SET firm_name='$firm_name',services='$services', industry='$industry',profession='$profession',day_phone='$day_phone', evening_phone='$evening_phone',suite_no='$suite_no',street='$street', city='$city', postal_code='$postal_code',state='$state',addr_location='$addr_location', description='$description',news='$news' WHERE id='$buff[0]'"; } $sth = $dbh->prepare($query); if (!$sth) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$sth->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $sth->finish(); db_disconnect(); exit(1); } $CookieData{'username'}=$username; $CookieData{'password'}=$password; $Cookie=cookie( -name => "BizInc USA", -value => \%CookieData, -expires => '+120m' ); print "Set-Cookie: $Cookie\n"; print_header('Biz Inc USA - Personal Information.'); print_menu('Basic Info','Payment Info','Personal Info','Web Template','New Password','Logout'); print "

The data was successful stored into our database.
\n"; print_footer(); } } ### Default else { print_header('BizInc USA - Members Login'); print_login(); print_footer(); db_disconnect(); exit(0); } if ($sth) { $sth->finish(); } db_disconnect(); # # # # # # # # # # # # # # # # # # # # # # # # # Subroutines # # # # # # # # # # # # # # # # # # # # # # # sub print_menu{ print<<"HTML";
HTML foreach (@_){ print<<"HTML"; HTML } print<<"HTML";
$_
HTML } sub print_login{ print<<"HTML"

 Registered users login 
 Login:    
 Password:    
  
 
 
New Members sign up.
Search for a CPA, Attorney,Financial Planner.
Forgot your password? Click here!
HTML } # user authentication sub auth{ #db_connect(); my $a=quotemeta($_[0]); my $b=quotemeta($_[1]); my @ret; $query="SELECT id,superuser,status,validated,salutation,surname,middle,name,email,prn,create_date,activation_date FROM basic_auth WHERE username='$a' AND password='$b'"; $_[2] = $dbh->prepare($query); if (!$_[2]) { print_error("[DBI]: Prepare Error Occured!",$DBI::errstr); db_disconnect(); exit(1); } $rc=$_[2]->execute; if (!$rc) { print_error("[DBI]: Execute Error Occured!",$DBI::errstr); $_[2]->finish(); db_disconnect(); exit(1); } @ret=$_[2]->fetchrow_array; if (defined(@ret) || $ret[0] ne ""){ # Validate Test if ($ret[3] eq 'N'){ print_header('BizInc USA - Login Invalid'); print_login(); print "
This account was not yet validated by the owner!
\n"; print_footer(); $_[2]->finish(); db_disconnect(); exit(113); } # Active Test if ($ret[2] eq 'inactive'){ print_header('BizInc USA - Account Inactive'); print_login(); print "
This account is inactive!
\n"; print_footer(); $sth->finish(); db_disconnect(); exit(113); } return(@ret); } else { undef(@ret); $ret[0]=0; return(@ret); } } sub print_pers_info{ print<<"HTML";
 Personal Information 
 Firm/Business Name:    
 Services Provided:   
 Industry serviced:   
 Profession:    
 Daytime Phone:    
 Evening Phone:    
 Suite Number:    
 Street Address:    
 City:    
 Postal Code:    
 State:   
 Is the address listed your  HTML if ($_[11] eq "Home"){ print "\t\t\t\t Office\n"; print "\t\t\t\t Home \n"; } else { print "\t\t\t\t Office\n"; print "\t\t\t\t Home \n"; } print<<"HTML";
 Image (jpg/gif):  
 Firm Description: 
HTML if($_[13] eq "N"){ print "\t\t\t\t  \n"; } else { print "\t\t\t\t  \n"; } print<<"HTML"; Please send me the monthy Professionals Network NewsLetter 
  
HTML } sub print_basic { print<<"HTML";
<