PHP-Snippets
 php::MySQL (0)
 php::Image (4)
   » Bild - Boxskalierung
   » Hex-Farbcode -> Farb-Array
   » Farb - Aufheller
   » Farb - Abdunkler
 php::Sonstiges (4)
   » Einfache Template-Funktion
   » Simple HTTP-Post Funktion
   » Simple HTTP-Get Funktion
   » zwischen()-Funktion
 php::Spezielles (2)
   » Zeichenvorkommisse prüfen
   » Array mischen (seeded)
Snippet: Simple HTTP-Get Funktion

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
<?php
function gethttp($host,$file,$cookie = -1,$ref = -1)
{
  
$fp fsockopen($host80$errno$errstr30);
  if (!
$fp)
  {
    
trigger_error"$errstr ($errno)<br />\n");
    return;
  }
      
  
$out "GET ".$file." HTTP/1.1\r\n";
  
$out .= "Host: ".$host."\r\n";
    
  
$out .= "User-Agent: Mozilla/5.3 (Windows; U; Windows NT 5.1; de; rv:1.8.1.6) Gecko/2232 Firefox/3.0.0.R\r\n";
    
  
$out .= "Accept-Charset: utf-8\r\n";
  if(
$cookie != -1)
  {
    
$out .= "Cookie: ".$cookie."\r\n";
  }
  if(
$ref != -1)
  {
    
$out .= "Referer: ".$ref."\r\n";
  }
  
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
  
$out .= "Connection: Close\r\n\r\n";
  
  
fwrite($fp$out);
  
  while (!
feof($fp)) 
  {
    
$data fgets($fp128);
    
$lines[] = $data
  }
  
fclose($fp);
  
  
$retu implode("",$lines);
  
  return 
$retu;
}
?>