Esempio n. 1
0
function rss_feed_check_feeds()
{
    if (($rss_feed = rss_feed_fetch()) !== false) {
        if (($rss_data = rss_feed_read_database($rss_feed['URL'])) !== false) {
            $max_item_count = min(10, $rss_feed['MAX_ITEM_COUNT']);
            foreach ($rss_data as $item_index => $rss_feed_item) {
                if ($item_index + 1 > $max_item_count) {
                    return;
                }
                if (!rss_feed_thread_exist($rss_feed['RSSID'], $rss_feed_item->link)) {
                    $rss_title = htmlentities_decode_array($rss_feed_item->title);
                    $rss_title = htmlentities_array(strip_tags($rss_title));
                    $rss_feed_name = htmlentities_array($rss_feed['NAME']);
                    $rss_quote_source = "{$rss_feed_name} {$rss_title}";
                    if (isset($rss_feed['PREFIX']) && strlen(trim($rss_feed['PREFIX'])) > 0) {
                        $rss_feed_prefix = htmlentities_array($rss_feed['PREFIX']);
                        $rss_title = "{$rss_feed_prefix} {$rss_title}";
                    }
                    if (mb_strlen($rss_title) > 64) {
                        $rss_title = mb_substr($rss_title, 0, 60);
                        if (($pos = mb_strrpos($rss_title, ' ')) !== false) {
                            $rss_title = trim(mb_substr($rss_title, 0, $pos));
                        }
                        $rss_title .= "...";
                    }
                    if (strlen($rss_feed_item->description) > 1) {
                        $rss_feed_item_description = htmlentities_decode_array($rss_feed_item->description);
                        $rss_content = fix_html(sprintf('<div class="quotetext"><b>%s:</b> <a href="%s">%s</a></div>
                             <div class="quote">%s</div>', gettext('quote'), $rss_feed_item->link, $rss_quote_source, $rss_feed_item_description));
                    } else {
                        $rss_content = fix_html(sprintf('<p>%s</p><a href=\\"%s\\" target=\\"_blank\\">%s</a>', $rss_quote_source, $rss_feed_item->link, gettext("Click here to read this article")));
                    }
                    $tid = post_create_thread($rss_feed['FID'], $rss_feed['UID'], $rss_title);
                    post_create($rss_feed['FID'], $tid, 0, $rss_feed['UID'], array(), $rss_content);
                    rss_feed_create_history($rss_feed['RSSID'], $rss_feed_item->link);
                }
            }
        }
    }
}
    }
} else {
    if (isset($_POST['checkfeedsubmit'])) {
        $valid = true;
        if (isset($_POST['t_url']) && strlen(trim($_POST['t_url'])) > 0) {
            $t_url = trim($_POST['t_url']);
        } else {
            if (isset($_POST['t_url_new']) && strlen(trim($_POST['t_url_new'])) > 0) {
                $t_url = trim($_POST['t_url_new']);
            } else {
                $error_msg_array[] = gettext("Must specify RSS Feed URL");
                $valid = false;
            }
        }
        if ($valid) {
            if ($rss_feed_items = rss_feed_read_database($t_url)) {
                if (is_array($rss_feed_items) && sizeof($rss_feed_items) > 0) {
                    $rss_stream_success = gettext("RSS stream appears to be working correctly");
                } else {
                    $error_msg_array[] = gettext("RSS stream was empty or could not be found");
                }
            } else {
                $error_msg_array[] = gettext("RSS stream was empty or could not be found");
            }
        }
        unset($t_url);
    } else {
        if (isset($_POST['addfeedsubmit'])) {
            $valid = true;
            if (isset($_POST['t_name_new']) && strlen(trim($_POST['t_name_new'])) > 0) {
                $t_name_new = trim($_POST['t_name_new']);
Esempio n. 3
0
    }
} else {
    if (isset($_POST['checkfeedsubmit'])) {
        $valid = true;
        if (isset($_POST['t_url']) && strlen(trim($_POST['t_url'])) > 0) {
            $t_url = trim($_POST['t_url']);
        } else {
            if (isset($_POST['t_url_new']) && strlen(trim($_POST['t_url_new'])) > 0) {
                $t_url = trim($_POST['t_url_new']);
            } else {
                $error_msg_array[] = gettext("Must specify RSS Feed URL");
                $valid = false;
            }
        }
        if ($valid) {
            if (($rss_feed_items = rss_feed_read_database($t_url)) !== false) {
                if (is_array($rss_feed_items) && sizeof($rss_feed_items) > 0) {
                    $rss_stream_success = gettext("RSS stream appears to be working correctly");
                } else {
                    $error_msg_array[] = gettext("RSS stream was empty or could not be found");
                }
            } else {
                $error_msg_array[] = gettext("RSS stream was empty or could not be found");
            }
        }
        unset($t_url);
    } else {
        if (isset($_POST['addfeedsubmit'])) {
            $valid = true;
            if (isset($_POST['t_name_new']) && strlen(trim($_POST['t_name_new'])) > 0) {
                $t_name_new = trim($_POST['t_name_new']);