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/*
19 defined('AK_CONFIG_DIR') ?
null : define('AK_CONFIG_DIR', AK_BASE_DIR
.DS
.'config');
21 // If you need to customize the framework default settings or specify internationalization options,
22 // edit the files config/testing.php, config/development.php, config/production.php
23 if(AK_ENVIRONMENT
!= 'setup'){
24 require_once(AK_CONFIG_DIR
.DS
.'environments'.DS
.AK_ENVIRONMENT
.'.php');
27 if (!defined('AK_TEST_DATABASE_ON')) {
28 defined('AK_DEFAULT_DATABASE_PROFILE') ?
null : define('AK_DEFAULT_DATABASE_PROFILE', AK_ENVIRONMENT
);
31 // Locale settings ( you must create a file at /config/locales/ using en.php as departure point)
32 // Please be aware that your charset needs to be UTF-8 in order to edit the locales files
33 // auto will enable all the locales at config/locales/ dir
34 defined('AK_AVAILABLE_LOCALES') ?
null : define('AK_AVAILABLE_LOCALES', 'auto');
37 // Set these constants in order to allow only these locales on web requests
38 // defined('AK_ACTIVE_RECORD_DEFAULT_LOCALES') ? null : define('AK_ACTIVE_RECORD_DEFAULT_LOCALES','en,es');
39 // defined('AK_APP_LOCALES') ? null : define('AK_APP_LOCALES','en,es');
40 // defined('AK_PUBLIC_LOCALES') ? null : define('AK_PUBLIC_LOCALES','en,es');
42 // defined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true);
44 defined('AK_TIME_DIFFERENCE') ?
null : define('AK_TIME_DIFFERENCE', 0); // Time difference from the webserver
46 // COMMENT THIS LINE IF YOU DONT WANT THE FRAMEWORK TO CONNECT TO THE DATABASE ON EACH REQUEST AUTOMATICALLY
47 defined('AK_WEB_REQUEST_CONNECT_TO_DATABASE_ON_INSTANTIATE') ?
null : define('AK_WEB_REQUEST_CONNECT_TO_DATABASE_ON_INSTANTIATE', true);
49 defined('AK_CLI') ?
null : define('AK_CLI', php_sapi_name() == 'cli');
50 defined('AK_WEB_REQUEST') ?
null : define('AK_WEB_REQUEST', !empty($_SERVER['REQUEST_URI']));
51 defined('AK_REQUEST_URI') ?
null : define('AK_REQUEST_URI', isset($_SERVER['REQUEST_URI']) ?
52 $_SERVER['REQUEST_URI'] :
53 $_SERVER['PHP_SELF'] .'?'.(isset($_SERVER['argv']) ?
$_SERVER['argv'][0] : $_SERVER['QUERY_STRING']));
55 defined('AK_DEBUG') ?
null : define('AK_DEBUG', AK_ENVIRONMENT
== 'production' ?
0 : 1);
57 defined('AK_ERROR_REPORTING') ?
null : define('AK_ERROR_REPORTING', AK_DEBUG ? E_ALL
: 0);
59 @error_reporting
(AK_ERROR_REPORTING
);
61 defined('AK_CACHE_HANDLER') ?
null : define('AK_CACHE_HANDLER', 1);
63 defined('AK_APP_DIR') ?
null : define('AK_APP_DIR', AK_BASE_DIR
.DS
.'app');
64 defined('AK_APIS_DIR') ?
null : define('AK_APIS_DIR', AK_APP_DIR
.DS
.'apis');
65 defined('AK_MODELS_DIR') ?
null : define('AK_MODELS_DIR', AK_APP_DIR
.DS
.'models');
66 defined('AK_CONTROLLERS_DIR') ?
null : define('AK_CONTROLLERS_DIR', AK_APP_DIR
.DS
.'controllers');
67 defined('AK_VIEWS_DIR') ?
null : define('AK_VIEWS_DIR', AK_APP_DIR
.DS
.'views');
68 defined('AK_HELPERS_DIR') ?
null : define('AK_HELPERS_DIR', AK_APP_DIR
.DS
.'helpers');
69 defined('AK_PUBLIC_DIR') ?
null : define('AK_PUBLIC_DIR', AK_BASE_DIR
.DS
.'public');
70 defined('AK_TEST_DIR') ?
null : define('AK_TEST_DIR', AK_BASE_DIR
.DS
.'test');
71 defined('AK_SCRIPT_DIR') ?
null : define('AK_SCRIPT_DIR',AK_BASE_DIR
.DS
.'script');
72 defined('AK_APP_VENDOR_DIR') ?
null : define('AK_APP_VENDOR_DIR',AK_APP_DIR
.DS
.'vendor');
73 defined('AK_APP_PLUGINS_DIR') ?
null : define('AK_APP_PLUGINS_DIR',AK_APP_VENDOR_DIR
.DS
.'plugins');
78 * Getting the temporary directory
80 function ak_get_tmp_dir_name(){
81 if(!defined('AK_TMP_DIR')){
82 if(defined('AK_BASE_DIR') && is_writable(AK_BASE_DIR
.DS
.'tmp')){
83 return AK_BASE_DIR
.DS
.'tmp';
85 if(!function_exists('sys_get_temp_dir')){
86 $dir = empty($_ENV['TMP']) ?
(empty($_ENV['TMPDIR']) ?
(empty($_ENV['TEMP']) ?
false : $_ENV['TEMP']) : $_ENV['TMPDIR']) : $_ENV['TMP'];
87 if(empty($dir) && $fn = tempnam(md5(rand()),'')){
92 $dir = sys_get_temp_dir();
95 trigger_error('Could not find a path for temporary files. Please define AK_TMP_DIR in your config.php', E_USER_ERROR
);
97 $dir = rtrim(realpath($dir), DS
).DS
.'ak_'.md5(AK_BASE_DIR
);
106 defined('AK_TMP_DIR') ?
null : define('AK_TMP_DIR', ak_get_tmp_dir_name());
107 defined('AK_COMPILED_VIEWS_DIR') ?
null : define('AK_COMPILED_VIEWS_DIR', AK_TMP_DIR
.DS
.'views');
108 defined('AK_CACHE_DIR') ?
null : define('AK_CACHE_DIR', AK_TMP_DIR
.DS
.'cache');
111 defined('AK_DEFAULT_LAYOUT') ?
null : define('AK_DEFAULT_LAYOUT', 'application');
113 defined('AK_CONTRIB_DIR') ?
null : define('AK_CONTRIB_DIR',AK_FRAMEWORK_DIR
.DS
.'vendor');
114 defined('AK_VENDOR_DIR') ?
null : define('AK_VENDOR_DIR', AK_CONTRIB_DIR
);
115 defined('AK_DOCS_DIR') ?
null : define('AK_DOCS_DIR',AK_FRAMEWORK_DIR
.DS
.'docs');
119 defined('AK_CONFIG_INCLUDED') ?
null : define('AK_CONFIG_INCLUDED',true);
120 defined('AK_FW') ?
null : define('AK_FW',true);
122 if(AK_ENVIRONMENT
!= 'setup'){
123 defined('AK_UPLOAD_FILES_USING_FTP') ?
null : define('AK_UPLOAD_FILES_USING_FTP', !empty($ftp_settings));
124 defined('AK_READ_FILES_USING_FTP') ?
null : define('AK_READ_FILES_USING_FTP', false);
125 defined('AK_DELETE_FILES_USING_FTP') ?
null : define('AK_DELETE_FILES_USING_FTP', !empty($ftp_settings));
126 defined('AK_FTP_AUTO_DISCONNECT') ?
null : define('AK_FTP_AUTO_DISCONNECT', !empty($ftp_settings));
128 if(!empty($ftp_settings)){
129 defined('AK_FTP_PATH') ?
null : define('AK_FTP_PATH', $ftp_settings);
130 unset($ftp_settings);
134 @ini_set
("arg_separator.output","&");
136 @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")));
137 defined('AK_PHP5') ?
null : define('AK_PHP5', version_compare(PHP_VERSION
, '5', '>=') == 1 ?
true : false);
139 if(!AK_CLI
&& AK_WEB_REQUEST
){
141 if (!defined('AK_SITE_URL_SUFFIX'))
143 $__ak_site_url_suffix_userdir = substr(AK_REQUEST_URI
,1,1) == '~' ?
substr(AK_REQUEST_URI
, 0, strpos(AK_REQUEST_URI
, '/', 1)) : '';
144 $__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
);
145 define('AK_SITE_URL_SUFFIX', $__ak_site_url_suffix_userdir.$__ak_site_url_suffix);
146 unset($__ak_site_url_suffix_userdir, $__ak_site_url_suffix);
149 defined('AK_AUTOMATIC_SSL_DETECTION') ?
null : define('AK_AUTOMATIC_SSL_DETECTION', 1);
151 defined('AK_PROTOCOL') ?
null : define('AK_PROTOCOL',isset($_SERVER['HTTPS']) ?
'https://' : 'http://');
152 defined('AK_HOST') ?
null : define('AK_HOST', $_SERVER['SERVER_NAME'] == 'localhost' ?
153 // Will force to IP4 for localhost until IP6 is supported by helpers
154 ($_SERVER['SERVER_ADDR'] == '::1' ?
'127.0.0.1' : $_SERVER['SERVER_ADDR']) :
155 $_SERVER['SERVER_NAME']);
156 defined('AK_REMOTE_IP') ?
null : define('AK_REMOTE_IP',(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);
158 defined('AK_SERVER_STANDARD_PORT') ?
null : define('AK_SERVER_STANDARD_PORT', AK_PROTOCOL
== 'https://' ?
'443' : '80');
160 $_ak_port = ($_SERVER['SERVER_PORT'] != AK_SERVER_STANDARD_PORT
)
161 ?
(empty($_SERVER['SERVER_PORT']) ?
'' : ':'.$_SERVER['SERVER_PORT']) : '';
163 if(isset($_SERVER['HTTP_HOST']) && strstr($_SERVER['HTTP_HOST'],':')){
164 $_ak_port = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'],':'));
167 if(defined('AK_SITE_HTPSS_URL_SUFFIX') && isset($_SERVER['HTTPS'])){
168 $_ak_suffix = AK_SITE_HTPSS_URL_SUFFIX
;
169 $_ak_port = strstr(AK_SITE_HTPSS_URL_SUFFIX
,':') ?
'' : $_ak_port;
170 }elseif(defined('AK_SITE_URL_SUFFIX') && AK_SITE_URL_SUFFIX
!= ''){
171 $_ak_suffix = AK_SITE_URL_SUFFIX
;
172 $_ak_port = strstr(AK_SITE_URL_SUFFIX
,':') ?
'' : $_ak_port;
174 if(!defined('AK_SITE_URL')){
175 defined('AK_SITE_URL') ?
null : define('AK_SITE_URL', trim(AK_PROTOCOL
.AK_HOST
, '/').$_ak_port.$_ak_suffix);
176 defined('AK_URL') ?
null : define('AK_URL', AK_SITE_URL
);
178 if(AK_AUTOMATIC_SSL_DETECTION
){
179 defined('AK_URL') ?
null : define('AK_URL', str_replace(array('https://','http://'),AK_PROTOCOL
, AK_SITE_URL
).$_ak_port.$_ak_suffix);
181 defined('AK_URL') ?
null : define('AK_URL', AK_SITE_URL
.$_ak_port.$_ak_suffix);
185 defined('AK_CURRENT_URL') ?
null : define('AK_CURRENT_URL', substr(AK_SITE_URL
,0,strlen($_ak_suffix)*-1).AK_REQUEST_URI
);
187 defined('AK_SERVER_PORT') ?
null : define('AK_SERVER_PORT', empty($_ak_port) ? AK_SERVER_STANDARD_PORT
: trim($_ak_port,':'));
189 unset($_ak_suffix, $_ak_port);
190 defined('AK_COOKIE_DOMAIN') ?
null : define('AK_COOKIE_DOMAIN', AK_HOST
);
191 // ini_set('session.cookie_domain', AK_COOKIE_DOMAIN);
193 defined('AK_INSECURE_APP_DIRECTORY_LAYOUT') ?
null : define('AK_INSECURE_APP_DIRECTORY_LAYOUT', false);
195 if(!defined('AK_ASSET_URL_PREFIX')){
196 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
);
201 defined('AK_PROTOCOL') ?
null : define('AK_PROTOCOL','http://');
202 defined('AK_HOST') ?
null : define('AK_HOST', 'localhost');
203 defined('AK_REMOTE_IP') ?
null : define('AK_REMOTE_IP','127.0.0.1');
204 defined('AK_SITE_URL') ?
null : define('AK_SITE_URL', 'http://localhost');
205 defined('AK_URL') ?
null : define('AK_URL', 'http://localhost/');
206 defined('AK_CURRENT_URL') ?
null : define('AK_CURRENT_URL', 'http://localhost/');
207 defined('AK_COOKIE_DOMAIN') ?
null : define('AK_COOKIE_DOMAIN', AK_HOST
);
209 defined('AK_ASSET_URL_PREFIX') ?
null : define('AK_ASSET_URL_PREFIX', '');
212 defined('AK_SESSION_HANDLER') ?
null : define('AK_SESSION_HANDLER', 0);
213 defined('AK_SESSION_EXPIRE') ?
null : define('AK_SESSION_EXPIRE', 600);
214 defined('AK_SESSION_NAME') ?
null : define('AK_SESSION_NAME', 'AK_'.substr(md5(AK_HOST
.AK_APP_DIR
),0,6));
215 @ini_set
("session.name", AK_SESSION_NAME
);
217 defined('AK_DESKTOP') ?
null : define('AK_DESKTOP', AK_SITE_URL
== 'http://akelos');
219 defined('AK_ASSET_HOST') ?
null : define('AK_ASSET_HOST','');
221 defined('AK_DEV_MODE') ?
null : define('AK_DEV_MODE', AK_ENVIRONMENT
== 'development');
222 defined('AK_AUTOMATICALLY_UPDATE_LANGUAGE_FILES') ?
null : define('AK_AUTOMATICALLY_UPDATE_LANGUAGE_FILES', AK_DEV_MODE
);
223 defined('AK_ENABLE_PROFILER') ?
null : define('AK_ENABLE_PROFILER', false);
224 defined('AK_PROFILER_GET_MEMORY') ?
null : define('AK_PROFILER_GET_MEMORY',false);
226 $ADODB_CACHE_DIR = AK_CACHE_DIR
;
229 * Mode types for error reporting and loggin
231 defined('AK_MODE_DISPLAY') ?
null : define('AK_MODE_DISPLAY', 1);
232 defined('AK_MODE_MAIL') ?
null : define('AK_MODE_MAIL', 2);
233 defined('AK_MODE_FILE') ?
null : define('AK_MODE_FILE', 4);
234 defined('AK_MODE_DATABASE') ?
null : define('AK_MODE_DATABASE', 8);
235 defined('AK_MODE_DIE') ?
null : define('AK_MODE_DIE', 16);
237 defined('AK_LOG_DIR') ?
null : define('AK_LOG_DIR', AK_BASE_DIR
.DS
.'log');
238 defined('AK_LOG_EVENTS') ?
null : define('AK_LOG_EVENTS', false);
240 defined('AK_ROUTES_MAPPING_FILE') ?
null : define('AK_ROUTES_MAPPING_FILE', AK_CONFIG_DIR
.DS
.'routes.php');
241 defined('AK_OS') ?
null : define('AK_OS', (strtoupper(substr(PHP_OS
, 0, 3)) === 'WIN' ?
'WINDOWS' : 'UNIX'));
242 defined('AK_CHARSET') ?
null : define('AK_CHARSET', 'UTF-8');
244 defined('AK_ACTION_CONTROLLER_DEFAULT_REQUEST_TYPE') ?
null : define('AK_ACTION_CONTROLLER_DEFAULT_REQUEST_TYPE', 'web_request');
245 defined('AK_ACTION_CONTROLLER_DEFAULT_ACTION') ?
null : define('AK_ACTION_CONTROLLER_DEFAULT_ACTION', 'index');
247 defined('AK_ERROR_REPORTING_ON_SCRIPTS') ?
null : define('AK_ERROR_REPORTING_ON_SCRIPTS', E_ALL
);
248 defined('AK_BEEP_ON_ERRORS_WHEN_TESTING') ?
null : define('AK_BEEP_ON_ERRORS_WHEN_TESTING', false);