자유게시판

torr.php RSS 수집 사이트 주소 자동 업데이트

페이지 정보

profile_image
작성자천사 조회 14,202회 작성일 2021-08-04 16:16:26 댓글 0

본문

https://www.clien.net/service/board/cm_nas/16381808?od=T31&po=0&category=0&groupCd=

 

[code]

예, site_domain.php

torr.php와 동일 디렉토리에 생성함

<?PHP
$SITE_DOMAIN = "torr.com";

// 도메인 관리 파일 include
if (file_exists("site_domain.php")) include "site_domain.php";

$CONFIG = array(
    "xxxx" => array(    # 내용
    'https://$SITE_DOMAIN/
    ),

도메인 주소 부분 변수 변경

function check_domain(){
    global $logger;
    global $SITE_DOMAIN;
    while(true){
    // 기존 저장되어 있던 정보로 체크
        list($http_code, $header, $html) = curl_fetch($SITE_DOMAIN);

    // location이 있는데 지금과 다르면 새로운 주소로 loop;
    // location이 있는데 지금과 동일하면 break;
    // location이 없으면 break;
    if (strpos($header,"Location:")!==false){
    // header 정보에서 location 정보 추출
    $newDomain = substr($header, strpos($header, "Location: ") + 10);
    // 지금과 동일 시 break;
    if($newDomain == $oldDomain || $newDomain == $SITE_DOMAIN){
        break;
    // 다르면 site_domain 변경
    }    else {
            $SITE_DOMAIN = $newDomain;
    }
    // location 정보가 없다면 break;
    } else {
        break;
    }
    }
    // loop 후
    if($newDomain !="" && $newDomain != $oldDomain) {
        $cont = "<?PHP\n\$SITE_DOMAIN = \"$SITE_DOMAIN\";";
        // 도메인 관리 파일 include
        $fp = fopen('site_domain.php',"\");
        // 파일에 내용 출력
        fwrite($fp, $cont);
        // 파일 닫기
        fclose($fp);
    }
    }

기존 torr.php 에 추가
function main()
{
    global $logger;
    # 요청 정보 출력
    $logger -> info("torr 버전: " . VERSION);
    $logger -> info("새로운 요청이 들어왔습니다. IP=" . $_SERVER['REMOTE_ADDR']);
    $logger -> info("REQUEST_URI:  " . $_SERVER['REQUEST_URI']);
    $logger -> debug($_SERVER);

    if(isset($_GET['d'])) {
        do_download(base64_decode($_GET['d']));
    }    else {
        check_domain();
        make_rss();
        self_update();
    }
    }

RSS 생성 이전 도메인 주소 확인 후 변경 시 파일 저장 RSS 수집

[/code]

댓글목록

등록된 댓글이 없습니다.

Copyright © Claw’s Lab · blog.batifa.com