master
Skylar Ittner 8 years ago
parent 9decd046ec
commit 02f50b551d

5
.gitignore vendored

@ -1,2 +1,3 @@
error* error*
stats* stats*
vendor*

@ -1,16 +1,16 @@
<?php <?php
require 'required.php'; require 'required.php';
if (is_empty($VARS['user'])) { if (is_empty($VARS['user'])) {
sendError("Missing data.", true); sendError("Missing data.", true);
} }
$badges = $database->select( $badges = $database->select(
'player_badges', ["[>]badges" => ["badgeid" => "badgeid"]], ['badgesid', 'badgename', 'badgedesc', 'gotdate'], ['playeruuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])] 'player_badges', ["[>]badges" => ["badgeid" => "badgeid"]], ['badgesid', 'badgename', 'badgedesc', 'gotdate'], ['playeruuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])]
); );
$out = []; $out = [];
$out['status'] = 'OK'; $out['status'] = 'OK';
$out['badges'] = $badges; $out['badges'] = $badges;
echo json_encode($out); echo json_encode($out);

@ -1,15 +1,15 @@
<?php <?php
require 'required.php'; require 'required.php';
if (is_empty($VARS['user'])) { if (is_empty($VARS['user'])) {
sendError("Missing data.", true); sendError("Missing data.", true);
} }
$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'lastping'], ['uuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])])[0]; $stats = $database->select('players', ['level', 'energy', 'maxenergy', 'lastping'], ['uuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])])[0];
$out = []; $out = [];
$out['status'] = 'OK'; $out['status'] = 'OK';
$out['stats'] = $stats; $out['stats'] = $stats;
echo json_encode($out); echo json_encode($out);

@ -1,13 +1,13 @@
<?php <?php
require 'required.php'; require 'required.php';
if (is_empty($VARS['user'])) { if (is_empty($VARS['user'])) {
sendError("Missing data.", true); sendError("Missing data.", true);
} }
$inv = $database->select('items', ['[>]inventory' => ['itemid' => 'itemid'], '[>]itemclasses' => ['classid', 'classid']], ['inventory.itemuuid', 'inventory.itemid', 'inventory.itemjson', 'items.itemname', 'items.itemdesc', 'itemclasses.classid', 'itemclasses.classname'], ['inventory.playeruuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])]); $inv = $database->select('items', ['[>]inventory' => ['itemid' => 'itemid'], '[>]itemclasses' => ['classid', 'classid']], ['inventory.itemuuid', 'inventory.itemid', 'inventory.itemjson', 'items.itemname', 'items.itemdesc', 'itemclasses.classid', 'itemclasses.classname'], ['inventory.playeruuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])]);
$out['status'] = 'OK'; $out['status'] = 'OK';
$out['items'] = $inv; $out['items'] = $inv;
echo json_encode($out); echo json_encode($out);

@ -1,2 +1,2 @@
<?php <?php
die("http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg"); die("http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg");

@ -1,21 +1,21 @@
<?php <?php
require 'required.php'; require 'required.php';
if (is_empty($VARS['user']) || is_empty($VARS['lat']) || is_empty($VARS['long'])) { if (is_empty($VARS['user']) || is_empty($VARS['lat']) || is_empty($VARS['long'])) {
sendError("Missing data.", true); sendError("Missing data.", true);
} }
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['lat'])) { if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['lat'])) {
sendError("Latitude (lat) is in the wrong format.", true); sendError("Latitude (lat) is in the wrong format.", true);
} }
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['long'])) { if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['long'])) {
sendError("Longitude (long) is in the wrong format.", true); sendError("Longitude (long) is in the wrong format.", true);
} }
$uuid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user']); $uuid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user']);
$database->update('players', ['latitude' => $VARS['lat'], 'longitude' => $VARS['long'], '#lastping' => 'NOW()'], ['uuid' => $uuid]); $database->update('players', ['latitude' => $VARS['lat'], 'longitude' => $VARS['long'], '#lastping' => 'NOW()'], ['uuid' => $uuid]);
sendOK(); sendOK();

@ -1,28 +1,28 @@
<?php <?php
require 'required.php'; require 'required.php';
if (is_empty($VARS['user'])) { if (is_empty($VARS['user'])) {
sendError("Missing data.", true); sendError("Missing data.", true);
} }
$guid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user']); $guid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user']);
if ($database->has('players', ['uuid' => $guid])) { if ($database->has('players', ['uuid' => $guid])) {
sendOK(); sendOK();
} else { } 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()']);
sendOK("Successfully synced Netsyms account to TerranQuest."); sendOK("Successfully synced Netsyms account to TerranQuest.");
ini_set("sendmail_from", "sso@netsyms.com"); 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 = "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 .= "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, " . $_SESSION['user'] . ". We hope you continue to use our services."; $message .= "Have a nice day, " . $_SESSION['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."; $message .= "\n\n--------\nNetsyms Technologies\n\nThis is an automated email. Do not reply to it.";
$headers = "From: Account System <sso@netsyms.com>"; $headers = "From: Account System <sso@netsyms.com>";
$email = file_get_contents("https://sso.netsyms.com/api/getemail.php?user=" . $VARS['user']); $email = file_get_contents("https://sso.netsyms.com/api/getemail.php?user=" . $VARS['user']);
mail($email, "Account Update", $message, $headers); mail($email, "Account Update", $message, $headers);
} }

@ -1,8 +1,8 @@
<?php <?php
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */

@ -1,60 +1,60 @@
<?php <?php
/* /*
Coordinate decimal places to earth resolution Coordinate decimal places to earth resolution
decimal decimal
places degrees distance places degrees distance
------- ------- -------- ------- ------- --------
0 1 111 km 0 1 111 km
1 0.1 11.1 km 1 0.1 11.1 km
2 0.01 1.11 km 2 0.01 1.11 km
3 0.001 111 m 3 0.001 111 m
4 0.0001 11.1 m 4 0.0001 11.1 m
5 0.00001 1.11 m 5 0.00001 1.11 m
6 0.000001 11.1 cm 6 0.000001 11.1 cm
7 0.0000001 1.11 cm 7 0.0000001 1.11 cm
8 0.00000001 1.11 mm 8 0.00000001 1.11 mm
*/ */
require 'required.php'; require 'required.php';
use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation; use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
if (is_empty($VARS['lat']) || is_empty($VARS['long'])) { if (is_empty($VARS['lat']) || is_empty($VARS['long'])) {
sendError("Missing information.", true); sendError("Missing information.", true);
} }
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{3,}/', $VARS['lat'])) { if (!preg_match('/-?[0-9]{1,3}\.[0-9]{3,}/', $VARS['lat'])) {
sendError("Latitude (lat) is in the wrong format.", true); sendError("Latitude (lat) is in the wrong format.", true);
} }
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{3,}/', $VARS['long'])) { if (!preg_match('/-?[0-9]{1,3}\.[0-9]{3,}/', $VARS['long'])) {
sendError("Longitude (long) is in the wrong format.", true); sendError("Longitude (long) is in the wrong format.", true);
} }
$radius = 1; $radius = 1;
if (!is_empty($VARS['radius']) && is_numeric($VARS['radius'])) { if (!is_empty($VARS['radius']) && is_numeric($VARS['radius'])) {
$radius = intval($VARS['radius']); $radius = intval($VARS['radius']);
} }
$userlocation = GeoLocation::fromDegrees($VARS['lat'], $VARS['long']); $userlocation = GeoLocation::fromDegrees($VARS['lat'], $VARS['long']);
$searchbounds = $userlocation->boundingCoordinates($radius, 'miles'); $searchbounds = $userlocation->boundingCoordinates($radius, 'miles');
$people = $database->select('players', ['uuid', 'level', 'latitude', 'longitude', 'lastping'], ['AND' => [ $people = $database->select('players', ['uuid', 'level', 'latitude', 'longitude', 'lastping'], ['AND' => [
'latitude[>]' => $searchbounds[0]->getLatitudeInDegrees(), 'latitude[>]' => $searchbounds[0]->getLatitudeInDegrees(),
'latitude[<]' => $searchbounds[1]->getLatitudeInDegrees(), 'latitude[<]' => $searchbounds[1]->getLatitudeInDegrees(),
'longitude[>]' => $searchbounds[0]->getLongitudeInDegrees(), 'longitude[>]' => $searchbounds[0]->getLongitudeInDegrees(),
'longitude[<]' => $searchbounds[1]->getLongitudeInDegrees(), 'longitude[<]' => $searchbounds[1]->getLongitudeInDegrees(),
'#lastping[>]' => 'DATE_SUB(NOW(), INTERVAL 5 MINUTE)'], '#lastping[>]' => 'DATE_SUB(NOW(), INTERVAL 5 MINUTE)'],
"LIMIT" => 50 "LIMIT" => 50
]); ]);
var_dump($database->error()); var_dump($database->error());
if (!$people) { if (!$people) {
die('[]'); die('[]');
} }
for ($i = 0; $i < count($people); $i++) { for ($i = 0; $i < count($people); $i++) {
$people[$i]['username'] = file_get_contents('https://sso.netsyms.com/api/getname.php?uuid=' . $people[$i]['uuid']); $people[$i]['username'] = file_get_contents('https://sso.netsyms.com/api/getname.php?uuid=' . $people[$i]['uuid']);
} }
echo json_encode($people); echo json_encode($people);

@ -1,27 +1,27 @@
<?php <?php
function sendOK($message = "", $die = false) { function sendOK($message = "", $die = false) {
if (!is_empty($message) && JSON) { if (!is_empty($message) && JSON) {
echo '{ "status": "OK", "message": "'.$message.'" }'; echo '{ "status": "OK", "message": "'.$message.'" }';
} elseif (is_empty($message) && JSON) { } elseif (is_empty($message) && JSON) {
echo '{ "status": "OK" }'; echo '{ "status": "OK" }';
} elseif (!is_empty($message) && !JSON) { } elseif (!is_empty($message) && !JSON) {
echo "OK:$message"; echo "OK:$message";
} else { } else {
echo "OK"; echo "OK";
} }
if ($die) { if ($die) {
die(); die();
} }
} }
function sendError($error, $die = false) { function sendError($error, $die = false) {
if (JSON) { if (JSON) {
echo '{ "status": "ERROR", "message": "' . $error . '" }'; echo '{ "status": "ERROR", "message": "' . $error . '" }';
} else { } else {
echo "Error: $error"; echo "Error: $error";
} }
if ($die) { if ($die) {
die(); die();
} }
} }