forked from tcm-project/tangocms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
115 lines (101 loc) · 3.8 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
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
<?php
/**
* Zula Framework index (collector/front controller)
*
* Please do not use any PHP5 specific syntax within this file, other wise a PHP4
* syntax error will occur. Instead we want to display our own, nicer error message
* to users of PHP4.
*
* @patches submit all patches to [email protected]
*
* @author Alex Cartwright
* @author Robert Clipsham
* @copyright Copyright (C) 2007, 2008, 2009, 2010 Alex Cartwright
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html GNU/LGPL 2.1
* @package Zula
*/
$sTime = microtime( true );
/**
* _PROJECT_ID should be a string containing A-Z, a-z, _ or - and is used
* as a identifier to the project that is using Zula, for example the
* TextDomain of controllers/modules will be prefixed with this value
* followed by a hypthen '-'.
*/
define( '_PROJECT_ID', 'tangocms' );
define( '_PROJECT_NAME', 'TangoCMS' );
/**
* Include common functions, 'starup' checks such as PHP version check
* and also some Unicode checks.
*/
require 'application/zula/common.php';
include 'application/zula/checks.php';
// Load and get an instance of the base Zula framework class
require 'application/zula/zula.php';
$zula = Zula::getInstance( dirname(__FILE__), (isset($state) ? $state : 'development') );
Registry::register( 'zula', $zula );
// _AJAX_REQUEST is DEPRECATED please use Zula::getMode() instead
define( '_AJAX_REQUEST', $zula->getMode() == 'standalone' );
if ( UNICODE_MBSTRING === false ) {
// Load needed unicode libraries
require $zula->getDir( '3rd_party' ).'/phputf8/utils/unicode.php';
require $zula->getDir( '3rd_party' ).'/phputf8/native/core.php';
}
/**
* Default directories in Zula should be fine, though you can configure
* them from here if you want, via Zula::setDir()
*/
if ( $zula->getState() == 'setup' ) {
define( '_REAL_MODULE_DIR', $zula->getDir( 'modules' ) );
// Reconfigure some directories so they work correctly when installing
$zula->setDir( 'modules', './modules' );
$zula->setDir( 'themes', './themes' );
$zula->setDir( 'assets', '../assets' );
$zula->setDir( 'js', '../assets/js' );
$zula->setDir( 'tmp', '../tmp' );
$zula->setDir( 'uploads', '../assets/uploads' );
$zula->setDir( 'config', '../config' );
}
$input = $zula->loadLib( 'input' ); # Early loading of a default lib
/**
* Get the correct config name to set the config directory, either based
* upon the server name or the provided CLI configuration.
*/
$configName = 'default';
if ( $zula->getMode() == 'cli' ) {
$configName = $input->cli( 'c' );
} else {
$serverName = $_SERVER['SERVER_NAME'];
if ( strlen( _BASE_DIR ) != 1 ) {
$serverName .= _BASE_DIR;
}
$serverName = str_replace( '/', '.', rtrim($serverName, '/') );
if ( strlen( $serverName ) ) {
if ( substr( $serverName, -8 ) == '.setup' ) {
$serverName = substr( $serverName, 0, -6 );
}
if ( strpos( $serverName, 'www.' ) === 0 ) {
$serverName = substr( $serverName, 4 );
}
if ( is_dir( $zula->getDir( 'config' ).'/'.$serverName ) ) {
$configName = $serverName;
}
}
}
// Load the main configuration file for the project and define version
$config = $zula->loadConfig( $configName );
define( '_PROJECT_VERSION', $config->get( 'config/version' ) );
// Load the default libraries that are most commonly needed
$zula->loadDefaultLibs();
Registry::get( 'i18n' )->setLocale( $config->get('locale/default') );
Module::setDirectory( $zula->getDir( 'modules' ) );
/**
* Finally run the bootstrap to handle our request, and exit correctly
*/
$status = require 'application/zula/bootstrap.php';
$msg = sprintf( 'Zula request finished %1$s in %2$f seconds',
($status ? 'successfully' : 'unsuccessfully'),
microtime(true)-$sTime );
$log = Registry::get( 'log' );
$log->message( $msg, 1 );
exit( $zula->getExitCode() );
?>