Visa ett inlägg
Oläst 2005-05-16, 15:56 #5
Jawns avatar
Jawn Jawn är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Aug 2004
Inlägg: 986
Jawn Jawn är inte uppkopplad
Mycket flitig postare
Jawns avatar
 
Reg.datum: Aug 2004
Inlägg: 986
Kod:
<?php
	

	function file_get_contents_an ($url) {
 if (substr ($url, 0, 7) == 'http://') {
 	$url = parse_url ($url);
 	$handle = fsockopen ($url['host'], 80);
 	fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
 	while (!feof($handle)) {
  $string .= fread($handle, 40960);
 	}
 	$string = explode ("\n", $string);
 	$string = array_pop ($string);
 } else {
 	$handle = fopen($url, 'r');
 	$string = fread($handle, 4096000);
 	
 }
 fclose($handle);
 return $string;
	}
	
	if (!function_exists('make_seed')) {
 function make_seed() {
 	list($usec, $sec) = explode(' ', microtime());
 	return (float) $sec + ((float) $usec * 100000);
 }
 mt_srand (make_seed());
	}

	if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;

	$ad_file = '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)) {
 $ad_network = array();
 $ads = file_get_contents_an ($ad_file);
 $ads = explode ('<ad_break>', $ads);
 $ads_temp = explode ('|', $ads[0]);

 $file = fopen($ad_file, 'r+');
 if (flock ($file, LOCK_EX|LOCK_NB, $would_block) && !$would_block) {
 	if ((count ($ads) < $ads_temp[3] + 1 && $ads_temp[0] + $ads_temp[5] < time()) || $ads_temp[0] + $ads_temp[4] < time()) {
  $new_ad = file_get_contents_an ('http://ads.digitalpoint.com/network.php?c=' . $_SERVER['SERVER_NAME'] . '&type=link');
  if ($new_ad) {
  	$ads_param = explode ('<ad_param>' , $new_ad);
  	$new_ad = $ads_param[1];
  	unset ($ads_param[1]);
  	$ads_temp = explode ('|', $ads_temp[0] . '|' . $ads_temp[1] . '|' . $ads_param[0]);
  } else {
  	$ads_param = array_slice ($ads_temp, 2, 4);
  }
  $ads[0] = time() . '|' . gethostbyname('validate.digitalpoint.com') . '|' . implode ('|', $ads_param);
  if ($new_ad) {
  	$ads[] = $new_ad;
  	if (count ($ads) > $ads_temp[3] + 1) $ads = array_merge ((array)$ads[0], (array)array_slice ($ads, -$ads_temp[3]));
  }
  fwrite ($file, implode ('<ad_break>', $ads));
  ftruncate ($file, ftell($file));
  $ad_network[] = $new_ad;
 	}
 	flock ($file, LOCK_UN);
 	fclose ($file);
 }
 while (count ($ad_network) < 5) {
 	$ad_network[] = $ads[mt_rand(1,count($ads) - 1)];
 }
 foreach ($ad_network as $key => $ad) {
 	$split = explode ('<id>', $ad);
 	$ad_ids[] = $split[1];
 	$ad = $split[0];
 	$output = $ads_temp[1] == $_SERVER['REMOTE_ADDR'] || $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR'];
 	if ($output) {
  $ad_network[$key] = str_replace ('" />', '" class="' . $ads_temp[2] . '" />', $ad);
 	} else {
  $ad_network[$key] = str_replace ('" />', '">', $ad);
 	}
 }
 $ad_network = implode ('<br />', $ad_network);
 if ($ads_temp[6] && ($output || preg_match('#(' . str_replace ('-', '|', $ads_temp[7]) . ')#si', $_SERVER['HTTP_USER_AGENT'])) && !$_SERVER['HTTPS']) $ad_network .= '<img src="http://ads.digitalpoint.com/t-' . implode ('-', $ad_ids) . '.gif" width="1" height="1" />';
	} else {
 $ad_network = 'You must set the ad network .txt file to be writable (or file is not within path).';
	}
	if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
 ini_set ('zlib.output_compression', 0);
 echo $ad_network;
	}

?>

detta är vad han sa

Citat:
The code, incidentally as you will see from the script:

gets ads from the ad server.
caches them locally in a text file

Nothing dodgy
Regards,

skulle få en viss summa $$ i månaden för randomized länkar vid footern men som det ser ut så kan han redirekta mina besökare till hans sida om han vill?
någon annan som ser något skummt i det?
Jawn är inte uppkopplad   Svara med citatSvara med citat