Advertisement
zero50x

Проблема 35, 36 строки

Apr 24th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title></title>
  6. </head>
  7. <body>
  8.  
  9. <?php
  10. error_reporting(E_ALL | E_STRICT);
  11. ini_set('display_errors', TRUE);
  12. ini_set('display_startup_errors', TRUE);
  13. header('Content-type: text/html; charset=UTF-8');
  14.  
  15. if (isset($_POST['add'])) {
  16.     $url_array = strip_tags(trim($_POST['text']));
  17.     $url_array = explode("\n", $url_array);
  18.  
  19.     // не уверен что тут нужен foreach но надо же как-то указать что каждая ссылка это $p
  20.  
  21.  
  22.     foreach ($url_array as $url_link) { // здесь правильно
  23.         $url_link = trim($url_link);
  24.         if ($url_link) {
  25.             echo "Fetching {$url_link}...<br/>\r\n";
  26.             $main = curl_init($url_link);
  27.             if ($main) {
  28.                 curl_setopt($main, CURLOPT_RETURNTRANSFER, 1);
  29.                 curl_setopt($main, CURLOPT_HEADER, 1);
  30.                
  31.                 // Выполняем запрос и приводим к одной кодировке
  32.                 $html = curl_exec($main);
  33.                
  34.                 // ВОТ ЗАГОЛОВОК ОН МНЕ НЕ ВЫВОДИТ
  35.                 $cha = curl_getinfo($main, CURLINFO_CONTENT_TYPE);
  36.                 echo $cha;
  37.                
  38.                 // $html = iconv("WINDOWS-1251", "UTF-8", $html); ВКЛЮЧИТЬ СТРОЧКУ ЕСЛИ КОДИРОВКА 1251
  39.                 echo "Receive " . strlen($html) . " bytes <br/>\r\n";
  40.                 $found = array(); // Массив $found должен быть предварительно объявлен
  41.                 $is_match_found = preg_match('/\<title\>([^<]+)\<\/title\>/sm', $html, $found);
  42.                 if ($is_match_found) {
  43.                     echo $found[1] . "<br/>\r\n";
  44.                 } else {
  45.                     echo "No Title tag in answer.<br/>\r\n";
  46.                 }
  47.             } else {
  48.                 echo "curl_init failure! <br/>\r\n";
  49.             }
  50.             curl_close($main);
  51.         }
  52.     }
  53. }
  54. ?>
  55.  
  56. <form action="" method="POST">
  57.     <textarea name="text">http://gyuzel-nn.ru/page/giv.html</textarea>
  58.     <button type="submit" name="add">Add</button>
  59. </form>
  60.  
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement