$dbmake = false; } make_db($dbhost, $dbuname, $dbpass, $dbname, $prefix, $dbtype, $dbmake, $dbtabletype); print_start(); break; case "Continue": print_continue(); break; case "Set Login": $inst_dbconn = dbconnect($dbhost, $dbuname, $dbpass, $dbname, $dbtype); update_config_php(true); // Scott - added input_data($dbhost, $dbuname, $dbpass, $dbname, $prefix, $dbtype, $aid, $name, $pwd, $repeatpwd, $email, $url); if (start_postnuke($aid, $pwd)) { set_config_vars($currentlang); install_modules(); insert_basic_data($prefix); close_postnuke(); } else { echo "unable to start PostNuke!!"; exit; } print_set_login(); break; case "Select Language": print_select_language(); break; case "Set Language": $currentlang = $alanguage; print_default(); break;
/** * INSTALLATION GOES HERE!!! **/ function __do_install() { global $config, $parser, $dirh; write2log('> [__do_install()]'); include dirname(__FILE__) . '/../framework/functions.php'; $cat_path = sanitize_path(dirname(__FILE__) . '/..'); $inst_path = sanitize_path($cat_path . '/' . pathinfo(dirname(__FILE__), PATHINFO_BASENAME)); if (isset($config['install_tables']) && $config['install_tables'] == 'true') { $install_tables = true; } else { $install_tables = false; } // get server IP if (array_key_exists('SERVER_ADDR', $_SERVER)) { $server_addr = $_SERVER['SERVER_ADDR']; } else { $server_addr = '127.0.0.1'; } // remove trailing / $config_cat_url = rtrim($config['cat_url'], '/'); // remove scheme $config_cat_url = preg_replace('~^https?:~i', '', $config_cat_url); $config_content = "" . "<?php\n" . "\n" . "if(defined('CAT_PATH')) {\n" . " die('By security reasons it is not permitted to load \\'config.php\\' twice!! " . "Forbidden call from \\''.\$_SERVER['SCRIPT_NAME'].'\\'!');\n}\n\n" . "// *****************************************************************************\n" . "// please set the path names for the backend subfolders here; that is,\n" . "// if you rename 'backend' to 'myadmin', for example, set 'CAT_BACKEND_FOLDER'\n" . "// to 'myadmin'.\n" . "// *****************************************************************************\n" . "// path to backend subfolder; default name is 'backend'\n" . "define('CAT_BACKEND_FOLDER', 'backend');\n" . "// *****************************************************************************\n" . "define('CAT_BACKEND_PATH', CAT_BACKEND_FOLDER );\n" . "define('CAT_DB_TYPE', 'mysql');\n" . "define('CAT_DB_HOST', '" . $config['database_host'] . "');\n" . "define('CAT_DB_PORT', '" . $config['database_port'] . "');\n" . "define('CAT_DB_USERNAME', '" . $config['database_username'] . "');\n" . "define('CAT_DB_PASSWORD', '" . $config['database_password'] . "');\n" . "define('CAT_DB_NAME', '" . $config['database_name'] . "');\n" . "define('CAT_TABLE_PREFIX', '" . $config['table_prefix'] . "');\n" . "\n" . "define('CAT_SERVER_ADDR', '" . $server_addr . "');\n" . "define('CAT_PATH', dirname(__FILE__));\n" . "define('CAT_URL', '" . $config_cat_url . "');\n" . "define('CAT_ADMIN_PATH', CAT_PATH.'/'.CAT_BACKEND_PATH);\n" . "define('CAT_ADMIN_URL', CAT_URL.'/'.CAT_BACKEND_PATH);\n" . "\n" . "// if you have problems with SSL, set this to 'false' or delete the following line\n" . "define('CAT_BACKEND_REQ_SSL', " . (isset($config['ssl']) && $config['ssl'] ? 'true' : 'false') . ");\n\n" . (isset($config['no_validate_admin_password']) && $config['no_validate_admin_password'] == "true" ? "define('ALLOW_SHORT_PASSWORDS',true);\n\n" : '') . "if (!defined('CAT_INSTALL')) require_once(CAT_PATH.'/framework/initialize.php');\n" . "\n" . "// WB2/Lepton backward compatibility\n" . "include_once CAT_PATH.'/framework/wb2compat.php';\n" . "\n"; $config_filename = $cat_path . '/config.php'; write2log('trying to create ' . $config_filename); // Check if the file exists and is writable first. if (($handle = @fopen($config_filename, 'w')) === false) { write2log('< [__do_install()] (cannot create config file)'); return array(false, $lang->translate("Cannot open the configuration file ({{ file }})", array('file' => $config_filename))); } else { if (fwrite($handle, $config_content, strlen($config_content)) === FALSE) { write2log('< [__do_install()] (cannot write to config file)'); fclose($handle); return array(false, $lang->translate("Cannot write to the configuration file ({{ file }})", array('file' => $config_filename))); } // Close file fclose($handle); } init_constants($cat_path); include $cat_path . '/framework/class.database.php'; $database = new database(); // ---- install tables ----- if ($install_tables) { list($result, $errors) = install_tables($database); // only try to fill tables if the creation succeeded if ($result && !count($errors)) { // ----- fill tables ----- list($result, $fillerrors) = fill_tables($database); if (!$result || count($fillerrors)) { $errors['populate tables'] = $fillerrors; } else { // ----- install addons ----- list($result, $insterrors) = install_modules($cat_path, $database); if (!$result || count($insterrors)) { $errors['install modules'] = $insterrors; } else { // ----- check tables ---- list($result, $checkerrors) = check_tables($database); if (!$result || count($checkerrors)) { $errors['check tables'] = $checkerrors; } else { create_default_page($database); } } } $config['install_tables_done'] = true; } } // ---- set index.php to read only ---- $dirh->setReadOnly($cat_path . '/index.php'); // ---- make sure we have an index.php everywhere ---- $dirh->recursiveCreateIndex($cat_path); write2log('< [__do_install()]'); if (count($errors)) { $parser->setPath(dirname(__FILE__) . '/templates/default'); $output = $parser->get('install_errors.tpl', array('errors' => $errors)); return array(count($errors) ? false : true, $output); } else { return array(true, ''); } }