Example #1
0
function fof_plain($text)
{
    $prefs = fof_prefs();
    if (empty($prefs['plugin_plain_enable'])) {
        return $text;
    }
    return strip_tags($text, "<a><b><i><blockquote>");
}
Example #2
0
function fof_wordpress($item)
{
    $prefs = fof_prefs();
    $wordpress = $prefs['plugin_wordpressurl'];
    if (!$wordpress) {
        return false;
    }
    $url = urlencode(html_entity_decode($item['item_link']));
    $title = urlencode($item['item_title']);
    $text = urlencode('<blockquote>' . $item['item_content'] . '</blockquote>');
    $link = "{$wordpress}/wp-admin/post-new.php?text={$text}&popupurl={$url}&popuptitle={$title}";
    return "<a href='{$link}'><img src='plugins/wordpress.png' height=12 width=12 border=0 /></a> <a href='{$link}'>blog it</a>";
}
Example #3
0
function fof_sharing($item)
{
    $prefs = fof_prefs();
    $sharing = $prefs['sharing'];
    if ($sharing != "tagged") {
        return false;
    }
    $tags = $item['tags'];
    $id = $item['item_id'];
    $shared = in_array("shared", $tags) ? true : false;
    $shared_image = $shared ? "plugins/share-on.gif" : "plugins/share-off.gif";
    $shared_link = $shared ? "javascript:remove_tag({$id}, 'shared')" : "javascript:add_tag({$id}, 'shared')";
    $shared_text = $shared ? "shared" : "not shared";
    return "<a href=\"{$shared_link}\"><img src=\"{$shared_image}\" width=\"12\" height=\"12\" border=\"0\"/></a> <a href=\"{$shared_link}\">{$shared_text}</a> ";
}
Example #4
0
function fof_autotag($link, $title, $content)
{
    $tags = array();
    $prefs = fof_prefs();
    $autotag = $prefs['plugin_autotag_tags'];
    if ($autotag) {
        $shebang = strip_tags($title . " " . $content);
        foreach (explode(" ", $autotag) as $tag) {
            if (preg_match("/\\b" . preg_quote($tag) . "\\b/i", $shebang)) {
                $tags[] = $tag;
            }
        }
    }
    return $tags;
}
Example #5
0
function fof_adv_autotag($link, $title, $content, $item)
{
    $tags = array();
    $prefs = fof_prefs();
    $autotag = empty($prefs['adv_autotag']) ? NULL : $prefs['adv_autotag'];
    if ($autotag) {
        foreach ($autotag as $pref) {
            $truth = false;
            switch ($pref['what']) {
                case 'item_title':
                    $what = $title;
                    break;
                case 'item_content':
                    $what = $title . ' ' . $content;
                    break;
                case 'item_author':
                    $what = $item['item_author'];
                    break;
            }
            switch ($pref['op']) {
                case 'is':
                    $truth = $what == $pref['filter'];
                    break;
                case 'contains':
                    $truth = stristr($what, $pref['filter']) !== false;
                    break;
                case 'regex':
                    $truth = preg_match($pref['filter'], $what);
                    break;
            }
            if ($truth) {
                $tags[] = $pref['tag'];
            }
        }
    }
    return $tags;
}
Example #6
0
function fof_db_get_items($user_id = 1, $feed = NULL, $what = "unread", $when = NULL, $start = NULL, $limit = NULL, $order = "desc", $search = NULL)
{
    global $FOF_SUBSCRIPTION_TABLE, $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_TAG_TABLE;
    $prefs = fof_prefs();
    $offset = $prefs['tzoffset'];
    if (!is_null($when) && $when != "") {
        if ($when == "today") {
            $whendate = fof_todays_date();
        } else {
            $whendate = $when;
        }
        $whendate = explode("/", $whendate);
        $begin = gmmktime(0, 0, 0, $whendate[1], $whendate[2], $whendate[0]) - $offset * 60 * 60;
        $end = $begin + 24 * 60 * 60;
    }
    if (is_numeric($start)) {
        if (!is_numeric($limit)) {
            $limit = $prefs["howmany"];
        }
        $limit_clause = " limit {$start}, {$limit} ";
    }
    $args = array();
    $select = "SELECT i.* , f.* ";
    $from = "FROM {$FOF_FEED_TABLE} f, {$FOF_ITEM_TABLE} i, {$FOF_SUBSCRIPTION_TABLE} s ";
    $where = sprintf("WHERE s.user_id = %d AND s.feed_id = f.feed_id AND f.feed_id = i.feed_id ", $user_id);
    if (!is_null($feed) && $feed != "") {
        $where .= sprintf("AND f.feed_id = %d ", $feed);
    }
    if (!is_null($when) && $when != "") {
        $where .= sprintf("AND i.item_published > %d and i.item_published < %d ", $begin, $end);
    }
    if ($what != "all") {
        $tags = split(" ", $what);
        $in = implode(", ", array_fill(0, count($tags), "'%s'"));
        $from .= ", {$FOF_TAG_TABLE} t, {$FOF_ITEM_TAG_TABLE} it ";
        $where .= sprintf("AND it.user_id = %d ", $user_id);
        $where .= "AND it.tag_id = t.tag_id AND ( t.tag_name IN ( {$in} ) ) AND i.item_id = it.item_id ";
        $group = sprintf("GROUP BY i.item_id HAVING COUNT( i.item_id ) = %d ", count($tags));
        $args = array_merge($args, $tags);
    }
    if (!is_null($search) && $search != "") {
        $where .= "AND (i.item_title like '%%%s%%'  or i.item_content like '%%%s%%' )";
        $args[] = $search;
        $args[] = $search;
    }
    $order_by = "order by i.item_published desc {$limit_clause} ";
    $query = $select . $from . $where . $group . $order_by;
    $result = fof_safe_query($query, $args);
    if (mysql_num_rows($result) == 0) {
        return array();
    }
    while ($row = mysql_fetch_assoc($result)) {
        $array[] = $row;
    }
    $array = fof_multi_sort($array, 'item_published', $order != "asc");
    $i = 0;
    foreach ($array as $item) {
        $ids[] = $item['item_id'];
        $lookup[$item['item_id']] = $i;
        $array[$i]['tags'] = array();
        $i++;
    }
    $items = join($ids, ", ");
    $result = fof_safe_query("select {$FOF_TAG_TABLE}.tag_name, {$FOF_ITEM_TAG_TABLE}.item_id from {$FOF_TAG_TABLE}, {$FOF_ITEM_TAG_TABLE} where {$FOF_TAG_TABLE}.tag_id = {$FOF_ITEM_TAG_TABLE}.tag_id and {$FOF_ITEM_TAG_TABLE}.item_id in (%s) and {$FOF_ITEM_TAG_TABLE}.user_id = %d", $items, $user_id);
    while ($row = fof_db_get_row($result)) {
        $item_id = $row['item_id'];
        $tag = $row['tag_name'];
        $array[$lookup[$item_id]]['tags'][] = $tag;
    }
    return $array;
}
Example #7
0
function fof_render_item($item)
{
    $items = true;
    $feed_link = $item['feed_link'];
    $feed_title = $item['feed_title'];
    $feed_image = $item['feed_image'];
    $feed_description = $item['feed_description'];
    $item_link = $item['item_link'];
    $item_id = $item['item_id'];
    $item_title = $item['item_title'];
    $item_content = $item['item_content'];
    $item_read = $item['item_read'];
    $prefs = fof_prefs();
    $offset = $prefs['tzoffset'];
    $item_published = gmdate("Y-n-d g:ia", $item['item_published'] + $offset * 60 * 60);
    $item_cached = gmdate("Y-n-d g:ia", $item['item_cached'] + $offset * 60 * 60);
    $item_updated = gmdate("Y-n-d g:ia", $item['item_updated'] + $offset * 60 * 60);
    if (!$item_title) {
        $item_title = "[no title]";
    }
    if ($_GET['search']) {
        $item_content = do_highlight("<span>{$item_content}</span>", $_GET['search'], "highlight");
        $item_title = do_highlight("<span>{$item_title}</span>", $_GET['search'], "highlight");
    }
    $tags = $item['tags'];
    $star = in_array("star", $tags) ? true : false;
    $star_image = $star ? "image/star-on.gif" : "image/star-off.gif";
    $unread = in_array("unread", $tags) ? true : false;
    ?>

<div class="header">

	<span class="controls">
		<a class='uparrow' href='javascript:hide_body("<?php 
    echo $item_id;
    ?>
")'>&uarr;</a>
		<a class='downarrow' href='javascript:show_body("<?php 
    echo $item_id;
    ?>
")'>&darr;</a>
		<input
			type="checkbox"
			name="c<?php 
    echo $item_id;
    ?>
"
			id="c<?php 
    echo $item_id;
    ?>
"
			value="checked"
			ondblclick='flag_upto("c<?php 
    echo $item_id;
    ?>
");'
            onclick='return checkbox(event);'
			title='shift-click or double-click to flag all items up to this one'
		/>
	</span>
	
	<h1 <?php 
    if ($unread) {
        echo "class='unread-item'";
    }
    ?>
 >
		<img
			height="16"
			width="16"
			src="<?php 
    echo $star_image;
    ?>
"
			id="fav<?php 
    echo $item_id;
    ?>
"
			onclick="return toggle_favorite('<?php 
    echo $item_id;
    ?>
')"
		/>
		<script>
			document.getElementById('fav<?php 
    echo $item_id;
    ?>
').star = <?php 
    if ($star) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
;
		</script>
		<a href="<?php 
    echo $item_link;
    ?>
">
			<?php 
    echo $item_title;
    ?>
		</a>
	</h1>
	
	<span class="tags">

<?php 
    if ($tags) {
        foreach ($tags as $tag) {
            if ($tag == "unread" || $tag == "star") {
                continue;
            }
            ?>
		<a href='?what=<?php 
            echo $tag;
            ?>
'><?php 
            echo $tag;
            ?>
</a>
		
		<a href='<?php 
            echo $tag;
            ?>
' onclick='return remove_tag("<?php 
            echo $item_id;
            ?>
", "<?php 
            echo $tag;
            ?>
");'>[x]</a>
<?php 
        }
    }
    ?>

		<a
			href=""
			onclick="document.getElementById('addtag<?php 
    echo $item_id;
    ?>
').style.display = '';
					 this.style.display = 'none';
					 return false;">
			add tag
		</a>

		<div id="addtag<?php 
    echo $item_id;
    ?>
" style="display: none !important">
			<input
				onfocus="this.value=''"
				onkeypress="if(event.keyCode == 13) add_tag('<?php 
    echo $item_id;
    ?>
', document.getElementById('tag<?php 
    echo $item_id;
    ?>
').value);"
				type="text"
				id="tag<?php 
    echo $item_id;
    ?>
"
				size="12"
				value="enter tag here"
			>
			<input
				type="button"
				name="add tag"
				value="tag"
				onclick="add_tag('<?php 
    echo $item_id;
    ?>
', document.getElementById('tag<?php 
    echo $item_id;
    ?>
').value);"
			>
		</div>

    </span>
    
    <span class='dash'> - </span>
    
    <h2>

    <?php 
    $prefs = fof_prefs();
    if ($feed_image && $prefs['favicons']) {
        ?>
    <a href="<?php 
        echo $feed_link;
        ?>
" title='<?php 
        echo $feed_description;
        ?>
'><img src="<?php 
        echo $feed_image;
        ?>
" height="16" width="16" border="0" /></a>
    <?php 
    }
    ?>
    <a href="<?php 
    echo $feed_link;
    ?>
" title='<?php 
    echo $feed_description;
    ?>
'><?php 
    echo $feed_title;
    ?>
</a>
    </h2>

	<span class="meta">on <?php 
    echo $item_published;
    ?>
</span>

</div>


<div class="body"><?php 
    echo $item_content;
    ?>
</div>

<?php 
    $widgets = fof_get_widgets($item);
    if ($widgets) {
        ?>

<div class="clearer"></div>

<div class="widgets">

<?php 
        foreach ($widgets as $widget) {
            echo "<span class='widget'>{$widget}</span> ";
        }
        ?>

</div>

<?php 
    }
    ?>

<?php 
}
Example #8
0
function fof_db_get_items($user_id = 1, $feed = NULL, $what = 'unread', $when = NULL, $start = NULL, $limit = NULL, $order = 'desc', $search = NULL)
{
    global $FOF_SUBSCRIPTION_TABLE, $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_TAG_TABLE;
    global $fof_connection;
    $all_items = array();
    if ($order != 'asc' && $order != 'desc') {
        $order = 'desc';
    }
    fof_trace();
    $prefs = fof_prefs();
    $select = "SELECT i.*, f.*, s.subscription_prefs";
    $from = " FROM {$FOF_FEED_TABLE} f, {$FOF_ITEM_TABLE} i, {$FOF_SUBSCRIPTION_TABLE} s";
    if ($what != 'all') {
        $from .= ", {$FOF_TAG_TABLE} t, {$FOF_ITEM_TAG_TABLE} it";
    }
    $where = " WHERE s.user_id = " . $fof_connection->quote($user_id) . " AND s.feed_id = f.feed_id AND f.feed_id = i.feed_id";
    if (!empty($feed)) {
        $where .= " AND f.feed_id = " . $fof_connection->quote($feed);
    }
    if (!empty($when)) {
        $tzoffset = isset($prefs['tzoffset']) ? $prefs['tzoffset'] : 0;
        $whendate = explode('/', $when == 'today' ? fof_todays_date() : $when);
        $when_begin = gmmktime(0, 0, 0, $whendate[1], $whendate[2], $whendate[0]) - $tzoffset * 60 * 60;
        $when_end = $when_begin + 24 * 60 * 60;
        $where .= " AND i.item_published > " . $fof_connection->quote($when_begin) . " AND i.item_published < " . $fof_connection->quote($when_end);
    }
    if ($what != 'all') {
        $tags_q = array();
        foreach (explode(' ', $what) as $tag) {
            $tags_q[] = $fof_connection->quote($tag);
        }
        $where .= " AND it.user_id = s.user_id AND it.tag_id = t.tag_id AND i.item_id = it.item_id AND t.tag_name IN (" . (count($tags_q) ? implode(', ', $tags_q) : "''") . ")";
    }
    if ($what == 'all') {
        $group = "";
    } else {
        $group = " GROUP BY i.item_id HAVING COUNT( i.item_id ) = " . count($tags_q);
    }
    if (!empty($search)) {
        $search_q = $fof_connection->quote('%' . $search . '%');
        $where .= " AND (i.item_title LIKE {$search_q} OR i.item_content LIKE {$search_q} )";
    }
    $order_by = " ORDER BY i.item_published " . strtoupper($order);
    if (is_numeric($start)) {
        $order_by .= " LIMIT " . $start . ", " . (is_numeric($limit) ? $limit : $prefs['howmany']);
    }
    $query = $select . $from . $where . $group . $order_by;
    // fof_log(__FUNCTION__ . " first query: " . $query);
    $statement = $fof_connection->prepare($query);
    $result = $statement->execute();
    $item_ids_q = array();
    $lookup = array();
    /* remember item_id->all_rows mapping, for populating tags */
    $idx = 0;
    while (($row = fof_db_get_row($statement)) !== FALSE) {
        fof_trace("collecting item_id:" . $row['item_id'] . " idx:{$idx}");
        fof_db_subscription_feed_fix($row);
        /* feed prefs are included, so decode them */
        $item_ids_q[] = $fof_connection->quote($row['item_id']);
        $lookup[$row['item_id']] = $idx;
        $all_items[$idx] = $row;
        $all_items[$idx]['tags'] = array();
        $idx += 1;
    }
    $all_items = fof_multi_sort($all_items, 'item_published', $order != "asc");
    $query = "SELECT t.tag_name, it.item_id" . " FROM {$FOF_TAG_TABLE} t, {$FOF_ITEM_TAG_TABLE} it" . " WHERE t.tag_id = it.tag_id" . " AND it.item_id IN (" . (count($item_ids_q) ? implode(',', $item_ids_q) : "''") . ")" . " AND it.user_id = " . $fof_connection->quote($user_id);
    // fof_log(__FUNCTION__ . " second query: " . $query);
    fof_trace('item_ids_q:' . implode(',', $item_ids_q));
    $statement = $fof_connection->prepare($query);
    $result = $statement->execute();
    while (($row = fof_db_get_row($statement)) !== FALSE) {
        $idx = $lookup[$row['item_id']];
        $all_items[$idx]['tags'][] = $row['tag_name'];
    }
    fof_trace("all_items:" . var_export($all_items, true));
    return $all_items;
}
Example #9
0
function fof_render_item($item, $include_div = true)
{
    global $fof_asset;
    global $fof_render_filters;
    $feed_link = fof_render_get_key_($item, 'feed_link');
    if ($feed_link == "[no link]") {
        $feed_link = $item['feed_url'];
    }
    $feed_title = fof_render_get_key_($item, 'display_title');
    if ($feed_title == "[no title]") {
        $feed_title = $feed_link;
    }
    $feed_image = fof_render_get_key_($item, 'display_image', $fof_asset['feed_icon']);
    $feed_description = fof_render_get_key_($item, 'feed_description');
    $item_link = fof_render_get_key_($item, 'item_link');
    $item_id = fof_render_get_key_($item, 'item_id');
    $item_title = fof_render_get_key_($item, 'item_title', '[no title]');
    $item_author = fof_render_get_key_($item, 'item_author', '');
    $item_content = fof_render_get_key_($item, 'item_content');
    $item_read = fof_render_get_key_($item, 'item_read');
    foreach ($fof_render_filters as $filter) {
        $item_content = $filter($item_content);
    }
    $prefs = fof_prefs();
    $offset = fof_render_get_key_($prefs, 'tzoffset') * 60 * 60;
    $item_published = gmdate("Y-n-d g:ia", $item['item_published'] + $offset);
    $item_cached = gmdate("Y-n-d g:ia", $item['item_cached'] + $offset);
    $item_updated = gmdate("Y-n-d g:ia", $item['item_updated'] + $offset);
    if (!empty($_GET['search'])) {
        $item_content = do_highlight("<span>{$item_content}</span>", $_GET['search'], "highlight");
        $item_title = do_highlight("<span>{$item_title}</span>", $_GET['search'], "highlight");
    }
    $tags = fof_render_get_key_($item, 'tags', array());
    $star = in_array("star", $tags) ? true : false;
    $star_image = $star ? $fof_asset['star_on_image'] : $fof_asset['star_off_image'];
    $unread = in_array("unread", $tags) ? true : false;
    $folded = in_array('folded', $tags) ? true : false;
    if ($include_div) {
        echo '<div class="item ' . ($folded ? 'hidden' : 'shown') . '" id="i' . $item_id . '" onclick="return itemClicked(event)">' . "\n";
    }
    ?>

<div class="header">
	<span class="controls">
		<a class="uparrow" href="#" onclick="hide_body('<?php 
    echo $item_id;
    ?>
');return false;">fold &uarr;</a>
		<a class="downarrow" href="#" onclick="show_body('<?php 
    echo $item_id;
    ?>
');return false;">unfold &darr;</a>
		<a href="#" onclick="ajax_mark_read('<?php 
    echo $item_id;
    ?>
'); return false;">mark read</a>
	</span>
	<h1 <?php 
    if ($unread) {
        echo "class='unread-item'";
    }
    ?>
>
		<input type="checkbox"
			   name="c<?php 
    echo $item_id;
    ?>
"
			   id="c<?php 
    echo $item_id;
    ?>
"
			   value="checked"
			   ondblclick="flag_upto('c<?php 
    echo $item_id;
    ?>
');"
			   onclick="return checkbox(event);"
			   title="shift-click or double-click to flag all items up to this one" />
<?php 
    echo '		<img id="fav' . $item_id . '" class="' . ($star ? '' : 'un') . 'starred" src="' . $star_image . '" onclick="return toggle_favorite(' . $item_id . ')" />' . "\n";
    ?>
		<script>
			document.getElementById('fav<?php 
    echo $item_id;
    ?>
').star = <?php 
    if ($star) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
;
		</script>
<?php 
    echo "\t\t<a href=\"{$item_link}\"" . (fof_render_get_key_($prefs, 'item_target') ? ' target="_blank"' : '') . ">{$item_title}</a>\n";
    if ($item_author) {
        echo '<span class="author">' . htmlentities($item_author) . '</span>';
    }
    ?>
	</h1>

	<span class="tags">
<?php 
    /* show non-system tags */
    foreach (array_diff($tags, array('unread', 'star', 'folded')) as $tag) {
        echo '		<a href="' . fof_url('.', array('what' => $tag)) . '">' . htmlentities($tag) . '</a>';
        echo '		<a href="#" class="untag" title="remove ' . htmlentities('"' . $tag . '"') . ' tag" onclick="return remove_tag(' . $item_id . ',' . htmlentities(json_encode($tag), ENT_QUOTES) . ');">[x]</a>' . "\n";
    }
    ?>
		<a href="#" onclick="return itemTagAddShow('<?php 
    echo $item_id;
    ?>
', this);">add tag</a>
		<div id="addtag<?php 
    echo $item_id;
    ?>
" style="display: none !important">
			<input onfocus="this.value=''" onkeypress="itemTagAdd('<?php 
    echo $item_id;
    ?>
', event.keyCode);" type="text" id="tag<?php 
    echo $item_id;
    ?>
" size="12" value="enter tag here" />
			<input type="button" name="add tag" value="tag" onclick="itemTagAdd('<?php 
    echo $item_id;
    ?>
');" />
		</div>
	</span>

	<span class="dash"> - </span>

	<h2>
<?php 
    if ($feed_image && $prefs['favicons']) {
        echo '		<img class="feed-icon" src="' . $feed_image . '" />' . "\n";
    }
    ?>
		<a href="<?php 
    echo $feed_link;
    ?>
" title="<?php 
    echo htmlspecialchars($feed_description);
    ?>
"><?php 
    echo $feed_title;
    ?>
</a>
	</h2>

	<span class="meta published">on <?php 
    echo $item_published;
    ?>
</span>
</div>

<div class="body"><?php 
    echo $item_content;
    ?>
</div>

<?php 
    $widgets = fof_get_widgets($item);
    $widgets[] = '<a href="#" onclick="return ajax_mark_read(\'' . $item_id . '\');">mark read</a>';
    if (!empty($widgets)) {
        echo '<div class="clearer"></div>' . "\n";
        echo '<div class="widgets">';
        foreach ($widgets as $widget) {
            echo '<span class="widget">' . $widget . "</span>";
        }
        echo "</div>\n";
    }
    if ($include_div) {
        echo "</div>\n";
    }
}
Example #10
0
/*
 * This file is part of FEED ON FEEDS - http://feedonfeeds.com/
 *
 * shared.php - display shared items for a user
 *
 *
 * Copyright (C) 2004-2007 Stephen Minutillo
 * steve@minutillo.com - http://minutillo.com/steve/
 *
 * Distributed under the GPL - see LICENSE
 *
 */
include_once "fof-main.php";
include_once "fof-render.php";
$result = fof_get_items($fof_user_id, NULL, "unread", NULL, 0, 10);
$prefs = fof_prefs();
$offset = isset($prefs['tzoffset']) ? $prefs['tzoffset'] : 0;
fof_set_content_type();
?>
<!DOCTYPE html>
<html>

   <head>
      <title>Feed on Feeds</title>
      <meta name = "viewport" content = "width=700">

      <link rel="stylesheet" href="fof.css" media="screen" />
      <?php 
if (is_readable('./fof-custom.css')) {
    ?>
<link rel="stylesheet" href="fof-custom.css" media="screen" /><?php 
Example #11
0
function fof_todays_date()
{
    $prefs = fof_prefs();
    $offset = $prefs['tzoffset'];
    return gmdate("Y/m/d", time() + $offset * 60 * 60);
}