글 삭제

작성자 본인만 삭제할 수 있습니다

← 홈으로
2023.07.20 · 조회 9,652
다른 사이트(로컬)의 파일을 클라이언트가 설치할 수 있게 해주는 php 코드 예제
<p>[code]</p><p><!--?php</p--></p><p>function downloadRemoteFile($url, $filename) {</p><p>&nbsp; &nbsp; $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';</p><p>&nbsp; &nbsp; $referer = 'https://www.google.com/';</p><p><br></p><p>&nbsp; &nbsp; $ch = curl_init();</p><p>&nbsp; &nbsp; curl_setopt($ch, CURLOPT_URL, $url);</p><p>&nbsp; &nbsp; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);</p><p>&nbsp; &nbsp; curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);</p><p>&nbsp; &nbsp; curl_setopt($ch, CURLOPT_REFERER, $referer);</p><p>&nbsp; &nbsp; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);</p><p>&nbsp; &nbsp; $data = curl_exec($ch);</p><p><br></p><p>&nbsp; &nbsp; if (curl_errno($ch)) {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; curl_close($ch);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; return false;</p><p>&nbsp; &nbsp; }</p><p><br></p><p>&nbsp; &nbsp; $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);</p><p>&nbsp; &nbsp; curl_close($ch);</p><p><br></p><p>&nbsp; &nbsp; if ($status_code == 200) {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; header('Content-Description: File Transfer');</p><p>&nbsp; &nbsp; &nbsp; &nbsp; header('Content-Type: application/octet-stream');</p><p>&nbsp; &nbsp; &nbsp; &nbsp; header('Content-Disposition: attachment; filename="' . $filename . '"');</p><p>&nbsp; &nbsp; &nbsp; &nbsp; header('Content-Transfer-Encoding: binary');</p><p>&nbsp; &nbsp; &nbsp; &nbsp; header('Expires: 0');</p><p>&nbsp; &nbsp; &nbsp; &nbsp; header('Content-Length: ' . strlen($data));</p><p><br></p><p>&nbsp; &nbsp; &nbsp; &nbsp; echo $data;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; return true;</p><p>&nbsp; &nbsp; } else {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; return false;</p><p>&nbsp; &nbsp; }</p><p>}</p><p><br></p><p>// 다운로드할 PHP 파일의 URL</p><p>$phpFileUrl = 'http://example.com/path/to/remote_php_file.php';</p><p><br></p><p>// 클라이언트가 다운로드할 때 사용되는 파일명</p><p>$clientFileName = 'downloaded_file.php';</p><p><br></p><p>if (downloadRemoteFile($phpFileUrl, $clientFileName)) {</p><p>&nbsp; &nbsp; echo '파일 다운로드 성공: ' . $clientFileName;</p><p>} else {</p><p>&nbsp; &nbsp; echo '파일 다운로드 실패';</p><p>}</p><p>?&gt;</p><div>[/code]</div><div>사이트의 접속 또는 다운로드 차단을 회피할 수 있고, 사진 동영상 html, js, css 파일 정도를 다운로드 할 수 있을 것으로 예상됨</div>
삭제된 게시글은 복구할 수 없습니다