Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Kopia strony do pliku html
szmerak
post
Post #1





Grupa: Zarejestrowani
Postów: 286
Pomógł: 12
Dołączył: 23.11.2006
Skąd: WL

Ostrzeżenie: (0%)
-----


Czy jest jakaś możliwość w PHP aby skrypt zrobił dokładną kopie html wpisanej strony i zapisał do pliku na serwerze?

Znalazłem taki skrypcik
  1. <?php
  2. $ip = $_SERVER["REMOTE_ADDR"];
  3.  
  4. function GetPage($url, $ip, $timeout = 5)
  5. {
  6. $result = '';
  7. $url = parse_url($url);
  8.  
  9. if(!isset($url['port'])) $url['port'] = 80;
  10. $port = $url['port'];
  11. if(strlen($url['path']) == 0) $url['path'] = '/';
  12.  
  13. if ($fp = @fsockopen($url['host'], $port, $errno, $errstr, $timeout))
  14. {
  15. fputs($fp,
  16. "GET " . $url['path'] . " HTTP/1.0r\n" .
  17. "Host: " . $url['host'] . ($port != 80 ? ':' . $port : '') . "r\n" .
  18. "Accept: text/html; */*r\n" .
  19. "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)r\n" .
  20. "X_Forwarded_For: " . $ip . "r\n" .
  21. "Via: " . $ip . "r\n" .
  22. "Client-IP: " . $ip . "r\n" .
  23. "Connection: closer\nr\nr\n");
  24.  
  25. while (!feof($fp) && ($buf = fread($fp, 8192))) $result .= $buf;
  26.  
  27. fclose($fp);
  28. return $result;
  29. } else
  30. echo "Błąd $errno: $errstr !";
  31.  
  32. return false;
  33. }
  34.  
  35.  
  36.  
  37. $zzz = GetPage('http://www.szmerak.pl', '83.9.251.98');
  38. $plik=fopen("katalogi/strona2.html", "w+");
  39. fwrite($plik, $zzz);
  40. fclose($plik);
  41. ?>

Ale zapisuje on do pliku
Bad Request

Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.

Ten post edytował szmerak 13.12.2010, 04:13:23
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.09.2025 - 11:30