1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18:
19: @ini_set('display_errors', false);
20:
21:
22: error_reporting(E_ALL ^E_NOTICE);
23:
24:
25: header('Content-Type: text/html; charset=ISO-8859-1');
26:
27:
28:
29: if (version_compare(PHP_VERSION, '5.0.0', '<')) {
30: die("You need PHP >= 5.0.0 for CONTENIDO. Sorry, even the setup doesn't work otherwise. Your version: " . PHP_VERSION . "\n");
31: }
32:
33:
34:
35: if (version_compare(PHP_VERSION, '6.0.0', '>=')) {
36: die("You need PHP >= 5.0.0 < 6.0.0 for CONTENIDO. Sorry, even the setup doesn't work otherwise. Your version: " . PHP_VERSION . "\n");
37: }
38:
39: 40: 41: 42: 43: 44: 45: 46:
47: if (!defined('CON_ENVIRONMENT')) {
48: if (getenv('CONTENIDO_ENVIRONMENT')) {
49: $sEnvironment = getenv('CONTENIDO_ENVIRONMENT');
50: } else if (getenv('CON_ENVIRONMENT')) {
51: $sEnvironment = getenv('CON_ENVIRONMENT');
52: } else {
53:
54: $sEnvironment = 'production';
55: }
56:
57: define('CON_ENVIRONMENT', $sEnvironment);
58: }
59:
60: 61: 62: 63: 64:
65: function checkAndInclude($filename) {
66: if (file_exists($filename) && is_readable($filename)) {
67: include_once($filename);
68: } else {
69: echo "<pre>";
70: echo "Setup was unable to include neccessary files. The file $filename was not found. Solutions:\n\n";
71: echo "- Make sure that all files are correctly uploaded to the server.\n";
72: echo "- Make sure that include_path is set to '.' (of course, it can contain also other directories). Your include path is: " . ini_get("include_path") . "\n";
73: echo "</pre>";
74: }
75: }
76:
77:
78: checkAndInclude(CON_FRONTEND_PATH . '/contenido/classes/class.filehandler.php');
79: checkAndInclude(CON_FRONTEND_PATH . '/contenido/classes/class.requestvalidator.php');
80: try {
81: $requestValidator = cRequestValidator::getInstance();
82: $requestValidator->checkParams();
83: } catch (cFileNotFoundException $e) {
84: die($e->getMessage());
85: }
86:
87: session_start();
88:
89: if (is_array($_REQUEST)) {
90: foreach ($_REQUEST as $key => $value) {
91: if ($key == 'c') {
92:
93: continue;
94: }
95: if (($value != '' && $key != 'dbpass' && $key != 'adminpass' && $key != 'adminpassrepeat') || ($key == 'dbpass' && $_REQUEST['dbpass_changed'] == 'true') || ($key == 'adminpass' && $_REQUEST['adminpass_changed'] == 'true') || ($key == 'adminpassrepeat' && $_REQUEST['adminpassrepeat_changed'] == 'true')) {
96: $_SESSION[$key] = $value;
97: }
98: }
99: }
100:
101:
102:
103: if (ini_get('max_execution_time') < 60) {
104: ini_set('max_execution_time', 60);
105: }
106:
107:
108: global $cfg;
109:
110: $cfg['path']['frontend'] = CON_FRONTEND_PATH;
111: $cfg['path']['contenido'] = $cfg['path']['frontend'] . '/contenido/';
112: $cfg['path']['contenido_config'] = CON_FRONTEND_PATH . '/data/config/' . CON_ENVIRONMENT . '/';
113:
114:
115: $cfg['sql']['sqlprefix'] = (isset($_SESSION['dbprefix'])) ? $_SESSION['dbprefix'] : 'con';
116: $cfg['db'] = array(
117: 'connection' => array(
118: 'host' => (isset($_SESSION['dbhost'])) ? $_SESSION['dbhost'] : '',
119: 'database' => (isset($_SESSION['dbname'])) ? $_SESSION['dbname'] : '',
120: 'user' => (isset($_SESSION['dbuser'])) ? $_SESSION['dbuser'] : '',
121: 'password' => (isset($_SESSION['dbpass'])) ? $_SESSION['dbpass'] : '',
122: 'charset' => (isset($_SESSION['dbcharset'])) ? $_SESSION['dbcharset'] : ''
123: ),
124: 'haltBehavior' => 'report',
125: 'haltMsgPrefix' => (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] . ' ' : '',
126: 'enableProfiling' => false,
127: );
128:
129: checkAndInclude($cfg['path']['contenido_config'] . 'config.path.php');
130: checkAndInclude($cfg['path']['contenido_config'] . 'config.misc.php');
131: checkAndInclude($cfg['path']['contenido_config'] . 'cfg_sql.inc.php');
132:
133:
134: if ($cfg['php_settings'] && is_array($cfg['php_settings'])) {
135: foreach ($cfg['php_settings'] as $settingName => $value) {
136:
137: if ($settingName !== 'date.timezone') {
138: @ini_set($settingName, $value);
139: }
140: }
141: }
142: error_reporting($cfg['php_error_reporting']);
143:
144:
145: $timezoneCfg = $cfg['php_settings']['date.timezone'];
146: if (!empty($timezoneCfg) && ini_get('date.timezone') !== $timezoneCfg) {
147:
148: date_default_timezone_set($timezoneCfg);
149: } else if (empty($timezoneCfg) && (ini_get('date.timezone') === '' || ini_get('date.timezone') === false)) {
150:
151: date_default_timezone_set('UTC');
152: }
153:
154:
155: checkAndInclude($cfg['path']['contenido'] . $cfg['path']['classes'] . 'class.autoload.php');
156: cAutoload::initialize($cfg);
157:
158:
159:
160: cHTML::setGenerateXHTML(false);
161:
162:
163: checkAndInclude(CON_SETUP_PATH . '/lib/defines.php');
164: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.php54.php');
165: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.i18n.php');
166: checkAndInclude($cfg['path']['contenido'] . 'includes/api/functions.api.general.php');
167: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.general.php');
168: checkAndInclude($cfg['path']['contenido'] . 'classes/class.template.php');
169: checkAndInclude(CON_SETUP_PATH . '/lib/class.setupcontrols.php');
170: checkAndInclude(CON_SETUP_PATH . '/lib/functions.filesystem.php');
171: checkAndInclude(CON_SETUP_PATH . '/lib/functions.environment.php');
172: checkAndInclude(CON_SETUP_PATH . '/lib/functions.safe_mode.php');
173: checkAndInclude(CON_SETUP_PATH . '/lib/functions.mysql.php');
174: checkAndInclude(CON_SETUP_PATH . '/lib/functions.phpinfo.php');
175: checkAndInclude(CON_SETUP_PATH . '/lib/functions.libraries.php');
176: checkAndInclude(CON_SETUP_PATH . '/lib/functions.system.php');
177: checkAndInclude(CON_SETUP_PATH . '/lib/functions.sql.php');
178: checkAndInclude(CON_SETUP_PATH . '/lib/functions.setup.php');
179: checkAndInclude(CON_SETUP_PATH . '/lib/class.setupmask.php');
180:
181:
182: if (false === isPHPCompatible()) {
183: $sNotInstallableReason = 'php_version';
184: checkAndInclude(CON_SETUP_PATH . '/steps/notinstallable.php');
185: }
186:
187:
188: if (getPHPIniSetting('session.use_cookies') == 0) {
189: $sNotInstallableReason = 'session_use_cookies';
190: checkAndInclude(CON_SETUP_PATH . '/steps/notinstallable.php');
191: }
192:
193:
194: $extension = getMySQLDatabaseExtension();
195: if (!is_null($extension)) {
196: $cfg['database_extension'] = $extension;
197: } else {
198: $sNotInstallableReason = 'database_extension';
199: checkAndInclude(CON_SETUP_PATH . '/steps/notinstallable.php');
200: }
201:
202: if (isset($_SESSION['language'])) {
203: i18nInit('locale/', $_SESSION['language'], 'setup');
204: }
205: