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