<?php
require($_SERVER['DOCUMENT_ROOT'].'/inc/getallheaders.php');
ob_start("ob_gzhandler");
$url 'http://mondo.happytreefriends.com/watch_episodes/episode_index.js';
require(
$_SERVER['DOCUMENT_ROOT'].'/inc/curl.php');
$content open_url($url);
$hash md5($content);
$headers getallheaders();
if (
ereg($hash$headers["If-None-Match"])){
    
header("HTTP/1.1 304 Not Modified");
    
ob_end_clean();
    exit();
}
@include_once(
$_SERVER["DOCUMENT_ROOT"]."/shortstat/inc.stats.php");
$content iconv('iso-8859-1''utf-8'$content);
$content str_replace("\r"""$content);
$content str_replace("<br>\n""<br>"$content);
$content preg_replace("/\+ '(.+)'/""$1"$content);
$content str_replace("\\n"""$content);
$content str_replace("'\n"""$content);
$content str_replace("\n"""$content);
$content str_replace("</tr>""</tr>\n"$content);
$content str_replace("// JavaScript Documentvar content = '"" "$content);
$content str_replace(";document.write(content);"""$content);
$content preg_replace("/  */"" "$content);
$content str_replace("class=\"episodeTHUMB\">""class=\"episodeTHUMB\">\n" $content);
$content stripslashes($content);
//print $content; exit;
preg_match_all("/<img src=\"([^\"]+)\" alt=\"([^\"]+)\" name=\"episode\" width=\"([^\"]+)\" height=\"([^\"]+)\" border=\"([^\"]+)\" class=\"episodeTHUMB\">/"$content$matches);
//print_r($matches); exit;

//preg_match_all("/usemap=\"([^\"]+)\"/", $content, $matches2);

//print_r($matches2); exit;

$url 'http://mondo.happytreefriends.com/watch_episodes/episode_map.js';
$content open_url($url);

$content iconv('iso-8859-1''utf-8'$content);
$content str_replace("\r"""$content);
$content str_replace("<br>\n""<br>"$content);
$content preg_replace("/\+ '(.+)'/""$1"$content);
$content str_replace("\\n"""$content);
$content str_replace("'\n"""$content);
$content str_replace("\n"""$content);
$content str_replace("</tr>""</tr>\n"$content);
$content str_replace("// JavaScript Documentvar content = '"" "$content);
$content str_replace(";document.write(content);"""$content);
$content preg_replace("/  */"" "$content);
$content str_replace("class=\"episodeTHUMB\">""class=\"episodeTHUMB\">\n" $content);
$content stripslashes($content);

preg_match_all("/play\d+\.asp\?episode=([^']+)/"$content$matches2);

//print_r($matches2); exit;

header("Content-type: application/xml; encoding=utf-8");
print 
'<?xml version="1.0" encoding="utf-8"?>' "\n";
?>
<rss version="2.0">
<channel>
  <title>Happy Tree Friends</title>
  <link>http://happytreefriends.atomfilms.com/</link>
  <ttl>60</ttl>
  <description>Cute, cuddly, and horribly wrong... It's the Happy Tree Friends! They may be sugary sweet but there's no way they'll escape their horrible fate! What chaos will these critters experience next? (Feed made by &lt;a href=&quot;http://www.brunotorres.net/&quot;&gt; Bruno Torres&lt;/a&gt;)</description>
  <language>en-us</language>
  <image>
    <url>http://feeds.feedburner.com/~fc/bt/happytreefriends?bg=F6F3D5&amp;fg=000000&amp;anim=0</url>
    <title>Happy Tree Friends</title>
    <link>http://mondo.happytreefriends.com/</link>
    <width>88</width>
    <height>26</height>
  </image>
<?php for ($i 0$i sizeof($matches[1]); $i++): ?>
  <?php
    $epname 
explode('/'$matches[1][$i]);
    
$epname explode('.'$epname[1]);
    
$epname $epname[0];
    
$epname str_replace("ep_sm_"""$epname);
  
?>
  <item>
    <title><?php print $matches[2][$i]; ?></title>
    <link>http://mondo.happytreefriends.com/watch_episodes/flash/loader_movie.swf?episode=<?php print $epname?></link>
    <description><![CDATA[<div>
      <p><a href="http://mondo.happytreefriends.com/watch_episodes/flash/loader_movie.swf?episode=<?php print $epname?>"><img src="http://mondo.happytreefriends.com/watch_episodes/<?php print $matches[1][$i]; ?>" width="64" height="64" border="0" alt="<?php print $matches[2][$i]; ?>" /></a></p>
    </div>]]></description>
  </item>
<?php endfor; ?>
</channel>
</rss>
<?php
header
("ETag: \"$hash\"");
ob_end_flush();
?>