示例#1
0
    if (is_numeric($_POST['close_poll'])) {
        $close_poll = $_POST['close_poll'];
    } else {
        $close_poll = POLL_CLOSE_NO_CHANGE;
    }
} else {
    $close_poll = POLL_CLOSE_NO_CHANGE;
}
$allow_html = true;
if (isset($fid) && !session::check_perm(USER_PERM_HTML_POSTING, $fid)) {
    $allow_html = false;
}
if (isset($_POST['aid']) && is_md5($_POST['aid'])) {
    $aid = $_POST['aid'];
} else {
    if (!($aid = attachments_get_id($tid, $pid))) {
        $aid = md5(uniqid(mt_rand()));
    }
}
if (isset($_POST['preview_poll']) || isset($_POST['preview_form']) || isset($_POST['apply'])) {
    $valid = true;
    if (!isset($thread_title) || strlen(trim($thread_title)) == 0) {
        $error_msg_array[] = gettext("You must enter a title for the thread!");
        $valid = false;
    }
    if (!isset($fid) || !folder_is_valid($fid)) {
        $error_msg_array[] = gettext("Unknown folder");
        $valid = false;
    }
    if (!session::check_perm(USER_PERM_THREAD_CREATE | USER_PERM_POST_READ, $fid)) {
        $error_msg_array[] = gettext("You cannot create new threads in this folder");
示例#2
0
function message_display($tid, $message, $msg_count, $first_msg, $folder_fid, $in_list = true, $closed = false, $limit_text = true, $is_poll = false, $show_sigs = true, $is_preview = false, $highlight_array = array())
{
    $perm_is_moderator = session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_fid);
    $post_edit_time = forum_get_setting('post_edit_time', null, 0);
    $post_edit_grace_period = forum_get_setting('post_edit_grace_period', null, 0);
    $webtag = get_webtag();
    if (($uid = session::get_value('UID')) === false) {
        return;
    }
    if ($posts_per_page = session::get_value('POSTS_PER_PAGE')) {
        if ($posts_per_page < 10) {
            $posts_per_page = 10;
        }
        if ($posts_per_page > 30) {
            $posts_per_page = 30;
        }
    } else {
        $posts_per_page = 20;
    }
    if (($quick_reply = session::get_value('REPLY_QUICK')) === false) {
        $quick_reply = 'N';
    }
    if ((!isset($message['CONTENT']) || $message['CONTENT'] == "") && !$is_preview) {
        message_display_deleted($tid, isset($message['PID']) ? $message['PID'] : 0, $message, $in_list, $is_preview, $first_msg, $msg_count, $posts_per_page);
        return;
    }
    $from_user_permissions = perm_get_user_permissions($message['FROM_UID']);
    if ($uid != $message['FROM_UID']) {
        if ($from_user_permissions & USER_PERM_WORMED && !$perm_is_moderator) {
            message_display_deleted($tid, $message['PID'], $message, $in_list, $is_preview, $first_msg, $msg_count, $posts_per_page);
            return;
        }
    }
    if (!isset($message['FROM_RELATIONSHIP'])) {
        $message['FROM_RELATIONSHIP'] = 0;
    }
    if (!isset($message['TO_RELATIONSHIP'])) {
        $message['TO_RELATIONSHIP'] = 0;
    }
    if ($message['TO_RELATIONSHIP'] & USER_IGNORED_COMPLETELY || $message['FROM_RELATIONSHIP'] & USER_IGNORED_COMPLETELY) {
        message_display_deleted($tid, $message['PID'], $message, $in_list, $is_preview, $first_msg, $msg_count, $posts_per_page);
        return;
    }
    // Add emoticons/WikiLinks and ignore signature ----------------------------
    if (session::get_value('IMAGES_TO_LINKS') == 'Y') {
        $message['CONTENT'] = preg_replace('/<a([^>]*)href="([^"]*)"([^\\>]*)><img[^>]*src="([^"]*)"[^>]*><\\/a>/iu', '[href: <a\\1href="\\2"\\3>\\2</a>][img: <a\\1href="\\4"\\3>\\4</a>]', $message['CONTENT']);
        $message['CONTENT'] = preg_replace('/<img[^>]*src="([^"]*)"[^>]*>/iu', '[img: <a href="\\1">\\1</a>]', $message['CONTENT']);
        $message['CONTENT'] = preg_replace('/<embed[^>]*src="([^"]*)"[^>]*>/iu', '[object: <a href="\\1">\\1</a>]', $message['CONTENT']);
    }
    if (!$is_poll || $is_poll && isset($message['PID']) && $message['PID'] > 1) {
        $message['CONTENT'] = message_apply_formatting($message['CONTENT'], $message['FROM_RELATIONSHIP'] & USER_IGNORED_SIG || !$show_sigs);
    }
    // Check length of post to see if we should truncate it for display --------
    if (mb_strlen(strip_tags($message['CONTENT'])) > intval(forum_get_setting('maximum_post_length', null, 6226)) && $limit_text) {
        $cut_msg = mb_substr($message['CONTENT'], 0, intval(forum_get_setting('maximum_post_length', null, 6226)));
        $cut_msg = preg_replace("/(<[^>]+)?\$/Du", "", $cut_msg);
        $message['CONTENT'] = fix_html($cut_msg);
        $message['CONTENT'] .= "&hellip;[" . gettext("Message Truncated") . "]\n<p align=\"center\"><a href=\"display.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" target=\"_self\">" . gettext("View full message") . "</a>";
    }
    // Check for words that should be filtered ---------------------------------
    if (!$is_poll || $is_poll && isset($message['PID']) && $message['PID'] > 1) {
        $message['CONTENT'] = word_filter_add_ob_tags($message['CONTENT'], false);
    }
    if ($in_list && isset($message['PID'])) {
        echo "<a name=\"a{$tid}_{$message['PID']}\"></a>\n";
    }
    // Check for search words to highlight -------------------------------------
    if (is_array($highlight_array) && sizeof($highlight_array) > 0) {
        $highlight_pattern = array();
        $highlight_replace = array();
        foreach ($highlight_array as $key => $word) {
            $highlight_word = preg_quote($word, "/");
            $highlight_pattern[$key] = "/({$highlight_word})/iu";
            $highlight_replace[$key] = "<span class=\"highlight\">\\1</span>";
        }
        $message_parts = preg_split('/([<|>])/u', $message['CONTENT'], -1, PREG_SPLIT_DELIM_CAPTURE);
        for ($i = 0; $i < sizeof($message_parts); $i++) {
            if (!($i % 4)) {
                $message_parts[$i] = preg_replace($highlight_pattern, $highlight_replace, $message_parts[$i], 1);
            }
        }
        $message['CONTENT'] = implode("", $message_parts);
    }
    // Little up/down arrows to the left of each message -----------------------
    if (forum_get_setting('require_post_approval', 'Y') && $message['FROM_UID'] != $uid) {
        if (isset($message['APPROVED']) && $message['APPROVED'] == 0 && !$perm_is_moderator) {
            message_display_approval_req($tid, $message['PID'], $in_list, $is_preview, $first_msg, $msg_count, $posts_per_page);
            return;
        }
    }
    // OUTPUT MESSAGE ----------------------------------------------------------
    if (!$is_preview && $message['MOVED_TID'] > 0 && $message['MOVED_PID'] > 0) {
        $post_link = "<a href=\"messages.php?webtag={$webtag}&amp;msg=%s.%s\" target=\"_self\">%s</a>";
        $post_link = sprintf($post_link, $message['MOVED_TID'], $message['MOVED_PID'], gettext("here"));
        echo "<div align=\"center\">\n";
        echo "<table class=\"thread_track_notice\" width=\"96%\">\n";
        echo "  <tr>\n";
        echo "    <td align=\"left\">", sprintf(gettext("<b>Thread Split:</b> This post has been moved %s"), $post_link), "</td>\n";
        echo "  </tr>\n";
        echo "</table>\n";
        echo "</div>\n";
        echo $in_list ? "<br />\n" : '';
        return;
    }
    echo "<div align=\"center\">\n";
    echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
    echo "  <tr>\n";
    if ($in_list && !$is_preview) {
        message_display_navigation($tid, $message['PID'], $first_msg, $msg_count, $posts_per_page);
    }
    echo "    <td align=\"center\">\n";
    echo "      <table width=\"100%\" class=\"box\" cellpadding=\"0\">\n";
    echo "        <tr>\n";
    echo "          <td align=\"left\">\n";
    echo "            <table class=\"posthead\" width=\"100%\">\n";
    echo "              <tr>\n";
    echo "                <td width=\"1%\" align=\"right\" style=\"white-space: nowrap\"><span class=\"posttofromlabel\">&nbsp;", gettext("From"), ":&nbsp;</span></td>\n";
    echo "                <td style=\"white-space: nowrap\" width=\"98%\" align=\"left\"><span class=\"posttofrom\">";
    if ($message['FROM_UID'] > -1) {
        echo "<a href=\"user_profile.php?webtag={$webtag}&amp;uid={$message['FROM_UID']}\" target=\"_blank\" class=\"popup 650x500\">";
        echo word_filter_add_ob_tags(format_user_name($message['FLOGON'], $message['FNICK']), true), "</a></span>";
    } else {
        echo word_filter_add_ob_tags(format_user_name($message['FLOGON'], $message['FNICK']), true), "</span>";
    }
    if (session::get_value('SHOW_AVATARS') == 'Y') {
        if (isset($message['AVATAR_URL']) && strlen($message['AVATAR_URL']) > 0) {
            echo "&nbsp;<img src=\"{$message['AVATAR_URL']}\" alt=\"\" title=\"", word_filter_add_ob_tags(format_user_name($message['FLOGON'], $message['FNICK']), true), "\" border=\"0\" width=\"16\" height=\"16\" />";
        } else {
            if (isset($message['AVATAR_AID']) && is_md5($message['AVATAR_AID'])) {
                $attachment = attachments_get_by_hash($message['AVATAR_AID']);
                if ($profile_picture_href = attachments_make_link($attachment, false, false, false, false)) {
                    echo "&nbsp;<img src=\"{$profile_picture_href}&amp;avatar_picture\" alt=\"\" title=\"", word_filter_add_ob_tags(format_user_name($message['FLOGON'], $message['FNICK']), true), "\" border=\"0\" width=\"16\" height=\"16\" />\n";
                }
            }
        }
    }
    $temp_ignore = false;
    // If the user posting a poll is ignored, remove ignored status for this message only so the poll can be seen
    if ($is_poll && isset($message['PID']) && $message['PID'] == 1 && $message['FROM_RELATIONSHIP'] & USER_IGNORED) {
        $message['FROM_RELATIONSHIP'] -= USER_IGNORED;
        $temp_ignore = true;
    }
    if ($message['FROM_RELATIONSHIP'] & USER_FRIEND) {
        echo "&nbsp;<img src=\"", html_style_image('friend.png'), "\" alt=\"", gettext("Friend"), "\" title=\"", gettext("Friend"), "\" />";
    } else {
        if ($message['FROM_RELATIONSHIP'] & USER_IGNORED || $temp_ignore) {
            echo "&nbsp;<img src=\"", html_style_image('enemy.png'), "\" alt=\"", gettext("Ignored user"), "\" title=\"", gettext("Ignored user"), "\" />";
        }
    }
    echo "</td>\n";
    echo "                <td width=\"1%\" align=\"right\" style=\"white-space: nowrap\"><span class=\"postinfo\">";
    if ($message['FROM_RELATIONSHIP'] & USER_IGNORED && $limit_text && $uid != 0) {
        echo "<b>", gettext("Ignored message"), "</b>";
    } else {
        if ($in_list) {
            if ($from_user_permissions & USER_PERM_WORMED) {
                echo "<b>", gettext("Wormed user"), "</b> ";
            }
            if ($message['FROM_RELATIONSHIP'] & USER_IGNORED_SIG) {
                echo "<b>", gettext("Ignored signature"), "</b> ";
            }
            if (forum_get_setting('require_post_approval', 'Y') && isset($message['APPROVED']) && $message['APPROVED'] == 0) {
                echo "<b>", gettext("Approval Required"), "</b> ";
            }
            echo format_time($message['CREATED']);
        }
    }
    echo "&nbsp;</span></td>\n";
    echo "              </tr>\n";
    echo "              <tr>\n";
    echo "                <td width=\"1%\" align=\"right\" style=\"white-space: nowrap\"><span class=\"posttofromlabel\">&nbsp;", gettext("To"), ":&nbsp;</span></td>\n";
    echo "                <td style=\"white-space: nowrap\" width=\"98%\" align=\"left\"><span class=\"posttofrom\">";
    if ($message['TLOGON'] != gettext("ALL") && $message['TO_UID'] != 0) {
        echo "<a href=\"user_profile.php?webtag={$webtag}&amp;uid={$message['TO_UID']}\" target=\"_blank\" class=\"popup 650x500\">";
        echo word_filter_add_ob_tags(format_user_name($message['TLOGON'], $message['TNICK']), true), "</a></span>";
        if ($message['TO_RELATIONSHIP'] & USER_FRIEND) {
            echo "&nbsp;<img src=\"", html_style_image('friend.png'), "\" alt=\"", gettext("Friend"), "\" title=\"", gettext("Friend"), "\" />";
        } else {
            if ($message['TO_RELATIONSHIP'] & USER_IGNORED) {
                echo "&nbsp;<img src=\"", html_style_image('enemy.png'), "\" alt=\"", gettext("Ignored user"), "\" title=\"", gettext("Ignored user"), "\" />";
            }
        }
        if (isset($message['VIEWED']) && $message['VIEWED'] > 0) {
            echo "&nbsp;<span class=\"smalltext\"><img src=\"", html_style_image('post_read.png'), "\" alt=\"\" title=\"", sprintf(gettext("Read: %s"), format_time($message['VIEWED'])), "\" /></span>";
        } else {
            if ($is_preview == false) {
                echo "&nbsp;<span class=\"smalltext\"><img src=\"", html_style_image('post_unread.png'), "\" alt=\"\" title=\"", gettext("Unread Message"), "\" /></span>";
            }
        }
    } else {
        echo "", gettext("ALL"), "</span>";
    }
    echo "</td>\n";
    echo "                <td align=\"right\" style=\"white-space: nowrap\"><span class=\"postinfo\">";
    if ($message['FROM_RELATIONSHIP'] & USER_IGNORED && $limit_text && $in_list && $uid != 0) {
        echo "<a href=\"user_rel.php?webtag={$webtag}&amp;uid={$message['FROM_UID']}&amp;msg={$tid}.{$message['PID']}\" target=\"_self\">", gettext("Stop ignoring this user"), "</a>&nbsp;&nbsp;&nbsp;";
        echo "<a href=\"display.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" target=\"_self\">", gettext("View Message"), "</a>";
    } else {
        if ($in_list && $msg_count > 0) {
            if ($is_poll) {
                echo "<a href=\"poll_results.php?webtag={$webtag}&amp;tid={$tid}\" target=\"_blank\" class=\"popup 800x600\"><img src=\"", html_style_image('poll.png'), "\" border=\"0\" alt=\"", gettext("This is a poll. Click to view results."), "\" title=\"", gettext("This is a poll. Click to view results."), "\" /></a> ", gettext("Poll"), " ";
            }
            echo sprintf(gettext("%s of %s"), $message['PID'], $msg_count);
        }
    }
    echo "&nbsp;</span></td>\n";
    echo "              </tr>\n";
    echo "            </table>\n";
    echo "          </td>\n";
    echo "        </tr>\n";
    if (!($message['FROM_RELATIONSHIP'] & USER_IGNORED) || !$limit_text) {
        echo "        <tr>\n";
        echo "          <td align=\"left\">\n";
        echo "            <table width=\"100%\">\n";
        echo "              <tr>\n";
        echo "                <td colspan=\"3\" align=\"right\"><span class=\"postnumber\">";
        if ($in_list && $msg_count > 0) {
            $title = $message['PID'] == 1 ? "" . gettext("Permanent link to this thread") . " ({$tid}.1)" : "" . gettext("Link to this post");
            if ($is_preview) {
                echo "<a href=\"messages.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" target=\"_blank\" title=\"{$title}\">{$tid}.{$message['PID']}</a>";
            } else {
                echo "<a href=\"index.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" target=\"", html_get_top_frame_name(), "\" title=\"{$title}\">{$tid}.{$message['PID']}</a>";
            }
            if ($message['REPLY_TO_PID'] > 0) {
                $title = "" . gettext("Link to post") . " #{$message['REPLY_TO_PID']}";
                echo " ", gettext("In reply to"), " ";
                if (intval($message['REPLY_TO_PID']) >= intval($first_msg)) {
                    echo "<a href=\"#a{$tid}_{$message['REPLY_TO_PID']}\" target=\"_self\" title=\"{$title}\">";
                    echo "{$tid}.{$message['REPLY_TO_PID']}</a>";
                } else {
                    if ($is_preview) {
                        echo "<a href=\"messages.php?webtag={$webtag}&amp;msg={$tid}.{$message['REPLY_TO_PID']}\" target=\"_blank\" title=\"{$title}\">";
                        echo "{$tid}.{$message['REPLY_TO_PID']}</a>";
                    } else {
                        echo "<a href=\"messages.php?webtag={$webtag}&amp;msg={$tid}.{$message['REPLY_TO_PID']}\" target=\"_self\" title=\"{$title}\">";
                        echo "{$tid}.{$message['REPLY_TO_PID']}</a>";
                    }
                }
            }
        }
        echo "&nbsp;</span></td>\n";
        echo "              </tr>\n";
        echo "              <tr>\n";
        echo "                <td class=\"postbody postcontent\" align=\"left\">{$message['CONTENT']}</td>\n";
        echo "              </tr>\n";
        if (isset($message['EDITED']) && $message['EDITED'] > 0) {
            if ($post_edit_grace_period == 0 || $message['EDITED'] - $message['CREATED'] > $post_edit_grace_period * MINUTE_IN_SECONDS) {
                if ($edit_user = user_get_logon($message['EDITED_BY'])) {
                    echo "              <tr>\n";
                    echo "                <td class=\"postbody\" align=\"left\"><p class=\"edit_text\">", sprintf(gettext("EDITED: %s by %s"), format_time($message['EDITED']), $edit_user), "</p></td>\n";
                    echo "              </tr>\n";
                }
            }
        }
        if (forum_get_setting('require_post_approval', 'Y') && isset($message['APPROVED']) && $message['APPROVED'] > 0 && $perm_is_moderator) {
            if (isset($message['APPROVED_BY']) && $message['APPROVED_BY'] > 0 && $message['APPROVED_BY'] != $message['FROM_UID']) {
                if ($approved_user = user_get_logon($message['APPROVED_BY'])) {
                    echo "              <tr>\n";
                    echo "                <td class=\"postbody\" align=\"left\"><p class=\"approved_text\">", sprintf(gettext("APPROVED: %s by %s"), format_time($message['APPROVED']), $approved_user), "</p></td>\n";
                    echo "              </tr>\n";
                }
            }
        }
        if ($tid != 0 && isset($message['PID']) || isset($message['AID'])) {
            $aid = isset($message['AID']) ? $message['AID'] : attachments_get_id($tid, $message['PID']);
            $attachments_array = array();
            $image_attachments_array = array();
            if (attachments_get($message['FROM_UID'], $aid, $attachments_array, $image_attachments_array)) {
                echo "              <tr>\n";
                echo "                <td class=\"postbody\" align=\"left\">\n";
                if (is_array($attachments_array) && sizeof($attachments_array) > 0) {
                    echo "                  <p><b>", gettext("Attachments"), ":</b><br />\n";
                    foreach ($attachments_array as $attachment) {
                        echo "                  ", attachments_make_link($attachment), "<br />\n";
                    }
                    echo "                  </p>\n";
                }
                if (is_array($image_attachments_array) && sizeof($image_attachments_array) > 0) {
                    echo "                  <p><b>", gettext("Image Attachments"), ":</b><br />\n";
                    foreach ($image_attachments_array as $key => $attachment) {
                        echo "                  ", attachments_make_link($attachment), "\n";
                    }
                    echo "                  </p>\n";
                }
                echo "                </td>\n";
                echo "              </tr>\n";
            }
        }
        echo "            </table>\n";
        if (!$is_preview) {
            echo "            <table width=\"100%\" class=\"postresponse\" cellspacing=\"1\" cellpadding=\"0\">\n";
            echo "              <tr>\n";
            if (isset($message['ANON_LOGON']) && $message['ANON_LOGON'] > USER_ANON_DISABLED || !isset($message['USER_ACTIVE']) || is_null($message['USER_ACTIVE'])) {
                echo "                <td width=\"25%\" align=\"left\">";
                echo "                  <img src=\"", html_style_image('status_offline.png'), "\" alt=\"\" title=\"", gettext("Inactive / Offline"), "\" />";
                echo "                </td>\n";
            } else {
                echo "                <td width=\"25%\" align=\"left\">";
                echo "                  <img src=\"", html_style_image('status_online.png'), "\" alt=\"\" title=\"", gettext("Online"), "\" />";
                echo "                </td>\n";
            }
            echo "                <td width=\"50%\" style=\"white-space: nowrap\">";
            if ($msg_count > 0) {
                if (!$closed && session::check_perm(USER_PERM_POST_CREATE, $folder_fid) || $perm_is_moderator) {
                    if ($quick_reply == 'Y') {
                        echo "<img src=\"", html_style_image('quickreply.png'), "\" border=\"0\" alt=\"", gettext("Quick Reply"), "\" title=\"", gettext("Quick Reply"), "\" />\n";
                        echo "<a href=\"Javascript:void(0)\" rel=\"{$tid}.{$message['PID']}\" target=\"_self\" class=\"quick_reply_link\">", gettext("Quick Reply"), "</a>\n";
                    } else {
                        echo "<img src=\"", html_style_image('post.png'), "\" border=\"0\" alt=\"", gettext("Reply"), "\" title=\"", gettext("Reply"), "\" />";
                        echo "&nbsp;<a href=\"post.php?webtag={$webtag}&amp;replyto={$tid}.{$message['PID']}\" target=\"_parent\" id=\"reply_{$message['PID']}\">", gettext("Reply"), "</a>";
                    }
                    echo "&nbsp;&nbsp;<img src=\"", html_style_image('quote_disabled.png'), "\" border=\"0\" alt=\"", gettext("Quote"), "\" title=\"", gettext("Quote"), "\" id=\"quote_img_{$message['PID']}\" />";
                    echo "&nbsp;<a href=\"post.php?webtag={$webtag}&amp;replyto={$tid}.{$message['PID']}&amp;quote_list={$message['PID']}\" target=\"_parent\" title=\"", gettext("Quote"), "\" id=\"quote_{$message['PID']}\" rel=\"{$message['PID']}\">", gettext("Quote"), "</a>";
                    if (!session::check_perm(USER_PERM_PILLORIED, 0) && ($uid != $message['FROM_UID'] && $from_user_permissions & USER_PERM_PILLORIED || $uid == $message['FROM_UID']) && session::check_perm(USER_PERM_POST_EDIT, $folder_fid) && ($post_edit_time == 0 || time() - $message['CREATED'] < $post_edit_time * HOUR_IN_SECONDS) && forum_get_setting('allow_post_editing', 'Y') || $perm_is_moderator) {
                        if ($is_poll && $message['PID'] == 1) {
                            if (!poll_is_closed($tid) || $perm_is_moderator) {
                                echo "&nbsp;&nbsp;<img src=\"", html_style_image('edit.png'), "\" border=\"0\" alt=\"", gettext("Edit Poll"), "\" title=\"", gettext("Edit Poll"), "\" />";
                                echo "&nbsp;<a href=\"edit_poll.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" target=\"_parent\">", gettext("Edit Poll"), "</a>\n";
                            }
                        } else {
                            echo "&nbsp;&nbsp;<img src=\"", html_style_image('edit.png'), "\" border=\"0\" alt=\"", gettext("Edit"), "\" title=\"", gettext("Edit"), "\" />";
                            echo "&nbsp;<a href=\"edit.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" target=\"_parent\">", gettext("Edit"), "</a>";
                        }
                    }
                }
            } else {
                echo "&nbsp;";
            }
            echo "</td>\n";
            echo "                <td width=\"25%\" align=\"right\" style=\"white-space: nowrap\">\n";
            echo "                  <span class=\"post_options\" id=\"post_options_{$tid}.{$message['PID']}\"></span>\n";
            echo "                </td>\n";
            echo "              </tr>";
            echo "            </table>\n";
        } else {
            echo "            <table width=\"100%\" class=\"postresponse\" cellspacing=\"1\" cellpadding=\"0\">\n";
            echo "              <tr>\n";
            echo "                <td>&nbsp;</td>\n";
            echo "              </tr>\n";
            echo "            </table>\n";
        }
    }
    echo "            </td>\n";
    echo "          </tr>\n";
    echo "        </table>\n";
    echo "      </td>\n";
    if ($in_list && !$is_preview) {
        message_display_navigation($tid, $message['PID'], $first_msg, $msg_count, $posts_per_page);
    }
    echo "    </tr>\n";
    echo "  </table>\n";
    if ($in_list && isset($message['PID'])) {
        echo "  <div id=\"quick_reply_{$message['PID']}\"></div>\n";
    }
    echo "</div>\n";
    echo $in_list ? "<br />\n" : '';
}
示例#3
0
function light_message_display($tid, $message, $msg_count, $first_msg, $folder_fid, $in_list = true, $closed = false, $limit_text = true, $is_poll = false, $is_preview = false)
{
    $perm_is_moderator = session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_fid);
    $post_edit_time = forum_get_setting('post_edit_time', null, 0);
    $post_edit_grace_period = forum_get_setting('post_edit_grace_period', null, 0);
    $webtag = get_webtag();
    $attachments_array = array();
    $image_attachments_array = array();
    if (($uid = session::get_value('UID')) === false) {
        return;
    }
    if ((!isset($message['CONTENT']) || $message['CONTENT'] == "") && !$is_preview) {
        light_message_display_deleted($tid, isset($message['PID']) ? $message['PID'] : 0);
        return;
    }
    $from_user_permissions = perm_get_user_permissions($message['FROM_UID']);
    if ($uid != $message['FROM_UID']) {
        if ($from_user_permissions & USER_PERM_WORMED && !$perm_is_moderator) {
            light_message_display_deleted($tid, $message['PID']);
            return;
        }
    }
    if (!isset($message['FROM_RELATIONSHIP'])) {
        $message['FROM_RELATIONSHIP'] = 0;
    }
    if (!isset($message['TO_RELATIONSHIP'])) {
        $message['TO_RELATIONSHIP'] = 0;
    }
    if ($message['TO_RELATIONSHIP'] & USER_IGNORED_COMPLETELY || $message['FROM_RELATIONSHIP'] & USER_IGNORED_COMPLETELY) {
        light_message_display_deleted($tid, $message['PID']);
        return;
    }
    if (forum_get_setting('require_post_approval', 'Y') && $message['FROM_UID'] != $uid) {
        if (isset($message['APPROVED']) && $message['APPROVED'] == 0 && !$perm_is_moderator) {
            light_message_display_approval_req($tid, $message['PID']);
            return;
        }
    }
    // OUTPUT MESSAGE ----------------------------------------------------------
    if (!$is_preview && $message['MOVED_TID'] > 0 && $message['MOVED_PID'] > 0) {
        $post_link = "<a href=\"messages.php?webtag={$webtag}&amp;msg=%s.%s\" target=\"_self\">%s</a>";
        $post_link = sprintf($post_link, $message['MOVED_TID'], $message['MOVED_PID'], gettext("here"));
        light_html_display_warning_msg(gettext("<b>Thread Split:</b> This post has been moved %s"), $post_link);
        return;
    }
    if ($in_list) {
        echo "<a name=\"a{$tid}_{$message['PID']}\"></a>";
    }
    echo "<div class=\"message\">\n";
    if (session::get_value('IMAGES_TO_LINKS') == 'Y') {
        $message['CONTENT'] = preg_replace('/<a([^>]*)href="([^"]*)"([^\\>]*)><img[^>]*src="([^"]*)"[^>]*><\\/a>/iu', '[img: <a\\1href="\\2"\\3>\\4</a>]', $message['CONTENT']);
        $message['CONTENT'] = preg_replace('/<img[^>]*src="([^"]*)"[^>]*>/iu', '[img: <a href="\\1">\\1</a>]', $message['CONTENT']);
        $message['CONTENT'] = preg_replace('/<embed[^>]*src="([^"]*)"[^>]*>/iu', '[object: <a href="\\1">\\1</a>]', $message['CONTENT']);
    }
    if (mb_strlen(strip_tags($message['CONTENT'])) > intval(forum_get_setting('maximum_post_length', null, 6226)) && $limit_text) {
        $cut_msg = mb_substr($message['CONTENT'], 0, intval(forum_get_setting('maximum_post_length', null, 6226)));
        $cut_msg = preg_replace("/(<[^>]+)?\$/Du", "", $cut_msg);
        $message['CONTENT'] = fix_html($cut_msg);
        $message['CONTENT'] .= "&hellip;[" . gettext("Message Truncated") . "]\n";
        $message['CONTENT'] .= "<a href=\"ldisplay.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" class=\"message_full_view\">" . gettext("View full message") . ".</a>";
    }
    echo "<div class=\"message_header\">\n";
    echo "<div class=\"message_from\">\n";
    echo "", gettext("From"), ": ", word_filter_add_ob_tags(format_user_name($message['FLOGON'], $message['FNICK']), true);
    if ($message['FROM_RELATIONSHIP'] & USER_FRIEND) {
        echo "<span class=\"user_friend\" title=\"", gettext("Friend"), "\">[F]</span>";
    } else {
        if ($message['FROM_RELATIONSHIP'] & USER_IGNORED) {
            echo "<span class=\"user_enemy\" title=\"", gettext("Ignored user"), "\">[E]</span>";
        }
    }
    // If the user posting a poll is ignored, remove ignored status for this message only so the poll can be seen
    if ($is_poll && $message['PID'] == 1 && $message['FROM_RELATIONSHIP'] & USER_IGNORED) {
        $message['FROM_RELATIONSHIP'] -= USER_IGNORED;
    }
    if ($message['FROM_RELATIONSHIP'] & USER_IGNORED && $limit_text) {
        echo gettext("Ignored message");
    } else {
        if ($in_list) {
            if ($from_user_permissions & USER_PERM_WORMED) {
                echo gettext("Wormed user");
            }
            echo "<span class=\"message_time\">", format_time($message['CREATED']), "</span>\n";
        }
    }
    echo "<div class=\"clearer\"></div>\n";
    echo "</div>";
    echo "<div class=\"message_to\">\n";
    if ($message['TLOGON'] != gettext("ALL") && $message['TO_UID'] != 0) {
        echo "", gettext("To"), ": ", word_filter_add_ob_tags(format_user_name($message['TLOGON'], $message['TNICK']), true);
        if ($message['TO_RELATIONSHIP'] & USER_FRIEND) {
            echo "<span class=\"user_friend\" title=\"", gettext("Friend"), "\">[F]</span>";
        } else {
            if ($message['TO_RELATIONSHIP'] & USER_IGNORED) {
                echo "<span class=\"user_enemy\" title=\"", gettext("Ignored user"), "\">[E]</span>";
            }
        }
        if (!$is_preview) {
            if (isset($message['VIEWED']) && $message['VIEWED'] > 0) {
                echo "<span class=\"message_read\">", format_time($message['VIEWED']), "</span>";
            } else {
                echo "<span class=\"message_unread\" title=\"", gettext("Unread"), "\"></span>";
            }
        }
    } else {
        echo "", gettext("To"), ": ", gettext("ALL"), "";
    }
    if ($in_list && $msg_count > 0) {
        echo "<span class=\"message_count\">", sprintf(gettext("%s of %s"), $message['PID'], $msg_count), "</span>";
    }
    echo "<div class=\"clearer\"></div>\n";
    echo "</div>\n";
    echo "</div>\n";
    echo "<div class=\"message_links\">\n";
    if ($in_list && $msg_count > 0) {
        echo "<a href=\"lmessages.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\">{$tid}.{$message['PID']}</a>";
        if ($message['REPLY_TO_PID'] > 0) {
            echo " ", gettext("In reply to"), " ";
            if (intval($message['REPLY_TO_PID']) >= intval($first_msg)) {
                echo "<a href=\"#a{$tid}_{$message['REPLY_TO_PID']}\" target=\"_self\">{$tid}.{$message['REPLY_TO_PID']}</a>";
            } else {
                echo "<a href=\"lmessages.php?webtag={$webtag}&amp;msg={$tid}.{$message['REPLY_TO_PID']}\">{$tid}.{$message['REPLY_TO_PID']}</a>";
            }
        }
    }
    echo "</div>\n";
    if (!$is_poll || $is_poll && isset($message['PID']) && $message['PID'] > 1) {
        $message['CONTENT'] = message_apply_formatting($message['CONTENT'], true);
    }
    $message['CONTENT'] = light_spoiler_enable($message['CONTENT']);
    if ($is_poll !== true) {
        $message['CONTENT'] = word_filter_add_ob_tags($message['CONTENT']);
    }
    echo "<div class=\"message_body\">\n";
    echo $message['CONTENT'];
    if (isset($message['EDITED']) && $message['EDITED'] > 0) {
        if ($post_edit_grace_period == 0 || $message['EDITED'] - $message['CREATED'] > $post_edit_grace_period * MINUTE_IN_SECONDS) {
            if ($edit_user = user_get_logon($message['EDITED_BY'])) {
                echo "<div class=\"edit_text\">", sprintf(gettext("EDITED: %s by %s"), format_time($message['EDITED']), $edit_user), "</div>\n";
            }
        }
    }
    echo "</div>\n";
    if ($tid != 0 && isset($message['PID']) || isset($message['AID'])) {
        $aid = isset($message['AID']) ? $message['AID'] : attachments_get_id($tid, $message['PID']);
        if (attachments_get($message['FROM_UID'], $aid, $attachments_array, $image_attachments_array)) {
            if (sizeof($attachments_array) > 0) {
                echo "<div class=\"message_attachments\">\n";
                echo "  <span>", gettext("Attachments"), ":</span>\n";
                echo "  <ul>\n";
                foreach ($attachments_array as $attachment) {
                    if ($attachment_link = light_attachments_make_link($attachment)) {
                        echo "<li>", $attachment_link, "</li>\n";
                    }
                }
                echo "  </ul>\n";
                echo "</div>\n";
            }
            if (sizeof($image_attachments_array) > 0) {
                echo "<div class=\"message_attachments\">\n";
                echo "  <span>", gettext("Image Attachments"), ":</span>\n";
                echo "  <ul>\n";
                foreach ($image_attachments_array as $attachment) {
                    if ($attachment_link = light_attachments_make_link($attachment)) {
                        echo "<li>", $attachment_link, "</li>\n";
                    }
                }
                echo "  </ul>\n";
                echo "</div>\n";
            }
        }
    }
    if (!$is_preview && $msg_count > 0) {
        $links_array = array();
        if (!$closed && session::check_perm(USER_PERM_POST_CREATE, $folder_fid)) {
            $links_array[] = "<a href=\"lpost.php?webtag={$webtag}&amp;replyto={$tid}.{$message['PID']}\" class=\"reply\">" . gettext("Reply") . "</a>";
        }
        if ($uid == $message['FROM_UID'] && session::check_perm(USER_PERM_POST_DELETE, $folder_fid) && !session::check_perm(USER_PERM_PILLORIED, 0) || $perm_is_moderator) {
            $links_array[] = "<a href=\"ldelete.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" class=\"delete\">" . gettext("Delete") . "</a>";
        }
        if (!session::check_perm(USER_PERM_PILLORIED, 0) && ($uid != $message['FROM_UID'] && $from_user_permissions & USER_PERM_PILLORIED || $uid == $message['FROM_UID']) && session::check_perm(USER_PERM_POST_EDIT, $folder_fid) && ($post_edit_time == 0 || time() - $message['CREATED'] < $post_edit_time * HOUR_IN_SECONDS) && forum_get_setting('allow_post_editing', 'Y') || $perm_is_moderator) {
            if (!$is_poll || $is_poll && isset($message['PID']) && $message['PID'] > 1) {
                $links_array[] = "<a href=\"ledit.php?webtag={$webtag}&amp;msg={$tid}.{$message['PID']}\" class=\"edit\">" . gettext("Edit") . "</a>";
            }
        }
        if (sizeof($links_array) > 0) {
            echo "<div class=\"message_footer_links\">", implode('&nbsp;&nbsp;', $links_array), "</div>\n";
        }
    } else {
        echo "<div class=\"message_footer_links\"></div>\n";
    }
    echo "</div>";
}