forked from murilloggomes/noodle-framework-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
67 lines (54 loc) · 1.69 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
<?php
// Start session
session_start();
/**
* Define very basic constants
*/
define("ENVIRONMENT", "production"); // [development|production|installation]
/**
* Check ENVIRONMENT
*/
error_reporting(E_ALL);
if (ENVIRONMENT == "installation") {
header("Location: ./install");
exit;
} else if (ENVIRONMENT == "development") {
ini_set('display_errors', 1);
} else if (ENVIRONMENT == "production") {
ini_set('display_errors', 0);
} else {
header('HTTP/1.1 503 Service Unavailable.', true, 503);
echo 'Environment is invalid. Please contact developer for more information.';
exit;
}
/**
* Define constants
*/
// Path to root directory of app.
define("ROOTPATH", dirname(__FILE__));
// Path to app folder.
define("APPPATH", ROOTPATH."/app");
// Check if SSL enabled.
$ssl = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] && $_SERVER["HTTPS"] != "off"
? true
: false;
define("SSL_ENABLED", $ssl);
// URL of the application root.
// This is not the URL of the app directory.
$app_url = (SSL_ENABLED ? "https" : "http")
. "://"
. $_SERVER["SERVER_NAME"]
. (dirname($_SERVER["SCRIPT_NAME"]) == DIRECTORY_SEPARATOR ? "" : "/")
. trim(str_replace("\\", "/", dirname($_SERVER["SCRIPT_NAME"])), "/");
define("APPURL", $app_url);
// Define Base Path (for routing)
$base_path = trim(str_replace("\\", "/", dirname($_SERVER["SCRIPT_NAME"])), "/");
$base_path = $base_path ? "/" . $base_path : "";
define("BASEPATH", $base_path);
// Required libraries, config files and helpers...
require_once APPPATH.'/autoload.php';
require_once APPPATH.'/config/config.php';
require_once APPPATH."/helpers/helpers.php";
// Run the app...
$App = new App;
$App->process();