function Initialize() { global $errors, $t, $C, $template; // Already initialized if (!empty($C['db_username'])) { $t->assign('mode', 'done'); echo $t->parse($template); } else { // Form submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { $connection = TestDBConnection(); if (!$connection) { $t->assign_by_ref('errors', $errors); $t->assign_by_ref('request', $_REQUEST); $t->assign('mode', 'getdb'); echo $t->parse($template); } else { // Create database tables and setup initial login FileWrite("{$GLOBALS['BASE_DIR']}/data/.htaccess", "deny from all"); CreateTables(); WriteConfig($_REQUEST); RecompileTemplates(); // Display initialization finished screen $t->assign('control_panel', "http://{$_SERVER['HTTP_HOST']}" . dirname($_SERVER['REQUEST_URI']) . "/index.php"); $t->assign('mode', 'login'); echo $t->parse($template); } } else { // Run pre-initialization tests ServerTest(); FilesTest(); DirectoriesTest(); TemplatesTest(); if (is_dir('../utilities')) { $errors[] = 'For security purposes, the utilities directory must be removed'; } if (count($errors)) { // Display failed test information $t->assign('mode', 'errors'); $t->assign_by_ref('errors', $errors); echo $t->parse($template); } else { $_REQUEST['db_hostname'] = 'localhost'; $t->assign_by_ref('request', $_REQUEST); $t->assign_by_ref('errors', $errors); $t->assign('mode', 'getdb'); echo $t->parse($template); } } } }
function ChangeMysql() { global $errors, $t, $C, $template; // Form submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { $connection = TestDBConnection(); if (!$connection) { $t->assign_by_ref('errors', $errors); $t->assign_by_ref('request', $_REQUEST); $t->assign('mode', 'getdb'); } else { // Write data to configuration file WriteConfig($_REQUEST); $t->assign('mode', 'done'); } } else { $_REQUEST['db_hostname'] = 'localhost'; $t->assign_by_ref('request', $_REQUEST); $t->assign('mode', 'getdb'); } echo $t->parse($template); }