서버 점검 안내

dsclub은 서비스의 안정성과 성능 향상을 위해
매일 04시 30분에 정기 점검이 진행됩니다.

점검 시간: 오전 4시 30분 ~ 4시 35분

해당 시간 동안 일시적으로 서비스에 접속이 불가능하오니, 양해 부탁드립니다.

다른 사이트(로컬)의 파일을 클라이언트가 설치할 수 있게 해주는 php 코드 예제 > 코딩 스토리

다른 사이트(로컬)의 파일을 클라이언트가 설치할 수 있게 해주는 php 코드 예제

페이지 정보

작성자  (192.♡.0.1) 작성일 23-07-20 23:02 조회 5,238 댓글 1

본문

[code]

function downloadRemoteFile($url, $filename) {

    $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';

    $referer = 'https://www.google.com/';


    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);

    curl_setopt($ch, CURLOPT_REFERER, $referer);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $data = curl_exec($ch);


    if (curl_errno($ch)) {

        curl_close($ch);

        return false;

    }


    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    curl_close($ch);


    if ($status_code == 200) {

        header('Content-Description: File Transfer');

        header('Content-Type: application/octet-stream');

        header('Content-Disposition: attachment; filename="' . $filename . '"');

        header('Content-Transfer-Encoding: binary');

        header('Expires: 0');

        header('Content-Length: ' . strlen($data));


        echo $data;

        return true;

    } else {

        return false;

    }

}


// 다운로드할 PHP 파일의 URL

$phpFileUrl = 'http://example.com/path/to/remote_php_file.php';


// 클라이언트가 다운로드할 때 사용되는 파일명

$clientFileName = 'downloaded_file.php';


if (downloadRemoteFile($phpFileUrl, $clientFileName)) {

    echo '파일 다운로드 성공: ' . $clientFileName;

} else {

    echo '파일 다운로드 실패';

}

?>

[/code]
사이트의 접속 또는 다운로드 차단을 회피할 수 있고, 사진 동영상 html, js, css 파일 정도를 다운로드 할 수 있을 것으로 예상됨
좋아요57 이 글을 좋아요하셨습니다
url 복사 카카오톡 공유 라인 공유 페이스북 공유 트위터 공유

2kat님의 댓글

no_profile 2kat 아이피 (220.♡.000.000) 작성일

좋네요

전체 269건
게시물 검색

접속자집계

오늘
1,339
어제
1,445
최대
4,271
전체
292,249