Exemple #1
0
if ($db_test->connect_error) {
    // send back with a failed connection message
    sendBack('<strong>Database Connection Error</strong>
				<p>The connection information you supplied is incorrect.<br />' . $db_test->connect_error . '</p>');
}
## Update DB ##
if ($is_add) {
    // add game queries
    $result = $dbl->addGame($name, $game_type, $name_short, $db_host, $db_user, $db_pw, $db_name);
    if (!$result) {
        // if everything is okay
        sendBack('There is a problem, the game information was not saved.');
    }
    $dbl->addGameCount();
    // Add one to the game counter in config table
} else {
    // edit game queries
    $mem->reAuthUser($password, $dbl);
    $result = $dbl->setGameSettings($game, $name, $name_short, $db_user, $db_host, $db_name, $db_pw, $change_db_pw, $enabled);
    // update the settings in the DB
    if (!$result) {
        sendBack('Something did not update. Did you edit anything?');
    }
}
## Return with result message
if ($is_add) {
    set_good('Game Added');
    send('../settings-games.php');
} else {
    sendGood('Your settings have been updated');
}
    sendBack('That server IP Address is not valid');
}
// Check Port is a number between 4-5 digits
if (!is_numeric($rcon_port) || !preg_match('/^[0-9]{4,5}$/', $rcon_port)) {
    sendBack('Rcon Port must be a number between 4-5 digits');
}
if ($is_add) {
    // if is add server request
    if (!is_numeric($game_id)) {
        // game_id is a digit
        sendBack('Invalid data sent');
    }
}
## Update DB ##
if ($is_add) {
    $result = $dbl->addServer($game_id, $name, $ip, $pb, $rcon_ip, $rcon_port, $rcon_pw);
    $dbl->addServerUpdateGames($game_id);
} else {
    $result = $dbl->setServerSettings($server_id, $name, $ip, $pb, $rcon_ip, $rcon_port, $rcon_pw, $change_rcon_pw);
    // update the settings in the DB
}
if (!$result) {
    sendBack('Something did not update');
}
## Return ##
if ($is_add) {
    set_good('Server ' . $name . ' has been added to the database records');
    send('../settings-server.php');
} else {
    sendGood('Your settings have been updated');
}
Exemple #3
0
/**
 * Send a user back to the reffering page with a sucess msg
 *
 * @param string $good - sucess message to be sent to the user
 */
function sendGood($good)
{
    $ref = $_SERVER['HTTP_REFERER'];
    set_good($good);
    send($ref);
    // send back to referering page
    exit;
    // end script
}
// find the hash of the supplied password and the new salt
$password = genPW($pw1, $salt);
if ($valid_key) {
    $results = $dbl->getGroupAndIdWithKey($key);
    // find the permissions for the user that are assoc with the sent key
    $group = $results[0];
    // perms for user
    $admin_id = $results[1];
    // id of the admin who added this user
} else {
    //self registered
    if ($config['cosmos']['self_reg'] != 'true') {
        sendBack('Self registration is disabled!');
    }
    $group = 1;
    $admin_id = 0;
}
// username, display, email, password, salt, permissions, admin_id
$result = $dbl->addUser($username, $display, $email, $password, $salt, $group, $admin_id);
if ($result == false) {
    // if user was not added to the Db
    sendBack('There was an error, account not setup.');
}
## Update user_keys table to deactive key ##
if ($valid_key) {
    $update = $dbl->deactiveKey($key);
}
// If we have gotten this far then nothing should of gone wrong so we send backa good message
set_good('Your account has been created, you can now login.');
send('../login.php');
exit;
Exemple #5
0
    // admin_id/user_id is return as the second item in an array
    if (!$result) {
        // if false
        sendBack('There is a problem with our records');
    } else {
        $id_with_key = $result;
    }
    // generate and reset password in this whole function
    $result = $mem->genAndSetNewPW($pw1, $id_with_key, $min_pw_len);
    if (!is_bool($result)) {
        // result is either a boolean (true) or an error string
        sendBack($result);
    }
    // deactive key to stop multiple use
    $dbl->deactiveKey($key);
    set_good('Your password has been changed.');
    sendLogin();
    exit;
} elseif ($_GET['t'] == 'reset') {
    // if this is a reset password
    // NOTE: This page can only be reached properly by a link in an email,
    //			so the sendBack() function will not work because sendBack() will send the user to the
    //			referer, which is their email client. We must set an error and return to the login page.
    // page normal setup
    $page = "resetpw";
    $page_title = "Reset Your Password";
    require 'inc/header.php';
    // require the header
    $token = genFormToken('resetpw');
    // setup token
    // gets vars and check valid
if ($db_test->connect_error) {
    // send back with a failed connection message
    sendBack('<strong>Database Connection Error</strong>
				<p>The connection information you supplied is incorrect.<br />' . $db_test->connect_error . '</p>');
}
## Update DB ##
if ($is_add) {
    // add game queries
    $result = $dbl->addGame($name, $game_type, $name_short, $db_host, $db_user, $db_pw, $db_name);
    if (!$result) {
        // if everything is okay
        sendBack('There is a problem, the game information was not saved.');
    }
    $dbl->addGameCount();
    // Add one to the game counter in config table
} else {
    // edit game queries
    $mem->reAuthUser($password, $dbl);
    $result = $dbl->setGameSettings($game, $name, $name_short, $db_user, $db_host, $db_name, $db_pw, $change_db_pw, $enabled, $enable);
    // update the settings in the DB
    if (!$result) {
        sendBack('Something did not update. Did you edit anything?');
    }
}
## Return with result message
if ($is_add) {
    set_good('Game Added');
} else {
    set_good('Your settings have been updated');
}
send('../settings-games.php');