First git commit
This commit is contained in:
35
public_html/message.php
Normal file
35
public_html/message.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/lib/bootstrap.php';
|
||||
$me = require_login();
|
||||
$id = (int)($_GET['id'] ?? 0);
|
||||
|
||||
$s = db()->prepare("SELECT m.*, f.username AS fromname, t.username AS toname
|
||||
FROM messages m
|
||||
LEFT JOIN users f ON f.id=m.from_id
|
||||
LEFT JOIN users t ON t.id=m.to_id
|
||||
WHERE m.id=?");
|
||||
$s->execute([$id]);
|
||||
$m = $s->fetch();
|
||||
if (!$m || ((int)$m['to_id'] !== (int)$me['id'] && (int)$m['from_id'] !== (int)$me['id'])) {
|
||||
bail('Message', 'Not found.', '/inbox.php');
|
||||
}
|
||||
if ((int)$m['to_id'] === (int)$me['id'] && !$m['is_read']) {
|
||||
db()->prepare("UPDATE messages SET is_read=1 WHERE id=?")->execute([$id]);
|
||||
}
|
||||
|
||||
page_start('Msg: ' . $m['subject'], ['back' => '/inbox.php']);
|
||||
p_para('From: ' . ($m['fromname'] ?? '[deleted]'));
|
||||
p_para('To: ' . ($m['toname'] ?? '[deleted]'));
|
||||
p_para('Date: ' . date('d/m/Y H:i', (int)$m['created_at']));
|
||||
p_rule();
|
||||
p_para(wtrim($m['body']));
|
||||
p_rule();
|
||||
if ((int)$m['from_id'] !== (int)$me['id'] && $m['fromname'] !== null) {
|
||||
p_link('/compose.php', 'Reply', ['to' => $m['from_id'], 're' => $m['id']]);
|
||||
}
|
||||
p_form('/inbox.php', [
|
||||
['name' => 'act', 'type' => 'hidden', 'value' => 'del'],
|
||||
['name' => 'id', 'type' => 'hidden', 'value' => (string)$id],
|
||||
], 'Delete');
|
||||
p_links([['/inbox.php', 'Inbox'], ['/index.php', 'Home']]);
|
||||
page_end();
|
||||
Reference in New Issue
Block a user