diff --git a/chat.php b/chat.php new file mode 100644 index 0000000..c0b33b4 --- /dev/null +++ b/chat.php @@ -0,0 +1,71 @@ +boundingCoordinates($radius, 'miles'); + + //echo $searchbounds[0]->getLatitudeInDegrees(); + //echo $searchbounds[0]->getLongitudeInDegrees(); + //echo $searchbounds[1]->getLatitudeInDegrees(); + //echo $searchbounds[1]->getLongitudeInDegrees(); + + $msgs = $database->select('messages', ["[>]players" => ["uuid" => "uuid"]], ['messages.uuid', 'messages.message', 'messages.time', 'players.nickname'], ['AND' => [ + 'lat[>]' => $searchbounds[0]->getLatitudeInDegrees(), + 'lat[<]' => $searchbounds[1]->getLatitudeInDegrees(), + 'long[>]' => $searchbounds[0]->getLongitudeInDegrees(), + 'long[<]' => $searchbounds[1]->getLongitudeInDegrees()], + "ORDER" => "messages.time DESC", + "LIMIT" => 30 + ]); + + echo json_encode($msgs); +} else { + // Post message + if (is_empty($VARS['lat']) || is_empty($VARS['long']) || is_empty($VARS['msg'])) { + sendError("Missing information.", true); + } + + $msg = strip_tags($VARS['msg']); + + $database->insert('messages', ['#time' => 'NOW()', 'uuid' => $_SESSION['uuid'], 'message' => $msg, 'lat' => $VARS['lat'], 'long' => $VARS['long']]); + + sendOK(); +} \ No newline at end of file diff --git a/database.mwb b/database.mwb index c5a0ad8..a4bab2f 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/database.mwb.bak b/database.mwb.bak index 3dbc6cc..6f08e87 100644 Binary files a/database.mwb.bak and b/database.mwb.bak differ diff --git a/login.php b/login.php index c4f102f..8a907e1 100644 --- a/login.php +++ b/login.php @@ -10,8 +10,12 @@ if (is_empty($VARS['pass'])) { sendError("Missing password.", true); } +/* Insert code to check login here, it should return "OK" or an error string */ +/* ------------------------------- */ + $logininfo = 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); } @@ -20,14 +24,12 @@ $guid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . urle if (is_empty($guid)) { sendError("Account does not exist.", true); -} else { - } if ($database->has('players', ['uuid' => $guid])) { sendOK(); } else { - $database->insert('players', ['uuid' => $guid, 'level' => 1.0, 'energy' => 100, 'maxenergy' => 100, '#lastping' => 'NOW()']); + $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"); diff --git a/pinglogin.php b/pinglogin.php index d809eaf..42af7dc 100644 --- a/pinglogin.php +++ b/pinglogin.php @@ -15,7 +15,7 @@ if (is_empty($guid)) { if ($database->has('players', ['uuid' => $guid])) { sendOK(); } else { - $database->insert('players', ['uuid' => $guid, 'level' => 1.0, 'energy' => 100, 'maxenergy' => 100, '#lastping' => 'NOW()']); + $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");