process.php 3.29 KB
<?php 

require_once 'classes/realops.php';


$get = new Get()
$db = $get->connect();



if(isset($_POST['forgot']))
{
	$selectPilot = $db->getRow("SELECT * FROM tbl_pilots WHERE vatsimID =?", array($_POST['vatsimID']));
	if(!empty($selectPilot))
	{
		$messageBody = "You are receiving this email because you have requested your VATPAC Sunday Night Live Passcode. \n
Your passcode for VATPAC's RealOps is: " . $selectPilot['passcode'] . "\n
Please use this passcode to make future bookings and to view your flight dispatch on the night. \n \n
We are looking forward to your participation this year!\n \n
VATPAC Events Team.";
require_once 'swift/lib/swift_required.php';
		// Create the Transport
		$transport = Swift_SmtpTransport::newInstance('mail.internode.on.net', 25);

		/*
		You could alternatively use a different transport such as Sendmail or Mail:

		// Sendmail
		$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

		// Mail
		$transport = Swift_MailTransport::newInstance();
		*/

		// Create the Mailer using your created Transport
		$mailer = Swift_Mailer::newInstance($transport);

		// Create a message
		$message = Swift_Message::newInstance('Your VATPAC RealOps Passcode')
		  ->setFrom(array('[email protected]'))
		  ->setTo(array($selectPilot['email']))
		  ->setBody($messageBody)
		  ;

		// Send the message
		$result = $mailer->send($message);
		
		echo "1";
	}
	else
	{
		echo "2";
		die();
	}
}
else if(isset($_POST['email']))
{
	if(!empty($_POST['vatsimID']) && !empty($_POST['email']) && !empty($_POST['passcode']))
	{
		$db->insertRow("INSERT INTO tbl_pilots (vatsimID, email, passcode) VALUES (?, ?, ?)", array($_POST['vatsimID'], $_POST['email'], $_POST['passcode']));
		session_start();
		$_SESSION['vatsimID'] = $_POST['vatsimID'];
		$_SESSION['authenticated'] = 1;
		$messageBody = "Your passcode for VATPAC's RealOps is: " . $_POST['passcode'] . "\n
Please use this passcode to make future bookings and to view your flight dispatch on the night. \n \n
We are looking forward to your participation this year!\n \n
VATPAC Events Team.";
require_once 'swift/lib/swift_required.php';

		// Create the Transport
		$transport = Swift_SmtpTransport::newInstance('mail.internode.on.net', 25);

		/*
		You could alternatively use a different transport such as Sendmail or Mail:

		// Sendmail
		$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

		// Mail
		$transport = Swift_MailTransport::newInstance();
		*/

		// Create the Mailer using your created Transport
		$mailer = Swift_Mailer::newInstance($transport);

		// Create a message
		$message = Swift_Message::newInstance('Your VATPAC RealOps Passcode')
		  ->setFrom(array('[email protected]'))
		  ->setTo(array($_POST['email']))
		  ->setBody($messageBody)
		  ;

		// Send the message
		$result = $mailer->send($message);
		if($result == 1)
			header("Location: slots.php?success=" . $result);
	}
	else
	{
		header("Location: slots.php?success=0");
	}
}
else if(!empty($_POST['vatsimID']) && !empty($_POST['passcode']))
{
	$row =$db->getRow("SELECT * FROM tbl_pilots WHERE vatsimID =?", array($_POST['vatsimID']));
	if(!empty($row))
	{
		if($_POST['passcode'] == $row['passcode'])
			session_start();
			$_SESSION['vatsimID'] = $_POST['vatsimID'];
			$_SESSION['authenticated'] = 1;
			echo "true";
	}
	else
	{

	}
}

?>