([0-9(\.)?]+)server = $s; $this->cookies = $c; $this->userAgent = $ua; } function http_request($m, $f, $d = "", $host = null, $c = "", $port = 80) { if ($host == null) $host = $this->server; sleep(1); if (($fp = fsockopen($host, $port, $errno, $errstr, 30))) { $out = strtoupper($m) ." /". $f ." HTTP/1.1\r\n"; $out .= "Host: ". $host ."\r\n"; $out .= "Cookie: ". $this->cookies; if ($c != "") $out .= "; ". $c; $out .= "\r\n"; $out .= "User-Agent: ". $this->userAgent ."\r\n"; if (strtolower($m) == "post") { $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Content-Length: ". strlen($d) ."\r\n"; } $out .= "Connection: Close\r\n\r\n"; if (strtolower($m) == "post") $out .= $d ."\r\n\r\n"; //echo $out; fwrite($fp, $out); $returnVal = ""; while (!feof($fp)) $returnVal .= fgets($fp, 128); fclose($fp); return $returnVal; } } } $hserv = new HServ("www.x-rates.com"); $data = $hserv->http_request("get", "d/GBP/table.html"); foreach($rate_pattern as $pattern) { preg_match($pattern,$data,$m); array_push($indices,$m[1]); array_push($exchange_rates,$m[2]); } echo "{exchange_rate:['".implode("','",$exchange_rates)."'], index:['".implode("','",$indices)."']}"; ?>