コード例 #1
0
ファイル: ecl.php プロジェクト: rdmenezes/pfsense
function test_config($file_location)
{
    global $g, $debug;
    if (!$file_location) {
        return;
    }
    // config.xml was found.  ensure it is sound.
    $root_obj = trim("<{$g['xml_rootobj']}>");
    $xml_file_head = exec("/usr/bin/head -2 {$file_location} | /usr/bin/tail -n1");
    if ($debug) {
        echo "\nroot obj  = {$root_obj}";
        echo "\nfile head = {$xml_file_head}";
    }
    if ($xml_file_head == $root_obj) {
        // Now parse config to make sure
        $config_status = config_validate($file_location);
        if ($config_status) {
            return true;
        }
    }
    return false;
}
コード例 #2
0
/**
 * Initial checks
 */
function config_init()
{
    global $config_ready;
    global $configs;
    // trim all post values and remove slashes
    foreach ($_POST as $k => $v) {
        $_POST[$k] = stripslashes(trim($v));
    }
    // default values
    if (!isset($_POST['wwwroot'])) {
        $_POST['wwwroot'] = "http://" . preg_replace("#install\\.php.*#", "", $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
    }
    if (!isset($_POST['admin'])) {
        $_POST['admin'] = 'admin';
    }
    if (!isset($_POST['dbtype'])) {
        $_POST['dbtype'] = 'mysql';
    }
    if (!isset($_POST['dbhost'])) {
        $_POST['dbhost'] = 'localhost';
    }
    if (!isset($_POST['dbuser'])) {
        $_POST['dbuser'] = '******';
    }
    if (!isset($_POST['dbpass'])) {
        $_POST['dbpass'] = '';
    }
    if (!isset($_POST['dbname'])) {
        $_POST['dbname'] = 'elgg';
    }
    if (!isset($_POST['prefix'])) {
        $_POST['prefix'] = 'elgg_';
    }
    //FIXME: force admin username
    $_POST['admin'] = 'news';
    $configs = array();
    $configs['wwwroot']->name = __gettext('Web root');
    $configs['wwwroot']->desc = __gettext('External URL to the site (eg: http://elgg.boston.edu/). *MUST* have a final slash at end.');
    $configs['admin']->name = __gettext('Admin username');
    $configs['admin']->desc = __gettext('Initial administrator username');
    $configs['adminpw']->name = __gettext('Admin password');
    $configs['adminpw']->desc = __gettext('Initial administrator password, at least 6 chars.');
    $configs['adminemail']->name = __gettext('System email');
    $configs['adminemail']->desc = __gettext('Email address for system notifications.');
    $configs['dbtype']->name = __gettext('Database type');
    $configs['dbtype']->desc = __gettext('PostgreSQL and MySQL supported. But is highly recommended MySQL');
    $configs['dbhost']->name = __gettext('Database host');
    $configs['dbuser']->name = __gettext('Database username');
    $configs['dbpass']->name = __gettext('Database password');
    $configs['dbpass']->not_required = true;
    $configs['dbname']->name = __gettext('Database name');
    $configs['prefix']->name = __gettext('Database table prefix');
    if (config_submitted()) {
        config_validate();
    } elseif (!$config_ready) {
        config_check_requirements();
    }
}