home *** CD-ROM | disk | FTP | other *** search
/ Neil's C++ Stuff / 2014-11-mediatemple-neilstuff.zip / neilo / hn.php < prev    next >
PHP Script  |  2014-11-20  |  1KB  |  29 lines

  1. <?php header('Content-Type: text/html; charset=utf-8');
  2. require('common.php');
  3.  
  4. if ($id = @$_GET['id']) {
  5.  
  6.     $text = HttpGet('http://news.ycombinator.com/item?id=' . $id);
  7.     $text = preg_replace('/<\/?(center|table|td|tr|img|span|font|div)[^>]*>/', '', $text);
  8.     $text = preg_replace('/<u><a href="reply\?id=[^"]+">reply<\/a><\/u><a id=up_[0-9]+ href="vote\?for=[^"]+"><\/a>/', '', $text);
  9.     $text = preg_replace('/[0-9]+ points?/', '<b><u>$0</u></b>', $text);
  10.     $text = preg_replace('/ \| <a href="item\?id=[0-9]+">link<\/a>/', '', $text);
  11.     $text = preg_replace('/<body.*?<span id=down_'.$id.'><\/span>/', '', $text);
  12.     echo($text);
  13.  
  14. } else if ($fnid = @$_GET['fnid']) {
  15.     
  16.     $text = HttpGet('http://news.ycombinator.com/x?fnid='.$fnid);
  17.     $text = str_replace('"item?id=', '"hn.php?id=', $text);
  18.     $text = str_replace('"/x?fnid=', '"hn.php?fnid=', $text);
  19.     echo($text);
  20.  
  21. } else {
  22.     $text = HttpGet('http://news.ycombinator.com/');
  23.     $text = str_replace('"item?id=', '"hn.php?id=', $text);
  24.     $text = str_replace('"/x?fnid=', '"hn.php?fnid=', $text);
  25.     echo($text);
  26. }
  27.  
  28. ?>
  29.