테스트 사이트 - 개발 중인 베타 버전입니다

소스 수정 문의드립니다. 채택완료

문의무늬 6년 전 조회 1,861

https://sir.kr/g5_tip/3716" rel="nofollow">https://sir.kr/g5_tip/3716

 

위에 팁대로 적용해서 네이버 블로그 최신글을 홈페이지 게시판으로 넘기는데에 성공했습니다.

블로그에 글을 작성할때마다 /get_rss.php 페이지로 가서 포스팅가져오기를 눌러줘야한다는 번거로움이 있습니다. 

자동으로 클릭하지 않아도 업데이트 할 수 있는 방법을 알고싶은데 소스 수정을 어떻게 해야할지 모르겠어서 문의드립니다.

/get_rss.php 소스는 아래와 같습니다.

 

 

</strong></p>

<p><strong><meta charset="utf-8">

<?php

define('_INDEX_', true);

include_once('./_common.php');</strong></p>

<p><strong>if(isset($_GET['rss'])){

    </strong></p>

<p><strong>    include "lib/Snoopy.class.php";

    $snoopy = new Snoopy;</strong></p>

<p>

<strong>    $snoopy->fetch("★★"); //★★ 끌어올 RSS 주소 입력 

    $table = "rss";//★★ 입력할 테이블 이름 입력 

 

     $xml = @simplexml_load_string($snoopy->results);</strong></p>

<p><strong>         foreach ($xml->channel->item as $key) {

            $xml2[]=$key ;

        }

        $xml = array_reverse($xml2);

 

    $all_data=0; //불러온  테이터 갯수 초기화 

    $sec_data=0; //DB에 입력한 데이터 갯수 초기화 </strong></p>

<p><strong>         $wrnum=sql_fetch_array(sql_query("SELECT * FROM `g5_write_".$table."` order by `wr_num`"));

        if($wrnum['wr_num']==""){

            $wrnum['wr_num']= -1;

        }else{

            $wrnum['wr_num']=$wrnum['wr_num']+1;

        }

        /*

        $wrid=sql_fetch_array(sql_query("SELECT * FROM `g5_write_".$table."` order by `wr_id`"));

        if($wrid['wr_id']==""){

            $wrid['wr_id']= 1;

        }

        */</strong></p>

<p><strong>    foreach($xml as $item) {

        $all_data=$all_data+1;</strong></p>

<p><strong>        $chklink_sql="SELECT * FROM `g5_write_".$table."` WHERE `wr_link1`='".$item->link."'"; //이미 불러왔었던 포스팅 인지 확인 -질의문 

        $chk_q=sql_query($chklink_sql);                        //이미 불러왔었던 포스팅 인지 확인 -질의문 쿼리 </strong></p>

<p><strong>        if($chk_q->num_rows<1){                                 //검색결과 합이 1건 이하일때만 db에 입력  

              

            $trans = array("'" => "\"");                    //내용중 기호 ' 가 있으면 " 로 변환 시킴 변환하지 한다고 정의 .

            $contt = strtr($item->description, $trans);        //내용중 기호 ' 가 있으면 " 로 변환 시킴.

            

            $str_date = $item->pubDate;                // 날자 포맷 할거임 

            $date = date("Y-m-d H:t:s", strtotime( $str_date ) );    //Wed, 30 Sep 2015 11:48:17 +0900 => 1900-01-01 12:00:00 이런식으로

                    

              $sql="INSERT INTO `g5_write_".$table."` (

                `wr_num` ,

                `wr_option` ,

                `wr_name` ,

                `wr_subject` ,

                `wr_content` ,

                `wr_link1` ,

                `wr_hit` ,

                `wr_datetime`

                )

                VALUES ('".$wrnum['wr_num']."','html1','".$item->author."','".$item->title."',  '".$contt."',  '".$item->link."','".RAND(1000,4000)."', '".$date."'

                )";</strong></p>

<p><strong>                if(sql_query($sql)){

                      $wr_id = sql_insert_id();

                    sql_query("update `g5_write_".$table."` set wr_parent = '".$wr_id."' ,wr_num = '".-$wr_id."' where wr_id = '".$wr_id."' "); //wr_parent update

                    sql_query("insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '".$table."', '".$wr_id."', '".$wr_id."', '".G5_TIME_YMDHIS."', '".$item->author."' ) "); //new     

                    sql_query("update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '".$table."' "); //write_count ++

                     $sec_data=$sec_data+1;

                     $wrnum['wr_num'] = $wrnum['wr_num']-1 ;

                     /*$wrid['wr_id'] = $wrid['wr_id']+1 ;*/

                 

                };

                

                

        }</strong></p>

<p>

<strong>         

    }

    echo  $msg = "총 불러온 포스팅 [".$all_data."] 건 중 DB에 [".$sec_data."] 건 입력 하였습니다.  ";

    echo "
";

    echo " <a href='".G5_BBS_URL."/board.php?bo_table=".$table."'>게시판으로 가기</a>";

}else{</strong></p>

<p><strong>    echo "<a href='?rss=get'>포스팅 가져오기</a>";

}</strong></p>

<p><strong> ?></strong></p>

<p><strong>

 

 

 

 

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
6년 전

자동으로 뭔가를 하려면 크론 등을 활용하셔야 합니다.

https://sir.kr/g5_plugin/4328

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인