file = $this->getCURL($url); } else if(CONNECTION == 'http'){ $this->file = $this->getHTTP($url); } else if(CONNECTION == 'socket'){ $this->file = $this->getSOCKET($url); } if(!$this->file){ $e = new mb_exception("connector: unable to load: ".$url); } } function getCURL($url){ $ch = curl_init ($url); // curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); if(CONNECTION_PROXY != ""){ curl_setopt($ch, CURLOPT_PROXY,CONNECTION_PROXY.":".CONNECTION_PORT); } if(CONNECTION_PASSWORD != ""){ curl_setopt ($ch, CURLOPT_PROXYUSERPWD, CONNECTION_USER.':'.CONNECTION_PASSWORD); } curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $file = curl_exec ($ch); curl_close ($ch); $h = fopen("/data/mapbender/http/tmp/".md5(microtime()).".png", "w"); fputs($h, $file); fclose($h); return $file; } function getHTTP($url){ return file_get_contents($url); } function getSOCKET($url){ $r = ""; $fp = fsockopen (CONNECTION_PROXY, CONNECTION_PORT, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)
\n"; } else { fputs ($fp, "GET ".$url." HTTP/1.0\r\n\r\n"); while (!feof($fp)) { $r .= fgets($fp,4096); } fclose($fp); return $r; } } } ?>