forked from nicholasmr/obblm
-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.php
106 lines (90 loc) · 4.15 KB
/
index.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
$time_start = microtime(true); # Used by MTS().
/* Includes, constants, error_reporting() level, session_start(), OBBLM run requirements, MySQL connection, language load. */
require('header.php');
/********************
* Main routine
********************/
// Make 'main' the default section if no GET section request was sent.
if (!isset($_GET['section'])) {
$_GET['section'] = 'main';
}
// Login?
$_VISSTATE['COOKIE'] = Coach::cookieLogin(); # If not already logged in then check for login-cookie and try to log in using the stored credentials.
if ($_VISSTATE['POST_IN'] = isset($_POST['login'])) {
if (get_magic_quotes_gpc()) {
$_POST['coach'] = stripslashes($_POST['coach']);
$_POST['passwd'] = stripslashes($_POST['passwd']);
}
if (!Coach::login($_POST['coach'], $_POST['passwd'], isset($_POST['remember']))) {
$_GET['section'] = 'login';
}
}
// Mobile?
$isMobile = isset($_GET['mobile']) ? ($_GET['mobile'] == '1') : false;
// Logout?
if ($_VISSTATE['POST_OUT'] = isset($_GET['logout'])) {
$_GET['section'] = 'main'; # Redirect logged out users to the main page.
Coach::logout();
}
Mobile::setIsMobile($isMobile);
if ($isMobile && !Coach::isLoggedIn()) {
// Redirect logged out mobile users to login
$_GET['section'] = 'login';
}
if ($_VISSTATE['COOKIE'] || $_VISSTATE['POST_IN'] || $_VISSTATE['POST_OUT']) {
setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_COACH_LOGINOUT);
}
// Upgrade install?
if($coach && $coach->isGlobalAdmin()) {
if(!isset($db_version)) {
echo '<div class="messagecontainer red">Your desired database version cannot be determined. Please ensure $db_version is set to a value in settings.php. If you aren\'t certain what to set it to, ask a NAFLM developer. 101 could be an appropriate default.</div>';
} else {
$databaseVersion = SQLUpgrade::getCurrentDatabaseVersion();
$fromVersion = $databaseVersion ? $databaseVersion : '075-080'; // set to earliest auto-upgrade version by default
if(!$databaseVersion || $fromVersion < $db_version) {
echo '<div class="messagecontainer lightgreen">';
if(!$databaseVersion) {
echo '<div>Your database version cannot be determined. Your system will run <strong>all</strong> automatic upgrades.</div>';
}
echo '<div>Your database will now be upgraded to version ' . $db_version . '.</div>';
upgrade_database_to_version($db_version, $fromVersion);
echo '</div>';
}
}
}
// Generate page
if(Mobile::isMobile()) {
HTMLOUT::mobile_frame_begin(); # Make page frame, banner and menu.
MTS('Header loaded, login auth, html frame generated');
// Check if a menu-link was picked, and execute section code from sections.php accordingly.
switch ($_GET['section'])
{
case 'login': sec_login(); break;
case 'matches': Match_HTMLOUT::userSched(); break;
case 'management': $teamId = Mobile_HTMLOUT::getSelectedTeamId();
Team_HTMLOUT::teamManagementBox($teamId);
break;
default: Mobile_HTMLOUT::sec_mobile_main();
}
} else {
HTMLOUT::frame_begin(); # Make page frame, banner and menu.
MTS('Header loaded, login auth, html frame generated');
// Check if a menu-link was picked, and execute section code from sections.php accordingly.
switch ($_GET['section'])
{
case 'login': sec_login(); break;
case 'admin': sec_admin(); break;
case 'teamlist': sec_teamlist(); break;
case 'coachlist': sec_coachlist(); break;
case 'rules': sec_rules(); break;
case 'about': sec_about(); break;
case 'matches': sec_matcheshandler(); break; // Tournaments, matches, match reports, recent matches, upcoming matches etc.
case 'objhandler': sec_objhandler(); break; // Object profiles, object standings.
case 'requestleague': sec_requestleague(); break;
default: sec_main();
}
}
HTMLOUT::frame_end(); // Spit out all the end-tags.
mysql_close($conn);
MTS('END OF SCRIPT');