This repository was archived by the owner on Jul 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
93 lines (81 loc) · 2.77 KB
/
index.php
File metadata and controls
93 lines (81 loc) · 2.77 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
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
<?php
/**
* index.php
*
* This is the entry point for the odin web application framework
*
* @package Odin Framework
* @author Wayne Oliver <wayne@open-is.co.za>
* @copyright Wayne Oliver <wayne@open-is.co.za> 2011 - 2017
* @license http://www.opensource.org/licenses/BSD-2-Clause
*
**/
// Session Start
session_start();
session_regenerate_id();
// Define some constants
// Log current time and mem usage
define('START_TIME', microtime(true));
define('START_MEMORY_USAGE', memory_get_usage());
// Server details
if (empty($_SERVER['HTTPS'])) {
$protocol = 'http';
}
else {
$protocol = 'https';
}
$port = '';
if(($_SERVER['SERVER_PORT'] != 80) && ($_SERVER['SERVER_PORT'] != 443))
$port = ':' . $_SERVER['SERVER_PORT'];
// Server information
define('SERVER', $protocol . '://' . $_SERVER['SERVER_NAME'] . $port);
define('BASE_URL', SERVER . substr($_SERVER['SCRIPT_NAME'], 0,
strrpos($_SERVER['SCRIPT_NAME'], "/")+1));
// Define the OS constants
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', realpath(dirname(__FILE__)));
// System CONSTANTS
define('SYS_DIR', ROOT . DS . 'system' . DS);
define('LOG_DIR', ROOT . DS . 'logs' . DS);
define('LIB_DIR', SYS_DIR . 'lib' . DS);
// Define URL constants
define('STAT_URL', BASE_URL . 'static/');
define('CSS_URL', STAT_URL . 'css/');
define('JS_URL', STAT_URL . 'js/');
define('IMG_URL', STAT_URL . 'img/');
define('IMAGES_URL', STAT_URL . 'images/');
define('ICO_URL', STAT_URL . 'ico/');
define('ASSET_URL', STAT_URL . 'assets/');
// Define application CONSTANTS
define('APP_DIR', ROOT . DS . 'app' . DS);
define('CONF_DIR', APP_DIR . 'config' . DS);
define('MOD_DIR', APP_DIR . 'modules' . DS);
define('APPLIB_DIR', APP_DIR . 'lib' . DS);
// Templating
define('TEMPLATE_DIR', ROOT . DS . 'static' . DS . 'templates' . DS);
define('CACHE_DIR', ROOT . DS . 'cache' . DS);
// Check that the app is installed and configured
if (!file_exists(CONF_DIR . 'config.inc.php')) {
//include 'install.php';
//TODO: Implement install.php
die("ERROR: Application not correctly installed, missing config.");
//Check the environment before starting the application
} else if ((!file_exists(LOG_DIR)) || (!is_writable(LOG_DIR)) || (phpversion() < 7.0)) {
//include 'errors/init-error.inc.php';
//TODO: ERROR Handling
echo "<p>ERROR: Initializing application!</p>";
echo "<p>check the following</p>";
echo "<p>PHP Version: " . floor(phpversion()) . " required 7.x</p> ";
die("<p>Check that " . LOG_DIR . " exists and is writable by your web server</p>");
} else {
// Get the requested URL
if (!isset($_GET['url'])) {
$url="/";
} else {
$url = filter_input(INPUT_GET, 'url', FILTER_SANITIZE_STRING);
}
// Load the config
require_once(CONF_DIR . 'config.inc.php');
// Start base the application
require_once(LIB_DIR . 'init.inc.php');
}