Fully end to end encrypted anonymous chat program. Server only stores public key lookup for users and the encrypted messages. No credentials are transfered to the server, but kept in local browser storage. This allows 100% safe chatting. https://safechat.ch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

10 years ago
<?php
9 years ago
/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
9 years ago
/// Get new messages
/** Get all messages that are newer than @c $start.
9 years ago
@param $start Number of message to start with.
9 years ago
@return json encoded array of messages:
@code
[
{
id: message-id,
time: unix-time-stamp,
user: 'sender's user name',
msg: 'armored and encrypted message as string'
}, ...
]
@endcode
@api Get New Messages
9 years ago
*/
function get($start) {
try {
require_once("opendb.php");
$start = $db->real_escape_string($start);
$q = $db->query("select id, UNIX_TIMESTAMP(time) as time, user, msg from message where id>$start;");
if ($q) echo json_encode($q->fetch_all(MYSQLI_ASSOC));
else echo json_encode(null);
} catch (Exception $e) {
echo json_encode(null);
}
10 years ago
}
get($_REQUEST['start']);
10 years ago
?>