Esempio n. 1
0
function light_thread_list_draw_top($mode, $folder = null)
{
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    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";
}
Esempio n. 2
0
function thread_list_draw_top($mode, $folder = false)
{
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
    echo "  <tr>\n";
    echo "    <td align=\"left\" class=\"postbody\">", html_style_image('post', gettext("New Discussion")), "&nbsp;<a href=\"post.php?webtag={$webtag}\" target=\"", html_get_frame_name('main'), "\">", gettext("New Discussion"), "</a></td>\n";
    echo "  </tr>\n";
    if (forum_get_setting('allow_polls', 'Y')) {
        echo "  <tr>\n";
        echo "    <td align=\"left\" class=\"postbody\">", html_style_image('poll', gettext("Create Poll")), "&nbsp;<a href=\"create_poll.php?webtag={$webtag}\" target=\"", html_get_frame_name('main'), "\">", gettext("Create Poll"), "</a></td>\n";
        echo "  </tr>\n";
    }
    echo "  <tr>\n";
    echo "    <td align=\"left\" class=\"postbody\">", html_style_image('search', gettext("Search")), "&nbsp;<a href=\"search.php?webtag={$webtag}\" target=\"", html_get_frame_name('right'), "\">", gettext("Search"), "</a></td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td align=\"left\" class=\"postbody\">", html_style_image('pm_unread', gettext("Inbox")), "&nbsp;<a href=\"pm.php?webtag={$webtag}\" target=\"", html_get_frame_name('main'), "\">", gettext("Inbox"), "</a> <span class=\"pmnewcount\" id=\"pm_message_count\"></span></td>\n";
    echo "  </tr>\n";
    echo "</table>\n";
    echo "<br />\n";
    $available_views = thread_list_available_views();
    echo "<form accept-charset=\"utf-8\" name=\"f_mode\" method=\"get\" action=\"thread_list.php\">\n";
    echo "  ", form_input_hidden("webtag", htmlentities_array($webtag)), "\n";
    echo "  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
    echo "    <tr>\n";
    echo "      <td align=\"left\" class=\"postbody\">\n";
    echo "        ", form_dropdown_array("mode", $available_views, htmlentities_array($mode)), "&nbsp;", form_submit("go", gettext("Go!")), "\n";
    if (is_numeric($folder) && in_array($folder, folder_get_available_array())) {
        echo "        ", form_input_hidden("folder", htmlentities_array($folder)), "\n";
    }
    echo "      </td>\n";
    echo "    </tr>\n";
    echo "  </table>\n";
    echo "</form>\n";
}
Esempio n. 3
0
    html_user_banned();
    exit;
}
// Check to see if the user has been approved.
if (!session::user_approved()) {
    html_user_require_approval();
    exit;
}
// Check that Guests are allowed
if (!session::logged_in()) {
    html_guest_error();
}
// Check to see if the user wants a specified list of folders
// or the default to show all folders.
if (isset($_GET['fid']) && is_numeric($_GET['fid'])) {
    if ($available_folders_array = folder_get_available_array()) {
        if (in_array($_GET['fid'], $available_folders_array) && ($folder_title = folder_get_title($fid))) {
            $fid = trim($_GET['fid']);
            $feed_title .= sprintf(' - %s', htmlentities_array($folder_title));
        } else {
            $fid = false;
        }
    }
}
// Enable caching on RSS Feed
cache_check_last_modified(time() + 300);
// Initialise Locale
lang_init();
// echo out the rss feed
header('Content-type: text/xml; charset=UTF-8');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
Esempio n. 4
0
require_once BH_INCLUDE_PATH . 'folder.inc.php';
require_once BH_INCLUDE_PATH . 'format.inc.php';
require_once BH_INCLUDE_PATH . 'header.inc.php';
require_once BH_INCLUDE_PATH . 'html.inc.php';
require_once BH_INCLUDE_PATH . 'lang.inc.php';
require_once BH_INCLUDE_PATH . 'light.inc.php';
require_once BH_INCLUDE_PATH . 'logon.inc.php';
require_once BH_INCLUDE_PATH . 'messages.inc.php';
require_once BH_INCLUDE_PATH . 'session.inc.php';
require_once BH_INCLUDE_PATH . 'thread.inc.php';
require_once BH_INCLUDE_PATH . 'threads.inc.php';
require_once BH_INCLUDE_PATH . 'word_filter.inc.php';
// Check thread list cache
cache_check_thread_list();
// Get the folders the user can see.
if (!($available_folders = folder_get_available_array())) {
    $available_folders = array();
}
// Are we viewing a specific folder only?
if (isset($_REQUEST['folder']) && in_array($_REQUEST['folder'], $available_folders)) {
    $folder = $_REQUEST['folder'];
} else {
    $folder = false;
}
// View offset.
if (isset($_REQUEST['start_from']) && is_numeric($_REQUEST['start_from'])) {
    $start_from = $_REQUEST['start_from'];
} else {
    $start_from = 0;
}
// View mode
Esempio n. 5
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";
    }
}
Esempio n. 6
0
// Default to showing all available folders
$fid = false;
// Check to see if the user wants threads ordered by created
// or modified date. Modified date bumps a thread to the top
// when it receives a reply. Created threads show the threads
// in the order they were created and is more useful as a
// RSS news feed within your forum.
if (isset($_GET['sort_created']) && $_GET['sort_created'] == 'Y') {
    $sort_created = 'Y';
} else {
    $sort_created = 'N';
}
// Check to see if the user wants a specified list of folders
// or the default to show all folders.
if (isset($_GET['fid']) && is_numeric($_GET['fid'])) {
    if (($available_folders_array = folder_get_available_array()) !== false) {
        if (in_array($_GET['fid'], $available_folders_array) && ($folder_title = folder_get_title($fid))) {
            $fid = trim($_GET['fid']);
            $feed_title .= sprintf(' - %s', htmlentities_array($folder_title));
        } else {
            $fid = false;
        }
    }
}
// Enable caching on RSS Feed
cache_check_request_throttle(300);
// echo out the rss feed
header('Content-type: text/xml; charset=UTF-8');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<rss xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
echo "<channel>\n";
Esempio n. 7
0
function search_execute($search_arguments, &$error)
{
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    // If the user has performed a search within the last x minutes bail out
    if (!check_search_frequency()) {
        $error = SEARCH_FREQUENCY_TOO_GREAT;
        return false;
    }
    // Database connection.
    if (!($db = db::get())) {
        return false;
    }
    // Ensure the date_from argument is set
    if (!isset($search_arguments['date_from']) || !is_numeric($search_arguments['date_from'])) {
        $search_arguments['date_from'] = SEARCH_FROM_ONE_MONTH_AGO;
    }
    // Ensure the date_to argument is set.
    if (!isset($search_arguments['date_to']) || !is_numeric($search_arguments['date_to'])) {
        $search_arguments['date_to'] = SEARCH_TO_TODAY;
    }
    // Ensure the sort_by argument is set.
    if (!isset($search_arguments['sort_by']) || !is_numeric($search_arguments['sort_by'])) {
        $search_arguments['sort_by'] = SEARCH_SORT_CREATED;
    }
    // Ensure the sort_dir argument is set.
    if (!isset($search_arguments['sort_dir']) || !is_numeric($search_arguments['sort_dir'])) {
        $search_arguments['sort_dir'] = SEARCH_SORT_DESC;
    }
    // Check the sort_dir is valid
    if (!in_array($search_arguments['sort_dir'], array(SEARCH_SORT_ASC, SEARCH_SORT_DESC))) {
        $search_arguments['sort_dir'] = SEARCH_SORT_DESC;
    }
    // Get available folders
    $folders_array = folder_get_available_array();
    // Check the selected folder is valid
    if (!isset($search_arguments['fid']) || !in_array($search_arguments['fid'], $folders_array)) {
        $search_arguments['fid'] = implode(',', $folders_array);
    }
    // Username based search.
    if (isset($search_arguments['username']) && strlen(trim($search_arguments['username'])) > 0) {
        // Make sure the uid_array key is an empty array.
        $search_arguments['user_uid_array'] = array();
        // Username argument is a comma separated list.
        $search_arguments['username_array'] = preg_split('/,\\s*/u', trim($search_arguments['username'], ', '));
        // Iterate over the provided usernames
        foreach ($search_arguments['username_array'] as $username) {
            // Check the username is valid.
            if (!($user = user_get_by_logon(trim($username)))) {
                $error = SEARCH_USER_NOT_FOUND;
                return false;
            }
            // Add the user UID to the uid_array
            $search_arguments['user_uid_array'][] = $user['UID'];
        }
    }
    // Each user can only store one search result so we should
    // clean up their previous search if applicable.
    $sql = "DELETE QUICK FROM SEARCH_RESULTS WHERE UID = '{$_SESSION['UID']}'";
    if (!$db->query($sql)) {
        return false;
    }
    // Execute search via Swiftsearch, unless we're searching for a tag.
    if (!isset($search_arguments['search_tag']) && forum_get_setting('sphinx_search_enabled', 'Y')) {
        return sphinx_search_execute($search_arguments, $error);
    }
    // Execute the search with MySQL Fulltext
    return search_mysql_execute($search_arguments, $error);
}