-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.php
74 lines (64 loc) · 2.18 KB
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/* File: routes.php
Desciption: Implementation file for passing user's address information on to the mapping javascript.
Author: Eric A. Bonney
Date: December 2, 2009
Updated: January 4, 2010 - updated so that the file can direct the user to either the main
view or to the actual mapping view.
*/
require_once "includes/db.inc";
require_once "fitlogfunc.php";
require_once "HTML/Template/IT.php";
$view = $_GET["view"];
// Get a connection to the database.
if( !($connection = @mysql_connect( $hostName, $username, $password ) ) )
die( "Could not connect to database" );
// Now that we are connected, select the correct database.
if( !mysql_select_db( $databaseName, $connection ) )
showerror();
// Create the template and load the correct template file.
$template = new HTML_Template_IT( "./templates" );
session_start();
//See if we have an authenticated user, if so, setup the appropriate message.
if( isset( $_SESSION["loggedinUserName"] ) )
{
switch( $view )
{
case 's':
$template->loadTemplatefile( "routesmainview.tpl", true, true );
loadMainView( $template, $connection );
break;
case 'm':
$template->loadTemplatefile( "routes.tpl", true, true );
$template->setVariable( "MONTH", "");
$template->parseCurrentBlock();
break;
default:
$template->loadTemplatefile( "routesmainview.tpl", true, true );
loadMainView( $template, $connection );
break;
}
}
else
{
//Seems the user has attempted to navigate directly to the dashboard without
//logging in. Send them to the logout page with an error message.
$_SESSION["headerMessage"] = "Error!!";
$_SESSION["message"] = "You must first log into the system before you can view the page.";
// Send user to the logout page.
header( "Location: logout.php" );
exit;
}
//Show the user the Routs Main View page.
$template->show();
/********************************** Helper functions *****************************************/
function loadMainView( $template, $connection )
{
// Get the logged in user's user_id
$usr_ID = getUserID( $connection );
// Fill in the user's routes.
$template->setCurrentBlock( "COURSELISTING" );
$template->setVariable( "DESC", "" );
$template->parseCurrentBlock();
}
?>