コード例 #1
0
ファイル: light.inc.php プロジェクト: DeannaG65/BeehiveForum
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();
    forum_check_webtag_available($webtag);
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        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 ($_SESSION['UID'] != $message['FROM_UID']) {
        if ($from_user_permissions & USER_PERM_WORMED && !$perm_is_moderator) {
            light_message_display_deleted($tid, $message['PID']);
            return;
        }
    }
    if (!$is_preview && !isset($message['APPROVED'])) {
        light_message_display_approval_req($tid, $message['PID']);
        return;
    }
    if (isset($message['RELATIONSHIP']) && $message['RELATIONSHIP'] & USER_IGNORED_COMPLETELY) {
        light_message_display_deleted($tid, $message['PID']);
        return;
    }
    if (isset($message['RECIPIENTS']) && sizeof($message['RECIPIENTS']) == 1) {
        $recipient = array_slice(array_values($message['RECIPIENTS']), 0, 1);
        if (isset($recipient['RELATIONSHIP']) && $recipient['RELATIONSHIP'] & USER_IGNORED_COMPLETELY) {
            light_message_display_deleted($tid, $message['PID']);
            return;
        }
    }
    if (!$is_preview && isset($message['MOVED_TID']) && isset($message['MOVED_PID'])) {
        light_message_display_moved($message);
        return;
    }
    if (isset($_SESSION['IMAGES_TO_LINKS']) && $_SESSION['IMAGES_TO_LINKS'] == 'Y') {
        $message['CONTENT'] = message_images_to_links($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']}&amp;return_msg={$tid}.{$first_msg}\" class=\"message_full_view\">" . gettext("View full message") . ".</a>";
    }
    if ($in_list && isset($message['PID'])) {
        echo "<a name=\"a{$tid}_{$message['PID']}\"></a>";
    }
    if ($in_list && isset($message['PID'])) {
        echo "<div class=\"message\" id=\"message_{$tid}_{$message['PID']}\">\n";
    } else {
        echo "<div class=\"message\">\n";
    }
    echo "<div class=\"message_header\">\n";
    echo "<div class=\"message_from\">\n";
    echo gettext("From"), ": ", word_filter_add_ob_tags(format_user_name($message['FROM_LOGON'], $message['FROM_NICKNAME']), true);
    if (isset($message['RELATIONSHIP']) && $message['RELATIONSHIP'] & USER_FRIEND) {
        echo html_style_image('friend', gettext("Friend"));
    } else {
        if (isset($message['RELATIONSHIP']) && $message['RELATIONSHIP'] & USER_IGNORED) {
            echo html_style_image('enemy', gettext("Ignored user"));
        }
    }
    // 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 && isset($message['RELATIONSHIP']) && $message['RELATIONSHIP'] & USER_IGNORED) {
        $message['RELATIONSHIP'] -= USER_IGNORED;
    }
    if (isset($message['RELATIONSHIP']) && $message['RELATIONSHIP'] & USER_IGNORED && $limit_text && $_SESSION['UID'] > 0) {
        echo "<span class=\"message_ignored\">", gettext("Ignored message"), "</span>\n";
    } else {
        if ($in_list) {
            if ($from_user_permissions & USER_PERM_WORMED) {
                echo gettext("Wormed user");
            }
            echo "<span class=\"message_time\">", format_date_time($message['CREATED']), "</span>\n";
        }
    }
    echo "<div class=\"clearer\"></div>\n";
    echo "</div>";
    echo "<div class=\"message_to\">", gettext("To"), ": ";
    if (isset($message['RECIPIENTS']) && sizeof($message['RECIPIENTS']) > 0) {
        foreach ($message['RECIPIENTS'] as $recipient) {
            if (isset($recipient['RELATIONSHIP']) && $recipient['RELATIONSHIP'] & USER_IGNORED_COMPLETELY) {
                continue;
            }
            echo word_filter_add_ob_tags(format_user_name($recipient['LOGON'], $recipient['NICKNAME']), true), "\n";
            if (isset($recipient['VIEWED']) && $recipient['VIEWED'] > 0) {
                echo "<span>", html_style_image('post_read', sprintf(gettext("Read: %s"), format_date_time($recipient['VIEWED']))), "</span>\n";
            } else {
                if ($is_preview == false) {
                    echo "<span>", html_style_image('post_unread', gettext("Unread Message")), "</span>\n";
                }
            }
        }
    } else {
        echo 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";
    if (!$is_poll || isset($message['PID']) && $message['PID'] > 1) {
        $message['CONTENT'] = message_apply_formatting($message['CONTENT'], true);
    }
    if ($limit_text && mb_strlen(strip_tags($message['CONTENT'])) > intval(forum_get_setting('maximum_post_length', null, 6226))) {
        $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']}&amp;return_msg={$tid}.{$first_msg}\" target=\"_self\">" . gettext("View full message") . "</a>";
    }
    $message['CONTENT'] = light_spoiler_enable($message['CONTENT']);
    if (!$is_poll || $is_poll && isset($message['PID']) && $message['PID'] > 1) {
        $message['CONTENT'] = word_filter_add_ob_tags($message['CONTENT'], false);
    }
    if ($is_preview || !isset($message['RELATIONSHIP']) || !($message['RELATIONSHIP'] & USER_IGNORED)) {
        if ($in_list && $msg_count > 0) {
            echo "<div class=\"message_links\">\n";
            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";
        } else {
            echo "<div class=\"message_links\">&nbsp;</div>\n";
        }
        echo "<div class=\"message_body\">\n";
        echo $message['CONTENT'];
        if (!$is_preview && isset($message['EDITED'])) {
            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'])) !== false) {
                    echo "<div class=\"edit_text\">", sprintf(gettext("EDITED: %s by %s"), format_date_time($message['EDITED']), $edit_user), "</div>\n";
                }
            }
        }
        if (!$is_preview && isset($message['APPROVED']) && isset($message['APPROVED_BY'])) {
            if ($message['APPROVED_BY'] != $message['FROM_UID'] && ($approved_user = user_get_logon($message['APPROVED_BY'])) !== false) {
                echo "<div class=\"edit_text\">", sprintf(gettext("APPROVED: %s by %s"), format_date_time($message['APPROVED']), $approved_user), "</div>\n";
            }
        }
        echo "</div>\n";
        if (isset($message['ATTACHMENTS']) && sizeof($message['ATTACHMENTS']) > 0) {
            if (($attachments_array = attachments_get($message['FROM_UID'], $message['ATTACHMENTS'])) !== false) {
                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)) !== false) {
                        echo "<li>", html_style_image('attach'), $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;reply_to={$tid}.{$message['PID']}&return_msg={$tid}.{$first_msg}\" class=\"reply\">" . html_style_image('post') . gettext("Reply") . "</a>";
            }
            if ($_SESSION['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']}&amp;return_msg={$tid}.{$first_msg}\" class=\"delete\">" . html_style_image('delete') . gettext("Delete") . "</a>";
            }
            if (!session::check_perm(USER_PERM_PILLORIED, 0) && ($_SESSION['UID'] != $message['FROM_UID'] && $from_user_permissions & USER_PERM_PILLORIED || $_SESSION['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']}&amp;return_msg={$tid}.{$first_msg}\" class=\"edit\">" . html_style_image('edit') . gettext("Edit") . "</a>";
                }
            }
            if (sizeof($links_array) > 0) {
                echo "<div class=\"message_footer\">\n";
                echo "  <div class=\"message_footer_links\">", implode('&nbsp;&nbsp;', $links_array), "</div>\n";
                echo "  <div class=\"message_vote_form\" data-msg=\"{$tid}.{$message['PID']}\">\n";
                echo "    ", light_message_get_vote_form_html($message), "\n";
                echo "  </div>\n";
                echo "</div>\n";
            }
        } else {
            echo "<div class=\"message_footer_links\"></div>\n";
        }
    }
    echo "</div>";
}
コード例 #2
0
ファイル: light.inc.php プロジェクト: richstokoe/BeehiveForum
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>";
}