Example #1
0
function get_the_favicon_url()
{
    if (is_favicon_enable()) {
        if (get_favicon_url()) {
            return get_favicon_url();
        } else {
            return get_stylesheet_directory_uri() . '/images/favicon.ico';
        }
    }
}
Example #2
0
 $last_id = isset($_GET['id']) && (int) $_GET['id'] > 0 ? (int) $_GET['id'] : 0;
 $api = new ShaarliApiClient(SHAARLI_API_URL);
 $rows = $api->latest();
 $json = array();
 $json['id'] = 0;
 $json['entries'] = array();
 if ($rows != null) {
     $rows = array_reverse($rows);
     foreach ($rows as $row) {
         if ($row->id > $last_id) {
             $entry = array();
             $content = array();
             $content[] = '<div class="entry">';
             $content[] = '<div class="entry-timestamp">' . date('d/m/Y H:i:s', strtotime($row->date)) . '</div>';
             $content[] = '<a class="entry-shaarli" target="_blank" href="' . @$row->feed->link . '">';
             $content[] = '<img class="favicon" src="' . get_favicon_url($row->feed->id) . '" />' . $row->feed->title . '</a> ';
             $content[] = '<a class="entry-title" target="_blank" href="' . $row->permalink . '">' . $row->title . '</a>';
             $content[] = '<div class="entry-content">' . $row->content . '</div>';
             $content[] = '</div>';
             $entry['content'] = implode($content);
             unset($content);
             $json['entries'][] = $entry;
         }
         if ($row->id > $json['id']) {
             // Max id
             $json['id'] = $row->id;
         }
     }
 }
 $json['count'] = count($json['entries']);
 header('Cache-Control: no-cache, must-revalidate');
Example #3
0
function check_feed_favicon($site_url, $feed)
{
    #		print "FAVICON [$site_url]: $favicon_url\n";
    $icon_file = ICONS_DIR . "/{$feed}.ico";
    if (!file_exists($icon_file)) {
        $favicon_url = get_favicon_url($site_url);
        if ($favicon_url) {
            // Limiting to "image" type misses those served with text/plain
            $contents = fetch_file_contents($favicon_url);
            // , "image");
            if ($contents) {
                // Crude image type matching.
                // Patterns gleaned from the file(1) source code.
                if (preg_match('/^\\x00\\x00\\x01\\x00/', $contents)) {
                    // 0       string  \000\000\001\000        MS Windows icon resource
                    //error_log("check_feed_favicon: favicon_url=$favicon_url isa MS Windows icon resource");
                } elseif (preg_match('/^GIF8/', $contents)) {
                    // 0       string          GIF8            GIF image data
                    //error_log("check_feed_favicon: favicon_url=$favicon_url isa GIF image");
                } elseif (preg_match('/^\\x89PNG\\x0d\\x0a\\x1a\\x0a/', $contents)) {
                    // 0       string          \x89PNG\x0d\x0a\x1a\x0a         PNG image data
                    //error_log("check_feed_favicon: favicon_url=$favicon_url isa PNG image");
                } elseif (preg_match('/^\\xff\\xd8/', $contents)) {
                    // 0       beshort         0xffd8          JPEG image data
                    //error_log("check_feed_favicon: favicon_url=$favicon_url isa JPG image");
                } else {
                    //error_log("check_feed_favicon: favicon_url=$favicon_url isa UNKNOWN type");
                    $contents = "";
                }
            }
            if ($contents) {
                $fp = @fopen($icon_file, "w");
                if ($fp) {
                    fwrite($fp, $contents);
                    fclose($fp);
                    chmod($icon_file, 0644);
                }
            }
        }
        return $icon_file;
    }
}
Example #4
0
function check_feed_favicon($site_url, $feed, $link)
{
    $favicon_url = get_favicon_url($site_url);
    #		print "FAVICON [$site_url]: $favicon_url\n";
    error_reporting(0);
    $icon_file = ICONS_DIR . "/{$feed}.ico";
    if ($favicon_url && !file_exists($icon_file)) {
        $contents = fetch_file_contents($favicon_url);
        $fp = fopen($icon_file, "w");
        if ($fp) {
            fwrite($fp, $contents);
            fclose($fp);
            chmod($icon_file, 0644);
        }
    }
    error_reporting(DEFAULT_ERROR_LEVEL);
}
Example #5
0
<div class="entry">
<div class="entry-timestamp"><?php 
echo date('d/m/Y H:i:s', strtotime($entry->date));
?>
</div>
<a class="entry-shaarli" target="_blank" href="<?php 
echo $entry->feed->link;
?>
"><img class="favicon" src="<?php 
echo get_favicon_url($entry->feed->id);
?>
" /><?php 
echo $entry->feed->title;
?>
</a> <a class="entry-title" target="_blank" href="<?php 
echo $entry->permalink;
?>
"><?php 
echo $entry->title;
?>
</a>
<div class="entry-content"><?php 
echo $entry->content;
?>
</div>
</div>
Example #6
0
function check_feed_favicon($site_url, $feed, $link)
{
    #		print "FAVICON [$site_url]: $favicon_url\n";
    $icon_file = ICONS_DIR . "/{$feed}.ico";
    if (!file_exists($icon_file)) {
        $favicon_url = get_favicon_url($site_url);
        if ($favicon_url) {
            $contents = fetch_file_contents($favicon_url, "image");
            if ($contents) {
                $fp = @fopen($icon_file, "w");
                if ($fp) {
                    fwrite($fp, $contents);
                    fclose($fp);
                    chmod($icon_file, 0644);
                }
            }
        }
    }
}
Example #7
0
?>

<h3>The Network (<?php 
echo count($feeds);
?>
 peoples)</h3>

<?php 
foreach ($feeds as $feed) {
    if (!empty($feed->link) && !empty($feed->title)) {
        ?>
<a class="btn btn-default" target="_blank" href="<?php 
        echo $feed->link;
        ?>
"><img class="favicon" src="<?php 
        echo get_favicon_url($feed->id);
        ?>
" /><?php 
        echo $feed->title;
        ?>
</a> 
<?php 
    }
}
?>

<script type="text/javascript">
document.getElementById('link-network').className+=' btn-primary';
</script>

<?php