Add chat API, move "items" to "inventory", add color+icon fields to items
부모
f9afcbe5d8
커밋
718bde141d
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
|
||||
|
||||
$userlocation = GeoLocation::fromDegrees($VARS["latitude"], $VARS["longitude"]);
|
||||
|
||||
$radius = 2;
|
||||
if (!empty($VARS["radius"])) {
|
||||
$radius = min(10.0, $VARS["radius"] * 1.0);
|
||||
}
|
||||
$searchbounds = $userlocation->boundingCoordinates($radius, "miles");
|
||||
|
||||
$where = [
|
||||
"LIMIT" => 100,
|
||||
"ORDER" => "time"
|
||||
];
|
||||
|
||||
if (!empty($VARS["latitude"]) && !empty($VARS["longitude"])) {
|
||||
$where["AND"] = [
|
||||
'lat[<>]' => [$searchbounds[0]->getLatitudeInDegrees(), $searchbounds[1]->getLatitudeInDegrees()],
|
||||
'long[<>]' => [$searchbounds[0]->getLongitudeInDegrees(), $searchbounds[1]->getLongitudeInDegrees()],
|
||||
];
|
||||
}
|
||||
|
||||
ob_flush();
|
||||
$database->debug()->select("messages", [
|
||||
"[>]players" => "accountid"
|
||||
], [
|
||||
"id",
|
||||
"time",
|
||||
"message",
|
||||
"messages.accountid",
|
||||
"players.nickname"
|
||||
], $where
|
||||
);
|
||||
$query = ob_get_contents();
|
||||
ob_clean();
|
||||
$messages = $database->query($query)->fetchAll();
|
||||
|
||||
$myid = getRequestUser()->getUID();
|
||||
for ($i = 0; $i < count($messages); $i++) {
|
||||
if ($messages[$i]["accountid"] == $myid) {
|
||||
$messages[$i]["me"] = true;
|
||||
} else {
|
||||
$messages[$i]["me"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
exitWithJson(["status" => "OK", "count" => count($messages), "messages" => $messages]);
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
$message = strip_tags($VARS['message']);
|
||||
if (empty($message)) {
|
||||
sendJsonResp($Strings->get("Message cannot be empty.", false), "ERROR");
|
||||
}
|
||||
|
||||
$database->insert('messages', [
|
||||
'time' => date("Y-m-d H:i:s"),
|
||||
'message' => $message,
|
||||
'lat' => $VARS['latitude'],
|
||||
'long' => $VARS['longitude'],
|
||||
'accountid' => getRequestUser()->getUID()
|
||||
]);
|
||||
|
||||
sendJsonResp();
|
Binary file not shown.
불러오는 중...
Reference in New Issue