Example #1
0
function message_get_meta_content($msg, &$meta_keywords, &$meta_description)
{
    if (!validate_msg($msg)) {
        return;
    }
    list($tid, $pid) = explode('.', $msg);
    if (($thread_data = thread_get($tid)) && ($message_content = message_get_content($tid, $pid))) {
        $meta_keywords_array = search_extract_keywords(strip_tags(htmlentities_decode_array($message_content)));
        $meta_description = $thread_data['TITLE'];
        $meta_keywords = htmlentities_array(implode(',', $meta_keywords_array['keywords_array']));
    }
}
Example #2
0
require_once BH_INCLUDE_PATH . 'html.inc.php';
require_once BH_INCLUDE_PATH . 'lang.inc.php';
require_once BH_INCLUDE_PATH . 'logon.inc.php';
require_once BH_INCLUDE_PATH . 'messages.inc.php';
require_once BH_INCLUDE_PATH . 'poll.inc.php';
require_once BH_INCLUDE_PATH . 'session.inc.php';
require_once BH_INCLUDE_PATH . 'thread.inc.php';
// User UID for fetching recent message
$uid = session::get_value('UID');
// Check that required variables are set
// default to display most recent discussion for user
if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
    $msg = $_GET['msg'];
    list($tid, $pid) = explode('.', $msg);
} else {
    if (isset($_GET['print_msg']) && validate_msg($_GET['print_msg'])) {
        $msg = $_GET['print_msg'];
        list($tid, $pid) = explode('.', $msg);
    } else {
        html_draw_error(gettext("Invalid Message ID or no Message ID specified."));
    }
}
if (!($thread_data = thread_get($tid, session::check_perm(USER_PERM_ADMIN_TOOLS, 0)))) {
    html_draw_error(gettext("The requested thread could not be found or access was denied."));
}
if (!($folder_data = folder_get($thread_data['FID']))) {
    html_draw_error(gettext("The requested folder could not be found or access was denied."));
}
if (!($message = messages_get($tid, $pid, 1))) {
    html_draw_error(gettext("That post does not exist in this thread!"));
}
Example #3
0
if (session::check_perm(USER_PERM_EMAIL_CONFIRM, 0)) {
    html_email_confirmation_error();
    exit;
}
if (!session::check_perm(USER_PERM_POST_EDIT | USER_PERM_POST_READ, $t_fid)) {
    html_draw_error(gettext("You cannot delete posts in this folder"));
}
if (!($thread_data = thread_get($tid))) {
    html_draw_error(gettext("The requested thread could not be found or access was denied."));
}
if (!thread_is_poll($tid) || $pid != 1) {
    $uri = "discussion.php?webtag={$webtag}";
    if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
        $uri .= "&msg=" . $_GET['msg'];
    } else {
        if (isset($_POST['msg']) && validate_msg($_POST['msg'])) {
            $uri .= "&msg=" . $_POST['msg'];
        }
    }
    header_redirect($uri);
}
if (!($edit_message = messages_get($tid, 1, 1))) {
    html_draw_top(sprintf("title=%s", gettext("Error")));
    html_display_error_msg(gettext("That post does not exist in this thread!"));
    html_draw_bottom();
    exit;
}
$post_edit_time = forum_get_setting('post_edit_time', null, 0);
$uid = session::get_value('UID');
if ((forum_get_setting('allow_post_editing', 'N') || $uid != $edit_message['FROM_UID'] && !(perm_get_user_permissions($edit_message['FROM_UID']) & USER_PERM_PILLORIED) || session::check_perm(USER_PERM_PILLORIED, 0) || $post_edit_time > 0 && time() - $edit_message['CREATED'] >= $post_edit_time * HOUR_IN_SECONDS) && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) {
    html_draw_error(gettext("You are not permitted to edit this message."), 'discussion.php', 'get', array('back' => gettext("Back")), array('msg' => $edit_message));
Example #4
0
// Get folder FIDs and titles
if (!($folder_info = threads_get_folders())) {
    html_draw_error(gettext("There are no folders available."));
}
// Get total number of messages for each folder
$folder_msgs = threads_get_folder_msgs();
// Check that the folder order is a valid array.
if (!is_array($folder_order)) {
    $folder_order = array();
}
// Check the folder display order.
if (session::get_value('THREADS_BY_FOLDER') == 'Y') {
    $folder_order = array_keys($folder_info);
}
// Check for a message to display and re-order the thread list.
if (isset($_REQUEST['msg']) && validate_msg($_REQUEST['msg'])) {
    list($selected_tid) = explode('.', $_REQUEST['msg']);
    if ($thread = thread_get($selected_tid)) {
        if (!isset($thread['RELATIONSHIP'])) {
            $thread['RELATIONSHIP'] = 0;
        }
        // Check the folder display order / user is a guest.
        if (session::get_value('THREADS_BY_FOLDER') != 'Y' || !session::logged_in()) {
            // Remove the folder from the list of folders.
            if (in_array($thread['FID'], $folder_order)) {
                array_splice($folder_order, array_search($thread['FID'], $folder_order), 1);
            }
            // Re-add it at the top of the list.
            array_unshift($folder_order, $thread['FID']);
        }
        // Check $thread_info is an array.
Example #5
0
function light_draw_thread_list($mode = ALL_DISCUSSIONS, $folder = false, $page = 1)
{
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    $error_msg_array = array();
    $available_views = thread_list_available_views();
    $visible_threads_array = array();
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return;
    }
    light_thread_list_draw_top($mode, $folder);
    switch ($mode) {
        case UNREAD_DISCUSSIONS:
            list($thread_info, $folder_order, $thread_count) = threads_get_unread($_SESSION['UID'], $folder, $page);
            break;
        case UNREAD_DISCUSSIONS_TO_ME:
            list($thread_info, $folder_order, $thread_count) = threads_get_unread_to_me($_SESSION['UID'], $folder, $page);
            break;
        case TODAYS_DISCUSSIONS:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_days($_SESSION['UID'], $folder, $page, 1);
            break;
        case UNREAD_TODAY:
            list($thread_info, $folder_order, $thread_count) = threads_get_unread_by_days($_SESSION['UID'], $folder, $page);
            break;
        case TWO_DAYS_BACK:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_days($_SESSION['UID'], $folder, $page, 2);
            break;
        case SEVEN_DAYS_BACK:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_days($_SESSION['UID'], $folder, $page, 7);
            break;
        case HIGH_INTEREST:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_interest($_SESSION['UID'], $folder, $page, THREAD_INTERESTED);
            break;
        case UNREAD_HIGH_INTEREST:
            list($thread_info, $folder_order, $thread_count) = threads_get_unread_by_interest($_SESSION['UID'], $folder, $page, THREAD_INTERESTED);
            break;
        case RECENTLY_SEEN:
            list($thread_info, $folder_order, $thread_count) = threads_get_recently_viewed($_SESSION['UID'], $folder, $page);
            break;
        case IGNORED_THREADS:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_interest($_SESSION['UID'], $folder, $page, THREAD_IGNORED);
            break;
        case BY_IGNORED_USERS:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_relationship($_SESSION['UID'], $folder, $page, USER_IGNORED_COMPLETELY);
            break;
        case SUBSCRIBED_TO:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_interest($_SESSION['UID'], $folder, $page, THREAD_SUBSCRIBED);
            break;
        case STARTED_BY_FRIEND:
            list($thread_info, $folder_order, $thread_count) = threads_get_by_relationship($_SESSION['UID'], $folder, $page, USER_FRIEND);
            break;
        case UNREAD_STARTED_BY_FRIEND:
            list($thread_info, $folder_order, $thread_count) = threads_get_unread_by_relationship($_SESSION['UID'], $folder, $page, USER_FRIEND);
            break;
        case STARTED_BY_ME:
            list($thread_info, $folder_order, $thread_count) = threads_get_started_by_me($_SESSION['UID'], $folder, $page);
            break;
        case POLL_THREADS:
            list($thread_info, $folder_order, $thread_count) = threads_get_polls($_SESSION['UID'], $folder, $page);
            break;
        case STICKY_THREADS:
            list($thread_info, $folder_order, $thread_count) = threads_get_sticky($_SESSION['UID'], $folder, $page);
            break;
        case MOST_UNREAD_POSTS:
            list($thread_info, $folder_order, $thread_count) = threads_get_longest_unread($_SESSION['UID'], $folder, $page);
            break;
        case DELETED_THREADS:
            list($thread_info, $folder_order, $thread_count) = threads_get_deleted($_SESSION['UID'], $folder, $page);
            break;
        default:
            list($thread_info, $folder_order, $thread_count) = threads_get_all($_SESSION['UID'], $folder, $page);
            break;
    }
    // Now, the actual bit that displays the threads...
    // Get folder FIDs and titles
    if (!($folder_info = threads_get_folders())) {
        light_html_display_error_msg(gettext("There are no folders available."));
        return;
    }
    // Get total number of messages for each folder
    $folder_msgs = threads_get_folder_msgs();
    // Check that the folder order is a valid array.
    if (!is_array($folder_order)) {
        $folder_order = array();
    }
    // Check the folder display order.
    if (isset($_SESSION['THREADS_BY_FOLDER']) && $_SESSION['THREADS_BY_FOLDER'] == 'Y') {
        $folder_order = array_keys($folder_info);
    }
    // Check for a message to display and re-order the thread list.
    if (isset($_REQUEST['msg']) && validate_msg($_REQUEST['msg'])) {
        list($selected_tid) = explode('.', $_REQUEST['msg']);
        if (($thread = thread_get($selected_tid)) !== false) {
            if (!isset($thread['RELATIONSHIP'])) {
                $thread['RELATIONSHIP'] = 0;
            }
            // Check the folder display order / user is a guest.
            if (!isset($_SESSION['THREADS_BY_FOLDER']) || $_SESSION['THREADS_BY_FOLDER'] != 'Y' || !session::logged_in()) {
                // Remove the folder from the list of folders.
                if (in_array($thread['FID'], $folder_order)) {
                    array_splice($folder_order, array_search($thread['FID'], $folder_order), 1);
                }
                // Re-add it at the top of the list.
                array_unshift($folder_order, $thread['FID']);
            }
            // Check $thread_info is an array.
            if (!is_array($thread_info)) {
                $thread_info = array();
            }
            // Check to see if the thread is already in the list.
            // If it is remove it, otherwise take the last thread
            // off the list so we always only have 50 threads on display.
            if (isset($thread_info[$selected_tid])) {
                unset($thread_info[$selected_tid]);
            } else {
                $thread_info = array_slice($thread_info, 0, 50, true);
            }
            // Add the requested thread to the top of the list of threads.
            array_unshift($thread_info, $thread);
        }
    }
    // Check for a specified folder and move it to the top of the thread list.
    if (isset($folder) && is_numeric($folder)) {
        if (in_array($folder, $folder_order)) {
            array_splice($folder_order, array_search($folder, $folder_order), 1);
        }
        array_unshift($folder_order, $folder);
    }
    if ($_SESSION['UID'] > 0) {
        // Array to hold our ignored folders in.
        $ignored_folders = array();
        // Loop through the list of folders and check their status.
        // If they're ignored and not already set to be on display
        // they need to be added to $ignored_folders so that they
        // appear at the bottom of the thread list.
        foreach ($folder_info as $fid => $folder_data) {
            if (!in_array($fid, $folder_order) && !in_array($fid, $ignored_folders)) {
                if ($folder_data['INTEREST'] != FOLDER_IGNORED || isset($folder) && $folder == $fid) {
                    array_push($folder_order, $fid);
                } else {
                    array_push($ignored_folders, $fid);
                }
            }
        }
        // Append ignored folders onto the end of the folder list.
        // This will make them appear at the bottom of the thread list.
        $folder_order = array_merge($folder_order, $ignored_folders);
    } else {
        foreach ($folder_info as $fid => $folder_data) {
            if (!in_array($fid, $folder_order)) {
                $folder_order[] = $fid;
            }
        }
    }
    // If no threads are returned, say something to that effect
    if (isset($_REQUEST['mark_read_success'])) {
        light_html_display_success_msg(gettext("Successfully marked selected threads as read"));
    } else {
        if (!is_array($thread_info)) {
            if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) {
                $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&amp;folder={$folder}&amp;mode=0\">%s</a>", gettext("click here"));
                light_html_display_warning_msg(sprintf(gettext("No &quot;%s&quot; in &quot;%s&quot; folder. Please select another folder, or %s for all threads."), $available_views[$mode], $folder_title, $all_discussions_link));
            } else {
                $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&amp;mode=0\">%s</a>", gettext("click here"));
                light_html_display_warning_msg(sprintf(gettext("No &quot;%s&quot; available. Please %s for all threads."), $available_views[$mode], $all_discussions_link));
            }
        } else {
            if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
                light_html_display_error_array($error_msg_array);
            } else {
                if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) {
                    $all_folders_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}\">%s</a>", gettext("click here"));
                    light_html_display_warning_msg(sprintf(gettext("Viewing &quot;%s&quot; in &quot;%s&quot; only. To view threads in all folders %s."), $available_views[$mode], $folder_title, $all_folders_link));
                }
            }
        }
    }
    if ($page > 1 && !is_numeric($folder)) {
        echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n";
    }
    // Unread cut-off
    $thread_unread_cutoff = threads_get_unread_cutoff();
    // Iterate through the information we've just got and display it in the right order
    foreach ($folder_order as $folder_number) {
        if (isset($folder_info[$folder_number]) && is_array($folder_info[$folder_number])) {
            echo "<div class=\"folder\">\n";
            echo "  <h3>", html_style_image('folder'), "<a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder_number}\">", word_filter_add_ob_tags($folder_info[$folder_number]['TITLE'], true), "</a></h3>";
            echo "  <div class=\"folder_inner\">\n";
            if (!session::logged_in() || $folder_info[$folder_number]['INTEREST'] > FOLDER_IGNORED || $mode == UNREAD_DISCUSSIONS_TO_ME || isset($folder) && $folder == $folder_number) {
                if (is_array($thread_info)) {
                    echo "  <div class=\"folder_info\">";
                    if (isset($folder_msgs[$folder_number])) {
                        echo $folder_msgs[$folder_number];
                    } else {
                        echo "0";
                    }
                    echo " ", gettext("threads"), "";
                    if (is_null($folder_info[$folder_number]['STATUS']) || $folder_info[$folder_number]['STATUS'] & USER_PERM_THREAD_CREATE) {
                        if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) {
                            echo "<span><a href=\"lpost.php?webtag={$webtag}&amp;fid={$folder_number}\">", gettext("Post New"), "</a></span>";
                        }
                    }
                    echo "  </div>\n";
                    if ($page > 1 && is_numeric($folder) && $folder_number == $folder) {
                        echo "<div class=\"folder_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder}&amp;page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n";
                    }
                    $folder_list_start = false;
                    $folder_list_end = false;
                    foreach ($thread_info as $thread) {
                        if (!in_array($thread['TID'], $visible_threads_array)) {
                            $visible_threads_array[] = $thread['TID'];
                        }
                        if ($thread['FID'] == $folder_number) {
                            if ($folder_list_start === false) {
                                echo "<ul>\n";
                                $folder_list_start = true;
                            }
                            echo "<li>";
                            if (!session::logged_in() || ($thread['LAST_READ'] == 0 || $thread['LAST_READ'] < $thread['LENGTH']) && $thread['MODIFIED'] > $thread_unread_cutoff) {
                                $new_posts = $thread['LENGTH'] - $thread['LAST_READ'];
                                if ($new_posts == $thread['LENGTH']) {
                                    $number = "[{$thread['LENGTH']}&nbsp;new]";
                                } else {
                                    $number = "[{$new_posts}&nbsp;new&nbsp;of&nbsp;{$thread['LENGTH']}]";
                                }
                                $latest_post = $thread['LAST_READ'] + 1;
                            } else {
                                $number = "[{$thread['LENGTH']}]";
                                $latest_post = 1;
                            }
                            // work out how long ago the thread was posted and format the time to display
                            $thread_time = format_date_time($thread['MODIFIED']);
                            echo "<span class=\"thread_icon\">", html_style_image('bullet'), "</span>";
                            echo "<span class=\"thread_title\">";
                            echo "<a href=\"lmessages.php?webtag={$webtag}&amp;msg={$thread['TID']}.{$latest_post}\" ";
                            echo "title=\"", sprintf(gettext("Thread #%s Started by %s. Viewed %s"), $thread['TID'], word_filter_add_ob_tags(format_user_name($thread['LOGON'], $thread['NICKNAME']), true), $thread['VIEWCOUNT'] == 1 ? gettext("1 time") : sprintf(gettext("%d times"), $thread['VIEWCOUNT'])), "\">";
                            echo word_filter_add_ob_tags($thread['TITLE'], true), "</a> ";
                            echo "<span class=\"thread_detail\">";
                            if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_INTERESTED) {
                                echo html_style_image('high_interest', gettext("High Interest"));
                            }
                            if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_SUBSCRIBED) {
                                echo html_style_image('subscribe', gettext("Subscribed"));
                            }
                            if (isset($thread['POLL_FLAG']) && $thread['POLL_FLAG'] == 'Y') {
                                echo html_style_image('poll', gettext("Poll"));
                            }
                            if (isset($thread['STICKY']) && $thread['STICKY'] == 'Y') {
                                echo html_style_image('sticky', gettext("Sticky"));
                            }
                            if (isset($thread['RELATIONSHIP']) && $thread['RELATIONSHIP'] & USER_FRIEND) {
                                echo html_style_image('friend', gettext("Friend"));
                            }
                            if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_SPLIT) {
                                echo html_style_image('split_thread', gettext("Thread has been split"));
                            }
                            if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_MERGE) {
                                echo html_style_image('merge_thread', gettext("Thread has been merged"));
                            }
                            if (isset($thread['ATTACHMENT_COUNT']) && $thread['ATTACHMENT_COUNT'] > 0) {
                                echo html_style_image('attach', gettext("Attachment"));
                            }
                            echo "<span class=\"thread_length\">{$number}</span>";
                            echo "</span>";
                            echo "</span>";
                            echo "<span class=\"thread_time\">{$thread_time}</span>";
                            echo "</li>\n";
                        }
                    }
                    if ($folder_list_end === false && $folder_list_start === true) {
                        echo "</ul>\n";
                    }
                    if (is_numeric($folder) && $folder_number == $folder && $thread_count >= 50) {
                        echo "<div class=\"folder_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder}&amp;page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n";
                    }
                } else {
                    if ($folder_info[$folder_number]['INTEREST'] != FOLDER_IGNORED) {
                        echo "<div class=\"folder_info\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder_number}\">";
                        if (isset($folder_msgs[$folder_number])) {
                            echo $folder_msgs[$folder_number];
                        } else {
                            echo "0";
                        }
                        echo " ", gettext("threads"), "</a>";
                        if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) {
                            echo "<span><a href=\"lpost.php?webtag={$webtag}&amp;fid={$folder_number}\">", gettext("Post New"), "</a></span>";
                        }
                        echo "</div>\n";
                    }
                }
            }
            echo "  </div>\n";
            echo "</div>\n";
            if (is_array($thread_info)) {
                reset($thread_info);
            }
        }
    }
    if (!is_numeric($folder) && $thread_count >= 50) {
        echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n";
    }
    if (session::logged_in()) {
        echo "<div id=\"thread_mark_read\">\n";
        echo "<h3>", gettext("Mark as Read"), "</h3>\n";
        echo "<form accept-charset=\"utf-8\" name=\"f_mark\" method=\"post\" action=\"lthread_list.php\">\n";
        echo "  ", form_csrf_token_field(), "\n";
        echo form_input_hidden("webtag", htmlentities_array($webtag)), "\n";
        echo form_input_hidden("mode", htmlentities_array($mode)), "\n";
        echo form_input_hidden("page", htmlentities_array($page)), "\n";
        echo form_input_hidden("mark_read_confirm", 'N'), "\n";
        $labels = array(gettext("All Discussions"), gettext("Next 50 discussions"));
        $selected_option = THREAD_MARK_READ_ALL;
        if (sizeof($visible_threads_array) > 0) {
            $labels[] = gettext("Visible discussions");
            $selected_option = THREAD_MARK_READ_VISIBLE;
            $visible_threads = implode(',', array_filter($visible_threads_array, 'is_numeric'));
            echo form_input_hidden("mark_read_threads", htmlentities_array($visible_threads)), "\n";
        }
        if (isset($_GET['folder']) && is_numeric($_GET['folder'])) {
            echo form_input_hidden('folder', htmlentities_array($folder)), "\n";
            $labels[] = gettext("Selected folder");
            $selected_option = THREAD_MARK_READ_FOLDER;
        }
        echo "<ul>\n";
        echo "<li>", light_form_dropdown_array("mark_read_type", $labels, $selected_option), "</li>\n";
        echo "<li class=\"right_col\">", light_form_submit("mark_read_submit", gettext("Go!")), "</li>\n";
        echo "</ul>\n";
        echo "</form>\n";
        echo "</div>\n";
    }
}
Example #6
0
// Check we have Admin / Moderator access
if (!session::check_perm(USER_PERM_ADMIN_TOOLS, 0)) {
    html_draw_error(gettext("You do not have permission to use this section."));
}
// Perform additional admin login.
admin_check_credentials();
if (isset($_GET['uid']) && is_numeric($_GET['uid'])) {
    $uid = $_GET['uid'];
} else {
    if (isset($_POST['uid']) && is_numeric($_POST['uid'])) {
        $uid = $_POST['uid'];
    } else {
        html_draw_error(gettext("No user specified."), 'admin_users.php', 'get', array('back' => gettext("Back")));
    }
}
if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
    $ret = "messages.php?webtag={$webtag}&msg={$_GET['msg']}";
} else {
    if (isset($_POST['ret']) && strlen(trim($_POST['ret'])) > 0) {
        $ret = trim($_POST['ret']);
    } else {
        $ret = "admin_users.php?webtag={$webtag}";
    }
}
// validate the return to page
if (isset($ret) && strlen(trim($ret)) > 0) {
    $available_files_preg = implode("|^", array_map('preg_quote_callback', get_available_files()));
    if (preg_match("/^{$available_files_preg}/u", basename($ret)) < 1) {
        $ret = "admin_users.php?webtag={$webtag}";
    }
}
Example #7
0
function cache_check_messages()
{
    if (!($db = db::get())) {
        return false;
    }
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!cache_check_enabled()) {
        return false;
    }
    if (browser_check(BROWSER_AOL)) {
        return false;
    }
    if (headers_sent()) {
        return false;
    }
    if (isset($_GET['post_success'])) {
        return false;
    }
    if (isset($_GET['delete_success'])) {
        return false;
    }
    if (isset($_GET['edit_success'])) {
        return false;
    }
    if (isset($_GET['font_resize'])) {
        return false;
    }
    if (isset($_GET['markasread'])) {
        return false;
    }
    if (isset($_GET['post_approve_success'])) {
        return false;
    }
    if (isset($_GET['relupdated'])) {
        return false;
    }
    if (isset($_GET['setinterest'])) {
        return false;
    }
    if (isset($_GET['setstats'])) {
        return false;
    }
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
        cache_disable();
        return false;
    }
    if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
        list($tid) = explode('.', $_GET['msg']);
        $sql = "SELECT * FROM (SELECT UNIX_TIMESTAMP(MAX(POST.CREATED)) AS CREATED, ";
        $sql .= "UNIX_TIMESTAMP(MAX(POST_RECIPIENT.VIEWED)) AS VIEWED, UNIX_TIMESTAMP(MAX(POST.APPROVED)) AS APPROVED, ";
        $sql .= "UNIX_TIMESTAMP(MAX(POST.EDITED)) AS EDITED FROM `{$table_prefix}POST` POST ";
        $sql .= "LEFT JOIN `{$table_prefix}POST_RECIPIENT` POST_RECIPIENT ";
        $sql .= "ON (POST_RECIPIENT.TID = POST.TID AND POST_RECIPIENT.PID = POST.PID) ";
        $sql .= "WHERE POST.TID = '{$tid}') AS POST_DATA, (SELECT UNIX_TIMESTAMP(MAX(USER_POLL_VOTES.VOTED)) ";
        $sql .= "AS POLL_VOTE FROM `{$table_prefix}USER_POLL_VOTES` USER_POLL_VOTES ";
        $sql .= "WHERE USER_POLL_VOTES.TID = '{$tid}') AS POLL_DATA";
    } else {
        $sql = "SELECT UNIX_TIMESTAMP(MAX(CREATED)) AS CREATED, ";
        $sql .= "0 AS VIEWED, 0 AS APPROVED, 0 AS EDITED, 0 AS POLL_VOTE ";
        $sql .= "FROM `{$table_prefix}POST`";
    }
    if (!($result = $db->query($sql))) {
        return false;
    }
    if ($result->num_rows == 0) {
        return true;
    }
    list($created, $viewed, $approved, $edited, $voted) = $result->fetch_row();
    $last_modified = max($created, $viewed, $approved, $edited, $voted);
    $etag = md5($_SESSION['UID'] . $_SESSION['LOGON']);
    return cache_check_last_modified($last_modified, $etag);
}
Example #8
0
    } else {
        if (isset($_GET['post_success']) && validate_msg($_GET['post_success'])) {
            list($return_tid, $return_pid) = explode(".", $_GET['post_success']);
            if ($return_tid != $tid || $return_pid > $pid + $posts_per_page) {
                message_display_success_msg($return_tid, $return_pid, $pid, gettext("Successfully created post %s"), $posts_per_page);
            }
        } else {
            if (isset($_GET['edit_success']) && validate_msg($_GET['edit_success'])) {
                list($return_tid, $return_pid) = explode(".", $_GET['edit_success']);
                message_display_success_msg($return_tid, $return_pid, $pid, gettext("Successfully edited post %s"), $posts_per_page);
            } else {
                if (isset($_GET['delete_success']) && validate_msg($_GET['delete_success'])) {
                    list($return_tid, $return_pid) = explode(".", $_GET['delete_success']);
                    message_display_success_msg($return_tid, $return_pid, $pid, gettext("Successfully deleted post %s"), $posts_per_page);
                } else {
                    if (isset($_GET['post_approve_success']) && validate_msg($_GET['post_approve_success'])) {
                        list($return_tid, $return_pid) = explode(".", $_GET['post_approve_success']);
                        message_display_success_msg($return_tid, $return_pid, $pid, gettext("Successfully approved post %s"), $posts_per_page);
                    } else {
                        if (!isset($thread_data['APPROVED'])) {
                            html_display_warning_msg(gettext("Thread is pending approval by a moderator"), '96%', 'center');
                        }
                    }
                }
            }
        }
    }
}
if (isset($_GET['font_resize'])) {
    echo "<div id=\"font_resize_success\">\n";
    html_display_success_msg(sprintf(gettext("Font Size Changed. %s"), gettext("Frames must be reloaded manually to see changes.")), '96%', 'center');
                 admin_add_log_entry(REMOVE_THREAD_STICKY, array($tid, $thread_data['TITLE']));
             } else {
                 $error_msg_array[] = gettext("Failed to update thread sticky status");
                 $valid = false;
             }
         }
     }
 }
 if (isset($_POST['thread_merge_split']) && is_numeric($_POST['thread_merge_split'])) {
     if ($_POST['thread_merge_split'] == THREAD_TYPE_MERGE) {
         if (isset($_POST['merge_thread']) && is_numeric($_POST['merge_thread'])) {
             if (isset($_POST['merge_type']) && is_numeric($_POST['merge_type']) && isset($_POST['merge_thread_con']) && $_POST['merge_thread_con'] == "Y") {
                 $error_str = '';
                 $merge_thread = $_POST['merge_thread'];
                 $merge_type = $_POST['merge_type'];
                 if (validate_msg($merge_thread)) {
                     list($merge_thread) = explode('.', $merge_thread);
                 }
                 if ($merge_result = thread_merge($tid, $merge_thread, $merge_type, $error_str)) {
                     post_add_edit_text($tid, 1);
                     admin_add_log_entry(THREAD_MERGE, $merge_result);
                 } else {
                     $error_msg_array[] = $error_str;
                     $valid = false;
                 }
             }
         }
     } else {
         if ($_POST['thread_merge_split'] == THREAD_TYPE_SPLIT) {
             if (isset($_POST['split_thread']) && is_numeric($_POST['split_thread']) && $_POST['split_thread'] > 1) {
                 if (isset($_POST['split_type']) && is_numeric($_POST['split_type']) && isset($_POST['split_thread_con']) && $_POST['split_thread_con'] == "Y") {
Example #10
0
function light_draw_thread_list($mode = ALL_DISCUSSIONS, $folder = false, $page = 1)
{
    $webtag = get_webtag();
    $error_msg_array = array();
    $available_views = thread_list_available_views();
    $visible_threads_array = array();
    if (($uid = session::get_value('UID')) === false) {
        return;
    }
    echo "<div id=\"thread_view\">\n";
    echo "<form accept-charset=\"utf-8\" name=\"f_mode\" method=\"get\" action=\"lthread_list.php\">\n";
    echo form_input_hidden("webtag", htmlentities_array($webtag));
    if (is_numeric($folder) && in_array($folder, folder_get_available_array())) {
        echo form_input_hidden('folder', htmlentities_array($folder)), "\n";
    }
    echo "<ul>\n";
    echo "<li>", light_threads_draw_discussions_dropdown($mode), "</li>\n";
    echo "<li class=\"right_col\">", light_form_submit("go", gettext("Go!")), "</li>\n";
    echo "</ul>\n";
    echo "</form>\n";
    echo "</div>\n";
    // Get the right threads for whichever mode is selected
    switch ($mode) {
        case UNREAD_DISCUSSIONS:
            list($thread_info, $folder_order) = threads_get_unread($uid, $folder, $page);
            break;
        case UNREAD_DISCUSSIONS_TO_ME:
            list($thread_info, $folder_order) = threads_get_unread_to_me($uid, $folder, $page);
            break;
        case TODAYS_DISCUSSIONS:
            list($thread_info, $folder_order) = threads_get_by_days($uid, $folder, $page, 1);
            break;
        case UNREAD_TODAY:
            list($thread_info, $folder_order) = threads_get_unread_by_days($uid, $folder, $page);
            break;
        case TWO_DAYS_BACK:
            list($thread_info, $folder_order) = threads_get_by_days($uid, $folder, $page, 2);
            break;
        case SEVEN_DAYS_BACK:
            list($thread_info, $folder_order) = threads_get_by_days($uid, $folder, $page, 7);
            break;
        case HIGH_INTEREST:
            list($thread_info, $folder_order) = threads_get_by_interest($uid, $folder, $page, 1);
            break;
        case UNREAD_HIGH_INTEREST:
            list($thread_info, $folder_order) = threads_get_unread_by_interest($uid, $folder, $page, 1);
            break;
        case RECENTLY_SEEN:
            list($thread_info, $folder_order) = threads_get_recently_viewed($uid, $folder, $page);
            break;
        case IGNORED_THREADS:
            list($thread_info, $folder_order) = threads_get_by_interest($uid, $folder, $page, -1);
            break;
        case BY_IGNORED_USERS:
            list($thread_info, $folder_order) = threads_get_by_relationship($uid, $folder, $page, USER_IGNORED_COMPLETELY);
            break;
        case SUBSCRIBED_TO:
            list($thread_info, $folder_order) = threads_get_by_interest($uid, $folder, $page, 2);
            break;
        case STARTED_BY_FRIEND:
            list($thread_info, $folder_order) = threads_get_by_relationship($uid, $folder, $page, USER_FRIEND);
            break;
        case UNREAD_STARTED_BY_FRIEND:
            list($thread_info, $folder_order) = threads_get_unread_by_relationship($uid, $folder, $page, USER_FRIEND);
            break;
        case STARTED_BY_ME:
            list($thread_info, $folder_order) = threads_get_started_by_me($uid, $folder, $page);
            break;
        case POLL_THREADS:
            list($thread_info, $folder_order) = threads_get_polls($uid, $folder, $page);
            break;
        case STICKY_THREADS:
            list($thread_info, $folder_order) = threads_get_sticky($uid, $folder, $page);
            break;
        case MOST_UNREAD_POSTS:
            list($thread_info, $folder_order) = threads_get_longest_unread($uid, $folder, $page);
            break;
        case DELETED_THREADS:
            list($thread_info, $folder_order) = threads_get_deleted($uid, $folder, $page);
            break;
        default:
            list($thread_info, $folder_order) = threads_get_all($uid, $folder, $page);
            break;
    }
    // Now, the actual bit that displays the threads...
    // Get folder FIDs and titles
    if (!($folder_info = threads_get_folders())) {
        light_html_display_error_msg(gettext("There are no folders available."));
        return;
    }
    // Get total number of messages for each folder
    $folder_msgs = threads_get_folder_msgs();
    // Check that the folder order is a valid array.
    // While we're here we can also check to see how the user
    // has decided to display the thread list.
    if (!is_array($folder_order) || session::get_value('THREADS_BY_FOLDER') == 'Y') {
        $folder_order = array_keys($folder_info);
    }
    // Sort the folders and threads correctly as per the URL query for the TID
    if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
        list($tid) = explode('.', $_GET['msg']);
        if ($thread = thread_get($tid)) {
            if (!isset($thread['RELATIONSHIP'])) {
                $thread['RELATIONSHIP'] = 0;
            }
            if (session::get_value('THREADS_BY_FOLDER') == 'N' || !session::logged_in()) {
                if (in_array($thread['FID'], $folder_order)) {
                    array_splice($folder_order, array_search($thread['FID'], $folder_order), 1);
                }
                array_unshift($folder_order, $thread['FID']);
            }
            if (!is_array($thread_info)) {
                $thread_info = array();
            }
            if (isset($thread_info[$tid])) {
                unset($thread_info[$tid]);
            } else {
                array_pop($thread_info);
            }
            array_unshift($thread_info, $thread);
        }
    }
    // Work out if any folders have no messages and add them.
    // Seperate them by INTEREST level
    if (session::get_value('UID') > 0) {
        if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
            list($tid) = explode('.', $_GET['msg']);
            if ($thread = thread_get($tid)) {
                $selected_folder = $thread['FID'];
            }
        } else {
            if (isset($_GET['folder'])) {
                $selected_folder = $_GET['folder'];
            } else {
                $selected_folder = 0;
            }
        }
        $ignored_folders = array();
        while (list($fid, $folder_data) = each($folder_info)) {
            if ($folder_data['INTEREST'] == FOLDER_NOINTEREST || isset($selected_folder) && $selected_folder == $fid) {
                if (!in_array($fid, $folder_order) && !in_array($fid, $ignored_folders)) {
                    $folder_order[] = $fid;
                }
            } else {
                if (!in_array($fid, $folder_order) && !in_array($fid, $ignored_folders)) {
                    $ignored_folders[] = $fid;
                }
            }
        }
        // Append ignored folders onto the end of the folder list.
        // This will make them appear at the bottom of the thread list.
        $folder_order = array_merge($folder_order, $ignored_folders);
    } else {
        while (list($fid, $folder_data) = each($folder_info)) {
            if (!in_array($fid, $folder_order)) {
                $folder_order[] = $fid;
            }
        }
    }
    // If no threads are returned, say something to that effect
    if (isset($_REQUEST['mark_read_success'])) {
        light_html_display_success_msg(gettext("Successfully marked selected threads as read"), '100%', 'left');
    } else {
        if (!is_array($thread_info)) {
            if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) {
                $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&amp;folder={$folder}&amp;mode=0\">%s</a>", gettext("click here"));
                light_html_display_warning_msg(sprintf(gettext("No &quot;%s&quot; in &quot;%s&quot; folder. Please select another folder, or %s for all threads."), $available_views[$mode], $folder_title, $all_discussions_link), '100%', 'left');
            } else {
                $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&amp;mode=0\">%s</a>", gettext("click here"));
                light_html_display_warning_msg(sprintf(gettext("No &quot;%s&quot; available. Please %s for all threads."), $available_views[$mode], $all_discussions_link), '100%', 'left');
            }
        } else {
            if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
                light_html_display_error_array($error_msg_array, '100%', 'left');
            } else {
                if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) {
                    $all_folders_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}\">%s</a>", gettext("click here"));
                    light_html_display_warning_msg(sprintf(gettext("Viewing &quot;%s&quot; in &quot;%s&quot; only. To view threads in all folders %s."), $available_views[$mode], $folder_title, $all_folders_link), '100%', 'left');
                }
            }
        }
    }
    if ($page > 1 && !is_numeric($folder)) {
        echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n";
    }
    // Iterate through the information we've just got and display it in the right order
    foreach ($folder_order as $folder_number) {
        if (isset($folder_info[$folder_number]) && is_array($folder_info[$folder_number])) {
            echo "<div class=\"folder\">\n";
            echo "  <h3><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder_number}\">", word_filter_add_ob_tags($folder_info[$folder_number]['TITLE'], true), "</a></h3>";
            echo "  <div class=\"folder_inner\">\n";
            if (!session::logged_in() || $folder_info[$folder_number]['INTEREST'] > FOLDER_IGNORED || $mode == UNREAD_DISCUSSIONS_TO_ME || isset($selected_folder) && $selected_folder == $folder_number) {
                if (is_array($thread_info)) {
                    echo "  <div class=\"folder_info\">";
                    if (isset($folder_msgs[$folder_number])) {
                        echo $folder_msgs[$folder_number];
                    } else {
                        echo "0";
                    }
                    echo " ", gettext("threads"), "";
                    if (is_null($folder_info[$folder_number]['STATUS']) || $folder_info[$folder_number]['STATUS'] & USER_PERM_THREAD_CREATE) {
                        if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) {
                            echo "<span><a href=\"lpost.php?webtag={$webtag}&amp;fid={$folder_number}\">", gettext("Post New"), "</a></span>";
                        }
                    }
                    echo "  </div>\n";
                    if ($page > 1 && is_numeric($folder) && $folder_number == $folder) {
                        echo "<div class=\"folder_navigation\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder}&amp;page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n";
                    }
                    $folder_list_start = false;
                    $folder_list_end = false;
                    foreach ($thread_info as $thread) {
                        if (!in_array($thread['TID'], $visible_threads_array)) {
                            $visible_threads_array[] = $thread['TID'];
                        }
                        if ($thread['FID'] == $folder_number) {
                            if ($folder_list_start === false) {
                                echo "<ul>\n";
                                $folder_list_start = true;
                            }
                            echo "<li>\n";
                            if ($thread['LAST_READ'] == 0) {
                                $number = "[{$thread['LENGTH']}&nbsp;new]";
                                $latest_post = 1;
                            } else {
                                if ($thread['LAST_READ'] < $thread['LENGTH']) {
                                    $new_posts = $thread['LENGTH'] - $thread['LAST_READ'];
                                    $number = "[{$new_posts}&nbsp;new&nbsp;of&nbsp;{$thread['LENGTH']}]";
                                    $latest_post = $thread['LAST_READ'] + 1;
                                } else {
                                    $number = "[{$thread['LENGTH']}]";
                                    $latest_post = 1;
                                }
                            }
                            // work out how long ago the thread was posted and format the time to display
                            $thread_time = format_time($thread['MODIFIED']);
                            echo "<span class=\"thread_title\">";
                            echo "<a href=\"lmessages.php?webtag={$webtag}&amp;msg={$thread['TID']}.{$latest_post}\" ";
                            echo "title=\"", sprintf(gettext("Thread #%s Started by %s. Viewed %s"), $thread['TID'], word_filter_add_ob_tags(format_user_name($thread['LOGON'], $thread['NICKNAME']), true), $thread['VIEWCOUNT'] == 1 ? gettext("1 time") : sprintf(gettext("%d times"), $thread['VIEWCOUNT'])), "\">";
                            echo word_filter_add_ob_tags($thread['TITLE'], true), "</a> ";
                            echo "<span class=\"thread_detail\">";
                            if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_INTERESTED) {
                                echo "<span class=\"thread_high_interest\" title=\"", gettext("High Interest"), "\">[H]</span>";
                            }
                            if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_SUBSCRIBED) {
                                echo "<span class=\"thread_subscribed\" title=\"", gettext("Subscribed"), "\">[S]</span>";
                            }
                            if (isset($thread['POLL_FLAG']) && $thread['POLL_FLAG'] == 'Y') {
                                echo "<span class=\"thread_poll\" title=\"", gettext("Poll"), "\">[P]</span>";
                            }
                            if (isset($thread['STICKY']) && $thread['STICKY'] == 'Y') {
                                echo "<span class=\"thread_sticky\" title=\"", gettext("Sticky"), "\">[ST]</span>";
                            }
                            if (isset($thread['RELATIONSHIP']) && $thread['RELATIONSHIP'] & USER_FRIEND) {
                                echo "<span class=\"thread_friend\" title=\"", gettext("Friend"), "\">[F]</span>";
                            }
                            if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_SPLIT) {
                                echo "<span class=\"thread_split\" title=\"", gettext("Thread has been split"), "\">[TS]</span>";
                            }
                            if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_MERGE) {
                                echo "<span class=\"thread_merge\" title=\"", gettext("Thread has been merged"), "\">[TM]</span>";
                            }
                            if (isset($thread['AID']) && is_md5($thread['AID'])) {
                                echo "<span class=\"thread_attachment\" title=\"", gettext("Attachment"), "\">[A]</span>";
                            }
                            echo "<span class=\"thread_length\">{$number}</span>";
                            echo "</span>";
                            echo "</span>";
                            echo "<span class=\"thread_time\">{$thread_time}</span>";
                            echo "</li>\n";
                        }
                    }
                    if ($folder_list_end === false && $folder_list_start === true) {
                        echo "</ul>\n";
                        $folder_list_end = true;
                    }
                    if (is_numeric($folder) && $folder_number == $folder) {
                        echo "<div class=\"folder_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder}&amp;page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n";
                    }
                } else {
                    if ($folder_info[$folder_number]['INTEREST'] != -1) {
                        echo "<div class=\"folder_info\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;folder={$folder_number}\">";
                        if (isset($folder_msgs[$folder_number])) {
                            echo $folder_msgs[$folder_number];
                        } else {
                            echo "0";
                        }
                        echo " ", gettext("threads"), "</a>";
                        if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) {
                            echo "<span><a href=\"lpost.php?webtag={$webtag}&amp;fid={$folder_number}\">", gettext("Post New"), "</a></span>";
                        }
                        echo "</div>\n";
                    }
                }
            }
            echo "  </div>\n";
            echo "</div>\n";
            if (is_array($thread_info)) {
                reset($thread_info);
            }
        }
    }
    if ($mode == ALL_DISCUSSIONS && !isset($folder)) {
        echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&amp;mode={$mode}&amp;page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n";
    }
    if (session::logged_in()) {
        echo "<div id=\"thread_mark_read\">\n";
        echo "<h3>", gettext("Mark as Read"), "</h3>\n";
        echo "<form accept-charset=\"utf-8\" name=\"f_mark\" method=\"post\" action=\"lthread_list.php\">\n";
        echo form_input_hidden("webtag", htmlentities_array($webtag)), "\n";
        echo form_input_hidden("mode", htmlentities_array($mode)), "\n";
        echo form_input_hidden("page", htmlentities_array($page)), "\n";
        echo form_input_hidden("mark_read_confirm", 'N'), "\n";
        $labels = array(gettext("All Discussions"), gettext("Next 50 discussions"));
        $selected_option = THREAD_MARK_READ_ALL;
        if (sizeof($visible_threads_array) > 0) {
            $labels[] = gettext("Visible discussions");
            $selected_option = THREAD_MARK_READ_VISIBLE;
            $visible_threads = implode(',', array_filter($visible_threads_array, 'is_numeric'));
            echo form_input_hidden("mark_read_threads", htmlentities_array($visible_threads)), "\n";
        }
        if (isset($_GET['folder']) && is_numeric($_GET['folder'])) {
            echo form_input_hidden('folder', htmlentities_array($folder)), "\n";
            $labels[] = gettext("Selected folder");
            $selected_option = THREAD_MARK_READ_FOLDER;
        }
        echo "<ul>\n";
        echo "<li>", light_form_dropdown_array("mark_read_type", $labels, $selected_option), "</li>\n";
        echo "<li class=\"right_col\">", light_form_submit("mark_read_submit", gettext("Go!")), "</li>\n";
        echo "</ul>\n";
        echo "</form>\n";
        echo "</div>\n";
    }
}
if (isset($_POST['msg'])) {
    if (validate_msg($_POST['msg'])) {
        $msg = $_POST['msg'];
    } else {
        html_draw_error(gettext("No message specified for editing"), 'admin_post_approve.php', 'post', array('cancel' => gettext("Cancel")), array('ret' => $ret), '_self', 'center');
    }
} else {
    if (isset($_GET['msg'])) {
        if (validate_msg($_GET['msg'])) {
            $msg = $_GET['msg'];
        } else {
            html_draw_error(gettext("No message specified for editing"), 'admin_post_approve.php', 'post', array('cancel' => gettext("Cancel")), array('ret' => $ret), '_self', 'center');
        }
    }
}
if (isset($msg) && validate_msg($msg)) {
    $valid = true;
    list($tid, $pid) = explode('.', $msg);
    if (!($t_fid = thread_get_folder($tid, $pid))) {
        html_draw_error(gettext("The requested thread could not be found or access was denied."), 'admin_post_approve.php', 'post', array('cancel' => gettext("Cancel")), array('ret' => $ret), '_self', 'center');
    }
    if (!session::check_perm(USER_PERM_POST_EDIT | USER_PERM_POST_READ, $t_fid)) {
        html_draw_error(gettext("You cannot edit posts in this folder"), 'admin_post_approve.php', 'post', array('cancel' => gettext("Cancel")), array('ret' => $ret), '_self', 'center');
    }
    if (!session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) {
        html_draw_error(gettext("You cannot edit posts in this folder"), 'admin_post_approve.php', 'post', array('cancel' => gettext("Cancel")), array('ret' => $ret), '_self', 'center');
    }
    if (!($thread_data = thread_get($tid))) {
        html_draw_error(gettext("The requested thread could not be found or access was denied."), 'admin_post_approve.php', 'post', array('cancel' => gettext("Cancel")), array('ret' => $ret), '_self', 'center');
    }
    if ($preview_message = messages_get($tid, $pid, 1)) {
<?php

$secret = 'dupa231';
include 'commons.php';
$logbook_type = validate_msg(decrypt($_POST['secret'], $secret));
if (!$logbook_type) {
    exit;
}
// Where the file is going to be placed
$target_path = "work/";
function file_begin($filename)
{
    return begin(explode(".", $filename));
}
function replace_text_in_file($file, $search, $replace)
{
    $f = fopen($file, 'r');
    if (!$f) {
        return;
    }
    while (!feof($f)) {
        $text .= fread($f, 4096);
    }
    fclose($f);
    $f = fopen($file, 'w');
    if (!$f) {
        return;
    }
    $text = str_replace($search, $replace, $text);
    fwrite($f, $text, strlen($text));
    fclose($f);
Example #13
0
function cache_check_messages()
{
    if (!($db = db::get())) {
        return false;
    }
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!cache_check_enabled()) {
        return false;
    }
    if (browser_check(BROWSER_AOL)) {
        return false;
    }
    if (headers_sent()) {
        return false;
    }
    // Disable cache on these URL queries.
    if (isset($_GET['delete_success'])) {
        return false;
    }
    if (isset($_GET['edit_success'])) {
        return false;
    }
    if (isset($_GET['font_resize'])) {
        return false;
    }
    if (isset($_GET['markasread'])) {
        return false;
    }
    if (isset($_GET['post_approve_success'])) {
        return false;
    }
    if (isset($_GET['relupdated'])) {
        return false;
    }
    if (isset($_GET['setinterest'])) {
        return false;
    }
    if (isset($_GET['setstats'])) {
        return false;
    }
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
        cache_disable();
        return false;
    }
    if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
        list($tid) = explode('.', $_GET['msg']);
        $sql = "SELECT * FROM (SELECT UNIX_TIMESTAMP(MAX(POST.CREATED)) AS CREATED, ";
        $sql .= "UNIX_TIMESTAMP(MAX(POST.VIEWED)) AS VIEWED, UNIX_TIMESTAMP(MAX(POST.APPROVED)) AS APPROVED, ";
        $sql .= "UNIX_TIMESTAMP(MAX(POST.EDITED)) AS EDITED FROM `{$table_prefix}POST` POST ";
        $sql .= "WHERE POST.TID = '{$tid}') AS POST_DATA, (SELECT UNIX_TIMESTAMP(MAX(USER_POLL_VOTES.VOTED)) ";
        $sql .= "AS POLL_VOTE FROM `{$table_prefix}USER_POLL_VOTES` USER_POLL_VOTES ";
        $sql .= "WHERE USER_POLL_VOTES.TID = '{$tid}') AS POLL_DATA";
    } else {
        $sql = "SELECT UNIX_TIMESTAMP(MAX(CREATED)) AS CREATED, ";
        $sql .= "0 AS VIEWED, 0 AS APPROVED, 0 AS EDITED, 0 AS POLL_VOTE ";
        $sql .= "FROM `{$table_prefix}POST`";
    }
    if (!($result = $db->query($sql))) {
        return false;
    }
    if ($result->num_rows == 0) {
        return true;
    }
    // Get the two modified dates from the query
    list($created, $viewed, $approved, $edited, $voted) = $result->fetch_row();
    // Work out which one is newer (higher).
    $local_cache_date = max($created, $viewed, $approved, $edited, $voted);
    // Last Modified Header for cache control
    $local_last_modified = gmdate("D, d M Y H:i:s", $local_cache_date) . " GMT";
    $local_cache_expires = gmdate("D, d M Y H:i:s", $local_cache_date) . " GMT";
    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strlen(trim($_SERVER['HTTP_IF_MODIFIED_SINCE'])) > 0) {
        $remote_last_modified = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
        if (strtotime($remote_last_modified) >= $local_cache_date) {
            header("Expires: {$local_cache_expires}", true);
            header("Last-Modified: {$remote_last_modified}", true);
            header('Cache-Control: private, must-revalidate', true);
            header_status(304, 'Not Modified');
            exit;
        }
    }
    header("Expires: {$local_cache_expires}", true);
    header("Last-Modified: {$local_last_modified}", true);
    header('Cache-Control: private, must-revalidate', true);
    return true;
}
                html_draw_bottom();
                exit;
            }
        } else {
            $error_msg_array[] = gettext("You must select some messages to delete");
            $valid = false;
        }
    }
}
html_draw_top(array('title' => gettext('Admin - Post Approval Queue'), 'class' => 'window_title', 'main_css' => 'admin.css'));
$post_approval_array = admin_get_post_approval_queue($page);
echo "<h1>", gettext("Admin"), html_style_image('separator'), gettext("Post Approval Queue"), "</h1>\n";
if (isset($_GET['post_approve_success']) && validate_msg($_GET['post_approve_success'])) {
    html_display_success_msg(sprintf(gettext("Successfully approved post %s"), $_GET['post_approve_success']), '86%', 'center');
} else {
    if (isset($_GET['delete_success']) && validate_msg($_GET['delete_success'])) {
        html_display_success_msg(sprintf(gettext("Successfully deleted post %s"), $_GET['delete_success']), '86%', 'center');
    } else {
        if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
            html_display_error_array($error_msg_array, '86%', 'center');
        } else {
            if (sizeof($post_approval_array['post_array']) < 1) {
                html_display_warning_msg(gettext("No posts are awaiting approval"), '86%', 'center');
            }
        }
    }
}
echo "<br />\n";
echo "<div align=\"center\">\n";
echo "<form accept-charset=\"utf-8\" name=\"f_delete\" action=\"admin_post_approve.php\" method=\"post\" target=\"_self\">\n";
echo "  ", form_csrf_token_field(), "\n";
Example #15
0
    }
    if (!($fid = thread_get_folder_fid($tid))) {
        light_html_draw_error(gettext("The requested thread could not be found or access was denied."));
    }
    if (session::check_perm(USER_PERM_EMAIL_CONFIRM, 0)) {
        light_html_email_confirmation_error();
        exit;
    }
    if (!session::check_perm(USER_PERM_POST_CREATE, $fid)) {
        light_html_draw_error(gettext("You cannot reply to posts in this folder"));
    }
    $new_thread = false;
} else {
    if (isset($_POST['reply_to']) && validate_msg($_POST['reply_to'])) {
        list($tid, $reply_to_pid) = explode(".", $_POST['reply_to']);
        if (isset($_POST['return_msg']) && validate_msg($_POST['return_msg'])) {
            $return_msg = $_POST['return_msg'];
        } else {
            $return_msg = $_POST['reply_to'];
        }
        if (!($fid = thread_get_folder_fid($tid))) {
            light_html_draw_error(gettext("The requested thread could not be found or access was denied."));
        }
        if (session::check_perm(USER_PERM_EMAIL_CONFIRM, 0)) {
            light_html_email_confirmation_error();
            exit;
        }
        if (!session::check_perm(USER_PERM_POST_CREATE, $fid)) {
            light_html_draw_error(gettext("You cannot reply to posts in this folder"));
        }
        if (sizeof($attachments) > 0 && !session::check_perm(USER_PERM_POST_ATTACHMENTS | USER_PERM_POST_READ, $fid)) {
Example #16
0
function html_draw_top(array $options = array())
{
    $title = null;
    $class = null;
    $base_target = null;
    $robots = null;
    $main_css = null;
    $images_css = null;
    $inline_css = null;
    $emoticons = null;
    $frame_set_html = false;
    $pm_popup_disabled = false;
    $js = array();
    $css = array();
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    $forum_name = forum_get_setting('forum_name', null, 'A Beehive Forum');
    foreach ($options as $key => $value) {
        switch ($key) {
            case 'title':
            case 'class':
            case 'base_target':
            case 'robots':
            case 'main_css':
            case 'images_css':
            case 'inline_css':
            case 'emoticons':
                ${$key} = !isset(${$key}) && isset($value) ? $value : ${$key};
                break;
            case 'frame_set_html':
            case 'pm_popup_disabled':
                ${$key} = is_bool($value) ? $value : ${$key};
                break;
            case 'js':
            case 'css':
                if (!is_array($value) || count(array_filter($value, 'is_string')) != count($value)) {
                    throw new InvalidArgumentException(sprintf('Expecting html_draw_top argument %s to be an array of strings', $key));
                }
                ${$key} = $value;
                break;
            default:
                throw new InvalidArgumentException(sprintf('Unknown html_draw_top argument "%s"', $key));
                break;
        }
    }
    if (!isset($main_css)) {
        $main_css = 'style.css';
    }
    if (!isset($images_css)) {
        $images_css = 'images.css';
    }
    if ($frame_set_html === false) {
        echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    } else {
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
    }
    echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"", gettext('en-gb'), "\" lang=\"", gettext('en-gb'), "\" dir=\"", gettext('ltr'), "\">\n";
    echo "<head>\n";
    echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
    // Default Meta keywords and description.
    $meta_keywords = html_get_forum_keywords();
    $meta_description = html_get_forum_description();
    if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
        list($tid, $pid) = explode('.', $_GET['msg']);
        message_get_meta_content($_GET['msg'], $meta_keywords, $meta_description);
        if (isset($_SESSION['POSTS_PER_PAGE']) && is_numeric($_SESSION['POSTS_PER_PAGE'])) {
            $posts_per_page = max(min($_SESSION['POSTS_PER_PAGE'], 30), 10);
        } else {
            $posts_per_page = 20;
        }
        if (($thread_data = thread_get($tid)) !== false) {
            echo "<title>", word_filter_add_ob_tags($thread_data['TITLE'], true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n";
            echo "<link rel=\"canonical\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&amp;msg={$tid}.1"), "\" />\n";
            if ($thread_data['LENGTH'] > $posts_per_page) {
                $prev_page = $pid - $posts_per_page > 0 ? $pid - $posts_per_page : 1;
                $next_page = $pid + $posts_per_page < $thread_data['LENGTH'] ? $pid + $posts_per_page : $thread_data['LENGTH'];
                $last_page = floor($thread_data['LENGTH'] / $posts_per_page) * $posts_per_page + 1;
                echo "<link rel=\"first\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&amp;msg={$tid}.1"), "\" />\n";
                echo "<link rel=\"last\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&amp;msg={$tid}.{$last_page}"), "\" />\n";
                if ($pid + $posts_per_page < $thread_data['LENGTH']) {
                    echo "<link rel=\"next\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&amp;msg={$tid}.{$next_page}"), "\" />\n";
                }
                if ($pid > 1) {
                    echo "<link rel=\"prev\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&amp;msg={$tid}.{$prev_page}"), "\" />\n";
                }
            }
        } else {
            if (isset($title)) {
                echo "<title>", word_filter_add_ob_tags($title, true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n";
            } else {
                echo "<title>", word_filter_add_ob_tags($forum_name, true), "</title>\n";
            }
        }
    } else {
        if (isset($title)) {
            echo "<title>", word_filter_add_ob_tags($title, true), " - ", htmlentities_array($forum_name), "</title>\n";
        } else {
            echo "<title>", htmlentities_array($forum_name), "</title>\n";
        }
    }
    $forum_content_rating = html_get_forum_content_rating();
    echo "<meta name=\"generator\" content=\"Beehive Forum ", BEEHIVE_VERSION, "\" />\n";
    echo "<meta name=\"keywords\" content=\"", word_filter_add_ob_tags($meta_keywords, true), "\" />\n";
    echo "<meta name=\"description\" content=\"", word_filter_add_ob_tags($meta_description, true), "\" />\n";
    echo "<meta name=\"rating\" content=\"{$forum_content_rating}\" />\n";
    if (forum_get_setting('allow_search_spidering', 'N') || isset($pid) && $pid > 1) {
        echo "<meta name=\"robots\" content=\"noindex,nofollow\" />\n";
    } else {
        if (isset($robots)) {
            echo "<meta name=\"robots\" content=\"", htmlentities_array($robots), "\" />\n";
        }
    }
    printf("<meta name=\"application-name\" content=\"%s\" />\n", htmlentities_array(word_filter_add_ob_tags($forum_name, true)));
    printf("<meta name=\"msapplication-tooltip\" content=\"%s\" />\n", htmlentities_array(word_filter_add_ob_tags($meta_description, true)));
    if (forum_check_webtag_available($webtag)) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Messages'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=discussion.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/unread_thread.ico', true));
        if (forum_get_setting('show_links', 'Y')) {
            printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Links'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=links.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/link.ico', true));
        }
    }
    if (forum_get_setting('show_pms', 'Y')) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Inbox'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=pm.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/pm_unread.ico', true));
    }
    if (forum_check_webtag_available($webtag)) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('My Controls'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=user.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/user_controls.ico', true));
    }
    if (session::logged_in() && (session::check_perm(USER_PERM_FORUM_TOOLS, 0) || session::check_perm(USER_PERM_ADMIN_TOOLS, 0) || session::get_folders_by_perm(USER_PERM_FOLDER_MODERATE))) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Admin'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=admin.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/admin_tool.ico', true));
    }
    printf("<meta name=\"msapplication-starturl\" content=\"%s\" />\n", htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}")));
    $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}");
    printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array(gettext('RSS Feed')), htmlentities_array($rss_feed_path));
    if (($folders_array = folder_get_available_details()) !== false) {
        foreach ($folders_array as $folder) {
            $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}&amp;fid={$folder['FID']}");
            printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array($folder['TITLE']), htmlentities_array(gettext('RSS Feed')), htmlentities_array($rss_feed_path));
        }
    }
    if (($user_style_path = html_get_user_style_path()) !== false) {
        printf("<link rel=\"apple-touch-icon\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-57x57.png', $user_style_path))));
        printf("<link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-72x72.png', $user_style_path))));
        printf("<link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-114x114.png', $user_style_path))));
        printf("<link rel=\"apple-touch-icon\" sizes=\"144x144\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-144x144.png', $user_style_path))));
        printf("<link rel=\"shortcut icon\" type=\"image/ico\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/favicon.ico', $user_style_path))));
    }
    $opensearch_path = html_get_forum_uri(sprintf('search.php?webtag=%s&opensearch', $webtag));
    printf("<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"%s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array($opensearch_path));
    if (($style_sheet = html_get_style_file($main_css)) !== false) {
        echo html_include_css($style_sheet);
    }
    if (($emoticon_style_sheet = html_get_emoticon_style_sheet($emoticons)) !== false) {
        echo html_include_css($emoticon_style_sheet, 'print, screen');
    }
    if (($images_style_sheet = html_get_style_file($images_css)) !== false) {
        echo html_include_css($images_style_sheet);
    }
    if (isset($inline_css)) {
        echo "<style type=\"text/css\">\n";
        echo "<!--\n\n", $inline_css, "\n\n//-->\n";
        echo "</style>\n";
    }
    // Font size (not for Guests)
    if (session::logged_in()) {
        echo html_include_css(html_get_forum_file_path(sprintf('font_size.php?webtag=%s', $webtag)), 'screen', 'user_font');
    }
    if ($base_target) {
        echo "<base target=\"", htmlentities_array($base_target), "\" />\n";
    }
    echo html_include_javascript(html_get_forum_file_path('js/jquery.min.js'));
    echo html_include_javascript(html_get_forum_file_path('js/jquery.placeholder.min.js'));
    echo html_include_javascript(html_get_forum_file_path('js/jquery.ui.autocomplete.min.js'));
    echo html_include_javascript(html_get_forum_file_path('js/jquery.parsequery.min.js'));
    echo html_include_javascript(html_get_forum_file_path('js/jquery.sprintf.min.js'));
    echo html_include_javascript(html_get_forum_file_path('js/jquery.url.min.js'));
    echo html_include_javascript(html_get_forum_file_path('js/general.js'));
    if ($frame_set_html === false) {
        // Check for any new PMs.
        if (session::logged_in()) {
            // Check to see if the PM popup is disabled on the current page.
            if ($pm_popup_disabled === false) {
                // Pages we don't want the popup to appear on
                $pm_popup_disabled_pages = get_pm_popup_disabled_files();
                // Check that we're not on one of the pages.
                if (!in_array(basename($_SERVER['PHP_SELF']), $pm_popup_disabled_pages)) {
                    echo html_include_javascript(html_get_forum_file_path('js/pm.js'));
                }
            }
            // Overflow auto-resize functionality.
            $resize_images_page = get_image_resize_files();
            if (in_array(basename($_SERVER['PHP_SELF']), $resize_images_page)) {
                if (isset($_SESSION['USE_OVERFLOW_RESIZE']) && $_SESSION['USE_OVERFLOW_RESIZE'] == 'Y') {
                    echo html_include_javascript(html_get_forum_file_path('js/overflow.js'));
                }
            }
            // Mouseover spoiler pages
            $message_display_pages = get_message_display_files();
            if (in_array(basename($_SERVER['PHP_SELF']), $message_display_pages)) {
                echo html_include_javascript(html_get_forum_file_path('js/spoiler.js'));
            }
        }
        // Stats Display pages
        $stats_display_pages = array('messages.php');
        if (in_array(basename($_SERVER['PHP_SELF']), $stats_display_pages)) {
            echo html_include_javascript(html_get_forum_file_path('js/stats.js'));
        }
    }
    foreach ($css as $css_file) {
        echo html_include_css(html_get_forum_file_path($css_file));
    }
    foreach ($js as $js_file) {
        echo html_include_javascript(html_get_forum_file_path($js_file));
    }
    echo html_include_javascript(html_get_forum_file_path("json.php?webtag={$webtag}"));
    if ($frame_set_html === true && ($google_analytics_code = html_get_google_analytics_code())) {
        echo "<script type=\"text/javascript\">\n\n";
        echo "  var _gaq = _gaq || [];\n";
        echo "  _gaq.push(['_setAccount', '{$google_analytics_code}']);\n";
        echo "  _gaq.push(['_trackPageview']);\n\n";
        echo "  (function() {\n";
        echo "    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n";
        echo "    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n";
        echo "    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n";
        echo "  })();\n\n";
        echo "</script>\n";
    }
    echo "</head>\n\n";
    if ($frame_set_html === false) {
        $classes = array(basename($_SERVER['PHP_SELF'], '.php'));
        if ($class) {
            $classes[] = $class;
        }
        printf("<body class=\"%s\">\n", implode(' ', htmlentities_array($classes)));
        if (html_output_adsense_settings() && adsense_check_user() && adsense_check_page()) {
            adsense_output_html();
            echo "<br />\n";
        }
        echo '<div id="fb-root"></div>';
    }
}
Example #17
0
     if ($user_prefs['FONT_SIZE'] > 15) {
         $user_prefs['FONT_SIZE'] = 15;
     }
     if (!user_update_prefs($uid, $user_prefs)) {
         header_status(500, 'Internal Server Error');
         exit;
     }
     header('Content-Type: application/json');
     $content = json_encode(array('success' => true, 'font_size' => $user_prefs['FONT_SIZE'], 'html' => messages_fontsize_form($tid, $pid, true, $user_prefs['FONT_SIZE'])));
     break;
 case 'post_options':
     if (!session::logged_in()) {
         break;
     }
     cache_disable();
     if (!isset($_GET['msg']) || !validate_msg($_GET['msg'])) {
         header_status(500, 'Internal Server Error');
         exit;
     }
     list($tid, $pid) = explode('.', $_GET['msg']);
     if (!($thread_data = thread_get($tid, session::check_perm(USER_PERM_ADMIN_TOOLS, 0)))) {
         header_status(500, 'Internal Server Error');
         exit;
     }
     if (!($content = message_get_post_options_html($tid, $pid, $thread_data['FID']))) {
         header_status(500, 'Internal Server Error');
         exit;
     }
     break;
 case 'poll_add_question':
     if (!session::logged_in()) {
Example #18
0
function html_draw_top()
{
    $arg_array = func_get_args();
    $title = null;
    $body_class = null;
    $base_target = null;
    $stylesheet_array = array();
    $meta_refresh = array('delay' => null, 'url' => null);
    $robots = null;
    $frame_set_html = false;
    $pm_popup_disabled = false;
    $inline_css = null;
    $emoticons = null;
    $webtag = get_webtag();
    $forum_name = forum_get_setting('forum_name', null, 'A Beehive Forum');
    $func_matches = array();
    foreach ($arg_array as $key => $func_args) {
        if (preg_match('/^title=(.+)?$/Disu', $func_args, $func_matches) > 0) {
            $title = !isset($title) && isset($func_matches[1]) ? $func_matches[1] : $title;
            unset($arg_array[$key]);
        }
        if (preg_match('/^class=(.+)?$/Disu', $func_args, $func_matches) > 0) {
            $body_class = !isset($body_class) && isset($func_matches[1]) ? $func_matches[1] : $body_class;
            unset($arg_array[$key]);
        }
        if (preg_match('/^basetarget=(.+)?$/Disu', $func_args, $func_matches) > 0) {
            $base_target = !isset($base_target) && isset($func_matches[1]) ? $func_matches[1] : $base_target;
            unset($arg_array[$key]);
        }
        if (preg_match('/^stylesheet=([^:]+)(:(.+))?$/Disu', $func_args, $func_matches) > 0) {
            $stylesheet_array[] = array('filename' => $func_matches[1], 'media' => isset($func_matches[3]) ? $func_matches[3] : 'screen');
            unset($arg_array[$key]);
        }
        if (preg_match('/^refresh=([^:]+):(.+)$/Disu', $func_args, $func_matches) > 0) {
            $meta_refresh['delay'] = isset($func_matches[1]) ? $func_matches[1] : null;
            $meta_refresh['url'] = isset($func_matches[2]) ? $func_matches[2] : null;
            unset($arg_array[$key]);
        }
        if (preg_match('/^robots=(.+)?$/Disu', $func_args, $func_matches) > 0) {
            $robots = !isset($robots) && isset($func_matches[1]) ? $func_matches[1] : $robots;
            unset($arg_array[$key]);
        }
        if (preg_match('/^frame_set_html$/Disu', $func_args, $func_matches) > 0) {
            $frame_set_html = true;
            unset($arg_array[$key]);
        }
        if (preg_match('/^pm_popup_disabled$/Disu', $func_args, $func_matches) > 0) {
            $pm_popup_disabled = true;
            unset($arg_array[$key]);
        }
        if (preg_match('/^inline_css=(.+)/Disu', $func_args, $func_matches) > 0) {
            $inline_css = !isset($inline_css) && isset($func_matches[1]) ? $func_matches[1] : $inline_css;
            unset($arg_array[$key]);
        }
        if (preg_match('/^emoticons=(.+)?$/Disu', $func_args, $func_matches) > 0) {
            $emoticons = !isset($emoticons) && isset($func_matches[1]) ? $func_matches[1] : $emoticons;
            unset($arg_array[$key]);
        }
    }
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    if ($frame_set_html === false) {
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    } else {
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
    }
    echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"", _('en-gb'), "\" lang=\"", _('en-gb'), "\" dir=\"", _('ltr'), "\">\n";
    echo "<head>\n";
    echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
    // Default Meta keywords and description.
    $meta_keywords = html_get_forum_keywords();
    $meta_description = html_get_forum_description();
    if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
        message_get_meta_content($_GET['msg'], $meta_keywords, $meta_description);
        list($tid, $pid) = explode('.', $_GET['msg']);
        if ($thread_data = thread_get($tid)) {
            $prev_page = $pid - 10 > 0 ? $pid - 10 : 1;
            $next_page = $pid + 10 < $thread_data['LENGTH'] ? $pid + 10 : $thread_data['LENGTH'];
            echo "<link rel=\"first\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&amp;msg={$tid}.1"), "\" />\n";
            echo "<link rel=\"previous\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&amp;msg={$tid}.{$thread_data['LENGTH']}"), "\" />\n";
            echo "<link rel=\"next\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&amp;msg={$tid}.{$next_page}"), "\" />\n";
            echo "<link rel=\"last\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&amp;msg={$tid}.{$prev_page}"), "\" />\n";
            echo "<title>", word_filter_add_ob_tags($thread_data['TITLE'], true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n";
        } else {
            if (isset($title)) {
                echo "<title>", word_filter_add_ob_tags($title, true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n";
            } else {
                echo "<title>", word_filter_add_ob_tags($forum_name, true), "</title>\n";
            }
        }
    } else {
        if (isset($title)) {
            echo "<title>", word_filter_add_ob_tags($title, true), " - ", htmlentities_array($forum_name), "</title>\n";
        } else {
            echo "<title>", htmlentities_array($forum_name), "</title>\n";
        }
    }
    $forum_content_rating = html_get_forum_content_rating();
    echo "<meta name=\"generator\" content=\"Beehive Forum ", BEEHIVE_VERSION, "\" />\n";
    echo "<meta name=\"keywords\" content=\"", word_filter_add_ob_tags($meta_keywords, true), "\" />\n";
    echo "<meta name=\"description\" content=\"", word_filter_add_ob_tags($meta_description, true), "\" />\n";
    echo "<meta name=\"rating\" content=\"{$forum_content_rating}\" />\n";
    if (forum_get_setting('allow_search_spidering', 'N')) {
        echo "<meta name=\"robots\" content=\"noindex,nofollow\" />\n";
    } else {
        if (isset($robots)) {
            echo "<meta name=\"robots\" content=\"{$robots}\" />\n";
        }
    }
    if (isset($meta_refresh['url'], $meta_refresh['delay'])) {
        echo "<meta http-equiv=\"refresh\" content=\"{$meta_refresh['delay']}; url={$meta_refresh['url']}\" />\n";
    }
    printf("<meta name=\"application-name\" content=\"%s\" />\n", word_filter_add_ob_tags($forum_name, true));
    printf("<meta name=\"msapplication-tooltip\" content=\"%s\" />\n", word_filter_add_ob_tags($meta_description, true));
    if (forum_check_webtag_available($webtag)) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Messages'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=discussion.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/unread_thread.ico', true, true));
        if (forum_get_setting('show_links', 'Y')) {
            printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Links'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=links.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/link.ico', true, true));
        }
    }
    if (forum_get_setting('show_pms', 'Y')) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Inbox'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=pm.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/pmunread.ico', true, true));
    }
    if (forum_check_webtag_available($webtag)) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('My Controls'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=user.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/user_controls.ico', true, true));
    }
    if (session::logged_in() && (session::check_perm(USER_PERM_FORUM_TOOLS, 0) || session::check_perm(USER_PERM_ADMIN_TOOLS, 0) || session::get_folders_by_perm(USER_PERM_FOLDER_MODERATE))) {
        printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Admin'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=admin.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/admintool.ico', true, true));
    }
    printf("<meta name=\"msapplication-starturl\" content=\"%s\" />\n", html_get_forum_file_path("index.php?webtag={$webtag}"));
    $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}");
    printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array(_('RSS Feed')), $rss_feed_path);
    if ($folders_array = folder_get_available_details()) {
        foreach ($folders_array as $folder) {
            $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}&amp;fid={$folder['FID']}");
            printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array($folder['TITLE']), htmlentities_array(_('RSS Feed')), $rss_feed_path);
        }
    }
    if ($user_style_path = html_get_user_style_path()) {
        printf("<link rel=\"apple-touch-icon\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-57x57.png', $user_style_path)));
        printf("<link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-72x72.png', $user_style_path)));
        printf("<link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-114x114.png', $user_style_path)));
        printf("<link rel=\"shortcut icon\" type=\"image/ico\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/favicon.ico', $user_style_path)));
    }
    $opensearch_path = html_get_forum_file_path(sprintf('search.php?webtag=%s&amp;opensearch', $webtag));
    printf("<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"%s\" href=\"%s\" />\n", $forum_name, $opensearch_path);
    if ($style_sheet = html_get_style_sheet()) {
        html_include_css($style_sheet);
    }
    if ($script_style_sheet = html_get_script_style_sheet()) {
        html_include_css($script_style_sheet);
    }
    if ($emoticon_style_sheet = html_get_emoticon_style_sheet($emoticons)) {
        html_include_css($emoticon_style_sheet, 'print, screen');
    }
    if (isset($stylesheet_array) && is_array($stylesheet_array)) {
        foreach ($stylesheet_array as $stylesheet) {
            if (isset($stylesheet['filename']) && isset($stylesheet['media'])) {
                html_include_css($stylesheet['filename'], $stylesheet['media']);
            }
        }
    }
    if ($style_path_ie6 = html_get_style_sheet('style_ie6.css')) {
        echo "<!--[if IE 6]>\n";
        html_include_css($style_path_ie6);
        echo "<![endif]-->\n";
    }
    if (isset($inline_css)) {
        echo "<style type=\"text/css\">\n";
        echo "<!--\n\n", $inline_css, "\n\n//-->\n";
        echo "</style>\n";
    }
    // Font size (not for Guests)
    if (session::logged_in()) {
        html_include_css(html_get_forum_file_path(sprintf('font_size.php?webtag=%s', $webtag)), 'screen', 'user_font');
    }
    if ($base_target) {
        echo "<base target=\"{$base_target}\" />\n";
    }
    html_include_javascript(html_get_forum_file_path('js/jquery-1.7.1.min.js'));
    html_include_javascript(html_get_forum_file_path('js/jquery-ui-1.8.22.autocomplete.min.js'));
    html_include_javascript(html_get_forum_file_path('js/jquery.parsequery.js'));
    html_include_javascript(html_get_forum_file_path('js/jquery.sprintf.js'));
    html_include_javascript(html_get_forum_file_path('js/jquery.url.js'));
    html_include_javascript(html_get_forum_file_path('js/general.js'));
    if ($frame_set_html === false) {
        // Check for any new PMs.
        if (session::logged_in()) {
            // Check to see if the PM popup is disabled on the current page.
            if ($pm_popup_disabled === false) {
                // Pages we don't want the popup to appear on
                $pm_popup_disabled_pages = array('admin.php', 'attachments.php', 'change_pw.php', 'confirm_email.php', 'dictionary.php', 'discussion.php', 'display_emoticons.php', 'edit_attachments.php', 'email.php', 'font_size.php', 'forgot_pw.php', 'get_attachment.php', 'index.php', 'mods_list.php', 'nav.php', 'pm.php', 'pm_edit.php', 'pm_folders.php', 'pm_messages.php', 'pm_options.php', 'poll_results.php', 'start.php', 'search_popup.php', 'threads_rss.php', 'user.php', 'user_font.php', 'user_profile.php', 'user_stats.php');
                // Check that we're not on one of the pages.
                if (!in_array(basename($_SERVER['PHP_SELF']), $pm_popup_disabled_pages)) {
                    html_include_javascript(html_get_forum_file_path('js/pm.js'));
                }
            }
            // Overflow auto-resize functionality.
            $resize_images_page = array('admin_post_approve.php', 'create_poll.php', 'delete.php', 'display.php', 'edit.php', 'edit_poll.php', 'edit_signature.php', 'messages.php', 'post.php', 'pm_write.php', 'pm_edit.php', 'pm_messages.php');
            if (in_array(basename($_SERVER['PHP_SELF']), $resize_images_page)) {
                if (session::get_value('USE_OVERFLOW_RESIZE') == 'Y') {
                    html_include_javascript(html_get_forum_file_path('js/overflow.js'));
                }
            }
            // Mouseover spoiler pages
            $message_display_pages = array('admin_post_approve.php', 'create_poll.php', 'delete.php', 'display.php', 'edit.php', 'edit_poll.php', 'edit_signature.php', 'ldisplay.php', 'lmessages.php', 'lpost.php', 'messages.php', 'post.php');
            if (in_array(basename($_SERVER['PHP_SELF']), $message_display_pages)) {
                html_include_javascript(html_get_forum_file_path('js/spoiler.js'));
            }
        }
        // Stats Display pages
        $stats_display_pages = array('messages.php');
        if (in_array(basename($_SERVER['PHP_SELF']), $stats_display_pages)) {
            html_include_javascript(html_get_forum_file_path('js/stats.js'));
        }
    }
    reset($arg_array);
    foreach ($arg_array as $func_args) {
        html_include_javascript(html_get_forum_file_path("js/{$func_args}"));
    }
    html_include_javascript(html_get_forum_file_path("ckeditor/ckeditor.js"));
    html_include_javascript(html_get_forum_file_path("ckeditor/adapters/jquery.js"));
    html_include_javascript(html_get_forum_file_path("json.php?webtag={$webtag}"));
    if ($frame_set_html === true && ($google_analytics_code = html_get_google_analytics_code())) {
        echo "<script type=\"text/javascript\">\n\n";
        echo "  var _gaq = _gaq || [];\n";
        echo "  _gaq.push(['_setAccount', '{$google_analytics_code}']);\n";
        echo "  _gaq.push(['_trackPageview']);\n\n";
        echo "  (function() {\n";
        echo "    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n";
        echo "    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n";
        echo "    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n";
        echo "  })();\n\n";
        echo "</script>\n";
    }
    if ($frame_set_html === false && forum_get_setting('show_share_links', 'Y') && session::get_value('SHOW_SHARE_LINKS') == 'Y') {
        echo "<script type=\"text/javascript\" src=\"https://apis.google.com/js/plusone.js\">\n";
        echo "{lang: 'en-GB'}\n";
        echo "</script>\n";
        echo "<script type=\"text/javascript\" src=\"http://platform.twitter.com/widgets.js\"></script>\n";
        echo "<script type=\"text/javascript\" src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script>\n";
    }
    echo "</head>\n\n";
    if ($frame_set_html === false) {
        echo "<body", $body_class ? " class=\"{$body_class}\">\n" : ">\n";
        if (html_output_adsense_settings() && adsense_check_user() && adsense_check_page()) {
            adsense_output_html();
            echo "<br />\n";
        }
        if (forum_get_setting('show_share_links', 'Y') && session::get_value('SHOW_SHARE_LINKS') == 'Y') {
            echo '<div id="fb-root"></div>';
        }
    }
}
Example #19
0
echo "                  <td align=\"left\" valign=\"top\" width=\"575\">\n";
echo "                    <table class=\"posthead\" width=\"100%\">\n";
echo "                      <tr>\n";
echo "                        <td align=\"left\">\n";
echo "                          <h2>", gettext("Message"), "</h2>\n";
echo "                          ", form_textarea("t_content", htmlentities_array(emoticons_apply($t_content)), 22, 100, 'tabindex="1"', 'post_content editor focus'), "\n";
echo "                        </td>\n";
echo "                      </tr>\n";
echo "                      <tr>\n";
echo "                        <td align=\"left\">\n";
echo form_submit("post", gettext("Post"), "tabindex=\"2\""), "\n";
echo form_submit("preview", gettext("Preview"), "tabindex=\"3\""), "\n";
if (isset($_POST['t_tid']) && is_numeric($_POST['t_tid']) && isset($_POST['t_rpid']) && is_numeric($_POST['t_rpid'])) {
    echo "<a href=\"discussion.php?webtag={$webtag}&amp;msg={$_POST['t_tid']}.{$_POST['t_rpid']}\" class=\"button\" target=\"_self\"><span>", gettext("Cancel"), "</span></a>\n";
} else {
    if (isset($_GET['replyto']) && validate_msg($_GET['replyto'])) {
        echo "<a href=\"discussion.php?webtag={$webtag}&amp;msg={$_GET['replyto']}\" class=\"button\" target=\"_self\"><span>", gettext("Cancel"), "</span></a>\n";
    } else {
        echo "<a href=\"discussion.php?webtag={$webtag}\" class=\"button\" target=\"_self\"><span>", gettext("Cancel"), "</span></a>\n";
    }
}
if (forum_get_setting('attachments_enabled', 'Y') && (session::check_perm(USER_PERM_POST_ATTACHMENTS | USER_PERM_POST_READ, $t_fid) || $new_thread)) {
    echo "<a href=\"attachments.php?aid={$aid}\" class=\"button popup 660x500\" id=\"attachments\"><span>", gettext("Attachments"), "</span></a>\n";
    echo form_input_hidden("aid", htmlentities_array($aid));
}
if ($allow_sig == true) {
    echo "                        </td>\n";
    echo "                      </tr>\n";
    echo "                      <tr>\n";
    echo "                        <td align=\"left\">&nbsp;</td>\n";
    echo "                      </tr>\n";
function message_get_meta_content($msg, &$meta_keywords, &$meta_description)
{
    if (!validate_msg($msg)) {
        return;
    }
    list($tid) = explode('.', $msg);
    if (($thread_data = thread_get($tid)) && ($message_content = message_get_content($tid, 1))) {
        $meta_keywords_array = search_extract_keywords(strip_tags(htmlentities_decode_array($message_content)));
        list($meta_description) = explode("\n", wordwrap($message_content, 150));
        $meta_keywords = htmlentities_array(implode(',', array_map('message_clean_meta_keyword', $meta_keywords_array['keywords_array'])));
    }
}