Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('simple_html_dom.php');
- function RUtreker($query){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://rutracker.org/forum/login.php');
- curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=free32&login_password=zxcvbq251&login=%E2%F5%EE%E4");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_COOKIESESSION, true);
- curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name'); //could be empty, but cause problems on some hosts
- curl_setopt($ch, CURLOPT_COOKIEFILE, '/'); //could be empty, but cause problems on some hosts
- $answer = curl_exec($ch);
- if (curl_error($ch)) {
- echo curl_error($ch);
- }
- //another request preserving the session
- $df = urlencode(iconv('UTF-8','CP1251',$query));
- curl_setopt($ch, CURLOPT_URL, 'https://rutracker.org/forum/tracker.php?nm='.$df);
- curl_setopt($ch, CURLOPT_POST, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "");
- $answer = curl_exec($ch);
- $re = '/<tr class="tCenter hl-tr">(.*?)<\/tr>/s';
- preg_match_all($re, $answer, $matchesR);
- foreach ($matchesR[0] as $key => $rut) {
- $html = str_get_html($rut);
- $Rurl ="";
- $Rtitle ="";
- $Rsize ="";
- $Rseed ="";
- $Rleech ="";
- $Rdate ="";
- foreach($html->find('a.hl-tags') as $e) $Rtitle = $e->innertext;
- foreach($html->find('a.tLink') as $e) $Rurl = $e->href;
- foreach($html->find('a.tr-dl') as $e) $Rsize = $e->innertext;
- foreach($html->find('b.seedmed') as $e) $Rseed =$e->innertext;
- foreach($html->find('td.leechmed') as $e) $Rleech = $e->innertext;
- foreach($html->find('td[style="padding: 1px 3px 2px;"]') as $e) $Rdate = $e->innertext;
- $Rdata[] = array(
- "title"=>strip_tags($Rtitle),
- "url"=>strip_tags($Rurl),
- "size"=>strip_tags($Rsize),
- "seed"=>strip_tags($Rseed),
- "leech"=>strip_tags($Rleech),
- "date"=>$Rdate,
- );
- }
- if (curl_error($ch)) {
- echo curl_error($ch);
- }
- return $Rdata;
- }
- function NNM($query){
- $ch = curl_init();
- $df = urlencode(iconv('UTF-8','CP1251',$query));
- curl_setopt($ch, CURLOPT_URL,"http://nnm-club.me/forum/tracker.php");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- "f=-1&nm=".$df."&search_submit=%C8%F1%EA%E0%F2%FC");
- // in real life you should use something like:
- // curl_setopt($ch, CURLOPT_POSTFIELDS,
- // http_build_query(array('postvar1' => 'value1')));
- // receive server response ...
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $server_output = curl_exec ($ch);
- curl_close ($ch);
- //$s = file_get_contents("nnm.html");
- $re = '/<tr class="prow(.*?)">(.*?)<\/tr>/s';
- preg_match_all($re, $server_output, $matches);
- foreach($matches as $key =>$x){
- $t = "";
- $u = "";
- $seed="";
- $leech = "";
- $date ="";
- foreach($x as $y){$sizeRE = $re = '/<\/u> (.*?)<\/td>/m';preg_match_all($sizeRE, $y, $matchesS);
- $html = str_get_html($y);
- foreach($html->find('a.topictitle') as $e) $t = $e->innertext;
- foreach($html->find('a.topictitle') as $e) $u = $e->href;
- foreach($html->find('td.seedmed') as $e) $seed = $e->innertext;
- foreach($html->find('td.leechmed') as $e) $leech = $e->innertext;
- foreach($html->find('td.gensmall') as $e) $date = $e->innertext;
- $data[] = array(
- "title"=>strip_tags($t),
- "url"=>strip_tags($u),
- "size"=>strip_tags($matchesS[1][0]),
- "seed"=>strip_tags($seed),
- "leech"=>strip_tags($leech),
- "date"=>$date,
- );
- }
- }
- $newClear = array();
- foreach ($data as $key => $items) {
- if(strlen($items['title'])>0){
- $newClear[] = $items;
- }
- }
- return $newClear;
- }
- $list = array();
- $list['rut'] = RUtreker($_POST['query']);
- $list['nnm'] = NNM($_POST['query']);
- //print_r($list);
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <style type="text/css">
- #search{
- background: #fff;
- margin: 50px ;
- float: center;
- }
- </style>
- <!-- Bootstrap CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
- <title>Hello, world!</title>
- </head>
- <body>
- <div class="row align-items-center justify-content-center">
- <div id="search">
- <center><form class="form-inline" method="POST">
- <div class="form-group mb-2">
- <label for="staticEmail2" class="sr-only">Email</label>
- <input type="text" readonly class="form-control-plaintext" id="staticEmail2" value="Найти торренты файлы!">
- </div>
- <div class="form-group mx-sm-3 mb-2">
- <label for="inputPassword2" id="inputlg" class="sr-only">Password</label>
- <input type="text" class="form-control" name="query" style="width: 500px" id="inputPassword2" placeholder="Текст.. .">
- </div>
- <button type="submit" name="submit" class="btn btn-primary mb-2">Найти торренты</button>
- </form></center>
- </div>
- </div>
- <table class="table">
- <thead>
- <tr>
- <th scope="col">#</th>
- <th scope="col">Имя торрента</th>
- <th scope="col">Источник</th>
- <th scope="col">Размер</th>
- <th scope="col">Seed</th>
- <th scope="col">Leechers</th>
- <th scope="col">Дата</th>
- <th scope="col">Скачать</th>
- </tr>
- </thead>
- <tbody>
- <?foreach ($list['rut'] as $key => $r):?>
- <tr>
- <th scope="row"><?=$key;?></th>
- <td><?=$r['title'];?></td>
- <td><img src="/favicon.ico" /></td>
- <td><?=$r['size'];?></td>
- <td><?=$r['seed'];?></td>
- <td><?=$r['leech'];?></td>
- <td><?=$r['date'];?></td>
- <td><?=$r['url'];?></td>
- </tr>
- <?php endforeach;?>
- <?foreach ($list['nnm'] as $key => $r):?>
- <tr>
- <th scope="row"><?=$key;?></th>
- <td><?=$r['title'];?></td>
- <td><img src="/favicon2.ico" /></td>
- <td><?=$r['size'];?></td>
- <td><?=$r['seed'];?></td>
- <td><?=$r['leech'];?></td>
- <td><?=$r['date'];?></td>
- <td><?=$r['url'];?></td>
- </tr>
- <?php endforeach;?>
- </tbody>
- </table>
- <!-- Optional JavaScript -->
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement