-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.php
executable file
·43 lines (36 loc) · 1.13 KB
/
app.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
<?php
define("REWRITE_BASE", "/");
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/src/class/class.tpl.php';
require __DIR__ . '/src/class/class.instagram.php';
require __DIR__ . '/fct.common.php';
ini_set('session.gc_maxlifetime', 3600); // server should keep session data for AT LEAST 1 hour
session_set_cookie_params(3600); // each client should remember their session id for EXACTLY 1 hour
session_start();
// Get controller
$path = $_SERVER['REDIRECT_URL'];
$path = preg_replace('#^' . REWRITE_BASE . '#', '', $path);
$path = trim($path, "/");
if(!$path) {
$controller = 'index.php';
} else {
$parts = explode('/', $path, 2);
$controller = $parts[0] . '.php';
$PATH = @$parts[1];
}
class RaisedError extends Exception {}
if(file_exists(__DIR__ . '/src/controllers/' . $controller)) {
try {
include __DIR__ . '/src/controllers/' . $controller;
} catch(RaisedError $e) {
print $tpl->error(['error' => $e->getMessage()]);
die;
}
} else {
header("HTTP/1.0 404 Not Found");
echo "404";
exit();
}