" || $file_contents != "") { file_put_contents($xml[$i]['feed_local'], $file_contents); } curl_close($ch); } function feed_add($feed_url, $feed_increment, $feed_name, $feed_local, $num) { $sql = "INSERT INTO " . $table_prefix . "feeds(feed_id, feed_url, feed_increment, feed_name, feed_local, num) VALUES ( '', '" . $feed_url . "', '" . $feed_increment . "', '" . $feed_name . "', '" . $feed_local . "', " . $num . ")"; $result = sqlquery($sql); $output = "Feed " . $feed_name . " successfully added. "; return $output; } function get_feed($feed_id = 777) { $now = time(); $xml = get_feed_data($feed_id); if($feed_id == 777) { for($k=0; $k strtotime($xml[$k]['feed_increment'], filectime($xml[$k]['feed_local']))) { grab_feed($xml, $k); } else { $time[$k] = round(date("U", strtotime($xml[$k]['feed_increment'], filectime($xml[$k]['feed_local'])) - time()) / 60, 2) . " minutes"; } } else { grab_feed($xml, $k); } } } } function get_feed_data($feed_id = 777) { global $table_prefix; if($feed_id == 777) { $sql = "SELECT * from " . $table_prefix . "feeds"; $result = sqlquery($sql); if(mysql_num_rows($result) != 0) { $i = 0; while($xmlresult = mysql_fetch_assoc($result)) { if(filesize($xmlresult['feed_local']) != 0) { $xml[$i]['feed_id'] = $xmlresult['feed_id']; $xml[$i]['feed_url'] = $xmlresult['feed_url']; $xml[$i]['feed_increment'] = $xmlresult['feed_increment']; $xml[$i]['feed_name'] = $xmlresult['feed_name']; $xml[$i]['feed_local'] = $xmlresult['feed_local']; $xml[$i]['num'] = $xmlresult['num']; $i++; } } } } return $xml; } function output_feed($feed_id = 777, $view = "composite") { $xml = get_feed_data($feed_id); if($view == "list") { if($feed_id == 777) { for($h=0; $h\n

" . $xml[$h]['feed_name'] . "

\n

next update: " . $time[$h] . "

\n"; } } else { if($icon != "") { $output .= "
\n

" . $xml[$h]['feed_name'] . "

\n

next update: " . $time[$h] . "

\n"; } } $output .= "
    "; for($j=0; $j<$xml[$h]['num']; $j++) { if(isSet($latest)) { if(!isSet($latest->channel->item[$j])) { if(!isSet($latest->item[$j]->title) && $xml[$i]['feed_name'] == "AudioScrobbler") { $latest->item[$j]->title = $latest->item[$j]->description; } else if (preg_match("/audioscrobbler/i", $xml[$h]['feed_url']) && !isSet($latest->item[$j]->title)) { $latest->item[$j]->title = "Untitled Item"; } $output .= "
  • item[$j]->link . "\">" . $latest->item[$j]->title . "
  • \n"; } else { if(!isSet($latest->channel->item[$j]->title) && $xml[$i]['feed_name'] == "AudioScrobbler") { $latest->channel->item[$j]->title = $latest->channel->item[$j]->description; } else if (preg_match("/audioscrobbler/i", $xml[$h]['feed_url']) && !isSet($latest->channel->item[$j]->title)) { $latest->item[$j]->title = "Untitled Item"; } $output .= "
  • channel->item[$j]->link . "\">" . $latest->channel->item[$j]->title . "
  • \n"; } } } $output .= "
\n\n"; } } } } else if($view == "composite") { $latest = simplexml_merge($xml); print_r($latest); } return $output; } function simplexml_merge ($xml) { for($i=0;$ichannel->item)) { $items[$i] = $xml_file[$i]->channel->item; if(isSet($xml_file[$i]->channel->item[0]->pubDate)) { $dates[$i] = strtotime($xml_file[$i]->channel->item[0]->pubDate); } else if(isSet($xml_file[$i]->channel->item[0]->date)) { /* ** The Dublin core's default data format uses ISO 8601 which can't ** be parsed directly using PHP's strtotime(). It is not the only ** valid format so this might fail nonetheless ... */ list($year, $month, $day, $hour, $minute, $second) = sscanf($xml_file[$i]->item[0]->date, "%4d-%2d-%2dT%2d:%2d:%2d"); echo($xml_file[$i]->item[0]->date); $dates[$i] = strtotime("$year-$month-$day $hour:$minute:$second"); } else { $dates[$i] = strtotime($xml_file[$i]->channel->item[0]->title); //xanga } } else if(isSet($xml_file[$i]->item)) { $items[$i] = $xml_file[$i]->item; if(isSet($xml_file[$i]->item[0]->pubDate)) { $dates[$i] = strtotime($xml_file[$i]->channel->item[0]->pubDate); } else if(isSet($xml_file[$i]->item[0]->date)) { /* ** The Dublin core's default data format uses ISO 8601 which can't ** be parsed directly using PHP's strtotime(). It is not the only ** valid format so this might fail nonetheless ... */ echo($xml_file[$i]->item[0]->date); list($year, $month, $day, $hour, $minute, $second) = sscanf($xml_file[$i]->item[0]->date, "%4d-%2d-%2dT%2d:%2d:%2d"); $dates[$i] = strtotime("$year-$month-$day $hour:$minute:$second"); } else { $dates[$i] = strtotime($xml_file[$i]->item[0]->title); //xanga } } } } ?>