2 /* See file COPYING for permissions and conditions to use the file. */
5 require_once("{$_SERVER['DOCUMENT_ROOT']}/extra/config.php");
8 if (empty($_GET['id'])) {
9 header("Location: $protocol://$server/index.php");
13 $result = mysqli_execute_query($dbc, "SELECT * FROM $msgtable WHERE msg_id=?", [$id]);
14 if (mysqli_num_rows($result) != 1) {
15 header("Location: $protocol://$server/index.php");
18 $assoc = mysqli_fetch_assoc($result);
19 mysqli_free_result($result);
20 if ($assoc['r_pwlvl'] > 0 && !isset($_SESSION['auth'])) {
21 /* unreadable for "normal" also unreadable for anonymous users */
22 header("Location: $protocol://$server/account/login.php");
25 foreach ($assoc as $k => $value) {
26 $assoc[$k] = export_data($value);
29 * Groups are separated extensively so admins can config how they want
31 * \\0 full url for sure.
34 * \\2 for the protocol, \\1 for protocol with ://
36 $urlre = "((http{1}s?):\/\/)" . "((([[:alnum:]-])+(\.))+" . "([[:alnum:]]){2,6}"
37 . "(:[0-9]{2,5})?)" . "(\/[[:alnum:]+=%#&_.:~?@\-\/]*)?";
39 $body = nl2br(preg_replace("/$urlre/ium", '<a href="\\0">\\0</a>',
40 str_replace("&", "&", $assoc['body'])), false);
42 $author = mysqli_fetch_assoc(mysqli_execute_query($dbc, "SELECT name, powerlevel FROM $table WHERE email='{$assoc['from_addr']}'"));
45 $title = $assoc['subject'];
46 include("{$_SERVER['DOCUMENT_ROOT']}/html/header.html");
47 if ($assoc['r_pwlvl'] <= $_SESSION['powerlevel'])
50 <h1
><?
=$assoc['subject']; ?
></h1
>
51 <p
><?php
echo "Boi " .
52 "<a href=\"$protocol://$server/profiles.php?email={$assoc['from_addr']}\">" .
53 "{$author['name']}</a> " .
54 "<<a href=\"mailto:{$assoc['from_addr']}\">{$assoc['from_addr']}</a>> ";
57 if ($assoc['relate_to'] != 0) {
58 echo "<p><a href=\"$protocol://$server/view.php?id={$assoc['relate_to']}\">Tin nhan truoc</a></p>";
61 <pre
><a href
="<?php echo "$protocol://$server{$_SERVER['REQUEST_URI']}"; ?>"><?=$assoc['last_edit'];?></a></pre>
63 if ($assoc['w_pwlvl'] <= $_SESSION['powerlevel']) {
65 <p><a href=\"$protocol://$server/board.php?relate_to=$id\">Viet tra loi</a></p>
69 <p
><br
><?
=$body;?
></p
>
72 $rmsg_result = mysqli_execute_query($dbc, "SELECT * FROM $msgtable "
73 . "WHERE relate_to=? AND r_pwlvl <= '{$_SESSION['powerlevel']}' "
74 . "AND to_addr='{$assoc['to_addr']}' ORDER BY last_edit DESC", [$id]);
75 $rmsg_count = mysqli_num_rows($rmsg_result);
76 echo "<h3>Tra loi ($rmsg_count)</h3>";
77 if ($rmsg_count > 0) {
78 while ($rmsg = mysqli_fetch_assoc($rmsg_result)) {
79 echo "<h4>{$rmsg['subject']}</h4>";
80 echo "<p>Boi {$rmsg['from_addr']}<br></p>";
81 echo "<p>{$rmsg['body']}</p>";
82 echo "<pre><a href=\"$protocol://$server/view.php?" .
83 "id={$rmsg['msg_id']}\">{$rmsg['last_edit']}</a>
91 echo "<h3>Ban khong co quyen truy cap vao noi dung nay.</h3>";
93 include("{$_SERVER['DOCUMENT_ROOT']}/html/footer.html");