All pastes #517768 Raw Edit

Untitled

public php v1 · immutable
#517768 ·published 2007-05-29 03:43 UTC
rendered paste body
<?php	$exchange_rates = array();	$indices = array();	$rate_pattern = array();	include("config.php");	foreach($indice as $country)		array_push($rate_pattern,"/\/d\/(".$country[0].")\/GBP\/graph.+[^\.]\.html\" class=\"menu\">([0-9(\.)?]+)</i");	class HServ	{	  function HServ($s, $c = "", $ua = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; Alexa Toolbar)") {		$this->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)."']}";?>