예제 #1
0
function INST_checkCacheDir($path, $template, $classCounter)
{
    $permError = 0;
    // special test to see if existing cache files exist and are writable...
    if ($dh = @opendir($path)) {
        while (($file = readdir($dh)) !== false) {
            if ($file == '.' || $file == '..' || $file == '.svn') {
                continue;
            }
            if (is_dir($path . $file)) {
                $rc = INST_checkCacheDir($path . $file . '/', $template, $classCounter);
                if ($rc > 0) {
                    $permError = 1;
                }
            } else {
                $ok = INST_isWritable($path . $file);
                if (!$ok) {
                    $template->set_var('location', $path . $file);
                    $template->set_var('status', $ok ? '<span class="yes">OK</span>' : '<span class="Unwriteable">NOT WRITABLE</span>');
                    $template->set_var('rowclass', $classCounter % 2 + 1);
                    $classCounter++;
                    $template->parse('perm', 'perms', true);
                    if (!$ok) {
                        $permError = 1;
                    }
                }
            }
        }
        closedir($dh);
    }
    return $permError;
}
예제 #2
0
파일: index.php 프로젝트: JohnToro/glfusion
/**
 * 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'));
}