Exemple #1
0
function publishRSS($blogid, $data)
{
    $context = Model_Context::getInstance();
    $blogid = getBlogId();
    ob_start();
    echo '<?xml version="1.0" encoding="UTF-8"?>', CRLF;
    echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', CRLF;
    echo '	<channel>', CRLF;
    echo '		<title>', htmlspecialchars($data['channel']['title'], ENT_QUOTES), '</title>', CRLF;
    echo '		<link>', $data['channel']['link'], '</link>', CRLF;
    echo '		<description>', htmlspecialchars($data['channel']['description'], ENT_QUOTES), '</description>', CRLF;
    echo '		<language>', $data['channel']['language'], '</language>', CRLF;
    echo '		<pubDate>', Timestamp::getRFC1123($data['channel']['pubDate']), '</pubDate>', CRLF;
    echo '		<generator>', $data['channel']['generator'], '</generator>', CRLF;
    if (!empty($data['channel']['feed_link'])) {
        echo '		<atom:link href="', $data['channel']['feed_link'], '" rel="self" type="application/rss+xml" />', CRLF;
    }
    if ($context->getProperty('blog.logo') && file_exists(ROOT . "/attach/{$blogid}/{$context->getProperty('blog.logo')}")) {
        echo '		<image>', CRLF;
        echo '		<title>', htmlspecialchars($data['channel']['title'], ENT_QUOTES), '</title>', CRLF;
        echo '		<url>', $data['channel']['url'], '</url>', CRLF;
        echo '		<link>', $data['channel']['link'], '</link>', CRLF;
        echo '		<width>', $data['channel']['width'], '</width>', CRLF;
        echo '		<height>', $data['channel']['height'], '</height>', CRLF;
        echo '		<description>', htmlspecialchars($data['channel']['description'], ENT_QUOTES), '</description>', CRLF;
        echo '		</image>', CRLF;
    }
    foreach ($data['channel']['items'] as $item) {
        echo '		<item>', CRLF;
        echo '			<title>', htmlspecialchars($item['title'], ENT_QUOTES), '</title>', CRLF;
        echo '			<link>', $item['link'], '</link>', CRLF;
        echo '			<description>', htmlspecialchars($item['description'], ENT_QUOTES), '</description>', CRLF;
        foreach ($item['categories'] as $category) {
            if ($category = trim($category)) {
                echo '			<category>', htmlspecialchars($category, ENT_QUOTES), '</category>', CRLF;
            }
        }
        if (!empty($item['email'])) {
            echo '			<author>', $item['email'], ' (', htmlspecialchars($item['author'], ENT_QUOTES), ')</author>', CRLF;
        } else {
            echo '			<author>', htmlspecialchars($item['author'], ENT_QUOTES), '</author>', CRLF;
        }
        echo '			<guid>', $item['guid'], '</guid>', CRLF;
        echo '			<comments>', $item['comments'], '</comments>', CRLF;
        echo '			<pubDate>', Timestamp::getRFC1123($item['pubDate']), '</pubDate>', CRLF;
        if (!empty($item['enclosure'])) {
            echo '			<enclosure url="', $item['enclosure']['url'], '" length="', $item['enclosure']['length'], '" type="', $item['enclosure']['type'], '" />', CRLF;
        }
        echo '		</item>', CRLF;
    }
    echo '	</channel>', CRLF;
    echo '</rss>', CRLF;
    $rss = ob_get_contents();
    ob_end_clean();
    return $rss;
}
Exemple #2
0
/**
 * @brief Send abstract about specific entry.
 * @see Tag, User, DBModel, Model_Context
 */
function sendAbstractToEolin()
{
    // TODO : Rewrite routines to fit Textcube 1.8 or later.
    requireModel('blog.category');
    $entryId = $_GET['entryId'];
    $context = Model_Context::getInstance();
    $blogid = $context->getProperty('blog.id');
    echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<response>\r\n";
    list($allComments, $allTrackbacks) = POD::queryRow("SELECT \n\t\t\tSUM(comments), SUM(trackbacks) \n\t\t\tFROM {$context->getProperty('database.prefix')}Entries \n\t\t\tWHERE blogid = " . $blogid . " AND draft = 0 AND visibility = 3", 'num');
    if ($entry = POD::queryRow("SELECT e.*, c.name AS categoryName \n\t\t\t\tFROM {$context->getProperty('database.prefix')}Entries e \n\t\t\t\tLEFT JOIN {$context->getProperty('database.prefix')}Categories c ON e.blogid = c.blogid AND e.category = c.id \n\t\t\t\tWHERE e.blogid = " . $blogid . " AND e.id = " . $entryId . " AND e.draft = 0 AND e.visibility = 3" . getPrivateCategoryExclusionQuery($blogid))) {
        header('Content-Type: text/xml; charset=utf-8');
        echo '<version>1.1</version>', "\r\n";
        echo '<status>1</status>', "\r\n";
        echo '<blog>', "\r\n";
        echo '<generator>' . TEXTCUBE_NAME . '/' . TEXTCUBE_VERSION . '</generator>', "\r\n";
        echo '<language>', htmlspecialchars($context->getProperty('blog.language')), '</language>', "\r\n";
        echo '<url>', htmlspecialchars($context->getProperty('uri.default')), '</url>', "\r\n";
        echo '<title>', htmlspecialchars($context->getProperty('blog.title')), '</title>', "\r\n";
        echo '<description>', htmlspecialchars($context->getProperty('blog.description')), '</description>', "\r\n";
        echo '<comments>', $allComments, '</comments>', "\r\n";
        echo '<trackbacks>', $allTrackbacks, '</trackbacks>', "\r\n";
        echo '</blog>', "\r\n";
        echo '<entry>', "\r\n";
        echo '<permalink>', htmlspecialchars($context->getProperty('uri.default') . "/" . ($context->getProperty('blog.useSloganOnPost') ? "entry/{$entry['slogan']}" : $entry['id'])), '</permalink>', "\r\n";
        echo '<title>', htmlspecialchars($entry['title']), '</title>', "\r\n";
        echo '<content>', htmlspecialchars(getEntryContentView($blogid, $entryId, $entry['content'], $entry['contentformatter'])), '</content>', "\r\n";
        echo '<author>', htmlspecialchars(User::authorName($blogid, $entryId)), '</author>', "\r\n";
        echo '<category>', htmlspecialchars($entry['categoryName']), '</category>', "\r\n";
        $tags = Tag::getTagsWithEntryId($blogid, $entry);
        foreach ($tags as $tag) {
            echo '<tag>', htmlspecialchars($tag), '</tag>', "\r\n";
        }
        echo '<location>', htmlspecialchars($entry['location']), '</location>', "\r\n";
        echo '<comments>', $entry['comments'], '</comments>', "\r\n";
        echo '<trackbacks>', $entry['trackbacks'], '</trackbacks>', "\r\n";
        echo '<written>', Timestamp::getRFC1123($entry['published']), '</written>', "\r\n";
        foreach (getAttachments($blogid, $entry['id']) as $attachment) {
            echo '<attachment>', "\r\n";
            echo '<mimeType>', $attachment['mime'], '</mimeType>', "\r\n";
            echo '<filename>', $attachment['label'], '</filename>', "\r\n";
            echo '<length>', $attachment['size'], '</length>', "\r\n";
            echo '<url>', $context->getProperty('uri.service'), '/attachment/', $attachment['name'], '</url>', "\r\n";
            echo '</attachment>', "\r\n";
        }
        echo '</entry>', "\r\n";
    } else {
        echo '<version>1.1</version>', "\r\n", '<status>0</status>', "\r\n";
    }
    echo "</response>";
    exit;
}