<?php
require($_SERVER['DOCUMENT_ROOT'].'/inc/getallheaders.php');
ob_start("ob_gzhandler");
error_reporting(E_NONE);
$url 'http://www.useit.com/alertbox/';
require(
$_SERVER['DOCUMENT_ROOT'].'/inc/curl.php');
$content open_url($url);
$hash md5($content);
$headers getallheaders();
if ((isset(
$headers["IF_NONE_MATCH"])) && (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 strip_tags($content"<li>,<a>");
$content preg_replace("/(<\/?)(LI|A)([^>]*)(>)/e""'$1'.strtolower('$2').stripslashes(strtolower('$3')).'$4'"$content);
$content preg_match_all("/<li><a href=\"(\w+)\.html\">([^<]+)<\/a> \((\w+) (\d\d?), (\d\d\d\d)\)/"$content$alerts);

header("Content-type: application/xml; encoding=utf-8");

print 
'<?xml version="1.0" encoding="utf-8"?>' "\n";
$offset 10800;
$datefeed date("D, d M Y H:i:s \G\M\T", (time()+$offset));
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>Jakob Nielsen - UseIt.com</title>
  <link>http://www.useit.com/alertbox/</link>
  <lastBuildDate><?php print $datefeed ?></lastBuildDate>
  <dc:creator>Jakob Nielsen</dc:creator>
  <description>Jakob Nielsen's Alertboxes (Provided by &lt;a href=&quot;http://www.brunotorres.net/&quot;&gt; Bruno Torres&lt;/a&gt;, while he doesn't publish an official feed).</description>
  <image>
    <url>http://feeds.feedburner.com/~fc/bt/nielsen?bg=F6F3D5&amp;fg=000000&amp;anim=0</url>
    <title>Jakob Nielsen - UseIt.com</title>
    <link>http://www.useit.com/alertbox/</link>
    <width>88</width>
    <height>26</height>
  </image>
<?php for($i=0$i<10$i++): ?>
  <item>
    <title><?php print $alerts[2][$i]; ?></title>
    <link>http://www.useit.com/alertbox/<?php print $alerts[1][$i?>.html</link>
<?php 
  $seccontent 
open_url("http://www.useit.com/alertbox/".$alerts[1][$i].".html");
  
$seccontent iconv('iso-8859-1''utf-8'$seccontent);
  
$seccontent str_replace("\r"""$seccontent);
  
$seccontent str_replace("\n"""$seccontent);
  
$seccontent str_replace("<h5""<h6"$seccontent);
  
$seccontent str_replace("</h5""</h6"$seccontent);
  
$seccontent str_replace("<h4""<h5"$seccontent);
  
$seccontent str_replace("</h4""</h5"$seccontent);
  
$seccontent str_replace("<h3""<h4"$seccontent);
  
$seccontent str_replace("</h3""</h4"$seccontent);
  
$seccontent str_replace("<h2""<h3"$seccontent);
  
$seccontent str_replace("</h2""</h3"$seccontent);
  
//echo $seccontent; exit;
  //$seccontent = preg_replace("/<\/blockquote>/", "</blockquoteSum>", $seccontent, 1);
  
preg_match("/<\/h1>(.+)<span class=\"cssSmallGray\">/"$seccontent$secmatches);
  
$description $secmatches[1];
  
$date_f date("D, d M Y H:i:s \G\M\T", (strtotime($alerts[3][$i] . ' ' $alerts[4][$i] . ' ' $alerts[5][$i]))+$offset);
  
$date_id date("Y-m-d"strtotime($alerts[3][$i] . ' ' $alerts[4][$i] . ' ' $alerts[5][$i]));
?>
    <pubDate><?php print $date_f ?></pubDate>
    <guid isPermaLink="false">tag:useit.com,<?php print $date_id.':'.(time()*($i+1)) ?></guid>
    <description>
    <![CDATA[
    <?php print $description$secmatches = array(); ?>
    <p><a href="http://www.useit.com/alertbox/<?php print $alerts[1][$i?>.html">Visit the site to read the full alertbox</a> | Feed made by <a href="http://brunotorres.net/">Bruno Torres</a></p>
    <p><small>The contents of this feed is <a href="http://www.useit.com/about/copyright.html">Copyright</a> &copy; 2006 by Jakob Nielsen</small></p>
    <p>Ad: Hosted by <a href="http://brunotorres.net/descontos-dreamhost">Dreamhost</a> (Sign <a href="http://brunotorres.net/descontos-dreamhost">Yearly L1 plan</a> with 50% off using the promo code <strong>BRUNOTORRES</strong>)</p>
    ]]>
    </description>
    <dc:creator>Jakob Nielsen</dc:creator>
    <dc:subject>Alertbox</dc:subject>
  </item>
<?php endfor; ?>
</channel>
</rss>
<?php
header
("ETag: \"$hash\"");
ob_end_flush();
?>