2008年8月12日 星期二

Time php v 1.1

Time 雜誌網頁 格式有少許更動
昨晚我把原來的程式也更新了
內定 time.php 為 U.S. edition

time.php?edition=asia  為亞洲版
分兩個檔案:

time.php

  1. <?
  2.     header('Content-type:text/html; charset=utf-8');
  3.     $edtion = $_GET['edition'];
  4.     $link = "http://www.time.com/time/magazine";
  5.     $dirlink = dirname($link);
  6.     $mylogo = "<img src=http://static.flickr.com/60/219160214_e6ed15d559_o.gif> <br>\r\n<font size=\"2\">time.php v1.1</font>";
  7.     $content = file_get_contents($link);
  8.     preg_match('/<!-- toc_masterhed -->(.*?)<\/ul>/s',$content,$edt);
  9.     $edition = $edt[1];
  10.     preg_match_all('/img src=\"(.*?)jpg/s',$edition,$cv);
  11.     preg_match_all('/<a href=\"(.*?)\"/s',$edition,$el);
  12.     $uscover = $cv[1][0].'jpg';
  13.     $asiacover = $cv[1][2].'jpg';
  14.     $uslink = $link;
  15.     $asialink = $el[1][1];
  16.     $link = $uslink;
  17.     $cover = $uscover;
  18.     if ($edtion == 'asia'){
  19.         $link = $dirlink.'/..'.$asialink;
  20.         $cover = $asiacover;
  21.     }
  22.     $content = file_get_contents($link);
  23.     preg_match("/<title>(.*)<\/title>/is",$content,$head);
  24.     $line = $head[0];
  25.     $line .= "<b>$head[1]</b><br><img src=$cover>\r\n<hr>\r\n";
  26.     preg_match_all("/<div class=\"toc_seched\">(.*?)<\/div></is",$content,$matches);
  27.     $z = count($matches[0]);
  28.     for ($i=0;$i<$z;$i++){
  29.         $area = $matches[0][$i];
  30.         preg_match("/<div class=\"toc_seched\">(.*?)<\/div>/is",$area,$h);
  31.         $line .= "<br>\r\n<b><font color=red>$h[1]</font></b><br>\r\n<ul>\r\n";
  32.         preg_match_all("/<a class=(.*?)<br \/>/is",$area,$t);
  33.             for ($j=0;$j<count($t[0]);$j++){
  34.                 $title = $t[0][$j];
  35.                 $title = eregi_replace("<br />","",$title);
  36.                 $title = eregi_replace('/time/','time_view.php?link=http://www.time.com/time/',$title);
  37.                 $line .= "<li>$title</li>\r\n";
  38.             }
  39.             $line .= "</ul><br>\r\n";
  40.     }
  41.     $line .= "<hr>\r\n$mylogo";
  42.     echo $line;
  43. ?>




time_view.php

  1. <?
  2.     header('Content-type:text/html; charset=utf-8');
  3.     $link = $_GET['link'];
  4.     $mylogo = "<img src=http://static.flickr.com/60/219160214_e6ed15d559_o.gif> <br>\n<font size=\"2\">time.php v1.1</font>";
  5.     $content = file_get_contents($link);
  6.     preg_match("/<head>(.*?)<\/head>/is",$content,$css);
  7.     preg_match("/<!-- Begin Tout1 -->(.*)<!-- End Tout1 -->/is",$content,$pix);
  8.     preg_match("/<div class=\'print\'><a href=\'(.*?)\'/is",$content,$nl);
  9.     preg_match("/<div class=\"print\"><a href=\"(.*?)\"/is",$content,$nl2);
  10.     if ($nl[1]||$nl2[1]){
  11.         $newlink = $nl[1];
  12.         $newlink .= $nl2[1];
  13.         $newlink = 'http://www.time.com/'.$newlink;
  14.         $newlink = eregi_replace('"',"",$newlink);
  15.         $content = file_get_contents($newlink);
  16.     }
  17.     preg_match("/<title>(.*?)<\/title>/is",$content,$t);
  18.     $title = $t[0];
  19.     $title = eregi_replace("printout","",$title);
  20.     preg_match("/<!-- Begin Tout1 -->(.*?)<!-- Begin Buttons -->/is",$content,$a);
  21.     $area = $a[1];
  22.     $line = $title."\r\n";
  23.     $line .= $area;
  24.     $allowed_tags = "<b>,<p>,<div>,<h1>,<span>,<title>,<br>,<hr>,<img>,<font>";
  25.     $line = strip_tags($line, $allowed_tags);
  26.     $line .=$pix[0];
  27.     $line = preg_replace('/<div id=\"copy\">(.*?)<\/span>/s','',$line);
  28.     $line = preg_replace('/<div class=\"enlarge\">(.*?)<\/div>/s','',$line);
  29.     $line = preg_replace('/<a id=\"enlargeImg\"(.*?)>/s','',$line);
  30.     $line = eregi_replace('a_','',$line);
  31.     $line = preg_replace('/width=(.*?)\//s','/',$line);
  32.     $line .= "<hr>\r\n$mylogo";
  33.     echo $line;
  34. ?>

Webmaster Tools - Advanced

 

U.S. edition 演示

Asia edition 演示

沒有留言:

張貼留言