This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pubDateToTimestamp(pubDate) { | |
if (typeof pubDate === "number") { | |
return pubDate; | |
} | |
var date = new Date(pubDate); | |
var pubDateParsed = Math.round(date.getTime() / 1000); | |
if (isNaN(pubDateParsed)) { | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Convert JSONfeed to RSS in a single function as a drop-in to make adding JSONfeed | |
//support to an aggregator easier | |
function convert_jsonfeed_to_rss($content = NULL, $max = NULL) | |
{ | |
//Test if the content is actual JSON | |
json_decode($content); | |
if( json_last_error() !== JSON_ERROR_NONE) return FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Follow redirects to get to the final, good url | |
function get_final_url($url, $timeout = 5, $count = 0) | |
{ | |
$count++; | |
$url = clean_url($url); | |
$ua = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0'; | |
$cookie = tempnam("/tmp", "CURLCOOKIE"); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_USERAGENT, $ua); |