3. filename regex 규칙 설정-> x
4. 중복처리
6. 호스트 나누기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | <?php if($_SERVER['REQUEST_URI'] == '/customrss.php'){ echo " <html> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title> 토렌트 rss </title> </head> <body> <h1> 토렌트 rss </h1> <h3>RSS Feed URL : http://localhost/rss.php?[b=<i>카테고리</i>][c=<i>게시물수</i>]&s=<i>검색어</i></h3> <p>사용법</p> <ul> <li>b = [drama : 드라마] or [ent : 예능] or [dacu : 다큐] (생략불가능)</li> <li>c = 숫자값만 허용 (생략시 20)</li> <li>예 : http://localhost/rss.php?b=ent&c=40&s=720p+next</li> </ul> </body> </html> "; exit(); } header("Content-Type: application/rss+xml"); header('Content-Type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>토렌트 RSS</title> <link><?=htmlentities('http://jangom.tistory.com')?></link> <language>ko-kr</language> <pubDate><?=date("Y-m-d H:i:s")?></pubDate> <?php include 'Snoopy.class.php'; include 'db_connect_kim.php'; #검색 if(isset($_GET['s'])){ $k = $_GET['s']; } else { $k = "720p"; } #게시판 구현 x(기본값 예능게시판) $b_all = array("ent","drama","dacu"); if(isset($_GET['b'])){ if(in_array($_GET['b'],$b_all)){ $b = $_GET['b']; } else { echo "<script> alert('b값을 정확히 넣어주세요'); history.back(); </script>"; } } else { echo "<script> alert('b값을 넣어주세요'); history.back(); </script>"; } #페이지 수 -> 보여 줄 레코드 갯수(기본값 20개) if(isset($_GET['c']) && is_numeric($_GET['c'])) { $c=abs($_GET['c']); } else { $c=20; } $board = array( "ent" => "torrent_variety", "drama" => "torrent_tv", "dacu" => "torrent_docu" ); #==== db 업데이트 ====# foreach($b_all as $b_sole){ $url = 'https://torrentkim.pro/bbs/s.php?'.'k='.$k.'&b='.$board[$b_sole]; //print_r($url); $traker = "&tr=udp://tracker.openbittorrent.com:80&tr=http://megapeer.org:6969/announce&tr=http://mgtracker.org:2710/announce&tr=http://tracker.files.fm:6969/announce&tr=http://tracker.flashtorrents.org:6969/announce&tr=http://tracker.mg64.net:6881/announce&tr=http://tracker.nwps.ws:6969/announce&tr=http://tracker.ohys.net/announce&tr=http://tracker.tfile.me/announce&tr=udp://9.rarbg.com:2710/announce&tr=udp://9.rarbg.me:2710/announce&tr=udp://coppersurfer.tk:6969/announce&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://exodus.desync.com:6969/announce&tr=udp://open.coppersurfer.com:1337/announce"; $intlink="magnet:?xt=urn:btih:"; $patten = "/<tr class=\"bg1\">.*Mag_dn\(\'(?<magnet>.*)\'.*\"red\">(?<red>\d{1,2}).*\/(?<id>\d+)\..*\'s\'>(?<title>.*)<.*<\/tr>/Us"; $patten2 = "/작성일 : (?<time>.*)<.*<div id=\"writeContents\">.*(토렌트명: (?<fname1>.*)<li>|en font-16\">(?<fname2>.*)<\/b>)/Us"; $snoopy = new snoopy; $snoopy->fetch("$url"); //echo $url; $html = $snoopy->results; preg_match_all($patten,$html,$trs); //print_r($trs['title']); for($i = 0 ; $i < count($trs['magnet']) ; $i++) { $red = $trs['red'][$i]; $id = $trs['id'][$i]; $magnet = $trs['magnet'][$i]; //echo $red.$id.$magnet; $sql = "select * from $b_sole where magnet='{$magnet}'"; $result = $mysqli->query($sql); //print_r($result); #db에 존재 할 떄 if($result->num_rows){ //echo "if"; #red 값이 존재할 때 if($red != '0'){ //echo "red"; $row = $result->fetch_assoc(); $created = $row['time']; $sql = "insert into del_red ( bo, fname, magnet, link, created, deleted ) "; $sql .= " values( '".$b_sole."' , '". $row['fname'] ."' , '".$row['magnet']."','".$row['link']."','".$created."', now() )"; if($mysqli->query($sql)){ $sql = "delete * from $b_sole where magnet='{$magnet}'"; $mysqli->query($sql); } } else continue; } else{ // if(!$result->num_rows) $sublink = "https://torrentkim.pro/{$board[$b_sole]}/{$id}.html"; //echo #sublink; $snoopy->fetch($sublink); $html = $snoopy->results; preg_match_all($patten2,$html,$subitem); $title = trim($subitem['fname1'][0].$subitem['fname2'][0]); //echo $title; # 파일 정보 업뎃 중 -> 패스 if(!trim($title)){ continue; } #red 값이 존재할 때 if($red != '0'){ $sql = "insert into del_red ( bo, fname, magnet, link, deleted ) "; $sql .= " values( '".$b_sole."' , '".htmlentities($title)."' , '".$magnet."','".$id."', now() )"; $mysqli->query($sql); continue; } //$time = $subitem['time'][0]; $sql = "insert into $b_sole (fname, magnet, link, time) "; $sql .= "values('$title', '$magnet', '$id' ,now())"; $result = $mysqli->query($sql); } // end if(!$result->num_rows) } //end for($i = 0 ; $i<$count ; $i++) } //end foreach($b_all as $b_sole) #==== rss 생성 ====# $sql = "select * from $b order by id desc limit {$c}"; $result = $mysqli->query($sql); //print_r($result); //$row = $result->fetch_assoc(); while($row = $result->fetch_assoc()){ $magnetlink = $intlink.$row['magnet'].'&dn='.myUrlEncode($row['fname']).$traker; echo "<item> <title>".$row['fname']."</title> <link>".htmlentities($magnetlink)."</link> <guid isPermaLink=\"false\">".htmlentities($row['magnet'])."</guid> <pubDate>".$row['time']."</pubDate> </item>"; //date("y-m-d H:i") } $result->free(); $mysqli->close(); # function to encode URLs according to RFC 3986. function myUrlEncode($string) { $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'); $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]"); return str_replace($entities, $replacements, urlencode($string)); } ?> </channel> </rss> | cs |
'php' 카테고리의 다른 글
토렌트 광고 회피하기 (0) | 2018.04.02 |
---|---|
$result (0) | 2018.03.29 |
count(*) mysqli 값이 하나만 나올때 (0) | 2018.03.29 |
php 변수 $_SERVER 값 추출 (0) | 2018.03.29 |
$_SERVER['REMOTE_ADDR']가 ::1 로 뜰때 (0) | 2018.03.29 |