Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> sockety, tresc obrazka, problem z rozdzieleniem
lucas131
post 27.03.2005, 11:05:25
Post #1





Grupa: Zarejestrowani
Postów: 30
Pomógł: 0
Dołączył: 21.03.2005

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


Moj kod socketow:

  1. <?php
  2. $fp = fsockopen(&#092;"www.lightspeedgalleries.com\", 80, $errno, $errstr, 30);
  3. if (!$fp) {
  4.  echo &#092;"$errstr ($errno)<br />n\";
  5. } else {
  6.  $out = &#092;"GET /fg/jor/001/images/12.jpg HTTP/1.1rn\";
  7.  $out .= &#092;"Host: www.lightspeedgalleries.comrn\";
  8.  $out .= &#092;"Referer: http://www.lightspeedgalleries.com/fg/jor/001/index.php?r=lucas131-rev&nc=1rn\";
  9.  $out .= &#092;"Connection: Closernrn\";
  10.  
  11.  fwrite($fp, $out);
  12.  while (!feof($fp)) {
  13.  $s = fgets($fp);
  14.  if(strstr($s, &#092;"n\"))
  15.  {
  16.  $kod_obrazka=fread($fp, 128);
  17.  if(strstr($kod_obrazka, &#092;"Content-Length: \")) 
  18.  {
  19.  $rozmiar=explode(&#092;"Content-Length: \", $kod_obrazka);
  20.  $rozmiar1=explode(&#092;"Connection:\", $rozmiar[1]);
  21.  $dlugosc=$rozmiar1[0];
  22.  }  
  23.  }
  24. echo $s.&#092;"<br>\";
  25. if (strstr($s, &#092;"rn\"))
  26. {
  27. $dane_obrazka=fread($fp, $dlugosc);
  28. echo &#092;"<br><br><b>Dane: \".$dane_obrazka.\"</b>\";
  29. break;
  30. }
  31.  }
  32.  
  33.  fclose($fp);
  34. }
  35.  
  36. ?>


Zwraca informacje o obrazku i tresc, chce oddzoelic tresc obrazka od informacji tzn to mi sie wyswietla:
HTTP/1.1 200 OK
<br>8:15 GMT
<br>JFIF (tu sie zaczyna tresc obrazka)

8:15 GMT od tresci dzieli \n, ale czas GMT sie ciagle zmeinia, nie moge podzielic przez explode, poniewaz sformatuje tresc obrazka do stringow, nie bedzie mozna zamienic go na obrazek jpg.
Czy ktos ma jakies pomysly??
Go to the top of the page
+Quote Post
SongoQ
post 27.03.2005, 12:56:19
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 923
Pomógł: 9
Dołączył: 25.10.2004
Skąd: Rzeszów - studia / Warszawa - praca

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


  1. <?php
  2.  
  3. $fp = fsockopen(&#092;"www.lightspeedgalleries.com\", 80, $errno, $errstr, 30);
  4. if(!$fp)
  5. {
  6. echo &#092;"$errstr ($errno)<br />n\";
  7. }
  8. else
  9. {
  10. $out = &#092;"GET /fg/jor/001/images/12.jpg HTTP/1.1rn\";
  11. $out .= &#092;"Host: www.lightspeedgalleries.comrn\";
  12. $out .= &#092;"Referer: http://www.lightspeedgalleries.com/fg/jor/001/index.php?r=lucas131-rev&nc=1rn\";
  13. $out .= &#092;"Connection: Closernrn\";
  14.  
  15. fwrite($fp, $out);
  16. while(!feof($fp))
  17.  $s .= fgets($fp);
  18.  fclose($fp);
  19.  
  20. $aNaglowki = explode(&#092;"n\", $s);
  21.  
  22. for($i = 0; $i < 9; $i++)
  23. $szNaglowki .= $aNaglowki[$i].&#092;"n\";
  24.  
  25. $s = str_replace($szNaglowki, '', $s);
  26.  
  27. echo $s;
  28.  
  29. }
  30.  
  31. ?>


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 8.07.2025 - 09:10