From 0edb67e93522fa512ffc2b9be257a962331d807b Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 9 Nov 2016 11:38:10 -0700 Subject: [PATCH] Add sending private messages without appearing in global chat --- privmsgs.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/privmsgs.php b/privmsgs.php index 44b8627..8b7665a 100644 --- a/privmsgs.php +++ b/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); } \ No newline at end of file