/
application.php
68 lines (62 loc) · 2.4 KB
/
application.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
<?php
/**
* Main application file. Use this file to register new classes to auto loader
* service, define application level constants, init specific application
* resources etc
*
* @version 1.0
* @http://www.projectpier.org/
*/
trace(__FILE__, 'begin');
define('FILE_STORAGE_FILE_SYSTEM', 'fs');
define('FILE_STORAGE_MYSQL', 'mysql');
define('TOKEN_COOKIE_NAME', 'pp088' . TABLE_PREFIX);
//$installation_root = config_option('installation_root', dirname($_SERVER['PHP_SELF']) );
$path=$_SERVER['PHP_SELF'];
$path=substr($path, 0, strpos($path, 'index.php'));
$installation_root = $path;
define('ROOT_URL', $installation_root);
// Init flash!
Flash::instance();
$language = config_option('installation_base_language', 'en_us');
if (isset($_SESSION['language'])) {
$language = $_SESSION['language'];
}
if (!plugin_active('i18n')) {
Localization::instance()->loadSettings($language, ROOT . '/language');
}
try {
trace(__FILE__, 'CompanyWebsite::init()');
CompanyWebsite::init();
if (config_option('upgrade_check_enabled', false)) {
VersionChecker::check(false);
} // if
if (config_option('file_storage_adapter', 'mysql') == FILE_STORAGE_FILE_SYSTEM) {
trace(__FILE__, 'FileRepository::setBackend() - use file storage');
FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR));
} else {
trace(__FILE__, 'FileRepository::setBackend() - use mysql storage');
FileRepository::setBackend(new FileRepository_Backend_MySQL(DB::connection()->getLink(), TABLE_PREFIX));
} // if
PublicFiles::setRepositoryPath(ROOT . '/public/files');
if (trim(PUBLIC_FOLDER) == '') {
PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files');
} else {
PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . PUBLIC_FOLDER . '/files');
} // if
// Owner company or administrator doen't exist? Let the user create them
} catch(OwnerCompanyDnxError $e) {
Env::executeAction('access', 'complete_installation');
} catch(AdministratorDnxError $e) {
Env::executeAction('access', 'complete_installation');
// Other type of error? We need to break here
} catch(Exception $e) {
trace(__FILE__, '- catch '.$e);
if (Env::isDebugging()) {
Env::dumpError($e);
} else {
Logger::log($e, Logger::FATAL);
Env::executeAction('error', 'system');
} // if
} // if
?>