4 * This file and the lib/constants.php file perform most part of Akelos
5 * environment guessing.
7 * You can retrieve a list of current settings by running Ak::get_constants();
9 * If you're running a high load site you might want to fine tune this options
10 * according to your environment. If you set the options implicitly you might
11 * gain in performance but loose in flexibility when moving to a different
14 * If you need to customize the framework default settings or specify
15 * internationalization options, edit the files at config/environments/*
18 defined('AK_CONFIG_DIR') ?
null : define('AK_CONFIG_DIR', AK_BASE_DIR
.DS
.'config');
20 // If you need to customize the framework default settings or specify internationalization options,
21 // edit the files config/testing.php, config/development.php, config/production.php
22 if(AK_ENVIRONMENT
!= 'setup'){
23 require_once(AK_CONFIG_DIR
.DS
.'environments'.DS
.AK_ENVIRONMENT
.'.php');
26 if (!defined('AK_TEST_DATABASE_ON')) {
27 defined('AK_DEFAULT_DATABASE_PROFILE') ?
null : define('AK_DEFAULT_DATABASE_PROFILE', AK_ENVIRONMENT
);
30 // Locale settings ( you must create a file at /config/locales/ using en.php as departure point)
31 // Please be aware that your charset needs to be UTF-8 in order to edit the locales files
32 // auto will enable all the locales at config/locales/ dir
33 defined('AK_AVAILABLE_LOCALES') ?
null : define('AK_AVAILABLE_LOCALES', 'auto');
36 // Set these constants in order to allow only these locales on web requests
37 // defined('AK_ACTIVE_RECORD_DEFAULT_LOCALES') ? null : define('AK_ACTIVE_RECORD_DEFAULT_LOCALES','en,es');
38 // defined('AK_APP_LOCALES') ? null : define('AK_APP_LOCALES','en,es');
39 // defined('AK_PUBLIC_LOCALES') ? null : define('AK_PUBLIC_LOCALES','en,es');
41 // defined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true);
43 defined('AK_TIME_DIFFERENCE') ?
null : define('AK_TIME_DIFFERENCE', 0); // Time difference from the webserver
45 // COMMENT THIS LINE IF YOU DONT WANT THE FRAMEWORK TO CONNECT TO THE DATABASE ON EACH REQUEST AUTOMATICALLY
46 defined('AK_WEB_REQUEST_CONNECT_TO_DATABASE_ON_INSTANTIATE') ?
null : define('AK_WEB_REQUEST_CONNECT_TO_DATABASE_ON_INSTANTIATE', true);
48 defined('AK_CLI') ?
null : define('AK_CLI', php_sapi_name() == 'cli');
49 defined('AK_WEB_REQUEST') ?
null : define('AK_WEB_REQUEST', !empty($_SERVER['REQUEST_URI']));
50 defined('AK_REQUEST_URI') ?
null : define('AK_REQUEST_URI', isset($_SERVER['REQUEST_URI']) ?
51 $_SERVER['REQUEST_URI'] :
52 $_SERVER['PHP_SELF'] .'?'.(isset($_SERVER['argv']) ?
$_SERVER['argv'][0] : $_SERVER['QUERY_STRING']));
54 defined('AK_DEBUG') ?
null : define('AK_DEBUG', AK_ENVIRONMENT
== 'production' ?
0 : 1);
56 defined('AK_ERROR_REPORTING') ?
null : define('AK_ERROR_REPORTING', AK_DEBUG ? E_ALL
: 0);
58 @error_reporting
(AK_ERROR_REPORTING
);
60 defined('AK_CACHE_HANDLER') ?
null : define('AK_CACHE_HANDLER', 1);
62 defined('AK_APP_DIR') ?
null : define('AK_APP_DIR', AK_BASE_DIR
.DS
.'app');
63 defined('AK_APIS_DIR') ?
null : define('AK_APIS_DIR', AK_APP_DIR
.DS
.'apis');
64 defined('AK_MODELS_DIR') ?
null : define('AK_MODELS_DIR', AK_APP_DIR
.DS
.'models');
65 defined('AK_CONTROLLERS_DIR') ?
null : define('AK_CONTROLLERS_DIR', AK_APP_DIR
.DS
.'controllers');
66 defined('AK_VIEWS_DIR') ?
null : define('AK_VIEWS_DIR', AK_APP_DIR
.DS
.'views');
67 defined('AK_HELPERS_DIR') ?
null : define('AK_HELPERS_DIR', AK_APP_DIR
.DS
.'helpers');
68 defined('AK_PUBLIC_DIR') ?
null : define('AK_PUBLIC_DIR', AK_BASE_DIR
.DS
.'public');
69 defined('AK_TEST_DIR') ?
null : define('AK_TEST_DIR', AK_BASE_DIR
.DS
.'test');
70 defined('AK_SCRIPT_DIR') ?
null : define('AK_SCRIPT_DIR',AK_BASE_DIR
.DS
.'script');
71 defined('AK_APP_VENDOR_DIR') ?
null : define('AK_APP_VENDOR_DIR',AK_APP_DIR
.DS
.'vendor');
72 defined('AK_APP_PLUGINS_DIR') ?
null : define('AK_APP_PLUGINS_DIR',AK_APP_VENDOR_DIR
.DS
.'plugins');
75 defined('AK_TMP_DIR') ?
null : define('AK_TMP_DIR', AK_BASE_DIR
.DS
.'tmp');
76 // defined('AK_COMPILED_VIEWS_DIR') ? null : define('AK_COMPILED_VIEWS_DIR', AK_TMP_DIR.DS.'views');
77 defined('AK_CACHE_DIR') ?
null : define('AK_CACHE_DIR', AK_TMP_DIR
.DS
.'cache');
80 defined('AK_DEFAULT_LAYOUT') ?
null : define('AK_DEFAULT_LAYOUT', 'application');
82 defined('AK_CONTRIB_DIR') ?
null : define('AK_CONTRIB_DIR',AK_FRAMEWORK_DIR
.DS
.'vendor');
83 defined('AK_VENDOR_DIR') ?
null : define('AK_VENDOR_DIR', AK_CONTRIB_DIR
);
84 defined('AK_DOCS_DIR') ?
null : define('AK_DOCS_DIR',AK_FRAMEWORK_DIR
.DS
.'docs');
88 defined('AK_CONFIG_INCLUDED') ?
null : define('AK_CONFIG_INCLUDED',true);
89 defined('AK_FW') ?
null : define('AK_FW',true);
91 if(AK_ENVIRONMENT
!= 'setup'){
92 defined('AK_UPLOAD_FILES_USING_FTP') ?
null : define('AK_UPLOAD_FILES_USING_FTP', !empty($ftp_settings));
93 defined('AK_READ_FILES_USING_FTP') ?
null : define('AK_READ_FILES_USING_FTP', false);
94 defined('AK_DELETE_FILES_USING_FTP') ?
null : define('AK_DELETE_FILES_USING_FTP', !empty($ftp_settings));
95 defined('AK_FTP_AUTO_DISCONNECT') ?
null : define('AK_FTP_AUTO_DISCONNECT', !empty($ftp_settings));
97 if(!empty($ftp_settings)){
98 defined('AK_FTP_PATH') ?
null : define('AK_FTP_PATH', $ftp_settings);
103 @ini_set
("arg_separator.output","&");
105 @ini_set
("include_path",(AK_LIB_DIR
.PATH_SEPARATOR
.AK_MODELS_DIR
.PATH_SEPARATOR
.AK_CONTRIB_DIR
.DS
.'pear'.PATH_SEPARATOR
.ini_get("include_path")));
106 defined('AK_PHP5') ?
null : define('AK_PHP5', version_compare(PHP_VERSION
, '5', '>=') == 1 ?
true : false);
108 if(!AK_CLI
&& AK_WEB_REQUEST
){
110 if (!defined('AK_SITE_URL_SUFFIX'))
112 $__ak_site_url_suffix_userdir = substr(AK_REQUEST_URI
,1,1) == '~' ?
substr(AK_REQUEST_URI
, 0, strpos(AK_REQUEST_URI
, '/', 1)) : '';
113 $__ak_site_url_suffix = str_replace(array(join(DS
,array_diff((array)@explode
(DS
,AK_BASE_DIR
), (array)@explode
('/',AK_REQUEST_URI
))), DS
,'//'), array('','/','/'), AK_BASE_DIR
);
114 define('AK_SITE_URL_SUFFIX', $__ak_site_url_suffix_userdir.$__ak_site_url_suffix);
115 unset($__ak_site_url_suffix_userdir, $__ak_site_url_suffix);
118 defined('AK_AUTOMATIC_SSL_DETECTION') ?
null : define('AK_AUTOMATIC_SSL_DETECTION', 1);
120 defined('AK_PROTOCOL') ?
null : define('AK_PROTOCOL',isset($_SERVER['HTTPS']) ?
'https://' : 'http://');
121 defined('AK_HOST') ?
null : define('AK_HOST', $_SERVER['SERVER_NAME'] == 'localhost' ?
122 // Will force to IP4 for localhost until IP6 is supported by helpers
123 ($_SERVER['SERVER_ADDR'] == '::1' ?
'127.0.0.1' : $_SERVER['SERVER_ADDR']) :
124 $_SERVER['SERVER_NAME']);
125 defined('AK_REMOTE_IP') ?
null : define('AK_REMOTE_IP',(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);
127 defined('AK_SERVER_STANDARD_PORT') ?
null : define('AK_SERVER_STANDARD_PORT', AK_PROTOCOL
== 'https://' ?
'443' : '80');
129 $_ak_port = ($_SERVER['SERVER_PORT'] != AK_SERVER_STANDARD_PORT
)
130 ?
(empty($_SERVER['SERVER_PORT']) ?
'' : ':'.$_SERVER['SERVER_PORT']) : '';
132 if(isset($_SERVER['HTTP_HOST']) && strstr($_SERVER['HTTP_HOST'],':')){
133 $_ak_port = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'],':'));
136 if(defined('AK_SITE_HTPSS_URL_SUFFIX') && isset($_SERVER['HTTPS'])){
137 $_ak_suffix = AK_SITE_HTPSS_URL_SUFFIX
;
138 $_ak_port = strstr(AK_SITE_HTPSS_URL_SUFFIX
,':') ?
'' : $_ak_port;
139 }elseif(defined('AK_SITE_URL_SUFFIX') && AK_SITE_URL_SUFFIX
!= ''){
140 $_ak_suffix = AK_SITE_URL_SUFFIX
;
141 $_ak_port = strstr(AK_SITE_URL_SUFFIX
,':') ?
'' : $_ak_port;
143 if(!defined('AK_SITE_URL')){
144 defined('AK_SITE_URL') ?
null : define('AK_SITE_URL', trim(AK_PROTOCOL
.AK_HOST
, '/').$_ak_port.$_ak_suffix);
145 defined('AK_URL') ?
null : define('AK_URL', AK_SITE_URL
);
147 if(AK_AUTOMATIC_SSL_DETECTION
){
148 defined('AK_URL') ?
null : define('AK_URL', str_replace(array('https://','http://'),AK_PROTOCOL
, AK_SITE_URL
).$_ak_port.$_ak_suffix);
150 defined('AK_URL') ?
null : define('AK_URL', AK_SITE_URL
.$_ak_port.$_ak_suffix);
154 defined('AK_CURRENT_URL') ?
null : define('AK_CURRENT_URL', substr(AK_SITE_URL
,0,strlen($_ak_suffix)*-1).AK_REQUEST_URI
);
156 defined('AK_SERVER_PORT') ?
null : define('AK_SERVER_PORT', empty($_ak_port) ? AK_SERVER_STANDARD_PORT
: trim($_ak_port,':'));
158 unset($_ak_suffix, $_ak_port);
159 defined('AK_COOKIE_DOMAIN') ?
null : define('AK_COOKIE_DOMAIN', AK_HOST
);
160 // ini_set('session.cookie_domain', AK_COOKIE_DOMAIN);
162 defined('AK_INSECURE_APP_DIRECTORY_LAYOUT') ?
null : define('AK_INSECURE_APP_DIRECTORY_LAYOUT', false);
164 if(!defined('AK_ASSET_URL_PREFIX')){
165 defined('AK_ASSET_URL_PREFIX') ?
null : define('AK_ASSET_URL_PREFIX', AK_INSECURE_APP_DIRECTORY_LAYOUT ? AK_SITE_URL_SUFFIX
.str_replace(array(AK_BASE_DIR
,'\\','//'),array('','/','/'), AK_PUBLIC_DIR
) : AK_SITE_URL_SUFFIX
);
170 defined('AK_PROTOCOL') ?
null : define('AK_PROTOCOL','http://');
171 defined('AK_HOST') ?
null : define('AK_HOST', 'localhost');
172 defined('AK_REMOTE_IP') ?
null : define('AK_REMOTE_IP','127.0.0.1');
173 defined('AK_SITE_URL') ?
null : define('AK_SITE_URL', 'http://localhost');
174 defined('AK_URL') ?
null : define('AK_URL', 'http://localhost/');
175 defined('AK_CURRENT_URL') ?
null : define('AK_CURRENT_URL', 'http://localhost/');
176 defined('AK_COOKIE_DOMAIN') ?
null : define('AK_COOKIE_DOMAIN', AK_HOST
);
178 defined('AK_ASSET_URL_PREFIX') ?
null : define('AK_ASSET_URL_PREFIX', '');
181 defined('AK_SESSION_HANDLER') ?
null : define('AK_SESSION_HANDLER', 0);
182 defined('AK_SESSION_EXPIRE') ?
null : define('AK_SESSION_EXPIRE', 600);
183 defined('AK_SESSION_NAME') ?
null : define('AK_SESSION_NAME', 'AK_'.substr(md5(AK_HOST
.AK_APP_DIR
),0,6));
184 @ini_set
("session.name", AK_SESSION_NAME
);
186 defined('AK_DESKTOP') ?
null : define('AK_DESKTOP', AK_SITE_URL
== 'http://akelos');
188 defined('AK_ASSET_HOST') ?
null : define('AK_ASSET_HOST','');
190 defined('AK_DEV_MODE') ?
null : define('AK_DEV_MODE', AK_ENVIRONMENT
== 'development');
191 defined('AK_AUTOMATICALLY_UPDATE_LANGUAGE_FILES') ?
null : define('AK_AUTOMATICALLY_UPDATE_LANGUAGE_FILES', AK_DEV_MODE
);
192 defined('AK_ENABLE_PROFILER') ?
null : define('AK_ENABLE_PROFILER', false);
193 defined('AK_PROFILER_GET_MEMORY') ?
null : define('AK_PROFILER_GET_MEMORY',false);
195 $ADODB_CACHE_DIR = AK_CACHE_DIR
;
198 * Mode types for error reporting and loggin
200 defined('AK_MODE_DISPLAY') ?
null : define('AK_MODE_DISPLAY', 1);
201 defined('AK_MODE_MAIL') ?
null : define('AK_MODE_MAIL', 2);
202 defined('AK_MODE_FILE') ?
null : define('AK_MODE_FILE', 4);
203 defined('AK_MODE_DATABASE') ?
null : define('AK_MODE_DATABASE', 8);
204 defined('AK_MODE_DIE') ?
null : define('AK_MODE_DIE', 16);
206 defined('AK_LOG_DIR') ?
null : define('AK_LOG_DIR', AK_BASE_DIR
.DS
.'log');
207 defined('AK_LOG_EVENTS') ?
null : define('AK_LOG_EVENTS', false);
209 defined('AK_ROUTES_MAPPING_FILE') ?
null : define('AK_ROUTES_MAPPING_FILE', AK_CONFIG_DIR
.DS
.'routes.php');
210 defined('AK_OS') ?
null : define('AK_OS', (strtoupper(substr(PHP_OS
, 0, 3)) === 'WIN' ?
'WINDOWS' : 'UNIX'));
211 defined('AK_CHARSET') ?
null : define('AK_CHARSET', 'UTF-8');
213 defined('AK_ACTION_CONTROLLER_DEFAULT_REQUEST_TYPE') ?
null : define('AK_ACTION_CONTROLLER_DEFAULT_REQUEST_TYPE', 'web_request');
214 defined('AK_ACTION_CONTROLLER_DEFAULT_ACTION') ?
null : define('AK_ACTION_CONTROLLER_DEFAULT_ACTION', 'index');
216 defined('AK_ERROR_REPORTING_ON_SCRIPTS') ?
null : define('AK_ERROR_REPORTING_ON_SCRIPTS', E_ALL
);
217 defined('AK_BEEP_ON_ERRORS_WHEN_TESTING') ?
null : define('AK_BEEP_ON_ERRORS_WHEN_TESTING', false);