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