#---------------------------------------------------------------------- # FILE: index.php #---------------------------------------------------------------------- # Author: Herman Van Keer, TuxyServices Inc - www.tuxyservices.com # index file # purpose: central piece of access to different parts of the promo application # use of templates: as requested through application # Last Update: 2006-06-20 # This PHP script is offered as is. #---------------------------------------------------------------------- # includes and init include("/home/www/lucrativelistbuilding.com/includes/lucrative_config.php"); include("{$config['includes']}lucrative_functions.php"); $var_array['message']=''; $command=strtolower(trim($_POST['command'])); # new registration if ( $_GET['command']=='newregistration' ) { # new registration reset values reset_values(); $var_array['message']=''; $template_file="register.html"; } elseif ( $_GET['command']=='logout' ) { log_out(); $template_file='login.html'; } elseif ( $command=='register' ) { # register applicant # verify data $ok++; $registration_values_array=set_registration_values(); while ( list($var,$description)=each($registration_values_array) ) { if ( empty($_POST[$var]) ) { $ok=0; $var_array['message'].="Missing $description
"; } } if ( $_POST['password1']!=$_POST['password2'] ) { $ok=0; $var_array['message'].='Passwords do NOT match!'; } # insert into database if ( $ok ) { # remove blanks from username $_POST['username']=ereg_replace(" ","",$_POST['username']); $ok=0; $registration_values_array=set_database_values(); while ( list($var,$desc)=each($registration_values_array) ) { $cols_array[]=$var; $values_array[]="'".addslashes($_POST[$var])."'"; $email_message.="$desc: ".$_POST[$var]."\n"; } # set password $cols_array[]='password'; $values_array[]="'".addslashes($_POST['password1'])."'"; $values=implode(',',$values_array); $cols=implode(',',$cols_array); $query="INSERT INTO promos ($cols) VALUES ($values)"; $db->query($query); switch($db->num_rows) { case 1: $ok++; break; case -1: $var_array['message']='Username already taken! Please choose another one'; break; default: $var_array['message']='Problems registering - please try again later'; break; } } # if OK we can continue, else back to register page if ( $ok ) { # auto login log_in($_POST['username']); # email to Glen email_glen('New subscription',$email_message); # email to autoresponder email_autoresponder(); # move to folowing page $template_file="update.html"; set_values(); reset_values(1); } else { $var_array['message']='Problems registering
'.$var_array['message']; set_values(); $template_file="register.html"; } } # check login elseif ( check_login() ) { if ( !empty($_POST['username']) && !empty($_POST['password']) ) { if ( check_user_login($_POST['username'],$_POST['password']) ) { $var_array['message']="Login failed!"; $template_file="login.html"; } else { get_promo_info($_SESSION['username']); $template_file="update.html"; } } else { $template_file="login.html"; } } # process command - we arrive here # because this is not a new registration and # we are logged in elseif ( $command ) { $javascript='register.js'; switch($command) { case 'log me in': $template_file="update.html"; get_promo_info($_SESSION['username']); break; case 'save changes': save_promo_info($_SESSION['username']); $template_file="update.html"; get_promo_info($_SESSION['username']); break; default: echo $_POST['command']; exit; break; } } else { $template_file="update.html"; get_promo_info($_SESSION['username']); } # template building and setup $template=new template("{$config['templates']}$template_file"); if ( !empty($javascript) ) { $template->insert_file("javascript","{$config['includes']}$javascript"); } else { $var_array['javascript']=''; } if ( $show_promo ) { $templat