Example #1
0
function getFeedEntry($blogid, $group = 0, $feed = 0, $entry = 0, $unreadOnly = false, $starredOnly = false, $searchKeyword = null, $position = 'current', $markAsRead = 'read')
{
    // if failed, return false or null. check both!
    global $database;
    $setting = getReaderSetting($blogid);
    $searchKeyword = escapeSearchString($searchKeyword);
    if ($entry == 0 || $position != 'current') {
        if ($starredOnly !== false) {
            $condition = 'AND s.item IS NOT NULL';
        } else {
            if ($searchKeyword !== null) {
                $condition = "AND (i.title LIKE '%{$searchKeyword}%' OR i.description LIKE '%{$searchKeyword}%')";
            } else {
                $condition = '';
            }
        }
        $condition .= $group == 0 ? '' : " AND g.id = {$group}";
        $condition .= $feed == 0 ? '' : " AND f.id = {$feed}";
        $sql = "SELECT\n\t\t\t\t\t\ti.id, i.title AS entry_title, i.description, f.title AS blog_title, i.author, i.written, i.tags, i.permalink, rd.item AS wasread, f.language, enclosure\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$database['prefix']}FeedGroups g,\n\t\t\t\t\t\t{$database['prefix']}FeedGroupRelations r,\n\t\t\t\t\t\t{$database['prefix']}Feeds f,\n\t\t\t\t\t\t{$database['prefix']}FeedItems i\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$database['prefix']}FeedStarred s\n\t\t\t\t\tON\n\t\t\t\t\t\ts.blogid = {$blogid} AND\n\t\t\t\t\t\ti.id = s.item\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$database['prefix']}FeedReads rd\n\t\t\t\t\tON\n\t\t\t\t\t\trd.blogid = {$blogid} AND\n\t\t\t\t\t\ti.id = rd.item\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tr.blogid = {$blogid} AND\n\t\t\t\t\t\tr.blogid = g.blogid AND\n\t\t\t\t\t\tg.id = r.groupid AND\n\t\t\t\t\t\tr.feed = f.id AND\n\t\t\t\t\t\tf.id = i.feed\n\t\t\t\t\t\t{$condition}\n\t\t\t\t\tGROUP BY i.id, entry_title, i.description, blog_title, i.author, i.written, i.tags, i.permalink, wasread, f.language, enclosure\n\t\t\t\t\tORDER BY i.written DESC, i.id DESC";
        if ($position == 'current') {
            if ($row = POD::queryRow("{$sql} LIMIT 1")) {
                $row['description'] = adjustRelativePathImage($row['description'], $row['permalink']);
                $row['description'] = filterJavaScript($row['description'], $setting['allowscript'] == 1 ? false : true);
            }
            return $row;
        } else {
            $result = POD::queryAll($sql);
            $prevRow = null;
            while ($row = array_shift($result)) {
                if ($row['id'] == $entry) {
                    if ($position == 'before') {
                        while ($row = array_shift($result)) {
                            if ($unreadOnly == false || !$row['wasread']) {
                                break;
                            }
                        }
                        if ($markAsRead == 'read') {
                            POD::query("REPLACE INTO {$database['prefix']}FeedReads VALUES({$blogid}, {$row['id']})");
                        }
                        if ($row) {
                            $row['description'] = adjustRelativePathImage($row['description'], $row['permalink']);
                            $row['description'] = filterJavaScript($row['description'], $setting['allowscript'] == 1 ? false : true);
                        }
                        return $row;
                    } else {
                        if ($position == 'after') {
                            if ($markAsRead == 'read') {
                                POD::query("REPLACE INTO {$database['prefix']}FeedReads VALUES({$blogid}, {$prevRow['id']})");
                            }
                            if ($prevRow) {
                                $prevRow['description'] = adjustRelativePathImage($prevRow['description'], $row['permalink']);
                                $prevRow['description'] = filterJavaScript($prevRow['description'], $setting['allowscript'] == 1 ? false : true);
                            }
                            return $prevRow;
                        }
                    }
                }
                if ($unreadOnly == false || !$row['wasread']) {
                    $prevRow = $row;
                }
            }
            return null;
        }
    } else {
        POD::query("REPLACE INTO {$database['prefix']}FeedReads VALUES({$blogid}, {$entry})");
        $sql = "SELECT\n\t\t\t\t\t\ti.id, i.title AS entry_title, i.description, f.title AS blog_title, i.author, i.written, i.tags, i.permalink, f.language, enclosure\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$database['prefix']}FeedGroups g,\n\t\t\t\t\t\t{$database['prefix']}FeedGroupRelations r,\n\t\t\t\t\t\t{$database['prefix']}Feeds f,\n\t\t\t\t\t\t{$database['prefix']}FeedItems i\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tr.blogid = {$blogid} AND\n\t\t\t\t\t\tr.blogid = g.blogid AND\n\t\t\t\t\t\tr.feed = f.id AND\n\t\t\t\t\t\tr.groupid = g.id AND\n\t\t\t\t\t\ti.id = {$entry} AND\n\t\t\t\t\t\tf.id = i.feed";
        if ($row = POD::queryRow($sql)) {
            $row['description'] = adjustRelativePathImage($row['description'], $row['permalink']);
            $row['description'] = filterJavaScript($row['description'], $setting['allowscript'] == 1 ? false : true);
        }
        return $row;
    }
}
Example #2
0
<?php

/// Copyright (c) 2004-2016, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
define('__TEXTCUBE_READER__', true);
$IV = array('GET' => array('forceRefresh' => array('any', 'mandatory' => false)));
require ROOT . '/library/preprocessor.php';
require ROOT . '/interface/common/owner/header.php';
$setting = getReaderSetting($blogid);
?>
			<script type="text/javascript">
				//<![CDATA[
					var s_unknownError = "<?php 
echo _t('알 수 없는 에러입니다.');
?>
";
					var s_notFoundPrevPost = "<?php 
echo _t('이전 포스트가 없습니다.');
?>
";
					var s_notFoundNextPost = "<?php 
echo _t('다음 포스트가 없습니다.');
?>
";
					var s_groupAdded = "<?php 
echo _t('그룹을 추가하였습니다.');
?>
";
					var s_enterFeedName = "<?php 
echo _t('피드 이름을 입력하세요.');