getUserArray($session, 1);
if (!$admin || (int)$admin['access'] !== 9) {
die('
Access Denied: You are not Admin!
');
}
// ---------------------------------------------------------------------------
// Insert mesaj
// ---------------------------------------------------------------------------
$time = time();
$topicEsc = $database->escape($topic);
$msgEsc = $database->escape($message);
$database->query(
"INSERT INTO " . TB_PREFIX . "mdata
(target, owner, topic, message, viewed, time, archive)
VALUES ($uid, 1, '$topicEsc', '$msgEsc', 0, $time, 0)"
);
// ---------------------------------------------------------------------------
// Log admin
// ---------------------------------------------------------------------------
$adminId = (int)$_SESSION['id'];
$logText = "Sent message to uid $uid: '$topicEsc'";
$logEsc = $database->escape($logText);
$database->query(
"INSERT INTO " . TB_PREFIX . "admin_log (`id`, `user`, `log`, `time`) " .
"VALUES (0, '$adminId', '$logEsc', $time)"
);
header("Location: ../../../Admin/admin.php?p=Newmessage&uid=" . $uid . "&msg=ok");
exit;
?>