Exemplo n.º 1
0
        }
    }
}
echo '<p>Welcome to the PHP Calendar installation process.</p>
<form method="post" action="install.php">
';
foreach ($_POST as $key => $value) {
    echo "<input name=\"{$key}\" value=\"{$value}\" type=\"hidden\">\n";
}
$drop_tables = isset($_POST["drop_tables"]) && $_POST["drop_tables"] == "yes";
if (!isset($_POST['my_hostname']) && !isset($_POST['my_username']) && !isset($_POST['my_passwd']) && !isset($_POST['my_prefix']) && !isset($_POST['my_database'])) {
    get_server_setup();
} elseif ((isset($_POST['create_user']) || isset($_POST['create_db'])) && !isset($_POST['done_user_db'])) {
    add_sql_user_db();
} elseif (!isset($_POST['base'])) {
    install_base();
} elseif (!isset($_POST['admin_user']) && !isset($_POST['admin_pass'])) {
    get_admin();
} else {
    add_calendar();
}
function check_config()
{
    global $phpc_config_file;
    if (is_writable($phpc_config_file)) {
        return true;
    }
    // Check if we can create the file
    if ($file = @fopen($phpc_config_file, 'a')) {
        fclose($file);
        return true;
Exemplo n.º 2
0
function write_config($host, $user, $pass, $dbname, $engine, $other)
{
    global $install_lang_load;
    $local_dir = dirname(dirname(str_replace('\\', '/', __FILE__)));
    $script_filename = str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']);
    $other_conf = '';
    if (strcmp($local_dir, substr($script_filename, 0, strlen($local_dir)))) {
        $epesi_dir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
        $other_conf .= "\n" . '@define(\'EPESI_DIR\',\'' . addcslashes($epesi_dir, '\'\\') . '\');';
    }
    $other_conf .= "\n" . 'define(\'DIRECTION_RTL\',\'' . ($other['direction'] ? '1' : '0') . '\');';
    $protocol = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== "off" ? 'https://' : 'http://';
    $domain_name = '';
    if (isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) {
        $domain_name = $_SERVER['HTTP_HOST'];
    } else {
        if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']) {
            $domain_name = $_SERVER['SERVER_NAME'];
        }
    }
    if ($domain_name) {
        $url = $protocol . $domain_name . dirname($_SERVER['REQUEST_URI']);
        $url = str_replace('\\', '/', $url);
        $other_conf .= "\n" . 'define(\'EPESI_URL\',\'' . addcslashes($url, '\'\\') . '\');';
    }
    $c =& fopen(DATA_DIR . '/config.php', 'w');
    fwrite($c, '<?php
/**
 * Config file.
 * 
 * All commented out defines are default values as they were
 * during the installation process. Default values may change after an update,
 * but your config file will remain as it was. If you want to know
 * current default values please look at file include/config.php
 *
 * This file contains database configuration.
 */
defined(\'_VALID_ACCESS\') || die(\'Direct access forbidden\');

/**
 * Address of SQL server.
 */
define(\'DATABASE_HOST\',\'' . addcslashes($host, '\'\\') . '\');

/**
 * User to log in to SQL server.
 */
define(\'DATABASE_USER\',\'' . addcslashes($user, '\'\\') . '\');

/**
 * User password to authorize SQL server.
 */
define(\'DATABASE_PASSWORD\',\'' . addcslashes($pass, '\'\\') . '\');

/**
 * Database to use.
 */
define(\'DATABASE_NAME\',\'' . addcslashes($dbname, '\'\\') . '\');

/**
 * Database driver.
 */
define(\'DATABASE_DRIVER\',\'' . addcslashes($engine, '\'\\') . '\');

/*
 * Turns on transfer reduction: not everything is sent to the client
 */
//define(\'REDUCING_TRANSFER\',1);

/*
 * A lot of debug info, starting with what modules are changed, what module variables are set... etc.
 */
//define(\'DEBUG\',0);

/*
 * Show module loading time ...  = module + all children times
 */
//define(\'MODULE_TIMES\',0);

/*
 * Show queries execution time.
 */
//define(\'SQL_TIMES\',0);

/*
 * If you have got good server, but poor connection, turn it on.
 */
//define(\'STRIP_OUTPUT\',0);

/*
 * Display errors on page.
 */
//define(\'DISPLAY_ERRORS\',1);

/*
 * Notify all errors, including E_NOTICE, etc. Developer should use it!
 */
//define(\'REPORT_ALL_ERRORS\',0);

/*
 * Compress history
 */
//define(\'GZIP_HISTORY\',1);

/*
 * Compress HTTP output
 */
//define(\'MINIFY_ENCODE\',1);

/*
 * Apply sources minifying algorithms.
 *
 * If enabled CPU usage may raise, but amount
 * of transferred data is smaller.
 */
//define(\'MINIFY_SOURCES\',0);

/*
 * Show donation links in EPESI
 */
//define(\'SUGGEST_DONATION\',1);

/*
 * automatically check for new version
 */
//define(\'CHECK_VERSION\',1);

/*
 * Disable some administrator preferences.
 */
//define(\'DEMO_MODE\',0);

define(\'FILE_SESSION_DIR\',\'' . str_replace('\\', '/', sys_get_temp_dir()) . '\');
define(\'FILE_SESSION_TOKEN\',\'epesi_' . md5(__FILE__) . '_\');

' . $other_conf . '
?>');
    fclose($c);
    ob_start();
    ob_start('rm_config');
    //fill database
    clean_database();
    install_base();
    ob_end_flush();
    if (file_exists(DATA_DIR . '/config.php')) {
        header("Location: setup.php?install_lang={$install_lang_load}&check=1");
    }
    ob_end_flush();
}