require_once('include/functions.php');
// require_once('include/regformClass.php'); CC: temporarily deleted to test the ...-OK version (Sep1407)
require_once('include/regformClass-14Sep07.php');
require_once('include/participant.php');
require_once('include/application.php');
require_once('include/user.php');
require_once('common/database.php');
require_once('common/properties.php');
error_reporting(7);
function checkParticipantForm(){
$return = 0;
if ((getVar("firstName")!="")&&(getVar("lastName")!="")&&(getVar("email")!="")&&(getVar("phone")!="")&&(getVar("address")!="")&&(getVar("city")!="")&&(getVar("country")!="")&&(getVar("zip")!="")){
$return = 1;
}
return $return;
}
function addToSubscription($email,$cConf){
# grab conference abreviation
$sql = "select confAbrev from conference where idConference = $cConf";
$result = mysql_query($sql);
$r = mysql_fetch_array($result);
# check if user already is subscribed for conference
$sql = "select * from subscription where email = '$email' and listName = '".$r[0]."'";
$result = mysql_query($sql);
if (!mysql_num_rows($result)){
# add to mailling list
$sql = "insert into subscription ( email, listName ) values ('$email','".$r[0]."')";
mysql_query($sql);
}
} // addToSubscription
function clearUserVars($t){
$t['title']="";
$t['firstName']="";
$t['middleName']="";
$t['lastName']="";
$t['email']="";
$t['workTitle']="";
$t['affiliation']="";
$t['phone']="";
$t['fax']="";
$t['ext']="";
$t['address']="";
$t['city']="";
$t['state']="";
$t['country']="";
$t['zip']="";
$t['description']="";
return $t;
} // clearUserVars
function confirm($eml,$p){
//conference info
global $db;
$query = "select * from conference where idConference = ".getVar("cConf");
$result = mysql_query($query,$db->con);
$a = mysql_fetch_array($result);
$query = "select * from user where email = '$eml'";
$result = mysql_query($query,$db->con);
$pp = mysql_fetch_array($result);
$p = array_merge( $p, $pp );
/*print_r($a);
echo "
";
print_r($p);
Work title: ".$p['workTitle']."
Description: ".$p['description']."
*/
$personalInfo = "Personal information:\n
Name: ".$pp['title']." ".$pp['firstName']." ".$pp['middleName']." ".$pp['lastName']."
Email: ".$pp['email']."
Affiliation: ".$pp['affiliation']."
Work phone: ".$pp['phone']." fax : ".$pp['fax']." ext : ".$pp['ext']."
Address: ".$pp['street'].", ".$pp['city']." ".$pp['state']." ".$pp['zip']."\n\tCountry: ".$pp['country']."
\n\nConference information:";
if ( $p['presenterType']>0 ){
$query = "select * from application where email = '$eml' and idConference = ".getVar("cConf");
$result = mysql_query($query,$db->con);
$p = array_merge( $p, mysql_fetch_array($result) );
$personalInfo.="\n\nTitle #1: ".stripslashes($p['title'])."\nAuthor: ".$p['author']."\nAuthor's email: ".$p['emailAuthor']."\nAuthor's affiliation: ".$p['affiliation']."\nOther information: ".stripslashes($p['info'])."\nAbstract #1:".$p['abstract'];
if ( $p['title2'] ){
$personalInfo .= "\n\nTitle #2: ".stripslashes($p['title2'])."\nAuthor: ".$p['author2']."\nAuthor's email: ".$p['emailAuthor2']."\nAuthor's affiliation: ".$p['affiliation2']."\nOther information: ".stripslashes($p['info2'])."\nAbstract #2:".$p['abstract2'];
}
$personalInfo .= "\n\nComments :\n".$p['info3'];
$cost = $a[$p['feeType']."Fee"]+$p['meals']*$a['mealPrice'];
}else {
$cost = $a[$p['feeType']."Fee"]+$p['meals']*$a['mealPrice'];
}
$personalInfo .="\n
fee type: ".$p['feeType']."
extra meal(s): ".$p['meals'];
$personalInfo .= "\nOverall payment due: $ ".$cost."\nThank you.";
$message="Dear Participant,\n\tWe have received your registration form for ".$a['name'];
$message.=". You provided the following information:\n\n".$personalInfo;
$message.="\n\n============================================================
Please do not reply to this email. This is an automated response letter.";
$headers = "From: ".$pp['firstName']." ".$pp['lastName']." <".$eml.">";
if ( mail($eml,"Registration to ".$a['name'],stripslashes($message),$headers)){
//output on screen
$out = "Thank you for registration.
Email has been sent to you.
Back";
$message = "Following participant has registred for the conference (".$a['name']."):\n".$personalInfo;
$message.="\n\n============================================================
Please do not reply to this email. This is an automated response letter.";
if ( strlen($a['sendEmail'])>0 ){
mail($a['sendEmail'],"Registration to ".$a['name'],stripslashes($message),$headers);
}
}else $out = "It was unable to send you email. Please verificate your email address and try again.
Back";
return $out;
} // confirm
function application($e){
Global $HTTP_POST_VARS;
Global $app,$c;
$ret = 0;
if ( getVar("action")=="Register" ){
if ((getVar("title")!="")&&(getVar("presenterType")>0)) {
if ( getVar("author")=="" ) $HTTP_POST_VARS['author']=getVar("title")." ".getVar("firstName")." ".getVar("middleName")." ".getVar("lastName");
if ( getVar("affiliation")=="" ) $HTTP_POST_VARS['affiliation'] = getVar("affiliation");
if ( getVar("address")=="" ) $HTTP_POST_VARS['address'] = getVar("address");
if ( getVar("city")=="" ) $HTTP_POST_VARS['city'] = getVar("city");
if ( getVar("state")=="" ) $HTTP_POST_VARS['state'] = getVar("state");
if ( getVar("zip")=="" ) $HTTP_POST_VARS['zip'] = getVar("zip");
if ( getVar("emailAuthor")=="" ) $HTTP_POST_VARS['emailAuthor'] = getVar("email");
if ( addApplication($e) ) {
$ret = 1;
}
}else {
if ( getVar("presenterType")==0 ) $caption = "You should choose appropriate presenter type";
else $caption.="if you choose presentation type you have to provide at least title";
if (getVar("email")!=""){
$HTTP_POST_VARS['emailDB'] = getVar("email");
// $HTTP_POST_VARS = clearUserVars($HTTP_POST_VARS);
}
global $cConf;
echo $c->conference($cConf,$HTTP_POST_VARS,$caption);
exit;
}
}else{//presenter type NONE
$p=$HTTP_POST_VARS;
$p['email']=$e;
$p['title']="";
$p['author']="";
$p['abstract']="";
$p['affiliation']="";
$p['presenterType']="0";
$p['address']="";
$p["city"]="";
$p['state']="";
$p['zip']="";
$p['emailAuthor']="";
$p['info']="";
//TEMPORARY
$p['newsletter']=0;
$p['resignation']=0;
if ( getVar("upApp")=="yes" ) {
$app->db("update",$p);
}
else {
$re = $app->db("get","email='".$e."' and idConference=".getVar("idConference"));
if ( mysql_num_rows($re)==0 ) $app->db("add",$p);
else $ret=0;
}
if ( mysql_errno()==0 ){
$ret=1;
}
}
return $ret;
} // application
function addApplication($e){
Global $HTTP_POST_VARS;
Global $app;
$p=$HTTP_POST_VARS;
$p['email']=$e;
$p['title']=getVar("title");
$p['affiliation']=getVar("affiliation");
$p['address']=getVar("address");
$p["city"]=getVar("city");
$p['state']=getVar("state");
$p['zip']=getVar("zip");
$p['info']=getVar("info");
// TEMPORARY
$p['newsletter']=0;
$p['resignation']=0;
if ( getVar("upApp")=="yes" )
$r = $app->db("update",$p);
else {
$re = $app->db("get","email='".$e."' and idConference=".getVar("idConference"));
if ( mysql_num_rows($re)==0 ) $app->db("add",$p);
}
if ( mysql_errno()==0 ){
// no error
return 1;
}else return 0;
} // addApplication
//************************************************************************************************
$db = new DataBase($property['host'],$property['user'], $property['password'],$property['name']);
$app = new Application();
$par = new Participant();
$c = new Regform;
$caption="";
$action = getVar("action");
if ( $action=="" ){ // empty form
echo $c->conference($cConf,"","");
}elseif ($action == "Update" || $action=="submit" || $action=="Go" || $action == "Answer" ||$action == "Send me my password"){
echo $c->conference($cConf,"","","2");
}elseif ($action == "Submit"){
$option = getVar("option");
$user = new User(getVar("email"),$db->con);
switch($option) {
// edit personal data
case 2 : {
if ($user->checkEmailDB() )
echo $c->conference($cConf,"","Edit personal data","2");
else
echo $c->conference($cConf,"","No user in database
Please register first ".$firstTime,"2");
break;
}
// unregister from conference
case 3: {
if ($user->checkEmailDB() )
echo $c->conference($cConf,"","Unsubscribe
Please provide password for ".getVar("email")."","3");
else
echo $c->conference($cConf,"","No user in database
You are not subscribed for this conference");
break;
}
/*
// log in to the system
case 1 : {
if ($user->checkEmailDB() )
echo $c->conference($cConf,"","Provide your password","3");
else
echo $c->conference($cConf,"","No user in database
Please register first");
break;
} */
// registering new person
case 0 : {
if ($user->checkEmailDB() )
echo $c->conference($cConf,"","User is already in database.
Please provide password for ".getVar("email")."","3");
else
echo $c->conference($cConf,"",$firstTime,"2");
break;
}
}
}
elseif ($action=="Log in"){
$user = new User(getVar("email"),$db->con);
if ( $user->checkPassword(getVar("passwd"))){
$resAppTemp = $app->db("get","email='".getVar("email")."' and idConference=".getVar("cConf"));
if ( mysql_num_rows($resAppTemp) ){
$r = mysql_fetch_array($resAppTemp);
echo $c->conference($cConf,$r,"User logged successfully
You are registered for this conference
You can update your data","4");
}else
echo $c->conference($cConf,"","User logged successfully","4");
}else echo $c->conference($cConf,"","Wrong password or email
Provide password for ".getVar("email")."","3");
}elseif ( $action =="Unregister"){
$resAppTemp = $app->db("get","email='".getVar("email")."' and idConference=".getVar("cConf"));
if ( mysql_num_rows($resAppTemp) ){
$app->db("delete","email='".getVar("email")."' and idConference=".getVar("cConf"));
$sql = "select confAbrev,sendEmail, name from conference where idConference=".getVar("cConf");
$rr = mysql_query($sql,$db->con);
$rowRR = mysql_fetch_row($rr);
$confAbrev = $rowRR[0];
$sendEmail = $rowRR[1];
$nameConfer= $rowRR[2];
$sql = "delete from subscription where email = '".getVar("email")."' and listName = '$confAbrev'";
mysql_query($sql,$db->con);
mail($sendEmail,"Conference unregister","Information:\n".getVar("email")." unregistered from the $nameConfer\nDate : ".date("m/d/y H:i"),"From: Conference system ");
echo $c->conference($cConf,""," ".getVar("email")." was unsubscribed from the conference.");
}else{
echo $c->conference($cConf,""," ".getVar("email")." was not subscribed for the conference.");
}
}
elseif ( $action == "Non presenter register" || $action == "Presenter form")
{
//$p=$HTTP_GET_VARS;
$p = getAllVars();
$p['email'] = getVar("email");
$p['presenterType']="0";
$p['idConference'] = getVar("cConf");
$p['idApplication'] = getVar("idApplication");
/*
$p['titleAuthor']="";
$p['author']="";
$p['abstract']="";
$p['affiliationAuthor']="";
$p['addressAuthor']="";
$p["cityAuthor"]="";
$p['stateAuthor']="";
$p['zipAuthor']="";
$p['emailAuthor']="";
$p['info']="";*/
//TEMPORARY
$p['newsletter'] =0;
$p['resignation'] =0;
if ( getVar("upApp")=="yes" ) {
if ($action == "Presenter form" ){
$resAppTemp = $app->db("get","email='".getVar("email")."' and idConference=".getVar("cConf"));
$r = mysql_fetch_array($resAppTemp);
$p = array_merge($p, $r);
$p['meals'] = getVar("meals");
$p['feeType'] = getVar("feeType");
$pp = $p;
while ( list($i,$v) = each($p) )
{
$p[$i] = addslashes($v);
}
$app->db("update",$p);
echo $c->conference($cConf,$pp,"Presenter form","6");
}else {
$app->db("update",$p);
#add user to mailing list with subscription to proper list connected to conference
addToSubscription(getVar("email"),getVar("cConf"));
confirm(getVar("email"),getAllVars());
echo $c->conference($cConf,"","Your data were updated
and the email has been sent to you.","5");
}
}
else {
$re = $app->db("get","email='".getVar("email")."' and idConference=".getVar("cConf"));
if ( mysql_num_rows($re)==0 ) {
$app->db("add",$p);
if ( $action == "Presenter form" ){
echo $c->conference($cConf,"","Presenter form","6");
}else {
#add user to mailing list with subscription to proper list connected to conference
addToSubscription(getVar("email"),getVar("cConf"));
confirm(getVar("email"),getAllVars());
echo $c->conference($cConf,"","You were registered for the conference.
An email has been sent to you.","5");
}
}
else echo $c->conference($cConf,"","Your data were not added","5");
}
}elseif ( $action == "Register" ){
# check required fields
if ( getVar("title") ){
$p = getAllVars();
$user = new User(getVar("email"),$db->con);
$r = $user->getUserData();
while ( list($i,$v) = each($r) )
{
$r[$i] = addslashes($v);
}
$re = $app->db("get","email='".getVar("email")."' and idConference=".getVar("cConf"));
$reArr = mysql_fetch_array($re);
while ( list($i,$v) = each($reArr) )
{
$reArr[$i] = addslashes($v);
}
$p = array_merge($p,$reArr);
//TEMPORARY
$p['newsletter']=0;
$p['resignation']=0;
//---
$p['title'] = getVar("title");
$p['abstract'] = getVar("abstract");
$p['presenterType'] = getVar("presenterType");
$p['info'] = getVar("info");
$p['author'] = $r['title']." ".$r['firstName']." ".$r['middleName']." ".$r['lastName'];
$p['affiliation']= $r['affiliation'];
$p['address'] = $r['street'];
$p["city"] = $r['city'];
$p['state'] = $r['state'];
$p['zip'] = $r['zip'];
$p['emailAuthor'] = $r['email'];
if ( getVar("title2") ){
$p['title2'] = getVar("title2");
$p['abstract2'] = getVar("abstract2");
$p['info2'] = getVar("info2");
$p['author2'] = $r['title']." ".$r['firstName']." ".$r['middleName']." ".$r['lastName'];
$p['affiliation2']= $r['affiliation'];
$p['address2'] = $r['street'];
$p["city2"] = $r['city'];
$p['state2'] = $r['state'];
$p['zip2'] = $r['zip'];
$p['emailAuthor2'] = $r['email'];
if ( getVar("author2") ) $p['author2'] = getVar("author2");
if ( getVar("affiliation2") ) $p['affiliation2'] = getVar("affiliation2");
if ( getVar("street2") ) $p['address2'] = getVar("street2");
if ( getVar("city2") ) $p['city2'] = getVar("city2");
if ( getVar("state2") ) $p['state2'] = getVar("state2");
if ( getVar("zip2") ) $p['zip2'] = getVar("zip2");
if ( getVar("emailAuthor2") ) $p['emailAuthor2'] = getVar("emailAuthor2");
} else
{
$p['title2'] = "";
$p['abstract2'] = "";
$p['info2'] = "";
$p['author2'] = "";
$p['affiliation2']= "";
$p['address2'] = "";
$p["city2"] = "";
$p['state2'] = "";
$p['zip2'] = "";
$p['emailAuthor2'] = "";
}
$p['info3'] = getVar("info3");
if ( getVar("author") ) $p['author'] = getVar("author");
if ( getVar("affiliation") ) $p['affiliation'] = getVar("affiliation");
if ( getVar("street") ) $p['address'] = getVar("street");
if ( getVar("city") ) $p['city'] = getVar("city");
if ( getVar("state") ) $p['state'] = getVar("state");
if ( getVar("zip") ) $p['zip'] = getVar("zip");
if ( getVar("emailAuthor") ) $p['emailAuthor'] = getVar("emailAuthor");
$app->db("update",$p);
//echo "ERROR : ".mysql_error();
#add user to mailing list with subscription to proper list connected to conference
addToSubscription(getVar("email"),getVar("cConf"));
confirm(getVar("email"),getAllVars());
echo $c->conference($cConf,"","Your data have been updated
and email has been sent to you","5");
}else echo $c->conference($cConf,"","Type the title in proper field.
Put Presenter form","6");
}
?>