This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
define.php
151 lines (131 loc) · 2.99 KB
/
define.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* default of all define
*/
// Define Global variables ****************************************************
// Core name
define('core_name' ,'dash');
// Define main service
if(!defined('MainService'))
{
define('MainService', 'ermile');
}
// Define Dash variables ****************************************************
if(!defined("core"))
{
define("core", preg_replace("[\\\\]", "/", __DIR__).'/' );
}
// Dash library
if(!defined("lib"))
{
define("lib", "lib/");
}
// set include path for lib
// Dash plugin
if(!defined("addons"))
{
define("addons", core."addons/");
}
// Dash helper
if(!defined("helper"))
{
define("helper", core."helper/");
}
// Define Project variables ***************************************************
if(!defined("root"))
{
define("root", dirname(dirname($_SERVER['SCRIPT_FILENAME'])).'/' );
}
// Project include folder
if(!defined("dir_includes"))
{
define("dir_includes", root.'includes/');
}
set_include_path(get_include_path() . PATH_SEPARATOR . dir_includes);
set_include_path(get_include_path() . PATH_SEPARATOR . core.'addons/');
set_include_path(get_include_path() . PATH_SEPARATOR . core);
// Project library
if(!defined("ilib"))
{
define("ilib", "ilib/");
}
// Project helper
if(!defined("ihelper"))
{
define("ihelper", dir_includes."helper/");
}
// Project default repository
if(!defined("repository"))
{
define("repository", root.'content/');
}
// Project cls
if(!defined("cls"))
{
define("cls", dir_includes."cls/");
}
// Project database
if(!defined("database"))
{
define("database", dir_includes."database/");
}
// Project MVC
if(!defined("mvc"))
{
define("mvc", dir_includes."mvc/");
}
// Set default timezone to Asia/Tehran, Please set timezone in your php.ini
if(!defined("timezone"))
{
date_default_timezone_set('Asia/Tehran');
}
else
{
date_default_timezone_set(constant('timezone'));
}
// if has subdomain and have private database for subdomain, set db
if(isset($_SERVER['HTTP_HOST']))
{
$subdomain = null;
$urlHostSegments = explode('.', $_SERVER['HTTP_HOST']);
// if have subdomain
if(count($urlHostSegments) > 2)
{
$subdomain = $urlHostSegments[0];
$subdomain_db = root.'customer/subdomain/'. $subdomain;
// if file of special database exist
if(file_exists($subdomain_db))
{
$private_db = trim(file_get_contents($subdomain_db));
if(!defined('db_name'))
{
define("db_name", $private_db);
}
}
}
}
// if personal config exist, require it
if(file_exists(root .'config.me.php'))
{
require_once(root .'config.me.php');
}
// elseif config exist, require it else show related error message
elseif(file_exists(root .'config.php'))
{
require_once(root .'config.php');
}
elseif(defined('CMS') && !constant('CMS'))
{
include_once(root .'config.php');
}
else
{
// A config file doesn't exist
// echo("<p>There doesn't seem to be a <code>config.php</code> file. I need this before we can get started.</p>");
}
// if personal define exist, require it
if(file_exists(root .'define.php'))
{
require_once(root .'define.php');
}
?>