Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Feedburner counter
- function nlt_getFeedCounter($feedid='medicsovet'){
- $output = get_transient('rss_counter');
- if (!isset($output['lastcheck'])) $output['lastcheck'] = 0;
- if (!isset($output['count'])) $output['count'] = 0;
- if (!isset($output['feedid'])) $output['feedid'] = '';
- if ($output['lastcheck'] < (mktime() - 3600) || $output['feedid'] != $feedid) {
- $url = 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $feedid;
- $headers = get_headers($url);
- if (strpos($headers[0], '200')) {
- $xml = file_get_contents($url);
- preg_match('/circulation="(\d+)"/', $xml, $match);
- if ($match[1] != 0) {
- $output['count'] = $match[1];
- $output['lastcheck'] = mktime();
- $output['feedid'] = $feedid;
- set_transient('rss_counter', $output, 60*10 );
- }
- }
- }
- echo $output['count'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement