示例#1
0
function auto_import()
{
    $Blog = new Blog();
    if ($_GET['import'] == urldecode($Blog->getSettingsData("autoimporterpass")) && $Blog->getSettingsData("autoimporter") == 'Y') {
        ini_set("memory_limit", "350M");
        define('MAGPIE_CACHE_DIR', GSCACHEPATH . 'magpierss/');
        require_once BLOGPLUGINFOLDER . 'inc/magpierss/rss_fetch.inc';
        $rss_feed_file = getXML(BLOGRSSFILE);
        foreach ($rss_feed_file->rssfeed as $the_fed) {
            $rss_uri = $the_fed->feed;
            $rss_category = $the_fed->category;
            $rss = fetch_rss($rss_uri);
            $items = array_slice($rss->items, 0);
            foreach ($items as $item) {
                $post_data['title'] = $item['title'];
                $post_data['slug'] = '';
                $post_data['date'] = $item['pubdate'];
                $post_data['private'] = '';
                $post_data['tags'] = '';
                $post_data['category'] = $rss_category;
                if ($Blog->getSettingsData('rssinclude') == 'Y') {
                    if (!empty($item['content']['encoded'])) {
                        $post_data['content'] = htmlentities($item['content']['encoded'], ENT_QUOTES, 'iso-8859-1');
                    } else {
                        $post_data['content'] = htmlentities($item['summary'], ENT_QUOTES, 'iso-8859-1') . '<p class="blog_auto_import_readmore"><a href="' . $item['link'] . '" target="_blank">' . i18n_r(BLOGFILE . '/READ_FULL_ARTICLE') . '</a></p>';
                    }
                } else {
                    $post_data['content'] = htmlentities($item['summary'], ENT_QUOTES, 'iso-8859-1') . '<p class="blog_auto_import_readmore"><a href="' . $item['link'] . '" target="_blank">' . i18n_r(BLOGFILE . '/READ_FULL_ARTICLE') . '</a></p>';
                }
                $post_data['excerpt'] = $Blog->create_excerpt($item['summary'], 0, $Blog->getSettingsData("excerptlength"));
                $post_data['thumbnail'] = auto_import_thumbnail($item);
                $post_data['current_slug'] = '';
                $post_data['author'] = htmlentities('<a href="' . $rss_uri . '">RSS Feed</a>', ENT_QUOTES, 'iso-8859-1');
                $Blog->savePost($post_data, true);
                echo '<p class="blog_rss_post_added">' . i18n_r(BLOGFILE . '/ADDED') . ': ' . $post_data['title'] . '</p>';
            }
        }
    }
}
示例#2
0
function savePost()
{
    $Blog = new Blog();
    $xmlNodes = $Blog->getXMLnodes(true);
    if (isset($_POST['post-title'])) {
        foreach ($xmlNodes as $key => $value) {
            if (!isset($_POST["post-" . $key])) {
                $post_value = '';
            } else {
                $post_value = $_POST["post-" . $key];
            }
            $post_data[$key] = $post_value;
        }
        $savePost = $Blog->savePost($post_data);
        $generateRSS = $Blog->generateRSSFeed();
        if ($savePost != false) {
            echo '<div class="updated">' . i18n_r(BLOGFILE . '/POST_ADDED') . '</div>';
        } else {
            echo '<div class="error">' . i18n_r(BLOGFILE . '/POST_ERROR') . '</div>';
        }
    } else {
        echo '<div class="error">' . i18n_r(BLOGFILE . '/BLOG_CREATE_EDIT_NO_TITLE');
        echo ' <a href="javascript:history.go(-1)">' . i18n_r(BLOGFILE . '/BLOG_RETURN_TO_PREVIOUS_PAGE') . '</a>';
        echo '</div>';
    }
}
示例#3
0
/** 
* RSS Feed Auto Importer
* Auto imports RSS feeds. Can be launched by a cron job 
* 
* @return void
*/
function auto_import()
{
    $Blog = new Blog();
    if ($_GET['import'] == urldecode($Blog->getSettingsData("autoimporterpass")) && $Blog->getSettingsData("autoimporter") == 'Y') {
        ini_set("memory_limit", "350M");
        require_once BLOGPLUGINFOLDER . 'inc/magpierss/rss_fetch.inc';
        $rss_feed_file = getXML(BLOGRSSFILE);
        foreach ($rss_feed_file->rssfeed as $the_fed) {
            $rss_uri = $the_fed->feed;
            $rss_category = $the_fed->category;
            $rss = fetch_rss($rss_uri);
            $items = array_slice($rss->items, 0);
            foreach ($items as $item) {
                $post_data['title'] = $item['title'];
                $post_data['slug'] = '';
                $post_data['date'] = $item['pubdate'];
                $post_data['private'] = '';
                $post_data['tags'] = '';
                $post_data['category'] = $rss_category;
                $post_data['content'] = $item['summary'] . '<p class="blog_auto_import_readmore"><a href="' . $item['link'] . '" target="_blank">' . i18n_r(BLOGFILE . '/READ_FULL_ARTICLE') . '</a></p>';
                $post_data['excerpt'] = '';
                $post_data['thumbnail'] = '';
                $post_data['current_slug'] = '';
                $Blog->savePost($post_data, true);
            }
        }
    }
}