<?php

include 'php/classes/page.php';
include 'functions/func_xml.php';
$page = new Page();
$page->init_user();

# log the user in if required
if(isset($_POST['login']))
{
	if($page->user()->login($_POST['username'],$_POST['password']))
		$page->addMessage('Login successful.  You can now view the travel info below.');
	else
		$page->addError('Invalid username/password combination.  Please try again.');
}
else if(isset($_GET['logout']))
{
	$page->user()->logout();
	$page->addMessage('Logout successful.');
}

$page->attr('title','Discipling the Nations: Mission and Travel');
$page->content('missionandtravel.php');
$page->addCSSFile('missionandtravel.css');
$page->addJSFile('ssm.js','ssmItems.js','ssmItems_missionandtravel.js');

# get the random verse and pass it to the template
$page->data('verse',xml_random_child($FILES['verses']));

# get missionary moments to display here
$xml['missionarymoments'] = new SimpleXMLElement(file_get_contents($DOCROOT.'/site/data/missionarymoments.xml'));
$xml['shorttermopportunities'] = new SimpleXMLElement(file_get_contents($DOCROOT.'/site/data/missionandtravel/shorttermopportunities.xml'));
$xml['travelinfo'] = new SimpleXMLElement(file_get_contents($DOCROOT.'/site/data/missionandtravel/travelinfo.xml'));
$page->data('xml',$xml);

$page->process();

?>