_amt=$amt; $this->_to=$to; $this->_from=$from; } function error() { return $this->_error; } function convert($amt=NULL,$to="",$from="") { if ($amt == 0) { return 0; } if($amt>1) $this->_amt=$amt; if(!empty($to)) $this->_to=$to; if(!empty($from)) $this->_from=$from; //$host="www.iraqidinar.org"; $host="www.xe.com"; $fp = @fsockopen($host, 80, $errno, $errstr, 30); if (!$fp) { $this->_error="$errstr ($errno)
\n"; return false; } else { //$file="/conversiontool2.asp"; $file="/ucc/convert.cgi"; //$str = "?amount=".$this->_amt."&ConvertFrom=".$this->_from."&ConvertTo=".$this->_to; $str = "?language=xe&Amount=".$this->_amt."&From=".$this->_from."&To=".$this->_to; $out = "GET ".$file.$str." HTTP/1.0\r\n"; $out .= "Host: $host\r\n"; $out .= "Connection: Close\r\n\r\n"; @fputs($fp, $out); while (!@feof($fp)) { $data.= @fgets($fp, 128); } @fclose($fp); @preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $data, $match); $data =$match[2]; $search = array ("']*?>.*?'si", // Strip out javascript "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags "'([\r\n])[\s]+'", // Strip out white space "'&(quot|#34);'i", // Replace HTML entities "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\d+);'e"); // evaluate as php $replace = array ("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)"); $data = @preg_replace($search, $replace, $data); @preg_match_all("/(\d[^\.]*(\.\d+)?)/",$data,$mathces); $return=preg_replace("/[^\d\.]*/","",$mathces[0][1]); return (double)$return; } } } ?>