You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

50 lines
1.6 KiB
PHTML

<?php
require 'required.php';
if (is_empty($VARS['user'])) {
7 years ago
sendError(USERNAME_MISSING, true);
}
if (is_empty($VARS['pass'])) {
7 years ago
sendError(PASSWORD_MISSING, true);
}
$VARS['user'] = strtolower(str_replace(" ", "", $VARS['user']));
/* Insert code to check login here */
/* ------------------------------- */
$loginok = file_get_contents("https://sso.netsyms.com/api/simpleauth.php?get=1&user=" . urlencode($VARS['user']) . "&pass=" . $VARS['pass']);
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)) {
7 years ago
sendError(ACCOUNT_MISSING, true);
}
if (!$database->has('players', ['uuid' => $guid])) {
$database->insert('players', ['uuid' => $guid, 'level' => 1.0, 'energy' => 100, 'maxenergy' => 100, '#lastping' => 'NOW()', 'nickname' => $VARS['user']]);
}
// Setup the session
$_SESSION['username'] = $VARS['user'];
$_SESSION['guid'] = $_SESSION['uuid'] = $guid;
$_SESSION['loggedin'] = true;
// Give out the beta tester badge and stuff to people
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' => 500], ['uuid' => $guid]);
}
}
sendOK();