Browse Source

Add sending private messages without appearing in global chat

master
Skylar Ittner 5 years ago
parent
commit
0edb67e935
  1. 19
      privmsgs.php

19
privmsgs.php

@ -3,7 +3,20 @@
require 'required.php';
require 'onlyloggedin.php';
if (!is_empty($VARS['markread'])) {
/*
* Handle everything with private messages.
* Figures out what you want based on context.
*/
if (!is_empty($VARS['msg'])) {
if (!is_empty($VARS['to'])) {
$touuid = $database->select("players", ['uuid'], ['nickname' => $VARS['to']])[0]['uuid'];
$database->insert("private_messages", ["from_uuid" => $_SESSION['uuid'], "to_uuid" => $touuid, "message" => $VARS['msg'], "msg_read" => 0, "#time" => "NOW()"]);
sendOK();
} else {
sendError("Missing required arguments.", true);
}
} else if (!is_empty($VARS['markread'])) {
if (preg_match("/[0-9]+/", $VARS['markread'])) {
$database->update('private_messages', ['msg_read' => 1], [
'AND' => [
@ -44,7 +57,7 @@ if (!is_empty($VARS['markread'])) {
], [
'AND' => $where,
"ORDER" => "private_messages.time DESC"]
);
);
echo json_encode($out);
}