$display .= '<p>' . $LANG_INSTALL[94] . '<p>' . LB . '<ul><li>' . $LANG_INSTALL[95] . '<br' . XHTML . '>' . LB . '<code>' . strtr(__FILE__, '\\', '/') . '</code></li>' . '<li>' . sprintf($LANG_INSTALL[96], '<code>db-config.php</code>') . '<br' . XHTML . '>' . LB . '<code>' . $gl_path . '</code></li></ul>' . LB; } break; /** * The second step is to check permissions on the files/directories * that Geeklog needs to be able to write to. The script uses the location of * db-config.php from the previous step to determine location of everything. */ /** * The second step is to check permissions on the files/directories * that Geeklog needs to be able to write to. The script uses the location of * db-config.php from the previous step to determine location of everything. */ case 'check_permissions': // Get the paths from the previous page $_PATH = array('db-config.php' => INST_sanitizePath(urldecode(isset($_GET['dbconfig_path']) ? $_GET['dbconfig_path'] : $_POST['dbconfig_path'])), 'public_html/' => INST_getHtmlPath()); // Be fault tolerant with the path the user enters if (!strstr($_PATH['db-config.php'], 'db-config.php')) { // If the user did not provide a trailing '/' then add one if (!preg_match('/^.*\\/$/', $_PATH['db-config.php'])) { $_PATH['db-config.php'] .= '/'; } $_PATH['db-config.php'] .= 'db-config.php'; } // The path to db-config.php is what we'll use to generate our /path/to/geeklog so // we want to make sure it's valid and exists before we continue and create problems. if (!file_exists($_PATH['db-config.php'])) { $display .= '<h1 class="heading">' . $LANG_INSTALL[3] . '</h1>' . LB . '<p><span class="error">' . $LANG_INSTALL[38] . '</span>' . LB . $LANG_INSTALL[84] . '<code>' . htmlspecialchars($_PATH['db-config.php']) . '</code>' . $LANG_INSTALL[85] . LB . '</p>' . LB . '<div style="margin-left: auto; margin-right: auto; width: 1px">' . LB . '<form action="index.php" method="post">' . LB . '<input type="hidden" name="language" value="' . $language . '"' . XHTML . '>' . LB . '<input type="submit" class="button big-button" value="<< ' . $LANG_INSTALL[61] . '"' . XHTML . '>' . LB . '</form>' . LB . '</div>' . LB; } else { require_once $_PATH['db-config.php']; // We need db-config.php the current DB information
$unpacked_file = substr($file['filename'], strlen($dirName) + 1); } $success = $archive->unpack($backupPath, array($file['filename'])); if (!$success || !file_exists($backupPath . $unpacked_file)) { // error unpacking file $display .= INST_getAlertMsg(sprintf($LANG_MIGRATE[41], $unpacked_file)); return false; } unset($archive); return $unpacked_file; } // +---------------------------------------------------------------------------+ // | Main | // +---------------------------------------------------------------------------+ // Set some vars $html_path = INST_getHtmlPath(); $siteconfig_path = '../../siteconfig.php'; if ($_CONF['path'] === '/path/to/Geeklog/') { // If the Geeklog path has not been defined. // Attempt to locate Geeklog's path $gl_path = strtr(__FILE__, '\\', '/'); // replace all '\' with '/' for ($i = 0; $i < 4; $i++) { $remains = strrchr($gl_path, '/'); if ($remains === false) { break; } else { $gl_path = substr($gl_path, 0, -strlen($remains)); } } $_CONF['path'] = $gl_path;
/** * Performs base site install and prompts for plugin / content install * * Initializes the database and configuration settings. * Prompts user for optional content and plugins to install. * * @return string HTML form * */ function INST_installAndContentPlugins() { global $_GLFUSION, $_SYSTEM, $_CONF, $_TABLES, $_DB, $_DB_dbms, $_DB_host, $_DB_user, $_DB_pass, $site_url, $_DB_table_prefix, $LANG_INSTALL; if (($rc = _checkSession()) !== 0) { return $rc; } $_GLFUSION['currentstep'] = 'contentplugins'; if (isset($_GLFUSION['innodb'])) { $use_innodb = $_GLFUSION['innodb']; } else { $use_innodb = false; } $utf8 = isset($_GLFUSION['utf8']) ? $_GLFUSION['utf8'] : 1; if ($utf8) { $charset = 'utf-8'; } else { $charset = 'iso-8859-1'; } if (isset($_GLFUSION['language'])) { $language = $_GLFUSION['language']; } else { $language = 'english'; } $_PATH['dbconfig_path'] = $_GLFUSION['dbconfig_path']; $_PATH['public_html'] = INST_getHtmlPath(); if (!preg_match('/^.*\\/$/', $_PATH['public_html'])) { $_PATH['public_html'] .= '/'; } $dbconfig_path = str_replace('db-config.php', '', $_PATH['dbconfig_path']); // check the lib-custom... if (!@file_exists($_PATH['dbconfig_path'] . 'system/lib-custom.php')) { if (@file_exists($_PATH['dbconfig_path'] . 'system/lib-custom.php.dist')) { $rc = @copy($_PATH['dbconfig_path'] . 'system/lib-custom.php.dist', $_PATH['dbconfig_path'] . 'system/lib-custom.php'); if ($rc === false) { return _displayError(LIBCUSTOM_NOT_WRITABLE, 'getsiteinformation'); } } else { // no lib-custom.php.dist found return _displayError(LIBCUSTOM_NOT_FOUND, 'getsiteinformation'); } } // check and see if site config really exists... if (!@file_exists($_PATH['public_html'] . 'siteconfig.php')) { if (@file_exists($_PATH['public_html'] . 'siteconfig.php.dist')) { $rc = @copy($_PATH['public_html'] . 'siteconfig.php.dist', $_PATH['public_html'] . 'siteconfig.php'); if ($rc === false) { return _displayError(SITECONFIG_NOT_WRITABLE, 'getsiteinformation'); } @chmod($_PATH['public_html'] . 'siteconfig.php', 0777); if (!@file_exists($_PATH['public_html'] . 'siteconfig.php')) { return _displayError(SITECONFIG_NOT_WRITABLE, 'getsiteinformation'); } } else { // no site config found return error return _displayError(SITECONFIG_NOT_FOUND, 'getsiteinformation'); } } // Edit siteconfig.php and enter the correct path and system directory path $siteconfig_path = $_PATH['public_html'] . 'siteconfig.php'; $siteconfig_file = fopen($siteconfig_path, 'r'); if ($siteconfig_file === false) { return _displayError(SITECONFIG_NOT_WRITABLE, 'getsiteinformation'); } $siteconfig_data = fread($siteconfig_file, filesize($siteconfig_path)); fclose($siteconfig_file); if (!file_exists($siteconfig_path)) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } require $siteconfig_path; $siteconfig_data = str_replace("\$_CONF['path'] = '{$_CONF['path']}';", "\$_CONF['path'] = '" . str_replace('db-config.php', '', $_PATH['dbconfig_path']) . "';", $siteconfig_data); $siteconfig_data = preg_replace('/\\$_CONF\\[\'default_charset\'\\] = \'[^\']*\';/', "\$_CONF['default_charset'] = '" . $charset . "';", $siteconfig_data); $siteconfig_file = fopen($siteconfig_path, 'w'); if (!fwrite($siteconfig_file, $siteconfig_data)) { return _displayError(SITECONFIG_NOT_WRITABLE, 'getsiteinformation'); } fclose($siteconfig_file); require $siteconfig_path; $config_file = $_GLFUSION['dbconfig_path'] . 'db-config.php'; if (!file_exists($config_file)) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } require $config_file; $db = array('host' => isset($_GLFUSION['db_host']) ? $_GLFUSION['db_host'] : $_DB_host, 'name' => isset($_GLFUSION['db_name']) ? $_GLFUSION['db_name'] : $_DB_name, 'user' => isset($_GLFUSION['db_user']) ? $_GLFUSION['db_user'] : $_DB_user, 'pass' => isset($_GLFUSION['db_pass']) ? $_GLFUSION['db_pass'] : $_DB_pass, 'table_prefix' => isset($_GLFUSION['db_prefix']) ? $_GLFUSION['db_prefix'] : $_DB_table_prefix, 'type' => isset($_GLFUSION['db_type']) ? $_GLFUSION['db_type'] : $_DB_type); $dbconfig_file = fopen($config_file, 'r'); $dbconfig_data = fread($dbconfig_file, filesize($config_file)); fclose($dbconfig_file); $dbconfig_data = str_replace("\$_DB_host = '" . $_DB_host . "';", "\$_DB_host = '" . $_GLFUSION['db_host'] . "';", $dbconfig_data); // Host $dbconfig_data = str_replace("\$_DB_name = '" . $_DB_name . "';", "\$_DB_name = '" . $_GLFUSION['db_name'] . "';", $dbconfig_data); // Database $dbconfig_data = str_replace("\$_DB_user = '******';", "\$_DB_user = '******'db_user'] . "';", $dbconfig_data); // Username $dbconfig_data = str_replace("\$_DB_pass = '******';", "\$_DB_pass = '******'db_pass'] . "';", $dbconfig_data); // Password $dbconfig_data = str_replace("\$_DB_table_prefix = '" . $_DB_table_prefix . "';", "\$_DB_table_prefix = '" . $_GLFUSION['db_prefix'] . "';", $dbconfig_data); // Table prefix $dbconfig_data = str_replace("\$_DB_dbms = '" . $_DB_dbms . "';", "\$_DB_dbms = '" . $_GLFUSION['db_type'] . "';", $dbconfig_data); // Database type // Write changes to db-config.php $dbconfig_file = fopen($config_file, 'w'); if (!fwrite($dbconfig_file, $dbconfig_data)) { return _displayError(DBCONFIG_NOT_WRITABLE, 'getsiteinformation'); } fflush($dbconfig_file); fclose($dbconfig_file); require $config_file; if (!file_exists($_CONF['path_system'] . 'lib-database.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error code: ' . __LINE__); } require $_CONF['path_system'] . 'lib-database.php'; if ($_DB_dbms == 'mysqli') { $_DB_dbms = 'mysql'; } list($rc, $errors) = INST_createDatabaseStructures($use_innodb); if ($rc != true) { return _displayError(DB_NO_CONNECT, 'getsiteinformation', $errors); } $site_name = isset($_GLFUSION['site_name']) ? $_GLFUSION['site_name'] : ''; $site_slogan = isset($_GLFUSION['site_slogan']) ? $_GLFUSION['site_slogan'] : ''; $site_url = isset($_GLFUSION['site_url']) ? $_GLFUSION['site_url'] : INST_getSiteUrl(); $site_admin_url = isset($_GLFUSION['site_admin_url']) ? $_GLFUSION['site_admin_url'] : INST_getSiteAdminUrl(); $site_mail = isset($_GLFUSION['site_mail']) ? $_GLFUSION['site_mail'] : ''; $noreply_mail = isset($_GLFUSION['noreply_mail']) ? $_GLFUSION['noreply_mail'] : ''; $log_path = isset($_GLFUSION['log_path']) ? $_GLFUSION['log_path'] : $gl_path . 'logs/'; $lang_path = isset($_GLFUSION['lang_path']) ? $_GLFUSION['lang_path'] : $gl_path . 'language/'; $backup_path = isset($_GLFUSION['backup_path']) ? $_GLFUSION['backup_path'] : $gl_path . 'backups/'; $data_path = isset($_GLFUSION['data_path']) ? $_GLFUSION['data_path'] : $gl_path . 'data/'; INST_personalizeAdminAccount($site_mail, $site_url); if (!file_exists($_CONF['path_system'] . 'classes/config.class.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } require_once $_CONF['path_system'] . 'classes/config.class.php'; require_once 'config-install.php'; install_config($site_url); $gl_path = $_GLFUSION['dbconfig_path']; $html_path = $_PATH['public_html']; $config = config::get_instance(); $config->set('site_name', $site_name); $config->set('site_slogan', $site_slogan); $config->set('site_url', $site_url); $config->set('site_admin_url', $site_admin_url); $config->set('site_mail', $site_mail); $config->set('noreply_mail', $noreply_mail); $config->set('path_html', $html_path); $config->set('path_log', $log_path); $config->set('path_language', $lang_path); $config->set('backup_path', $backup_path); $config->set('path_data', $data_path); $config->set('path_images', $html_path . 'images/'); $config->set('path_themes', $html_path . 'layout/'); $config->set('rdf_file', $html_path . 'backend/glfusion.rss'); $config->set('path_pear', $_CONF['path_system'] . 'pear/'); $config->set_default('default_photo', $site_url . '/default.jpg'); $lng = INST_getDefaultLanguage($gl_path . 'language/', $language, $utf8); if (!empty($lng)) { $config->set('language', $lng); } $_CONF['path_html'] = $html_path; $_CONF['site_url'] = $site_url; $_CONF['site_admin_url'] = $site_admin_url; // Setup default theme $config->set('theme', 'cms'); DB_query("UPDATE {$_TABLES['users']} SET theme='cms' WHERE uid=2", 1); $var = time() - rand(); $session_cookie = 'pw' . substr(md5($var), 0, 3); DB_query("UPDATE {$_TABLES['conf_values']} SET value='" . serialize($session_cookie) . "' WHERE name='cookie_password'", 1); $var = time() - rand(); $session_cookie = 'pc' . substr(md5($var), 0, 3); DB_query("UPDATE {$_TABLES['conf_values']} SET value='" . serialize($session_cookie) . "' WHERE name='cookie_name'", 1); $var = time() - rand(); $session_cookie = 'sc' . substr(md5($var), 0, 3); DB_query("UPDATE {$_TABLES['conf_values']} SET value='" . serialize($session_cookie) . "' WHERE name='cookie_session'", 1); $config->_purgeCache(); // rebuild the config array if (!file_exists($siteconfig_path)) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } include $siteconfig_path; $config->set_configfile($_CONF['path'] . 'db-config.php'); $config->load_baseconfig(); $config->initConfig(); $_CONF = $config->get_config('Core'); $config->_purgeCache(); @touch($log_path . 'error.log'); @touch($log_path . 'access.log'); @touch($log_path . 'captcha.log'); @touch($log_path . 'spamx.log'); global $_CONF, $_SYSTEM, $_DB, $_DB_dbms, $_GROUPS, $_RIGHTS, $TEMPLATE_OPTIONS; if (!file_exists($_CONF['path_html'] . 'lib-common.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } require $_CONF['path_html'] . 'lib-common.php'; if ($_DB_dbms == 'mysqli') { $_DB_dbms = 'mysql'; } INST_pluginAutoInstall('bad_behavior2'); INST_pluginAutoInstall('captcha'); INST_pluginAutoInstall('ckeditor'); INST_pluginAutoInstall('commentfeeds'); INST_pluginAutoInstall('spamx'); INST_pluginAutoInstall('staticpages'); $config->_purgeCache(); INST_clearCache(); $T = new TemplateLite('templates/'); $T->set_file('page', 'contentplugins.thtml'); $T->set_var(array('lang_content_plugins' => $LANG_INSTALL['content_plugins'], 'lang_load_sample_content' => $LANG_INSTALL['load_sample_content'], 'lang_samplecontent_desc' => $LANG_INSTALL['samplecontent_desc'], 'lang_calendar' => $LANG_INSTALL['calendar'], 'lang_filemgmt' => $LANG_INSTALL['filemgmt'], 'lang_mediagallery' => $LANG_INSTALL['mediagallery'], 'lang_forum' => $LANG_INSTALL['forum'], 'lang_polls' => $LANG_INSTALL['polls'], 'lang_links' => $LANG_INSTALL['links'], 'lang_calendar_desc' => $LANG_INSTALL['calendar_desc'], 'lang_filemgmt_desc' => $LANG_INSTALL['filemgmt_desc'], 'lang_mediagallery_desc' => $LANG_INSTALL['mediagallery_desc'], 'lang_forum_desc' => $LANG_INSTALL['forum_desc'], 'lang_polls_desc' => $LANG_INSTALL['polls_desc'], 'lang_links_desc' => $LANG_INSTALL['links_desc'], 'lang_next' => $LANG_INSTALL['next'], 'hiddenfields' => _buildHiddenFields())); $T->parse('output', 'page'); return $T->finish($T->get_var('output')); }