메뉴 건너뛰기

app

[RSS] 파싱 주요 함수 - feedonfeeds_0.1.9

박영식2007.07.29 17:42조회 수 7583댓글 0

    • 글자 크기

http://suritam9.woweb.net/www/php/zb41/view.php?id=php&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=27

위의 url을 참고

function fof_update_feed($url)
{
   global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;


   if(!$url) return 0;


   $rss = fetch_rss( $url );


   if(!$rss)
   {
      print "Error: <B>" . magpie_error() . "</b> ";
      print "<a href="http://feeds.archive.org/validator/check?url=$url">try to validate it?</a> ";
      return 0;
   }


   $title = mysql_escape_string($rss->channel['title']);
   $link = $rss->channel['link'];
   $description = mysql_escape_string($rss->channel['description']);
   $safeurl = mysql_escape_string( $url );
   $result = fof_do_query("select id, url from $FOF_FEED_TABLE where url='$safeurl'");


   $row = mysql_fetch_array($result);
   $feed_id = $row['id'];


   $items = $rss->items;


   foreach ($items as $item)
   {
      $link = mysql_escape_string($item['link']);
      $title = mysql_escape_string($item['title']);
      $content = mysql_escape_string($item['description']);


      if($item['content']['encoded'])
      {
         $content = mysql_escape_string($item['content']['encoded']);
      }


      if($item['atom_content'])
      {
         $content = mysql_escape_string($item['atom_content']);
      }


      $dcdate = mysql_escape_string($item['point']['x']);
      $dccreator = mysql_escape_string($item['author']);
      $dcsubject = mysql_escape_string($item['address']);


      if(!$link)
      {
         $link = $item['guid'];
      }


      if(!$title)
      {
         $title = "[no title]";
      }


      $result = fof_do_query("select id from $FOF_ITEM_TABLE where feed_id='$feed_id' and link='$link'");
      $row = mysql_fetch_array($result);
      $id = $row['id'];


      if(mysql_num_rows($result) == 0)
      {
         $n++;
         $sql = "insert into $FOF_ITEM_TABLE (feed_id,link,title,content,dcdate,dccreator,dcsubject) values ('$feed_id','$link','$title','$content','$dcdate','$dccreator','$dcsubject')";
         $result = fof_do_query($sql);
      }
      else
      {
         $ids[] = $id;
      }


   }


   if(defined('FOF_KEEP_DAYS'))
   {
      $keep_days = FOF_KEEP_DAYS;


      if(count($ids) != 0)
      {
         $first = 1;


         foreach ($ids as $id)
         {
            if($first)
            {
               $stat = "($id";
               $first = 0;
            }
            else
            {
               $stat .= ", $id";
            }
         }


         $stat .= ")";


         $sql =  "delete from $FOF_ITEM_TABLE where feed_id = $feed_id and `read`=1 and id not in $stat and to_days( CURDATE(  )  )  - to_days( timestamp )  > $keep_days";



         fof_do_query($sql);
      }
   }


   return $n;
}

박영식 (비회원)
    • 글자 크기
[PSpise] DCsweep 과 가변저항 (by 박영식) [flash] loadmovie(), other size (by 박영식)

댓글 달기

박영식
2010.09.09 조회 4980
박영식
2010.05.25 조회 4397
박영식
2010.01.14 조회 5176
박영식
2009.09.21 조회 4370
박영식
2008.08.18 조회 6290
박영식
2008.08.17 조회 4479
박영식
2008.07.24 조회 4958
박영식
2008.07.23 조회 8248
박영식
2008.07.22 조회 3562
박영식
2008.04.11 조회 2416
박영식
2008.01.20 조회 2266
박영식
2007.12.23 조회 3430
첨부 (0)
위로