-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.php
95 lines (81 loc) · 2.99 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
<?php
require(dirname(__FILE__) . '/app/user.php');
require(dirname(__FILE__) . '/app/utils.php');
// version replaced by Gruntfile as part of release
define('RG2VERSION', '2.1');
define("RG_LOG_FILE", dirname(__FILE__) . "/log/rg2log.txt");
if (file_exists(dirname(__FILE__) . '/rg2-config.php')) {
require_once(dirname(__FILE__) . '/rg2-config.php');
} else {
echo "Routegadget 2: Configuration file " . dirname(__FILE__) . "/rg2-config.php not found.";
return;
}
$base = "/rg2/";
$api_url = RG_BASE_DIRECTORY . $base . "rg2api.php";
if (defined('OVERRIDE_SOURCE_DIRECTORY')) {
$source_url = OVERRIDE_SOURCE_DIRECTORY . $base;
} else {
$source_url = RG_BASE_DIRECTORY . $base;
}
// messy but works OK for now
// Overrides work OK on a local server which is what they are intended for
if (defined('OVERRIDE_KARTAT_DIRECTORY')) {
$maps_dir = OVERRIDE_KARTAT_DIRECTORY;
$maps_url = OVERRIDE_KARTAT_DIRECTORY;
} else {
$maps_dir = "../kartat/";
$maps_url = RG_BASE_DIRECTORY . "/kartat/";
}
define('KARTAT_DIRECTORY', $maps_dir);
// save grief when initial set-up is wrong...
if (!file_exists($maps_dir)) {
echo "Routegadget 2: Kartat directory " . $maps_dir . " not found.";
return;
}
// include manager function as parameter for now until we decide the best way forward
if (isset($_GET['manage'])) {
$manager = true;
$keksi = user::generateNewKeksi();
} else {
$manager = false;
}
// include language file if requested
if ((defined('START_LANGUAGE'))) {
$lang = START_LANGUAGE;
} else {
$lang = "en";
}
// Need to determine if we are in production, in which case we need to use the manifest to generate the relevant includes, or
// are in development in which case vite deals with all that.
// Should never be a manifest file in the development root directory so this should be a valid test...
$manifestfile = 'manifest.json';
$production = false;
if (file_exists($manifestfile)) {
$production = true;
// based on https://github.com/firtadokei/codeigniter-vitejs
$manifest = file_get_contents($manifestfile);
$manifest = json_decode($manifest);
$jsfiles = "";
$cssfiles = "";
foreach ($manifest as $file) {
$fileExtension = substr($file->file, -3, 3);
if ($fileExtension === '.js' && isset($file->isEntry) && $file->isEntry === true && (!isset($file->isDynamicEntry) || $file->isDynamicEntry !== true)) {
$jsfiles .= '<script type="module" src="' . trim($source_url . $file->file) . '"></script>';
if (!empty($file->css)) {
foreach ($file->css as $cssFile) {
$cssfiles .= '<link rel="stylesheet" href="' . $source_url . $cssFile . '" />';
}
}
}
}
}
header('Content-type: text/html; charset=utf-8');
// This forces Siteground to disable its dynamic caching default which does not work for Routegadget
// since response contents may change even if URL is the same (e.g. start-up config info)
header('Cache-Control: no-cache');
?>
<!DOCTYPE html>
<html lang="en">
<?php include 'app/html/head.html'; ?>
<?php include 'app/html/body.html'; ?>
</html>