-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
56 lines (47 loc) · 1.6 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
<?php
/**
* @file
* @brief Main file, or "controller".
*
* See page @link Controller @endlink for more details.
*/
require_once 'config.php';
/* user saves a roster => process it, return xml ************************ */
if ( isset($_POST['TEAM']) ) {
require_once PROJECT_DIR . '/lib/TeamSaver.php';
$data = translateTeamBeforeSaving($_POST, $_POST['LANG']);
header('Content-type: application/xml');
header('Content-Disposition: attachment; filename="'.$_POST['TEAM'].'.xml"');
echo TeamSaver::save($data);
}
/* user selected a race => show a roster ************************************ */
elseif ( isset($_GET['race']) ) {
$race_id = htmlentities($_GET['race']);
if ( is_numeric($race_id) && $race_id >= 0 && $race_id <= 20 ) {
show_roster($race_id);
}
else {
$errorCode = 1; // for the template
show_index($errorCode); // invalid race, show welcome-page instead of roster
}
}
/* user uploaded a file => parse it, show a roster ************************** */
elseif ( isset($_POST['upload']) ) {
if ( array_key_exists('userfile', $_FILES) &&
$_POST['upload'] == true &&
$_FILES['userfile']['error'] != UPLOAD_ERR_NO_FILE ) {
$file = $_FILES['userfile']['tmp_name'];
require_once PROJECT_DIR . '/lib/TeamLoader.php';
$team = translateTeamAfterLoading(TeamLoader::load($file), $_POST['LANG']);
show_roster($team['raceName'], $team);
}
else {
$errorCode = 2; // for the template
show_index($errorCode); // invalid upload, show welcome-page
}
}
/* nothing happened => show the welcome-page ******************************** */
else {
show_index();
}
?>