コード例 #1
0
ファイル: index.php プロジェクト: spacequad/glfusion
/**
 * 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;
}
コード例 #2
-1
ファイル: index.php プロジェクト: JohnToro/glfusion
/**
 * 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'));
}