-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·54 lines (43 loc) · 1.15 KB
/
Copy pathindex.php
File metadata and controls
executable file
·54 lines (43 loc) · 1.15 KB
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
<?php
session_start();
include_once ('init.php');
$user = [];
$user = authGetUser();
$pageCanonical = HOST . BASE_URL;
$uri = $_SERVER['REQUEST_URI'];
$wrongUrl = BASE_URL . 'index.php';
if (strpos($uri, $wrongUrl) === 0) {
$cname = 'errors/e404';
} else {
$routes = include ('routes.php');
$url = $_GET['querysystemurl'] ?? '';
$routerRes = parseUrl($url, $routes);
$cname = $routerRes['controller'] ?? 'index';
define('URL_PARAMS', $routerRes['params']);
$urlLen = strlen($url);
if ($urlLen > 0 && $url[$urlLen - 1] === '/') {
$url = substr($url, $urlLen - 1);
}
$pageCanonical .= $url;
}
$path = "controllers/$cname.php";
$pageTitle = $pageContent = '';
$authLink = 'auth/login';
$authText = 'Login';
if (!empty($user['name'])) {
$authText = $user['name'] . ' LouOut';
$authLink = 'auth/logout';
}
if (!file_exists($path)) {
$cname = 'errors/e404';
$path = "controllers/$cname.php";
}
include_once ($path);
$html = template('/base/v_main', [
'title' => $pageTitle,
'content' => $pageContent,
'canonical' => $pageCanonical,
'authText' => $authText,
'authLink' => $authLink,
]);
echo $html;