Add private messaging (closes #8), add more formatting options to chat
names, add multi-server list for clients to choose frommaster
parent
88175dbe9d
commit
89fb2fc69b
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send the client a list of servers that share the database. The client should
|
||||||
|
* pick one at random and use it for the entire session.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require 'required.php';
|
||||||
|
|
||||||
|
$servers = [];
|
||||||
|
|
||||||
|
if (is_empty(SERVER_URLS) || SERVER_URLS == []) {
|
||||||
|
$servers[] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
|
||||||
|
} else {
|
||||||
|
foreach (SERVER_URLS as $server) {
|
||||||
|
$servers[] = $server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
die(json_encode($servers));
|
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
include.path=${php.global.include.path}
|
include.path=${php.global.include.path}
|
||||||
php.version=PHP_54
|
php.version=PHP_70
|
||||||
source.encoding=UTF-8
|
source.encoding=UTF-8
|
||||||
src.dir=.
|
src.dir=.
|
||||||
tags.asp=false
|
tags.asp=false
|
||||||
tags.short=false
|
tags.short=false
|
||||||
web.root=.
|
web.root=.
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'required.php';
|
||||||
|
require 'onlyloggedin.php';
|
||||||
|
|
||||||
|
if (!is_empty($VARS['markread'])) {
|
||||||
|
if (preg_match("/[0-9]+/", $VARS['markread'])) {
|
||||||
|
$database->update('private_messages', ['msg_read' => 1], [
|
||||||
|
'AND' => [
|
||||||
|
"id" => $VARS['markread'],
|
||||||
|
"to_uuid" => $_SESSION['uuid']
|
||||||
|
]]);
|
||||||
|
sendOK();
|
||||||
|
} else {
|
||||||
|
sendError("Malformed input.", true);
|
||||||
|
}
|
||||||
|
} else if (!is_empty($VARS['delete'])) {
|
||||||
|
if (preg_match("/[0-9]+/", $VARS['delete'])) {
|
||||||
|
$database->delete('private_messages', [
|
||||||
|
'AND' => [
|
||||||
|
"id" => $VARS['delete'],
|
||||||
|
"to_uuid" => $_SESSION['uuid']
|
||||||
|
]]);
|
||||||
|
sendOK();
|
||||||
|
} else {
|
||||||
|
sendError("Malformed input.", true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$where = [
|
||||||
|
"private_messages.to_uuid" => $_SESSION['uuid']
|
||||||
|
];
|
||||||
|
if ($VARS['filter'] == 'read') {
|
||||||
|
$where["msg_read"] = 1;
|
||||||
|
} else if ($VARS['filter'] == 'unread') {
|
||||||
|
$where["msg_read"] = 0;
|
||||||
|
}
|
||||||
|
$out = ["status" => "OK", "msgs" => []];
|
||||||
|
$out['msgs'] = $database->select('private_messages', [
|
||||||
|
"[>]players" => [
|
||||||
|
"from_uuid" => "uuid"
|
||||||
|
]
|
||||||
|
], [
|
||||||
|
'private_messages.id', 'private_messages.message', 'private_messages.time', 'players.nickname', 'private_messages.msg_read'
|
||||||
|
], [
|
||||||
|
'AND' => $where,
|
||||||
|
"ORDER" => "private_messages.time DESC"]
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode($out);
|
||||||
|
}
|
Reference in New Issue