header('Content-type: text/xml');
// $sec_id= $_GET['sec_id'];
$page= $_GET['page'];
// $title = array("港聞","國際","財經","娛樂","體育","潮流","科技","家庭","名彩","豪情");
//------Update:2009-05-11-------------//
$title = array("港聞","國際","財經","娛樂","體育","飲食","旅遊","科技","消費","文化","汽車","親子","名采","豪情");
$heads = array("4104","15335","15307","462","25391","12187363","12187369","12187373","12187376","12187379","12187383","12187386","12187389","12187396");
if (!$page) { $page=0;}
$sec_id= $heads[$page];
//-----------------------------------------//
$hkline=file_get_contents("http://hk.nextmedia.com");
$hkline = eregi("iss_id=([0-9]+)&sec_id",$hkline,$matches);
$date = $matches[1];
echo '';
echo '';
echo '';
?>
生果 echo $title[$page]; ?>
http://www.fruitdaily.net
Fruit Daily Rss
echo date("D, d M Y H:i:s T");?>
echo date("D, d M Y H:i:s T");?>
if($page > 4){
//------Add on:2009-05-11-------------//
$checkurl = get_headers("http://hk.apple.nextmedia.com/template/apple_sub/cache/$date/sec_art_$sec_id.js");
if ($checkurl[0] == 'HTTP/1.1 200 OK') {
$requesturl = "http://hk.apple.nextmedia.com/template/apple_sub/cache/$date/sec_art_$sec_id.js";
}else{
$item =' -
' . $title[$page] . '
今天沒有刊出 ' .$title[$page] . '版
' . $date . '
';
echo $item;
}
//-----------------------------------------//
// $requesturl = "http://hk.apple.nextmedia.com/template/apple_sub/cache/$date/sec_art_$sec_id.js";
}else{
$requesturl = "http://hk.apple.nextmedia.com/template/apple/cache/$date/sec_art_$sec_id.js";
}
if ($fp = fopen("$requesturl", "r"))
{
while(!feof($fp))
{
$line = fgets($fp,256);
if (eregi("^sub_title",$line))
{
$line = ereg_replace("[:\", ]","",$line);
$line = ereg_replace("sub_title","",$line);
$title = eregi_replace("\\\"",'"',$line);
}
if (eregi("^art_id",$line))
{
$line = ereg_replace("[:\",\\]","",$line);
$article_id = ereg_replace("art_id","",$line);
feedItems($title, $article_id);
}
}
fclose($fp);
}
echo '';
function feedItems($title, $art_id)
{
global $date;
$item = ' -
' . $title . '
' . feedContent(trim($art_id)) . '
' . $date . $art_id . '
';
echo $item;
}
function feedContent($art_id)
{
global $date, $page;
if ($page > 4)
$hkline = file_get_contents("http://202.85.162.120/template/apple_sub/cache/$date/art_$art_id.xml");
else
$hkline = file_get_contents("http://202.85.162.120/template/apple/cache/$date/art_$art_id.xml");
$reader = new XMLReader();
$reader->XML(utf8_encode($hkline));
$content = "";
while ($reader->read())
{
if($reader->nodeType == XMLReader::ELEMENT)
{
if ($reader->getAttribute("name") == "content" || $reader->getAttribute("name") == "caption")
{
$reader->read();
$reader->read();
$text = utf8_decode($reader->value);
if(strlen($text) > 1)
$content .= $text . "
";
}
else if ($reader->getAttribute("name") == "image_path")
{
$reader->read();
$reader->read();
$content .= 'value) . ">
";
}
else if ($reader->getAttribute("name") == "sub_head")
{
$reader->read();
$reader->read();
$text = utf8_decode($reader->value);
if(strlen($text) > 1)
$content .= "
" . $text . "
";
}
else if ($reader->getAttribute("name") == "intro")
{
$reader->read();
$reader->read();
$content .= '
' . utf8_decode($reader->value) . "
";
}
/*
else if ($reader->getAttribute("name") == "title")
{
$reader->read();
$reader->read();
$title = "" . utf8_decode($reader->value) . "
";
}*/
}
}
$reader->close();
$item_date = substr($date,0,4)."年".substr($date,4,2)."月".substr($date,6,2)."日";
return "";
}
?>