1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

URL file-access is disabled in the server

Discussion in 'Co-op Advertising Network' started by normanos, Dec 17, 2004.

  1. #1
    Warning: file_get_contents(): URL file-access is disabled in the server configuration in /xxx/web/forum/ad_network.php on line 36

    Warning: file_get_contents(http://ads.digitalpoint.com/network.php?s=xxx&type=link): failed to open stream: no suitable wrapper could be found in /xxx/web/forum/ad_network.php on line 36

    and now what? :confused:
     
    normanos, Dec 17, 2004 IP
  2. moskita

    moskita Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this in ad_network.php

    
    <?php
    if (!function_exists('url_fopen')) 
    {
    		
    function url_fopen ($url)
    {
           $user_agent = "Mozilla/8.0 (Windows 2008 SP32 + 3patch)";
           $ch = curl_init();
           curl_setopt ($ch, CURLOPT_URL, $url);
           curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
           curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt");
           curl_setopt ($ch, CURLOPT_HEADER, 0);
           curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
           curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
           $string = curl_exec ($ch);
           curl_close($ch);
           return $string;
    }
    }
    	
    	if (!function_exists('make_seed')) {
    		function make_seed() {
    			list($usec, $sec) = explode(' ', microtime());
    			return (float) $sec + ((float) $usec * 100000);
    		}
    		srand (make_seed());
    	}
    
    	if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;
    
    	$ad_file = 'ad_network_ads.txt';
    	for ($i = 0; $i <= 11; $i++) {
    		$p = substr ('../../../../../../../../../../', 0, $i * 3);
    		if (file_exists ($p . $ad_file)) {
    			$ad_file = $p . $ad_file;
    			break;
    		}
    	}
    
    	if (is_writable ($ad_file)) {
    		$ads = file_get_contents ($ad_file);
    		$ads = explode ('<ad_break>', $ads);
    
    		if (count ($ads) < 401 || $ads[0] + 900 < time()) {
    			$new_ad = url_fopen ('http://ads.digitalpoint.com/network.php?s=' . $_SERVER['SERVER_NAME'] . '&type=link');
    			$ads[] = $new_ad;
    			$ads[0] = time();
    			if (count ($ads) > 401) unset ($ads[1]);
    			if ($new_ad) {
    				$file = fopen($ad_file, 'r+');
    				if (flock ($file, LOCK_EX)) {
    					fwrite ($file, implode ('<ad_break>', $ads));
    					ftruncate ($file, ftell($file));
    					flock ($file, LOCK_UN);
    				}
    				fclose ($file);
    			}
    			$ad = end ($ads);
    		} else {
    			$ad = $ads[rand(1,count($ads) - 1)];
    		}
    		$ad_network[] = $ad;
    		while (count ($ad_network) < 5) {
    			$ad_network[] = $ads[rand(1,count($ads) - 1)];
    		}
    	} else {
    		$ad_network[] = 'You must set the "ad_network_ads.txt" file to be writable.';
    	}
    	if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
    		ini_set ('zlib.output_compression', 0);
    		echo end ($ad_network);
    	}
    
    ?>
    
    Code (markup):
     
    moskita, Dec 17, 2004 IP
  3. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ask your hosting company to switch it on. It's a PHP function called Http wrapper.

    It's standard and there is no reason to not have this on.

    M

    If they can't you may want to consider to go to a real host
     
    expat, Dec 17, 2004 IP