コード例 #1
0
ファイル: step4.php プロジェクト: Kheros/Plexis
<?php

// Check if everything is given for Plexis DB
if (!$_POST['db_host'] | !$_POST['db_port'] | !$_POST['db_username'] | !$_POST['db_password'] | !$_POST['db_name']) {
    show_error('One or more fields are blank. Please <a href="javascript: history.go(-1)">Go Back</a> and correct it.');
    die;
}
// Check if everything is given for realm DB
if (!$_POST['rdb_host'] | !$_POST['rdb_port'] | !$_POST['rdb_username'] | !$_POST['rdb_password'] | !$_POST['rdb_name']) {
    show_error('One or more fields are blank. Please <a href="javascript: history.go(-1)">Go Back</a> and correct it.');
    die;
}
// == Check DB connections first! == //
$connect = get_database_connections(true);
$DB = $connect['plexis'];
// Everthing should be fine, so first insert info into protected config file
$conffile = "../system/config/database.config.php";
$build = '';
$build .= "<?php\n\$DB_configs = array(\n    'DB' => array(\n        'driver'\t   => 'mysql',\n        'host'         => '" . $_POST['db_host'] . "',\n        'port'         => '" . $_POST['db_port'] . "',\n        'username'     => '" . $_POST['db_username'] . "',\n        'password'     => '" . $_POST['db_password'] . "',\n        'database'     => '" . $_POST['db_name'] . "'\n    ),\n    'RDB' => array(\n        'driver'\t   => 'mysql',\n        'host'         => '" . $_POST['rdb_host'] . "',\n        'port'         => '" . $_POST['rdb_port'] . "',\n        'username'     => '" . $_POST['rdb_username'] . "',\n        'password'     => '" . $_POST['rdb_password'] . "',\n        'database'     => '" . $_POST['rdb_name'] . "'\n    )\n);\n?>";
// Make sure the  config is still writable
if (is_writeable($conffile)) {
    $openconf = fopen($conffile, 'wb');
    fwrite($openconf, $build);
    fclose($openconf);
} else {
    show_error('Couldn\'t open database.config.php for editing, it must be writable by webserver! Please set your premissions and try again.');
    die;
}
// Edit the config.php file and switch it to the Trinity emulator (Thanks Skye :p )
$cmsconf = "../system/config/config.php";
if (is_writeable($cmsconf)) {
コード例 #2
0
ファイル: step5.php プロジェクト: Kheros/Plexis
if (empty($_POST['account'])) {
    show_error('No account name was given. Please <a href="javascript: history.go(-1)">go back</a> and correct it.');
    die;
}
// Make sure username is correct length
if (strlen($_POST['account']) < 4) {
    show_error('Account name needs to be at least 4 characters long.');
    die;
}
// Make sure password is correct length
if (strlen($_POST['pass']) < 4) {
    show_error('Password needs to be at least 4 characters long.');
    die;
}
// == Check DB connections first! == //
$connect = get_database_connections(false);
$DB = $connect['plexis'];
$Realm = $connect['realm'];
// == Include emulator file == //
include ROOT . DS . 'emulators' . DS . $_POST['emulator'] . '.php';
// Fetch posted account name
$account = fetch_account($_POST['account']);
if ($account != FALSE) {
    $array = array('id' => $account['id'], 'username' => $account['username'], 'email' => $account['email'], 'registration_ip' => $_SERVER['REMOTE_ADDR'], 'activated' => 1, 'group_id' => 4);
    $mode = 1;
    $success = $DB->insert('pcms_accounts', $array, true) != false ? true : false;
} else {
    // No such account, creating one, in this case pwd is needed, so checking whether it's provided...
    $result = create_account($_POST['account'], $_POST['pass']);
    if ($result != FALSE) {
        // Get the account ID