Пример #1
0
                 }
                 // Extract the uploaded archive to the plugins directory
                 if ($_FILES['plugin']['type'] == 'application/zip') {
                     // Zip
                     $upload_success = $archive->extract(array('add_path' => $_CONF['path'] . 'plugins/'));
                 } else {
                     // Tarball
                     $upload_success = $archive->extract($_CONF['path'] . 'plugins/');
                 }
                 $plg_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
                 if ($upload_success) {
                     if (file_exists($plg_path . 'public_html')) {
                         rename($plg_path . 'public_html', $_CONF['path_html'] . $pi_name);
                     }
                     if (file_exists($plg_path . 'admin')) {
                         rename($plg_path . 'admin', INST_getAdminPath() . 'plugins/' . $pi_name);
                     }
                 }
                 unset($archive);
                 // Collect some garbage
             }
         }
     }
 }
 // End check if a plugin file was uploaded
 // If the web server will allow the user to upload a plugin
 if ($upload_enabled) {
     // Show the upload form
     $display .= '<br' . XHTML . '>' . LB . ($upload_success ? '<div class="notice"><span class="success">' . $LANG_PLUGINS[7] . '</span> ' . sprintf($LANG_PLUGINS[8], $pi_name) . '</div>' : '') . LB . '<h2>' . $LANG_PLUGINS[9] . '</h2>' . LB . '<form name="plugins_upload" action="install-plugins.php" method="POST" enctype="multipart/form-data">' . LB . '<input type="hidden" name="language" value="' . $language . '"' . XHTML . '>' . LB . '<p><label class="' . $form_label_dir . '">' . $LANG_PLUGINS[10] . ' ' . INST_helpLink('plugin_upload') . '</label> ' . LB . '<input type="file" name="plugin" size="25"' . XHTML . '></p>' . LB . '<p><input type="submit" class="button big-button" name="upload" value="' . $LANG_PLUGINS[11] . '"' . XHTML . '></p>' . LB . '</form>' . LB;
 }
 // Check if there are any plugins that need to be installed
Пример #2
0
/**
 * 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'));
}