Advertisement
Guest User

Untitled

a guest
Aug 10th, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.04 KB | None | 0 0
  1. <?php
  2.     ob_start();
  3.     header("Content-Type: text/html;charset=utf-8");
  4.    
  5.     $uas = array(
  6.     //Chrome
  7.     "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13",
  8.     "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.9 Safari/532.9",
  9.     "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.1 (KHTML, like Gecko) Chrome/6.0.437.3 Safari/534.1",
  10.     //IE
  11.     "Mozilla/4.0 (compatible; MSIE 6.0; MSN 2.5; Windows 98)",
  12.     "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)",
  13.     "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)",
  14.     "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022)",
  15.     //Opera
  16.     "Opera/9.02 (Windows NT 5.1; U; en)",
  17.     "Opera/10.00 (Windows NT 6.0; U; en) Presto/2.2.0",
  18.     "Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.5.24 Version/10.52"
  19.     );
  20.    
  21.     function checkPhotos($host, $mask, $from, $to, $right)
  22.     {
  23.         global $uas;
  24.        
  25.         $host = (substr($host, strlen($host)-1, 1) == '/')?($host):($host.'/');
  26.        
  27.         $links = array();
  28.        
  29.         $i = 0;
  30.         for ($i = 0; $i <= ($to - $from); $i++)
  31.         {
  32.             $links[] = $host.str_replace('{NUM}', ($from+$i), $mask);
  33.         }
  34.        
  35.         $curls = curl_multi_init();
  36.         $threads = array();
  37.         $results = array();
  38.        
  39.         $i = 0;
  40.         for ($i = 0; $i < count($links); $i++)
  41.         {
  42.             $threads[$i] = curl_init();
  43.            
  44.             curl_setopt($threads[$i], CURLOPT_URL, $links[$i]);
  45.             curl_setopt($threads[$i], CURLOPT_USERAGENT, $uas[rand(0, count($uas)-1)]);
  46.             curl_setopt($threads[$i], CURLOPT_RETURNTRANSFER, true);
  47.             curl_setopt($threads[$i], CURLOPT_HEADER, true);
  48.             curl_setopt($threads[$i], CURLOPT_NOBODY, true);
  49.            
  50.             curl_multi_add_handle($curls, $threads[$i]);
  51.         }
  52.        
  53.         $done = null;
  54.        
  55.         do
  56.         {
  57.             curl_multi_exec($curls, $done);
  58.         }
  59.         while ($done > 0);
  60.        
  61.         $i = 0;
  62.         for ($i = 0; $i < count($links); $i++)
  63.         {
  64.             $out = curl_multi_getcontent($threads[$i]);
  65.             if (strstr($out, trim($right)))
  66.             {
  67.                 $results[] = $links[$i];
  68.             }
  69.         }
  70.         curl_multi_close($curls);
  71.         return $results;
  72.     }
  73. ?>
  74. <html>
  75.     <style>
  76.         body
  77.         {
  78.             background-color:black;
  79.             color:orange;
  80.             margin:5%;
  81.             font-family:verdana;
  82.             font-size:8pt;
  83.         }
  84.         .inpc
  85.         {
  86.             border:1px solid gray;
  87.             color:orange;
  88.             background-color: #3D3D3D;
  89.             padding:2px;
  90.             font-family:verdana;
  91.             font-size:8pt;
  92.         }
  93.         td
  94.         {
  95.             font-size:8pt;
  96.         }
  97.     </style>
  98.     <body>
  99.         <form action="" method="post">
  100.             <table>
  101.                 <tr>
  102.                     <td>
  103.                         Хост <span style="color:gray;">(http://xxx.com/)</span>:<br>
  104.                         <input type="text" name="host" class="inpc">
  105.                     </td>
  106.                 </tr>
  107.                 <tr>
  108.                     <td>
  109.                         Маска файлов, где {NUM} - число фотографии <span style="color:gray;">(DSC_{NUM}.jpg)</span>:<br>
  110.                         <input type="text" name="mask" class="inpc">
  111.                     </td>
  112.                 </tr>
  113.                 <tr>
  114.                     <td>
  115.                         Начальное значение {NUM} <span style="color:gray;">(3400)</span>:<br>
  116.                         <input type="text" name="from" class="inpc">
  117.                     </td>
  118.                 </tr>
  119.                 <tr>
  120.                     <td>
  121.                         Конечное значение {NUM} <span style="color:gray;">(3600)</span>:<br>
  122.                         <input type="text" name="upto" class="inpc">
  123.                     </td>
  124.                 </tr>
  125.                 <tr>
  126.                     <td>
  127.                         Успешная шапка <span style="color:gray;">(Content-Type: image/jpeg)</span>:<br>
  128.                         <input type="text" name="head" class="inpc">
  129.                     </td>
  130.                 </tr>
  131.             </table>
  132.             <br>
  133.             <input type="submit" value="Search" class="inpc">
  134.         </form>
  135.         <?php
  136.             if (isset($_POST['host']))
  137.             {
  138.                 $photos = checkPhotos($_POST['host'], $_POST['mask'], $_POST['from'], $_POST['upto'], $_POST['head']);
  139.                 if (count($photos) > 0)
  140.                 {
  141.                     foreach ($photos as $photo)
  142.                     {
  143.                         echo('<a href="'.$photo.'" style="text-decoration:none; color:white; margin-bottom:5px;" target="_blank">'.$photo.'</a><br>');
  144.                     }
  145.                 }
  146.                 else
  147.                 {
  148.                     echo ('Ничего не найдено');
  149.                 }
  150.             }
  151.         ?>
  152.     </body>
  153. </html>
  154. <?php ob_end_flush(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement