-
Notifications
You must be signed in to change notification settings - Fork 43
/
index.php
277 lines (237 loc) · 7.25 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
/*
================================================================================
LISENCE
================================================================================
This file is part of php4dvd.
php4dvd is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
php4dvd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with php4dvd. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This page controls your site. Do not change anything unless you know what you are doing.
* If you want to change the looks of your page, copy the default directory in /tpl/ and create your own template.
*/
// Only load .php files from index.php
define('DIRECTACCESS', TRUE);
// Start timer
$time_start = microtime(true);
// Default config
require_once("common.inc.php");
// Installer
if(file_exists($loc . "install/index.php")) {
// New version to install?
if(version_compare(VERSION, NEW_VERSION, '<')) {
header("Location: ./install/");
exit();
}
// Remove install directory
else {
$Website->assign("message", "REMOVE_INSTALL_DIR");
}
}
// Language
require_once($loc . "includes/languages.inc.php");
// Login script
require_once($loc . "includes/login.inc.php");
// Template
$template = "index.html";
// Fallback for 404-pages
$Website->assign("main", "404.html");
// Switch to the correct page
$go = isset($_GET['go']) ? $_GET['go'] : '';
switch ($go) {
default: /**
* Default opening page
*/
// Template
$Website->assign("main", "movies/collection.html");
// Movies
require_once($loc . "includes/movie.search.inc.php");
break;
case "login": /**
* Login form
*/
// Template
$Website->assign("main", "users/login.html");
break;
case "movies": /**
* Create a list of the movies
*/
// Viewing movies is only possible when logged in or when guests can view movie information
if($loggedin || $guestview) {
// Template
$template = "movies/movies/".$templateName.".html";
// Only count movies ones
$refreshMovieList = true;
// Movies
require_once($loc . "includes/movie.search.inc.php");
}
break;
case "movie": /**
* Show the information of one movie
*/
// Viewing movie information is only possible when logged in or when guests can view movie information
if($loggedin || $guestview) {
// Template
$Website->assign("main", "movies/movie.html");
// Movies
require_once($loc . "includes/movie.inc.php");
}
break;
case "trailer": /**
* Show movie trailer
*/
// Viewing trailers is only possible when logged in or when guests can view movie information
if($loggedin || $guestview) {
// Template
$Website->assign("main", "movies/trailer.html");
// Trailer
$trailer = true;
require_once($loc . "includes/movie.trailer.inc.php");
}
break;
case "add":
case "edit": /**
* Add/edit a movie
*/
// Adding/editing is only possible if the user is logged in and editor
if($loggedin && $User->isEditor()) {
// Template
$Website->assign("main", "movies/update.html");
// Movies
require_once($loc . "includes/movie.update.inc.php");
} else {
home();
}
break;
case "favourite":
case "seen":
case "own": /**
* Change the movie favourite/seen/own status
*/
// Changing is only possible if the user is logged in and editor
if($loggedin && $User->isEditor()) {
// Movies
require_once($loc . "includes/movie.update.inc.php");
} else {
home();
}
break;
case "delete": /**
* Remove a movie
*/
// Removing is only possible if the user is logged in and editor
if($loggedin && $User->isEditor()) {
$goremove = "movie";
require_once($loc . "includes/movie.delete.inc.php");
}
exit();
break;
case "downloadcover":
/**
* Download the movie cover
*/
// Downloading movie cover is only possible when logged in or when guests can view movie information
if($loggedin || $guestview) {
$godownload = "cover";
require_once($loc . "includes/movie.download.inc.php");
}
break;
case "deletecover": /**
* Remove a movie
*/
// Removing is only possible if the user is logged in and editor
if($loggedin && $User->isEditor()) {
$goremove = "cover";
require_once($loc . "includes/movie.delete.inc.php");
}
exit();
break;
case "imdbupdate": /**
* Update all movie information from IMDb
*/
// Updating is only possible if the user is logged in and editor
if($loggedin && $User->isEditor()) {
require_once($loc . "includes/movie.autoupdate.inc.php");
} else {
home();
}
break;
case "export": /**
* Download movie list as CSV
*/
// Exporting movies is only possible when logged in
if($loggedin) {
// Export
require_once($loc . "includes/export.inc.php");
}
exit();
break;
case "users": /**
* Modify the user accounts
*/
// Updating is only possible if the user is logged in and admin
if($loggedin && $User->isAdmin()) {
// Template
$Website->assign("main", "users/users.html");
// Users
require_once($loc . "includes/users.inc.php");
} else {
home();
}
break;
case "profile": /**
* Modify your profile
*/
if($loggedin) {
$_GET["id"] = $User->id;
}
case "user": /**
* Modify a single user account
*/
// Updating is only possible if the user is logged
if($loggedin) {
// Template
$Website->assign("main", "users/user.html");
// Users
require_once($loc . "includes/user.update.inc.php");
} else {
home();
}
break;
case "deleteuser": /**
* Remove a user
*/
// Removing is only possible if the user is logged in and admin
if($loggedin && $User->isAdmin()) {
require_once($loc . "includes/user.delete.inc.php");
} else {
home();
}
break;
}
// PHP parse time
$time_end = microtime(true);
$managertime = $time_end - $time_start;
// Display template
try {
$Website->display($template);
} catch(Exception $e) {
echo "<h1>Error</h1>";
echo "<p>Make sure the /compiled/ folder is writable (chmod 777).</p>";
echo "<pre>" . $e . "</pre>";
}
// Smarty template parse time
$time_end = microtime(true);
$tpltime = $time_end - $time_start - $managertime;
// Print the parse timings at the end of the HTML page
print "\n\n<!-- ** php parsetime: ".number_format($managertime, 5)." sec. ** -->\n";
print "<!-- ** tpl parsetime: ".number_format($tpltime, 5)." sec. ** -->";