require_once("../common/includes/settings.php");
require_once("config.php");
require_once("../common/includes/globalconstants_pp_items.php"); //include paypal specific constants
//Var ini
$status = "";
$memberstatus_str = "";
$MEMBER_TAB_ID = "CREDITS";
$MENU_ID = "MEMBERS"; //for menubar
$target_email = "sales@togoparts.com";
$status = "* Compulsory Fields";
$thissubmit = 0;
$thisformverified = 0;
$thisformrenew = 0;
//define js vars
$js_redirect_time = 100; //10000
function validate_email($email) {
//if (ereg("^([a-zA-Z0-9\._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+",$email)){
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
return true;
} else {
return false;
}
}
function checkdatefunc($dt) {
$yr=strval(substr($dt,0,4));
$mo=strval(substr($dt,4,2)-1);
if($mo < 10)
$mo = "0" . $mo;
$da=strval(substr($dt,6,2));
$dat = $yr."-".$mo."-".$da ;
return $dat;
}
function checkdatefunc2($dt) {
$yr=strval(substr($dt,0,4));
$mo=strval(substr($dt,4,2));
$da=strval(substr($dt,6,2));
$dat = $yr."-".$mo."-".$da ;
return $dat;
}
//PM Signup for members only and for non carded members
if (isInSession()) {
$u = new User(getSessionUserid());
$thistab_user = $u;
if ($u->getWarnflag()) {
header("Location: ../index.php");
exit;
}
if($u->isPaid()) {
//if user is paid echo "i am here 1
";
$paiduntil = $u->getPaiddate(); // get the end paid date?
$today = date("Y-m-d");
$today;
$lastmonth = checkdatefunc($paiduntil);
$tismnth = checkdatefunc2($paiduntil);
if($today == $tismnth) {
$expire = true;
$expirestat = "3wks";
} else if($today < $tismnth) {
if($today > $lastmonth) { //still a member, but expiring in 4 weeks.
$expire = true;
$expirestat = "4wks";
} else if($today <= $lastmonth) { //still a member
$expire = false;
$memberstatus_str = "
You are already a Privi Member! Your membership ends " . sporetime_date($tismnth) . "
";
}
}
} else { //if not paid
if($u->checkisPreviousPaid()) {
$expirestat = "overdue";
$expire = true;
} else {
$expire = false;
}
}
// chec if renew button is pressed.
if($_POST['Submit'] == "Click To Renew!") {
$thissubmit = 1;
$ref = "tgp-rwsp-".time();
$subject = "Togoparts Renewal Privi Membership App Form";
$message = "The following is the renewal of privi membership application from " . $u->getUsername() . "\n\n";
$message .= "Transaction Ref: $ref (Refer to Paypal to ensure that payment has been made)\n";
$message .= "Username: " . $u->getUsername() . "\n";
$message .= "Full Name: " . $u->getLastname() . " " . $u->getFirstname() . "\n";
$message .= "Email: " . $u->getEmail() . "\n";
$message .= "Gender: " . $u->getGender() . "\n";
$headers = "From: " . $u->getUsername() . "\nReply-To:" . $u->getUsername() . "\nX-Mailer: PHP/" . phpversion();
$thisformverified = 1;
$thisformrenew = 1;
//send pre-sale email
mail($target_email, "Togoparts : ".$subject, $message, "From: " . $u->getEmail() . "\nReply-To:" . $u->getEmail() . "\nX-Mailer: PHP/" . phpversion());
} //end submit
//New User applied for Privi Membership
if ($_POST['Submit']) {
// user has submitted the form.
$thissubmit = 1;
if (!$subject) {
$subject = "Togoparts Privi Membership App Form";
}
$originator = trim($_POST['email']);
//perform checks
if (trim($_POST['contactno']) && trim($_POST['name']) && trim($_POST['address']) && trim($_POST['nric']) && trim($_POST['postalcode']) && isset($_POST['agreement'])) {
//email checks ok. Email to admin.
$ref = "tgp-mbsp-".time();
//compose message
$message = "The following is privi membership application from " . $_POST['name'] . " Contact: " . $_POST['contactno'] . "\n\n";
$message .= "User is Logged-in. Username: " . $u->getUsername() . " Email: " . $u->getEmail() . "\n\n";
$message .= "Transaction Ref: $ref \n";
$message .= "Username:" . $u->getUsername() . "\n";
$message .= "NRIC:" . $_POST['nric'] . "\n";
$message .= "Full Name:" . $_POST['name'] . "\n";
$message .= "Email:" . $u->getEmail() . "\n";
$message .= "Contact no:" . $_POST['contactno'] . "\n";
$message .= "Gender:" . $_POST['gender'] . "\n";
$message .= "Address:" . $_POST['address'] . "\n";
$message .= "Country:" . $_POST['country'] . "\n";
$message .= "Postal Code:" . $_POST['postalcode'] . "\n\n";
$message .= "Comments:" . $_POST['comments'] . "\n";
$headers = "From: " . $originator . "\nReply-To:" . $originator . "\nX-Mailer: PHP/" . phpversion();
$thisformverified = 1;
//send pre-sale email
mail($target_email, "Togoparts : ".$subject, $message, "From: " . $originator . "\nReply-To:" . $originator . "\nX-Mailer: PHP/" . phpversion());
} else {
$status = "Please enter the required fields (*)";
}
} //end submit
//VARS USED IN HTML
if ($expire) {
$html_title = "Renewal";
} else {
$html_title = "Sign-Up";
}
} else {
//VARS USED IN HTML
$thistab_user = new stdClass();
$html_title = "";
$status_lign = "";
if(strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
$username='';
if(isset($_POST['username'])){ $username=$_POST['username'];}
$password='';
if(isset($_POST['password'])){$password=$_POST['password'];}
$loginbox='';
if(isset($_POST['loginbox'])){$loginbox=$_POST['loginbox'];}
$submit='';
if(isset($_POST['Submit'])){$submit=$_POST['Submit'];}
$remember=0;
if(isset($_POST['remember'])){$remember=$_POST['remember'];}
if($remember==1) {
$remember = true;
}
if ($username && $password) {
//person is not registered, process login
$lr = login($username, $password, $link,$remember);
if (!$lr){
//$status = "Login Togoparts!";
} else {
if ($lr == 1) {
$status_login = "Success!";
//redirect to callback page
header ("Location: $cb");
exit;
} else if ($lr == 2) {
$status_login = "Invalid Login";
} else if ($lr == 3) {
$status_login = "Invalid Login";
} else if ($lr == 4) {
$status_login = "Invalid Login";
} else {
$status_login = "Invalid Login";
}
}
} else {
$status_login = "Invalid Login";
}
}
} //end of isInSession()
$WEBPAGE_TITLE = "Togoparts.com - Privi Membership";
if($html_title) {
$WEBPAGE_TITLE .= " ".$html_title;
}
$meta_description = "";
$meta_keywords = "";
include_once('../common/zopim_inc.php');
?>