Simplify/reorganize login.php
This commit is contained in:
parent
0edb67e935
commit
c4ff5f0f3a
34
login.php
34
login.php
@ -12,39 +12,26 @@ if (is_empty($VARS['pass'])) {
|
||||
|
||||
$VARS['user'] = strtolower(str_replace(" ", "", $VARS['user']));
|
||||
|
||||
/* Insert code to check login here, it should return "OK" or an error string */
|
||||
/* Insert code to check login here */
|
||||
/* ------------------------------- */
|
||||
|
||||
$logininfo = file_get_contents("https://sso.netsyms.com/api/simplehashauth.php?get=1&user=" . urlencode($VARS['user']) . "&pass=" . hash('sha1', $VARS['pass']));
|
||||
$loginok = file_get_contents("https://sso.netsyms.com/api/simplehashauth.php?get=1&user=" . urlencode($VARS['user']) . "&pass=" . hash('sha1', $VARS['pass']));
|
||||
|
||||
/* ------------------------------- */
|
||||
if ($logininfo != "OK") {
|
||||
sendError(str_replace("Error: ", "", $logininfo), true);
|
||||
if ($loginok != "OK") {
|
||||
sendError(str_replace("Error: ", "", $loginok), true);
|
||||
}
|
||||
|
||||
/* Put code here to get the unique UUID (internal ID) for the player */
|
||||
$guid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . urlencode($VARS['user']));
|
||||
|
||||
/* ------------------------------- */
|
||||
|
||||
if (is_empty($guid)) {
|
||||
sendError("Account does not exist.", true);
|
||||
}
|
||||
|
||||
if ($database->has('players', ['uuid' => $guid])) {
|
||||
sendOK();
|
||||
} else {
|
||||
if (!$database->has('players', ['uuid' => $guid])) {
|
||||
$database->insert('players', ['uuid' => $guid, 'level' => 1.0, 'energy' => 100, 'maxenergy' => 100, '#lastping' => 'NOW()', 'nickname' => $VARS['user']]);
|
||||
sendOK("Successfully synced Netsyms account to TerranQuest.");
|
||||
ini_set("sendmail_from", "sso@netsyms.com");
|
||||
|
||||
$message = "This is just a quick message confirming that you have successfully linked TerranQuest to your Netsyms Technologies account. \n\n";
|
||||
$message .= "If you have any questions or need assistance with anything, email admin@netsyms.com and we will be happy to assist you. \n\n";
|
||||
$message .= "Have a nice day, " . $VARS['user'] . ". We hope you continue to use our services.";
|
||||
$message .= "\n\n--------\nNetsyms Technologies\n\nThis is an automated email. Do not reply to it.";
|
||||
|
||||
$headers = "From: Account System <sso@netsyms.com>";
|
||||
|
||||
$email = file_get_contents("https://sso.netsyms.com/api/getemail.php?user=" . $VARS['user']);
|
||||
|
||||
mail($email, "Account Update", $message, $headers);
|
||||
}
|
||||
// Setup the session
|
||||
$_SESSION['username'] = $VARS['user'];
|
||||
@ -56,6 +43,7 @@ if (BETA_MODE) {
|
||||
if (!$database->has('player_badges', ["AND" => ['playeruuid' => $guid, 'badgeid' => 1]])) {
|
||||
$database->insert('player_badges', ['playeruuid' => $guid, 'badgeid' => 1, '#gotdate' => "NOW()"]);
|
||||
// Give some free credits as thanks
|
||||
$database->update('players', ['credits' => 250], ['uuid' => $guid]);
|
||||
$database->update('players', ['credits' => 500], ['uuid' => $guid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
sendOK();
|
||||
|
Reference in New Issue
Block a user