function INST_footer() { global $LANG_INSTALL; $footer = new TemplateLite('templates/'); $footer->set_file('footer', 'footer.thtml'); $footer->set_var('copyright', $LANG_INSTALL['copyright']); $footer->parse('output', 'footer'); return $footer->finish($footer->get_var('output')); }
function INST_doSiteConfigUpgrade() { global $_SYSTEM, $_CONF; $_SYSDEFAULT = array('use_direct_style_js' => true, 'html_filter' => 'htmlpurifier', 'site_enabled' => true, 'maintenance_mode' => false, 'rootdebug' => false, 'debug_oauth' => false, 'debug_html_filter' => false, 'no_fail_sql' => false, 'no_cache_config' => false, 'disable_instance_caching' => false, 'admin_session' => 1200, 'swedish_date_hack' => false, 'verification_token_ttl' => 86400, 'token_ip' => false, 'max_captcha_atttempts' => 4, 'custom_topic_templates' => false, 'token_ttl' => 1200, 'alert_timeout' => 4000, 'alert_position' => 'top-right'); if (is_array($_SYSTEM) && count($_SYSTEM) > 1) { $_NEWSYSTEM = array_merge($_SYSDEFAULT, $_SYSTEM); } else { $_NEWSYSTEM = $_SYSDEFAULT; } $_CFDEFAULT['css_cache_filename'] = 'style.cache'; $_CFDEFAULT['js_cache_filename'] = 'js.cache'; $_CFDEFAULT['path'] = '/path/to/glfusion/'; $_CFDEFAULT['path_system'] = $_CONF['path'] . 'system/'; $_CFDEFAULT['default_charset'] = 'iso-8859-1'; if (!defined('CONFIG_CACHE_FILE_NAME')) { define('CONFIG_CACHE_FILE_NAME', "'\$\${$config}\$\$\$.cache'"); } $_CFDEFAULT['config_cache_file_name'] = CONFIG_CACHE_FILE_NAME; $_NEWSYSCONF = array_merge($_CFDEFAULT, $_CONF); $T = new TemplateLite('templates/'); $T->set_file('page', 'siteconfig.thtml'); $T->set_var(array('use_direct_style_js' => $_NEWSYSTEM['use_direct_style_js'] ? 'true' : 'false', 'html_filter' => $_NEWSYSTEM['html_filter'], 'site_enabled' => $_NEWSYSTEM['site_enabled'] ? 'true' : 'false', 'maintenance_mode' => $_NEWSYSTEM['maintenance_mode'] ? 'true' : 'false', 'rootdebug' => $_NEWSYSTEM['rootdebug'] ? 'true' : 'false', 'debug_oauth' => $_NEWSYSTEM['debug_oauth'] ? 'true' : 'false', 'debug_html_filter' => $_NEWSYSTEM['debug_html_filter'] ? 'true' : 'false', 'no_fail_sql' => $_NEWSYSTEM['no_fail_sql'] ? 'true' : 'false', 'no_cache_config' => $_NEWSYSTEM['no_cache_config'] ? 'true' : 'false', 'disable_instance_caching' => $_NEWSYSTEM['disable_instance_caching'] ? 'true' : 'false', 'admin_session' => $_NEWSYSTEM['admin_session'], 'swedish_date_hack' => $_NEWSYSTEM['swedish_date_hack'] ? 'true' : 'false', 'verification_token_ttl' => $_NEWSYSTEM['verification_token_ttl'], 'token_ip' => $_NEWSYSTEM['token_ip'] ? 'true' : 'false', 'max_captcha_atttempts' => $_NEWSYSTEM['max_captcha_atttempts'], 'custom_topic_templates' => $_NEWSYSTEM['custom_topic_templates'] ? 'true' : 'false', 'css_cache_filename' => $_NEWSYSCONF['css_cache_filename'], 'js_cache_filename' => $_NEWSYSCONF['js_cache_filename'], 'path' => $_NEWSYSCONF['path'], 'default_charset' => $_NEWSYSCONF['default_charset'], 'config_cache_file_name' => $_NEWSYSCONF['config_cache_file_name'], 'token_ttl' => $_NEWSYSTEM['token_ttl'], 'alert_timeout' => $_NEWSYSTEM['alert_timeout'], 'alert_position' => $_NEWSYSTEM['alert_position'])); if ($_CONF['path'] . 'system/' == $_CONF['path_system']) { $T->set_var('path_system', "\$_CONF['path'] . 'system/'"); } else { $T->set_var('path_system', $_NEWSYSTEM['path_system']); } $T->parse('output', 'page'); $siteconfig_data = $T->finish($T->get_var('output')); $siteconfig_path = $_CONF['path_html'] . 'siteconfig.php'; if (is_writable($siteconfig_path)) { $siteconfig_file = fopen($siteconfig_path, 'w'); if (!fwrite($siteconfig_file, $siteconfig_data)) { // return _displayError(SITECONFIG_NOT_WRITABLE,'getsiteinformation'); } fclose($siteconfig_file); COM_errorLog("UPGRADE: Successfully updated siteconfig.php with latest options."); } else { COM_errorLog("UPGRADE: Unable to update siteconfig.php due to permissions."); } return; }
/** * Display upgrade details * * Displays important upgrade informaton to the user * * @return string HTML * */ function INST_upgradeAlert() { global $_GLFUSION, $LANG_INSTALL; // set the session expire time. $_GLFUSION['expire'] = time() + 1800; $_GLFUSION['currentstep'] = 'upgradealert'; if (isset($_GLFUSION['language'])) { $language = $_GLFUSION['language']; } else { $language = 'english'; } $retval = ''; $T = new TemplateLite('templates/'); $T->set_file('page', 'upgrade-alert.thtml'); $prevAction = 'languagetask'; $nextAction = 'startupgrade'; $T->set_var(array('nextaction' => $nextAction, 'prevaction' => $prevAction, 'step_heading' => $LANG_INSTALL['upgrade_heading'], 'lang_next' => $LANG_INSTALL['next'], 'lang_prev' => $LANG_INSTALL['previous'], 'lang_doc_alert' => $LANG_INSTALL['doc_alert'], 'lang_doc_alert2' => $LANG_INSTALL['doc_alert2'], 'lang_backup' => $LANG_INSTALL['backup'], 'lang_backup_instructions' => $LANG_INSTALL['backup_instructions'], 'lang_bullet1' => $LANG_INSTALL['upgrade_bullet1'], 'lang_bullet2' => $LANG_INSTALL['upgrade_bullet2'], 'lang_bullet3' => $LANG_INSTALL['upgrade_bullet3'], 'lang_bullet4' => $LANG_INSTALL['upgrade_bullet4'], 'lang_bullet_title' => $LANG_INSTALL['upgrade_bullet_title'], 'hiddenfields' => _buildHiddenFields())); $T->parse('output', 'page'); $retval = $T->finish($T->get_var('output')); return $retval; }
/** * 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')); }