forked from NeptuneFW/NeptuneFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
87 lines (69 loc) · 2.54 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
<?php
session_start();
define('DS', DIRECTORY_SEPARATOR);
define('NO_SERVERNAME', 'localhost');
define('SECRET', "165te12fsC564RW46RWx645RRWE45");
$request_scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] . '://' : 'http://';
$server_name = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : NO_SERVERNAME;
$server_port = isset($_SERVER['SERVER_PORT']) ? ':' .$_SERVER['SERVER_PORT'] : null;
$scriptName = $_SERVER['SERVER_NAME'];
if($_SERVER['SCRIPT_NAME'] != '/index.php')
{
$base = preg_replace("/\\/\\index\\.php/", "",$_SERVER['SCRIPT_NAME']);
define('BASE_URL', $request_scheme . $server_name . $server_port . $base);
}
else
{
define('BASE_URL', $request_scheme . $server_name . $server_port);
}
//define("TITLE", )
define('ROOT', realpath('.'));
define('STYLE_DIR', ROOT . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "style");
define('SCRIPT_DIR', ROOT . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "script");
define('CACHE', true);
define('CACHE_TIME', 5);
define('METHOD', $_SERVER['REQUEST_METHOD']);
$explode = @explode("?",$_SERVER['REQUEST_URI']);
if(!$explode)
{
define('PATH', $_SERVER['REQUEST_URI']);
}
else
{
define('PATH', $explode[0]);
}
$databases = glob("database/databases/*");
foreach ($databases as $database) {
$connectionSettings = file_get_contents($database . "/connection.ntconfig");
eval("\$connectionSettings = " . $connectionSettings );
$databaseName = explode("/", $database);
$databaseName = end($databaseName);
$GLOBALS['Databases'][$databaseName] = new \PDO("mysql:host=". $connectionSettings['host'] .";dbname=" . $databaseName . ";charset=utf8", $connectionSettings['user'], $connectionSettings['pass']);
}
$routed = true;
$route = null;
$callRoute = array();
$middlewares = array();
require "vendor/autoload.php";
define("DEFAULT_APP", 'production');
$default_lang = explode(',', apache_request_headers()['Accept-Language']);
/*
* DEFAULT_LANG @define
*/
$default_lang = explode("-", $default_lang[0]);
if(file_exists('languages/'. $default_lang[0] . "_" . $default_lang[1] . ".nt"))
{
define('DEFAULT_LANG', $default_lang[0] . "_" . $default_lang[1]);
\Libs\Languages::setDefault(DEFAULT_LANG);
}
else
{
define('DEFAULT_LANG', "tr_TR");
if(file_exists('languages/'. DEFAULT_LANG . ".nt"))
{
\Libs\Languages::setDefault(DEFAULT_LANG);
}
}
\System\Application::set("development", "/development", "ip", array("127.0.0.1", "::1"));
\System\Application::set("admin", "/admin", 'public', '');
\System\Application::end();