-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
201 lines (167 loc) · 6.16 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/*
* This is an UTF-8 file
*
* This file is part of the furgovw.org meeting inscription system
* and it's used in conjunction with:
*
* SMF - Simple Machines Forum - http://www.simplemachines.org
*
* Inscription system working at: http://www.furgovw.org/nacional/
*
* (C) Javier Montes <[email protected]>
*
* Twitter: @mooontes
* Web: http://mooontes.com
*
* "Furgovw Meeting Inscription System" is being written to be used in furgovw.org's
* annual photo contest,
*
* Here you can see more info about our contest: http://www.furgovw.org/calendario/
*
* "Furgovw Meeting Inscription System" is licensed under GPL 2.0
* http://www.gnu.org/licenses/gpl-2.0.html
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
require_once 'class_Nacional.php';
require_once 'Montes/Strings.php';
require_once 'Zend/Pdf.php';
/*
** Init database
** settings are loaded from SMF settings file
** (it's in parent directory)
*/
require_once '../Settings.php';
$db = new mysqli($db_server, $db_user, $db_passwd, $db_name);
$db->query("SET NAMES utf8");
// Init SMF's SSI
require_once('../SSI.php');
// Init Nacional
if (!Nacional::init($db, $user_info)) {
throw new Exception('Error initializing Nacional');
}
// Set page title
if (isset($_GET['menu']) && $_GET['menu'] == 'apuntarse') {
$title = Nacional::getTitle();
} else {
$title = 'Concentración Nacional Furgovw';
}
// Show page header
$config = Nacional::getConfig();
if (isset($_GET['menu2']))
$config['menu2'] = $_GET['menu2'];
else
$config['menu2'] = '';
$moderator = Nacional::getModerator();
$year = date('Y');
if (!isset($_GET['ajax'])) {
include 'templates/header.php';
}
if ((!isset($_GET['ajax'])
&& !isset($_GET['edita']))
&& (!isset($_GET['menu'])
|| ($_GET['menu'] == ''))
) {
include 'templates/index.php';
}
// If the user is a moderator check if we must do any moderator task
// or if he wants to see admin menu
if ($moderator) {
if (isset($_GET['ajax']) && $_GET['ajax'] != '') {
echo Nacional::ajax($_GET['ajax'], $_GET['op']);
return;
} else {
$msg = Nacional::doModeratorTasks();
if ($msg !== false) {
$error = $msg;
include 'templates/error.php';
} elseif (isset($_GET['menu']) && $_GET['menu'] == 'admin') {
$config = Nacional::getConfig();
$allInscriptionsArray = Nacional::getAllInscriptions();
$tShirtStats = Nacional::getTshirtStats();
$totalPaidTShirts = $tShirtStats['paidTShirts'];
$totalPaidExtraTShirts = $tShirtStats['paidExtraTShirts'];
$totalNotPaidTShirts = $tShirtStats['notPaidTShirts'];
$paidSizes = $tShirtStats['paidSizes'];
$notPaidSizes = $tShirtStats['notPaidSizes'];
$paidInscriptions = $tShirtStats['paidInscriptions'];
include('templates/admin_index.php');
$msg = true;
}
}
}
if (isset($_GET['menu']) && $_GET['menu'] == 'historia') {
include 'templates/history.php';
} elseif (isset($_GET['menu']) && $_GET['menu'] == 'estadisticas') {
$allInscriptionsArray = Nacional::getAllInscriptions();
$statistics = Nacional::getStatistics();
if ($allInscriptionsArray && $statistics) {
include('templates/stats.php');
}
// Are we at the inscriptions menu?
} elseif ((isset($_GET['menu']) && $_GET['menu'] == 'apuntarse') || (isset($_GET['edita']) && is_numeric($_GET['edita']))) {
include('templates/inscriptions.php');
if (isset($_POST['nacionalForm']) && $_POST['nacionalForm'] == 'yes') {
Nacional::saveInscriptionDataFromPost();
}
if (!isset($_GET['edita']) || !is_numeric($_GET['edita'])) {
if (Nacional::getError() !== false) {
$error = Nacional::getError();
include 'templates/error.php';
}
}
$config = Nacional::getConfig();
$data = Nacional::getInscriptionData();
//Last checks before show inscription's form
if (($config['inscriptionsOpened'] == '1'
&& (!isset($data['numpago']) || !is_numeric($data['numpago']))
&& ($moderator || !isset($error)))
||
($moderator && isset($_GET['edita']) && is_numeric($_GET['edita']))) {
$dates = array();
for ($cont = 0; $cont < 3; $cont++) {
$dow = strftime('%A', strtotime($config['firstDay'].' +
'.$cont.' DAYS'));
$dates[($cont+1)]['show'] = strftime('%A %e de %B del %G', strtotime($config['firstDay'].' +'.$cont.' DAYS'));
$dates[($cont+1)]['save']= date('Y-m-d',
strtotime($config['firstDay'].' +'.$cont.' DAYS'));
}
if ($result =
$db->query("SELECT * FROM vehiculos_marca ORDER BY nombre ASC")) {
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
$vehicleBrands[] = $row;
}
}
if ($result =
$db->query("SELECT * FROM kedadas_paises ORDER BY pais ASC")) {
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
$countries[] = $row;
}
}
if ($result = $db->query("SELECT * FROM kedadas_provincias".
" ORDER BY provincia ASC")) {
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
$counties[] = $row;
}
}
if (isset($_GET['edita']) && is_numeric($_GET['edita'])) {
$data['edita'] = $_GET['edita'];
}
$userInfo = $user_info;
$tShirtSizes = Nacional::getTShirtsSizes();
include('templates/form.php');
}
}
//Fix utf member's nick bug
$db->query("UPDATE fnacional n JOIN smf_members m ".
"ON n.idmember = m.id_member SET n.nick = m.real_name ");
include 'templates/footer.php';