View Single Post
  #2  
Old 23rd May 2012, 10:22
Ripeed Ripeed is offline
Member
 
Join Date: Oct 2011
Posts: 85
Thanks: 11
Thanked 1 Time in 1 Post
Default

This is that script that does not work on server.
Its OK until starts call

Code:
 include_once("./php_adlinks/adlinks.inc.php");
          echo adlinks_zobrazitListu("utf-8","curl");
Than the page is like without styles and the code of page ends until i call that.

Code:
<?

	
	define("SEO_LISTA_GETAD","http://adlinks.effectix.com/getad/getad.py?");
	

	function adlinks_zobrazitListu($encoding = "utf-8",$gettype = "fopen") {
		$RURL = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		$RURL = trim($RURL,"/");
		$RURL_ENCODED = urlencode($RURL);
		$data = "";
		switch ($gettype) {
			case "fopen":
				@$fp = fopen(SEO_LISTA_GETAD."q=$RURL_ENCODED", "r");
				if (!$fp) {
		      		@$fp = fopen(SEO_LISTA_GETAD."t=links&amp;q=$RURL_ENCODED", "r");
			    }
			    if ($fp) {
			      		while(!feof($fp)) {
				            $data .= fread($fp, 2048);
			      		}
			      		fclose($fp);
			    }
			    break;
			case "curl":
				$curl = curl_init();
				curl_setopt($curl, CURLOPT_URL, SEO_LISTA_GETAD."q=$RURL_ENCODED");
				curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
				$data = curl_exec($curl);
				$info = curl_getinfo($curl);
				curl_close($curl);
				if ($info['http_code'] == 307) {
					$curl = curl_init();
					curl_setopt($curl, CURLOPT_URL, SEO_LISTA_GETAD."t=links&amp;q=$RURL_ENCODED");
					curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
					$data = curl_exec($curl);
					curl_close($curl);
				}
				break;
			case "file_get_contents":
				$data = file_get_contents(SEO_LISTA_GETAD."q=$RURL_ENCODED");				
        $pos = strpos($http_response_header[0], "307");
    if ($pos === true) {
					$data = file_get_contents(SEO_LISTA_GETAD."t=links&amp;q=$RURL_ENCODED");
				}
				break;
		}
		if ($data != "") {
	    	    switch ($encoding) {
	      			case "windows-1250":
	      				$data = iconv("utf-8",$encoding,$data);
	      			break;
	      			case "iso-8859-2":
	      				$data = iconv("utf-8",$encoding,$data);
	      			break;
	      			default:
	      			break;
	      		}
	      		return $data;
	    }
	}
?>
Reply With Quote