<?php

require_once('./lastRSS.php');

if(isSet($_GET["url"]) && $_GET["url"] != ""){
  $url = $_GET["url"];

  $rss = new lastRSS;
  $rss->cache_dir = './rsscache'; 
  $rss->cache_time = 3600;
  $rss->cp = "UTF-8";

  if ($rssArr = $rss->get($url)) {
    $str = "";
    foreach($rssArr['items'] as $row){
      $str .= $row['title'] . "\n";
      $str .= $row['pubDate'] . "\n";
      $str .= $row['link'] . "\n";
      $str .= $row['description'] . "\n\n";
    }
    echo rtrim($str);
  }
  else {
    echo ("error");
  }
}
else{
  echo "error";
}
?>