За последние 24 часа нас посетили 22809 программистов и 1278 роботов. Сейчас ищут 807 программистов ...

Помогите доработать скрипт на PHP

Тема в разделе "PHP для новичков", создана пользователем Medvedoc, 6 ноя 2018.

Метки:
  1. Medvedoc

    Medvedoc Активный пользователь

    С нами с:
    17 окт 2011
    Сообщения:
    65
    Симпатии:
    0
    Добрый вечер форумчане!!! Помогите доработать скрипт.

    PHP:
    1. <?php
    2. header('Content-Type: text/html; charset=utf-8');
    3. ini_set('error_reporting', E_ALL);
    4. ini_set('display_errors', 1);
    5. ini_set('display_startup_errors', 1);
    6. $arr_cms=array(
    7. 'WordPress' => 'content="WordPress',
    8. 'WordPress_2' => '/wp-content/themes/',
    9. 'Bitrix' => '/bitrix/'
    10. );
    11. // таймаут (сколько ждать ответа сайта)
    12. $tm_out=10; // сек.
    13.  
    14. function pars_url($str){
    15.     $str=str_ireplace('https://','',$str);
    16.     $str=str_ireplace('http://','',$str);
    17.     $arr=array();
    18.     $arr=explode("\n",$str);
    19.     $arr=array_unique($arr);
    20.     return $arr;
    21.     }
    22. function simple_curl($url){
    23.     global $tm_out;
    24.     $curl = curl_init();
    25.     curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
    26.     curl_setopt($curl, CURLOPT_AUTOREFERER,true);
    27.     curl_setopt($curl, CURLOPT_FOLLOWLOCATION,true);
    28.     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $tm_out);
    29.     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    30.     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    31.     curl_setopt($curl, CURLOPT_URL, $url);
    32.     $x = curl_exec($curl);
    33.     return $x;
    34. }  
    35. function rrr($str) {
    36.     global $arr_cms;
    37.     $arr=array(0=>'Неизвестно',1=>'');
    38.     foreach ($arr_cms as $a=>$b){
    39.     $pos = stripos($str, $b);
    40.     if ($pos===false)
    41.     {}else {
    42.         $arr[1]=$b;
    43.         $arr[0]=$a;
    44.         return $arr;
    45.         }
    46.         }
    47.     return $arr;
    48.     }
    49. $f=array();
    50. if (isset($_POST['url']) && ($_POST['url'] != '' )){
    51.     $arr=pars_url($_POST['url']);
    52.     echo '<center>';
    53.     foreach ($arr as $a=>$b){
    54.     $content = simple_curl('http://'.trim($b));
    55.     $f=rrr($content);
    56.     echo  'Цмс: <b>' . $f[0].'</b>';
    57.     echo ' ('.$f[1].') ';
    58.     echo  ' Сайт: <b>'. $b.'</b><br>'."\n";
    59.     }
    60. echo '</center>';  
    61. } else {
    62. echo $frm='
    63. <html>
    64.    <head>
    65.        <title>Проверка</title>
    66.    </head>
    67.    <body>
    68.        <h1>Введите урл (без http:// и https:// )</h1>
    69.        <form action="index.php" method="post">
    70.            <textarea rows="10" cols="45" name="url"></textarea><br>
    71.            <input type="submit" value="Go">
    72.        </form>
    73.      
    74. </body>
    75. </html>';
    76. }

    1. Как добавить возможность определения по регулярным выражениям?
    html
    "<link rel=[\"']stylesheet[\"'] [^>]+wp-(?:content|includes)"
    "<link[^>]+s\\d+\\.wp\\.com"

    js
    "wp_username": ""

    meta
    "generator": "WordPress( [\\d.]+)?\\;version:\\1"

    script
    "/wp-includes/"

    website
    "http://wordpress.org"
    headers
    "Set-Cookie": "BITRIX_"
    "X-Powered-CMS": "Bitrix Site Manager"

    html
    "(?:<link[^>]+components/bitrix|(?:src|href)=\"/bitrix/(?:js|templates))"

    script
    "1c-bitrix"

    website
    "http://www.1c-bitrix.ru"

    2. Сделать обработку запроса через ajax