if (INST_mysqlOutOfDate($DB)) { $display .= INST_getAlertMsg(sprintf($LANG_INSTALL[51], SUPPORTED_MYSQL_VER)); $importErrors++; } } // Check if the database doesn't exist if (!INST_dbExists($DB)) { $display .= INST_getAlertMsg($LANG_INSTALL[56]); $importErrors++; } // Continue with the import if there were no previous errors if ($importErrors == 0) { // Check if the form was received from Step 1 if (isset($_REQUEST['db'])) { // Write the database info to db-config.php if (!INST_writeConfig(INST_sanitizePath($dbconfig_path), $DB)) { exit($LANG_INSTALL[26] . ' ' . $dbconfig_path . $LANG_INSTALL[58]); } } require_once $dbconfig_path; // Not sure if this needs to be included.. switch ($_REQUEST['migration_type']) { case 'select': header('Location: migrate.php?step=3&dbconfig_path=' . $dbconfig_path . '&language=' . $language . '&backup_file=' . urlencode($backupFile['name']) . '&site_url=' . urlencode($_REQUEST['site_url']) . '&site_admin_url=' . urlencode($_REQUEST['site_admin_url'])); break; case 'upload': $backupFile = $_FILES['backup_file']; if (file_exists($backup_dir . $backupFile['name'])) { // If file already exists. // Ask the user if they want to overwrite the original // but for now save the file as a copy so it won't need
// 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; } else { // TODO: Remove all references to $gl_path and use $_CONF['path'] for consistency. $gl_path = $_CONF['path']; } $dbconfig_path = isset($_POST['dbconfig_path']) ? $_POST['dbconfig_path'] : (isset($_GET['dbconfig_path']) ? $_GET['dbconfig_path'] : $gl_path . '/db-config.php'); $dbconfig_path = INST_sanitizePath($dbconfig_path); $step = isset($_GET['step']) ? $_GET['step'] : (isset($_POST['step']) ? $_POST['step'] : 1); // $display holds all the outputted HTML and content $display = INST_getHeader($LANG_PLUGINS[2] . ' 3 - ' . $LANG_PLUGINS[1]); // Grab the beginning HTML for the installer theme. // Make sure the version of PHP is supported. if (INST_phpOutOfDate()) { // If their version of PHP is not supported, print an error: $display .= '<h1>' . sprintf($LANG_INSTALL[4], SUPPORTED_PHP_VER) . '</h1>' . LB; $display .= '<p>' . sprintf($LANG_INSTALL[5], SUPPORTED_PHP_VER) . $phpv[0] . '.' . $phpv[1] . '.' . (int) $phpv[2] . $LANG_INSTALL[6] . '</p>' . LB; } else { // Ok, the user's version of PHP is supported. Let's move on switch ($step) { /** * Step 1 - Display the upload form and allow * the user to select which plugins to install
} } // Show the "Select your installation method" buttons $upgr_class = $LANG_DIRECTION == 'rtl' ? 'upgrade-rtl' : 'upgrade'; $display .= '<h1 class="heading">' . $LANG_INSTALL[101] . ' ' . $display_step . ' - ' . $LANG_INSTALL[23] . '</h1>' . LB . '<div><form action="index.php" method="get">' . LB . '<input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($dbconfig_path) . '"' . XHTML . '>' . LB . '<input type="hidden" name="mode" value="' . htmlspecialchars($mode) . '"' . XHTML . '>' . LB . '<input type="hidden" name="language" value="' . $language . '"' . XHTML . '>' . LB . '<input type="hidden" name="display_step" value="' . ($display_step + 1) . '"' . XHTML . '>' . LB . '<input type="submit" name="install_type" class="button big-button" value="' . $LANG_INSTALL[24] . '"' . XHTML . '>' . LB . '<input type="submit" name="install_type" class="button big-button" value="' . $LANG_INSTALL[25] . '"' . XHTML . '>' . LB . '<input type="submit" name="install_type" class="button big-button" value="' . $LANG_INSTALL[16] . '"' . XHTML . '>' . LB . '</form> </div> <br' . XHTML . '>' . LB; } break; /** * Write the GL path to siteconfig.php */ /** * Write the GL path to siteconfig.php */ case 'write_paths': // Get the paths from the previous page $_PATH = array('db-config.php' => INST_sanitizePath(urldecode($_REQUEST['dbconfig_path'])), 'public_html/' => INST_sanitizePath(urldecode($_REQUEST['public_html_path']))); $dbconfig_path = str_replace('db-config.php', '', $_PATH['db-config.php']); // Edit siteconfig.php and enter the correct GL path and system directory path $siteconfig_path = $_PATH['public_html/'] . 'siteconfig.php'; $siteconfig_file = fopen($siteconfig_path, 'rb'); $siteconfig_data = fread($siteconfig_file, filesize($siteconfig_path)); fclose($siteconfig_file); // $_CONF['path'] require_once $siteconfig_path; $siteconfig_data = str_replace("\$_CONF['path'] = '{$_CONF['path']}';", "\$_CONF['path'] = '" . str_replace('db-config.php', '', $_PATH['db-config.php']) . "';", $siteconfig_data); $siteconfig_file = fopen($siteconfig_path, 'wb'); if (!fwrite($siteconfig_file, $siteconfig_data)) { exit($LANG_INSTALL[26] . ' ' . $_PATH['public_html/'] . $LANG_INSTALL[28]); } fclose($siteconfig_file); // Continue onto the install, upgrade, or migration
/** * Check PHP settings and path permissions * * Validates the PHP settings will support glFusion and also * checks for proper permissions on the file system. * * @return string HTML screen with environment status * */ function INST_checkEnvironment($dbconfig_path = '') { global $_GLFUSION, $LANG_INSTALL, $_DB, $_DB_host, $_DB_name, $_DB_user, $_DB_pass, $_DB_table_prefix, $_DB_dbms, $_TABLES, $_SYSTEM; if (($rc = _checkSession()) !== 0) { return $rc; } $_GLFUSION['currentstep'] = 'checkenvironment'; $previousaction = 'pathsetting'; // was it passed from the previous step if ($dbconfig_path == '') { if (!isset($_GLFUSION['dbconfig_path'])) { return INST_getPathSetting(); } $dbconfig_path = $_GLFUSION['dbconfig_path']; } $permError = 0; $T = new TemplateLite('templates/'); $T->set_file('page', 'checkenvironment.thtml'); $T->set_var('step_heading', $LANG_INSTALL['hosting_env']); /* * First we will validate the general environment.. */ $T->set_block('page', 'envs', 'env'); // PHP Version $T->set_var('item', $LANG_INSTALL['php_version']); if (INST_phpOutOfDate()) { $T->set_var('status', '<span class="no">' . phpversion() . '</span>'); } else { $T->set_var('status', '<span class="yes">' . phpversion() . '</span>'); } $T->set_var('recommended', '5.3.0+'); $T->set_var('notes', $LANG_INSTALL['php_req_version']); $T->parse('env', 'envs', true); $rg = ini_get('register_globals'); $sm = ini_get('safe_mode'); $ob = ini_get('open_basedir'); $rg = ini_get('register_globals'); $T->set_var('item', 'register_globals'); $T->set_var('status', $rg == 1 ? '<span class="no">' . $LANG_INSTALL['on'] . '</span>' : '<span class="yes">' . $LANG_INSTALL['off'] . '</span>'); $T->set_var('recommended', $LANG_INSTALL['off']); $T->set_var('notes', $LANG_INSTALL['register_globals']); $T->parse('env', 'envs', true); $sm = ini_get('safe_mode'); $T->set_var('item', 'safe_mode'); $T->set_var('status', $sm == 1 ? '<span class="no">' . $LANG_INSTALL['on'] . '</span>' : '<span class="yes">' . $LANG_INSTALL['off'] . '</span>'); $T->set_var('recommended', $LANG_INSTALL['off']); $T->set_var('notes', $LANG_INSTALL['safe_mode']); $T->parse('env', 'envs', true); $ob = ini_get('open_basedir'); if ($ob == '') { $open_basedir_restriction = 0; } else { $open_basedir_restriction = 1; $open_basedir_directories = $ob; } $T->set_var('item', 'open_basedir'); $T->set_var('status', $ob == '' ? '<span class="yes">' . $LANG_INSTALL['none'] . '</span>' : '<span class="no">' . $LANG_INSTALL['enabled'] . '</span>'); $T->set_var('notes', $LANG_INSTALL['open_basedir']); $T->parse('env', 'envs', true); $memory_limit = INST_return_bytes(ini_get('memory_limit')); $memory_limit_print = $memory_limit / 1024 / 1024; $T->set_var('item', 'memory_limit'); $T->set_var('status', $memory_limit < 50331648 ? '<span class="no">' . $memory_limit_print . 'M</span>' : '<span class="yes">' . $memory_limit_print . 'M</span>'); $T->set_var('recommended', '48M'); $T->set_var('notes', $LANG_INSTALL['memory_limit']); $T->parse('env', 'envs', true); $fu = ini_get('file_uploads'); $T->set_var('item', 'file_uploads'); $T->set_var('status', $fu == 1 ? '<span class="yes">' . $LANG_INSTALL['on'] . '</span>' : '<span class="no">' . $LANG_INSTALL['off'] . '</span>'); $T->set_var('recommended', $LANG_INSTALL['on']); $T->set_var('notes', $LANG_INSTALL['file_uploads']); $T->parse('env', 'envs', true); $upload_limit = INST_return_bytes(ini_get('upload_max_filesize')); $upload_limit_print = $upload_limit / 1024 / 1024; $T->set_var('item', 'upload_max_filesize'); $T->set_var('status', $upload_limit < 8388608 ? '<span class="no">' . $upload_limit_print . 'M</span>' : '<span class="yes">' . $upload_limit_print . 'M</span>'); $T->set_var('recommended', '8M'); $T->set_var('notes', $LANG_INSTALL['upload_max_filesize']); $T->parse('env', 'envs', true); $post_limit = INST_return_bytes(ini_get('post_max_size')); $post_limit_print = $post_limit / 1024 / 1024; $T->set_var('item', 'post_max_size'); $T->set_var('status', $post_limit < 8388608 ? '<span class="no">' . $post_limit_print . 'M</span>' : '<span class="yes">' . $post_limit_print . 'M</span>'); $T->set_var('recommended', '8M'); $T->set_var('notes', $LANG_INSTALL['post_max_size']); $T->parse('env', 'envs', true); if ($_GLFUSION['method'] == 'upgrade' && @file_exists('../../siteconfig.php')) { require '../../siteconfig.php'; $_GLFUSION['dbconfig_path'] = $_CONF['path']; if (!file_exists($_CONF['path'] . 'db-config.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error code: ' . __LINE__); } require $_CONF['path'] . 'db-config.php'; if (!file_exists($_CONF['path_system'] . 'lib-database.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error code: ' . __LINE__); } require_once $_CONF['path_system'] . 'lib-database.php'; 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'; $config = config::get_instance(); $config->set_configfile($_CONF['path'] . 'db-config.php'); $config->load_baseconfig(); $config->initConfig(); $_CONF = $config->get_config('Core'); $_PATH['public_html'] = $_CONF['path_html']; $_PATH['dbconfig_path'] = $_CONF['path']; $_PATH['admin_path'] = INST_getAdminPath(); $_PATH['log_path'] = $_CONF['path_log']; $_PATH['lang_path'] = $_CONF['path_language']; $_PATH['backup_path'] = $_CONF['backup_path']; $_PATH['data_path'] = $_CONF['path_data']; } else { $_PATH['public_html'] = INST_getHtmlPath(); if ($dbconfig_path == '') { $_PATH['dbconfig_path'] = INST_sanitizePath(INST_stripslashes($_POST['private_path'])); } else { $_PATH['dbconfig_path'] = $dbconfig_path; } $_PATH['admin_path'] = INST_getAdminPath(); $_PATH['log_path'] = $_GLFUSION['log_path']; $_PATH['lang_path'] = $_GLFUSION['lang_path']; $_PATH['backup_path'] = $_GLFUSION['backup_path']; $_PATH['data_path'] = $_GLFUSION['data_path']; } if (!preg_match('/^.*\\/$/', $_PATH['public_html'])) { $_PATH['public_html'] .= '/'; } if (!preg_match('/^.*\\/$/', $_PATH['dbconfig_path'])) { $_PATH['dbconfig_path'] .= '/'; } if (!preg_match('/^.*\\/$/', $_PATH['admin_path'])) { $_PATH['admin_path'] .= '/'; } $file_list = array($_PATH['dbconfig_path'] . 'db-config.php', $_PATH['data_path'], $_PATH['log_path'] . 'error.log', $_PATH['log_path'] . 'access.log', $_PATH['log_path'] . 'captcha.log', $_PATH['log_path'] . 'spamx.log', $_PATH['data_path'] . 'layout_cache/', $_PATH['data_path'] . 'temp/', $_PATH['dbconfig_path'] . 'plugins/mediagallery/tmp/', $_PATH['dbconfig_path'] . 'system/lib-custom.php', $_PATH['public_html'], $_PATH['public_html'] . 'siteconfig.php', $_PATH['public_html'] . 'backend/glfusion.rss', $_PATH['public_html'] . 'images/articles/', $_PATH['public_html'] . 'images/topics/', $_PATH['public_html'] . 'images/userphotos/', $_PATH['public_html'] . 'images/library/File/', $_PATH['public_html'] . 'images/library/Flash/', $_PATH['public_html'] . 'images/library/Image/', $_PATH['public_html'] . 'images/library/Media/', $_PATH['public_html'] . 'mediagallery/mediaobjects/', $_PATH['public_html'] . 'mediagallery/mediaobjects/covers/', $_PATH['public_html'] . 'mediagallery/mediaobjects/orig/', $_PATH['public_html'] . 'mediagallery/mediaobjects/disp/', $_PATH['public_html'] . 'mediagallery/mediaobjects/tn/', $_PATH['public_html'] . 'mediagallery/mediaobjects/orig/0/', $_PATH['public_html'] . 'mediagallery/mediaobjects/disp/0/', $_PATH['public_html'] . 'mediagallery/mediaobjects/tn/0/', $_PATH['public_html'] . 'mediagallery/watermarks/', $_PATH['public_html'] . 'filemgmt_data/', $_PATH['public_html'] . 'filemgmt_data/category_snaps/', $_PATH['public_html'] . 'filemgmt_data/category_snaps/tmp/', $_PATH['public_html'] . 'filemgmt_data/files/', $_PATH['public_html'] . 'filemgmt_data/files/tmp/', $_PATH['public_html'] . 'filemgmt_data/snaps/', $_PATH['public_html'] . 'filemgmt_data/snaps/tmp/', $_PATH['public_html'] . 'forum/media/', $_PATH['public_html'] . 'forum/media/tn/'); $T->set_var('dbconfig_path', $_PATH['dbconfig_path']); $T->set_block('page', 'perms', 'perm'); $classCounter = 0; foreach ($file_list as $path) { $ok = INST_isWritable($path); if (!$ok) { $T->set_var('location', $path); $T->set_var('status', $ok ? '<span class="yes">' . $LANG_INSTALL['ok'] . '</span>' : '<span class="Unwriteable">' . $LANG_INSTALL['not_writable'] . '</span>'); $T->set_var('rowclass', $classCounter % 2 + 1); $classCounter++; $T->parse('perm', 'perms', true); if (!$ok) { $permError = 1; } } } // special test to see if we can create a directory under layout_cache... $rc = mkdir($_PATH['dbconfig_path'] . 'data/layout_cache/test/'); if (!$rc) { $T->set_var('location', $_PATH['dbconfig_path'] . 'data/layout_cache/<br /><strong>' . $_GLFUSION['errstr'] . '</strong>'); $T->set_var('status', '<span class="Unwriteable">' . $LANG_INSTALL['unable_mkdir'] . '</span>'); $T->set_var('rowclass', $classCounter % 2 + 1); $classCounter++; $T->parse('perm', 'perms', true); $permError = 1; @rmdir($_PATH['dbconfig_path'] . 'data/layout_cache/test/'); } else { $ok = INST_isWritable($_PATH['dbconfig_path'] . 'data/layout_cache/test/'); if (!$ok) { $T->set_var('location', $path); $T->set_var('status', $ok ? '<span class="yes">' . $LANG_INSTALL['ok'] . '</span>' : '<span class="Unwriteable">' . $LANG_INSTALL['not_writable'] . '</span>'); $T->set_var('rowclass', $classCounter % 2 + 1); $classCounter++; $T->parse('perm', 'perms', true); if (!$ok) { $permError = 1; } } @rmdir($_PATH['dbconfig_path'] . 'data/layout_cache/test/'); } // special test to see if existing cache files exist and are writable... $rc = INST_checkCacheDir($_PATH['dbconfig_path'] . 'data/layout_cache/', $T, $classCounter); if ($rc > 0) { $permError = 1; } if ($permError) { $button = 'Recheck'; $action = 'checkenvironment'; $T->set_var('error_message', $LANG_INSTALL['correct_perms']); $recheck = '<button type="submit" name="submit" onclick="submitForm( checkenv, \'checkenvironment\' );">' . LB; $recheck .= 'Recheck' . LB; $recheck .= '<img src="layout/arrow-recheck.gif" alt=""/>' . LB; $recheck .= '</button>' . LB; } else { $recheck = ''; $T->set_var('location', $LANG_INSTALL['directory_permissions']); $T->set_var('status', 1 ? '<span class="yes">' . $LANG_INSTALL['ok'] . '</span>' : '<span class="Unwriteable">' . $LANG_INSTALL['not_writable'] . '</span>'); $classCounter++; $T->parse('perm', 'perms', true); $T->set_var('location', $LANG_INSTALL['file_permissions']); $T->set_var('status', 1 ? '<span class="yes">' . $LANG_INSTALL['ok'] . '</span>' : '<span class="Unwriteable">' . $LANG_INSTALL['not_writable'] . '</span>'); $classCounter++; $T->parse('perm', 'perms', true); $button = $LANG_INSTALL['next']; if ($_GLFUSION['method'] == 'upgrade') { $action = 'doupgrade'; $previousaction = ''; } else { $action = 'getsiteinformation'; $previousaction = 'pathsetting'; } } $button = $LANG_INSTALL['next']; if ($_GLFUSION['method'] == 'upgrade') { $action = 'doupgrade'; $previousaction = ''; } else { $action = 'getsiteinformation'; $previousaction = 'pathsetting'; } $T->set_var(array('previousaction' => $previousaction, 'nextaction' => $action, 'button' => $button, 'recheck' => $recheck, 'back_to_top' => $LANG_INSTALL['back_to_top'], 'lang_previous' => $LANG_INSTALL['previous'], 'lang_host_env' => $LANG_INSTALL['hosting_env'], 'lang_setting' => $LANG_INSTALL['setting'], 'lang_current' => $LANG_INSTALL['current'], 'lang_recommended' => $LANG_INSTALL['recommended'], 'lang_notes' => $LANG_INSTALL['notes'], 'lang_filesystem' => $LANG_INSTALL['filesystem_check'], 'lang_php_settings' => $LANG_INSTALL['php_settings'], 'lang_php_warning' => $LANG_INSTALL['php_warning'], 'hiddenfields' => _buildHiddenFields())); $T->parse('output', 'page'); return $T->finish($T->get_var('output')); }