Многопоточный парсер Слил.Ру [slil.ru]

Discussion in 'PHP' started by |qbz|, 21 Jul 2011.

  1. |qbz|

    |qbz| Banned

    Joined:
    25 Dec 2009
    Messages:
    385
    Likes Received:
    169
    Reputations:
    65
    Вчера вечерком почему-то захотелось написать данную вещицу, поэтому представляю:

    Slil.Ru Parser (multicurl)

    — бесплатный
    — написан на php с использованием многопоточного cURL (есть на большинстве платных хостингов)
    — средняя скорость - 1000 файлов / 3-4 секунды
    — парсит по диапазону от и до
    — можно указать желаемые расширения файлов (например txt;jpg)
    — можно указать текст, который ищется в названии файла (например акки;accounts)
    — при выдаче результата мы имеем:
    • ссылку для скачивания
    • ссылку на страницу на слил.ру
    • если файл = картинка, то можно сразу-же просмотреть встренным просмотрщиком
    • размер файла
    • название файла
    • ид файла
    — все файлы рассортированы по расширениям для удобной ориентации

    Требования: PHP 5, Curl

    Скачать: http://rghost.ru/15346781, пароль: qbz

    Скрин:
    [​IMG]

    Код: http://pastebin.com/yHQAH9E7
    PHP:
    <html>
    <script type="text/javascript" src="./slil/highslide/highslide.js"></script>
    <link rel="stylesheet" type="text/css" href="./slil/highslide/highslide.css" />
    <script type="text/javascript">
        hs.graphicsDir = './slil/highslide/graphics/';
        hs.outlineType = 'outer-glow';
        hs.wrapperClassName = 'outer-glow';
        function t(d)
        {
            document.getElementById(d).style.display = (document.getElementById(d).style.display == 'none')?('inline-table'):('none');
        }
    </script>
    <style>
    body
    {
        font-family: verdana;
        background-image:url(./plain.png);
        background-attachment: fixed;
    }
    .extup
    {
        font-family: Tahoma;
        color:white;
        border:1px solid black;
        padding:4px;
        background-color:#262308;
        font-size:14pt;
        width:100%;
        margin-top:10px;
    }
    .extup:hover
    {
        color:orange;
        cursor:pointer;
    }
    .lighty
    {
        background-color:#1E1E1E;
    }
    .darky
    {
        background-color:#333333;
    }
    a
    {
        text-decoration:none;
    }
    td
    {
        font-family:verdana;
        font-size:10pt;
        color:orange;
    }
    tr:hover
    {
        border:1px solid orange;
        background-color:black;
    }
    table
    {
        border:1px solid black;
    }
    input
    {
        border:1px solid black;
        padding:4px;
        background-color:#333333;
        color:orange;
        font-size:10pt;
        font-family:verdana;
    }
    </style>
    <form action="" method="post">
    <table width="100%" cellspacing="0" cellpadding="6" border="0">
        <tr>
            <td>
                From: <input type="text" name="slilfrom" value="<?php if(isset($_POST['slilfrom'])){echo(stripslashes(htmlspecialchars($_POST['slilfrom'])));} ?>">
            </td>
            
            <td>
                To: <input type="text" name="slilto" value="<?php if(isset($_POST['slilto'])){echo(stripslashes(htmlspecialchars($_POST['slilto'])));} ?>">
            </td>
            
            <td>
                Extensions (;): <input type="text" name="slilext" value="<?php if(isset($_POST['slilext'])){echo(stripslashes(htmlspecialchars($_POST['slilext'])));} ?>">
            </td>
            
            <td>
                Text (;): <input type="text" name="sliltxt" value="<?php if(isset($_POST['sliltxt'])){echo(stripslashes(htmlspecialchars($_POST['sliltxt'])));} ?>">
            </td>
            
            <td>
                <input type="submit" value="Parse">
            </td>
        </tr>
    </table>
    </form>
    <?php
        
        $uas 
    = array(
        
    //Chrome
        
    "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",
        
    "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.9 Safari/532.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",
        
    //IE
        
    "Mozilla/4.0 (compatible; MSIE 6.0; MSN 2.5; Windows 98)",
        
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)",
        
    "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)",
        
    "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)",
        
    //Opera
        
    "Opera/9.02 (Windows NT 5.1; U; en)",
        
    "Opera/10.00 (Windows NT 6.0; U; en) Presto/2.2.0",
        
    "Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.5.24 Version/10.52"
        
    );
        
        
    $head = array(
            
    'Host: slil.ru',
            
    'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
            
    'Accept-Language: en-us,en;q=0.5',
            
    'Accept-Encoding: gzip,deflate',
            
    'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
            
    'Keep-Alive: 300',
            
    'Connection: keep-alive'
        
    );
        
        
    $exts = array();
        foreach (
    explode(';'$_POST['slilext']) as $ext)
        {
            
    $ext trim(mb_strtolower($ext));
            if (
    $ext != '')
            {
                
    $exts[] = $ext;
            }
        }
        
        
    $exts array_unique($exts);
        
        
    $texts = array();
        foreach (
    explode(';'$_POST['sliltxt']) as $txt)
        {
            
    $txt trim(mb_strtolower($txt));
            if (
    $txt != '')
            {
                
    $texts[] = $txt;
            }
        }
        
        
    $texts array_unique($texts);
        
        function 
    genLinks($from$to)
        {
            
    $i 0$links = array();
            for (
    $i 0$i <= ($to $from); $i++)
            {
                
    $links[] = 'http://slil.ru/'.($from+$i);
            }
            return 
    $links;
        }
        
        function 
    parseLinks($links)
        {
            global 
    $uas$head$exts$texts;

            
    $multi_thread curl_multi_init();
            
    $threads = array();
            
    $results = array();
            
            
    $i 0;
            for (
    $i 0$i count($links); $i++)
            {
                
    $threads[$i] = curl_init();
                
                
    curl_setopt($threads[$i], CURLOPT_URL,                $links[$i]);
                
    curl_setopt($threads[$i], CURLOPT_USERAGENT,         $uas[rand(0count($uas)-1)]);
                
    curl_setopt($threads[$i], CURLOPT_RETURNTRANSFER,    true);
                
    curl_setopt($threads[$i], CURLOPT_HTTPHEADER,         $head);
                
    curl_setopt($threads[$i], CURLOPT_ENCODING,         'gzip,deflate');
                
                
    curl_multi_add_handle($multi_thread$threads[$i]);
            }
            
            
    $start_check null; do { curl_multi_exec($multi_thread$start_check); } while ($start_check 0);
            
            
    $i 0;
            for (
    $i 0$i count($links); $i++)
            {
                
    $cResult curl_multi_getcontent($threads[$i]);
                
                
    $filedata explode('<p align="center">'$cResult);
                
    $filedata explode('</p>'$filedata[1]);
                list(
    $filename$filesize) = explode('&nbsp;&nbsp;&nbsp;'trim(strip_tags($filedata[0])));
                
    $id explode('/'$links[$i]); $id $id[count($id)-1];
                
                
    $temp_link explode('var l1nk=\''$cResult);
                
    $temp_link explode('\';'$temp_link[1]);
                
    $temp_link trim(str_replace("'+'"''$temp_link[0]));
                
                
    $fext explode('.'$filename);
                
    $fext mb_strtolower(trim($fext[count($fext)-1]));
                
                if (
    count($exts) > 0)
                {
                    if (!
    in_array($fext$exts))
                    {
                        continue;
                    }
                }
                
                
                
    $text_found false;
                if (
    count($texts) > 0)
                {
                    foreach (
    $texts as $text)
                    {
                        if (
    strstr($filename$text))
                        {
                            
    $text_found true; break;
                        }
                    }
                }
                else
                {
                    
    $text_found true;
                }
                
                if (!
    $text_found){continue;}
                
                
    $results[$fext][] = array('id' => $id'name' => $filename'size' => $filesize'link' => $temp_link);
            }
            
            
    curl_multi_close($multi_thread);
            return 
    $results;
        }
        
        if (isset(
    $_POST['slilfrom']))
        {
            if ((
    $_POST['slilto'] - $_POST['slilfrom']) > 100)
            {
                echo(
    '<span style="color:white;">Too big range! Maximal range is 100.</span><hr noshade></html>'); exit;
            }
            
    $parsed parseLinks(genLinks($_POST['slilfrom'],$_POST['slilto']));
            echo(
    '<hr noshade>');
            echo(
    '<h2 class="extup" style="color:red;">Files not found: '.count($parsed['']).'</h2>');
            foreach (
    $parsed as $ext => $p)
            {
                if (
    $ext == '') {continue;}
                
    $tr_color true;
                echo(
    '<button class="extup" onClick="t(\''.$ext.'\');">*.'.mb_strtoupper($ext)." files (".count($p)."):</button>");
                echo(
    '<table width="100%" cellspacing="0" cellpadding="6" border="0" id="'.$ext.'" style="display:none;">');
                foreach (
    $p as $pf)
                {
                    
    $tr_color = ($tr_color)?(false):(true);
                    
    $tr_class = ($tr_color)?('lighty'):('darky');
                    
                    
    $bytes str_replace(str_split('0123456789.'1), ''$pf['size']);
                    
    $pf['size'] = round(str_replace($bytes''$pf['size'])).' '.$bytes;
                    
                    if (
    in_array($ext, array('jpg''jpeg''bmp''gif''png')))
                    {
                        
    $preview '
                            <td width="20" height="20">
                            <a href="http://slil.ru/'
    .$pf['link'].'" onClick="return hs.expand(this);">
                                    <img src="./preview.png" border="0" align="absmiddle">
                                </a>
                            </td>
                        '
    ;
                    } else {
    $preview '';}
                    
                    
                    echo(
    '<tr class="'.$tr_class.'">');
                    echo(
    '
                        <td width="20" height="20">
                            <a href="http://slil.ru/'
    .$pf['link'].'">
                                <img src="./download.png" border="0" align="absmiddle"></td>
                            </a>
                        <td width="20" height="20">
                            <a href="http://slil.ru/'
    .$pf['id'].'" target="_blank">
                                <img src="./forward.png" border="0" align="absmiddle">
                            </a>
                        </td>
                        '
    .$preview.'
                        <td width="100" align="right">'
    .$pf['size'].'</td>
                        <td style="border-left:1px solid black;">'
    .$pf['name'].'</td>
                        <td width="100" align="right">'
    .$pf['id'].'</td>
                    '
    );
                    echo(
    '</tr>');
                }
                echo(
    '</table><br>');
            }
            
        }
    ?>
    </html>
     
    #1 |qbz|, 21 Jul 2011
    Last edited: 22 Jul 2011
    4 people like this.
  2. dpe_x

    dpe_x Elder - Старейшина

    Joined:
    8 Sep 2010
    Messages:
    155
    Likes Received:
    35
    Reputations:
    14
    это для того, чтобы накачать троянцев себе на комп ?
     
  3. |qbz|

    |qbz| Banned

    Joined:
    25 Dec 2009
    Messages:
    385
    Likes Received:
    169
    Reputations:
    65
    Вполне возможно, хотя если хорошо искать, то можно найти всевозможные акки, сканы, софт, конфиги.
     
  4. ShyRka_coder

    ShyRka_coder Member

    Joined:
    27 Jul 2010
    Messages:
    127
    Likes Received:
    7
    Reputations:
    5
    Супер мен , так держать ..
     
  5. Ups

    Ups Member

    Joined:
    11 Apr 2011
    Messages:
    113
    Likes Received:
    12
    Reputations:
    0
    Чего-то у меня не работает. пхп5 и курл есть.
    [​IMG]

    upd
    На другом хосте заработало. Спасибо.
     
    #5 Ups, 21 Jul 2011
    Last edited: 21 Jul 2011
  6. |qbz|

    |qbz| Banned

    Joined:
    25 Dec 2009
    Messages:
    385
    Likes Received:
    169
    Reputations:
    65
    На мастерхосте летает норм, мен, посмотри настройки сервака.

    Тебе говорит, что не обьявлена переменная в $_ПОСТ. Попробуй после <?php поставить error_reporting(0);
     
    #6 |qbz|, 21 Jul 2011
    Last edited: 21 Jul 2011
  7. |qbz|

    |qbz| Banned

    Joined:
    25 Dec 2009
    Messages:
    385
    Likes Received:
    169
    Reputations:
    65
    Ну и чудесно
     
  8. NetSter

    NetSter Moderator

    Joined:
    30 Jul 2007
    Messages:
    810
    Likes Received:
    414
    Reputations:
    62
    мм найс мэн.
    кто не шарит - лесом.
    я на слил ру в свое время 2к уинов для спама поднял, когда еще поиск был))
    просто good.txt решает))
     
    _________________________
  9. Vlad3d

    Vlad3d Elder - Старейшина

    Joined:
    18 Jan 2008
    Messages:
    47
    Likes Received:
    54
    Reputations:
    -1
    зря ты такое выкладываешь, ну ладно
     
  10. |qbz|

    |qbz| Banned

    Joined:
    25 Dec 2009
    Messages:
    385
    Likes Received:
    169
    Reputations:
    65
    Позволь спросить, почему?
     
  11. Vlad3d

    Vlad3d Elder - Старейшина

    Joined:
    18 Jan 2008
    Messages:
    47
    Likes Received:
    54
    Reputations:
    -1
    шклололо начнет продавать все что там найдет