<?php
header("Content-Type:text/xml");

$lines = file("feeds.txt");

$nats = $_GET["nats"];
$amt = $_GET["amt"];

function writeXML ($name, $description, $url, $thumb, $date, $nats) {
  $XML .= "<item>
           <title>$description</title>
           <pubDate>$date</pubDate>
           <author>Penthouse Mike &lt;Sales@PenthousePartners.com&gt;</author>
           <guid isPermaLink=\"true\">$url$nats/</guid>
           <link>$url$nats/</link>
           <comments>$url$nats/</comments>
           <description>
           <![CDATA[
           <table cellspacing=10 cellpadding=0 border=0>
           <tr>
           <td width=100 height=150 valign=\"top\"><a href=\"$url$nats/\" target=\"_blank\"><img alt=\"$name\" src=\"$thumb\" border=\"1\" height=\"150\" width=\"100\" align=\"left\"></a></td>
           <td valign=\"top\">$description</td> 
           </tr>
           <tr>
           <td colspan=2><a href=\"$url$nats/\" target=\"_blank\">Click to See More Penthouse Pics of $name</a></td>
           </tr>
           </table>
           ]]>
           </description>
           </item>\n";
  return $XML;
}

if ($nats == "") {
  $nats = "MzozOjE";
}
$XML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
        <rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">
        <channel>
        <title>Latest Galleries at Penthouse.com</title>
        <link>http://www.penthouse.com/?nats=$nats</link>
        <description>Latest Gallery Updates</description>
        <image>
        <url>http://nats.penthousepartners.com/images/v2-members/penthouseLogo.gif</url>
        <title>Penthouse.com</title>
        <link>http://www.penthouse.com/?nats=$nats</link>
        </image>
        <language>en-us</language>\n";

if ($amt>1 && is_numeric($amt)) {
  for ($i=0;$i<$amt;$i++) {
    list($name, $description, $url, $thumb, $date) = split("\|",$lines[$i]);
    $name = trim($name);
    $description = trim($description);
    $url = trim($url);
    $thumb  = trim($thumb);

    $XML .= writeXML($name, $description, $url, $thumb, $date, $nats);
  }
}
else {
  for ($i=0;$i<count($lines);$i++) {
    list($name, $description, $url, $thumb, $date) = split("\|",$lines[$i]);
    $name = trim($name);
    $description = trim($description);
    $url = trim($url);
    $thumb  = trim($thumb);

    $XML .= writeXML($name, $description, $url, $thumb, $date, $nats);
  }
}
$XML .= "</channel>\n</rss>";
print $XML;
?>
