",$ads[$n]); if (!$url) return ""; $text = "".htmlspecialchars($desc).""; $n++; if ($n == $num_ads) $n = 0; $text_ads_n[$file] = $n; return $text; } //duplicate of rid.php //dir - absolute path from web root to dir inc. trailing slash //urlroot - what to append the name to to get the url function rid_in_directory($dir,$urlroot) { global $document_root; $realdir = "/www/global/imgtop/dontblockthis/".$dir; $ft = "$realdir/files.txt"; $names = file_array_cached($ft); if (!$names) { $arr = scandir($realdir); foreach ($arr as $fi) { if (preg_match("/\.(jpg|gif|png)$/", $fi)) { $names[] = $fi; } } file_put_contents($ft, join($names, "\n")); } return $urlroot.$names[rand(0, count($names)-1)]; } // Takes a dir and a filename and uses file() to parse it // then returns a random value. function rand_from_flatfile( $dir, $filename ) { $file = $dir . $filename; $names = file_array_cached( $file ); return $names[ rand( 0, count($names)-1 ) ]; } function form_ads(&$dat) { $error = false; // unused, errors have ads too $dat .= "
"; /*if(!$error && FIXED_AD == 1) { $dat.=''; }*/ if(FIXED_LEFT_AD == 1) { if(defined('FIXED_LEFT_TXT') && FIXED_LEFT_TXT) { $dat.= ad_text_for(FIXED_LEFT_TXT); } else if(defined('FIXED_LEFT_TABLE')) { list($ldimg,$ldhref) = rid(FIXED_LEFT_TABLE,1); $dat.=''; } } if(FIXED_RIGHT_AD == 1) { if(defined('FIXED_RIGHT_TXT') && FIXED_RIGHT_TXT) { $dat.= ad_text_for(FIXED_RIGHT_TXT); } else if(defined('FIXED_RIGHT_TABLE')) { list($ldimg,$ldhref) = rid(FIXED_RIGHT_TABLE,1); $dat.=''; } } $dat .= "
"; } function ad_text_for($path) { $txt = @file_get_contents_cached($path); if (!$txt) return $txt; return preg_replace_callback("@RANDOM@", "rand", $txt); } function global_msg_txt() { static $globalmsgtxt, $globalmsgdate; if (!$globalmsgdate) { if (file_exists(GLOBAL_MSG_FILE)) { $globalmsgtxt = file_get_contents(GLOBAL_MSG_FILE); $globalmsgdate = filemtime(GLOBAL_MSG_FILE); if ($globalmsgtxt) { $globalmsgtxt = str_replace('{{4CHAN_DOMAIN}}', MAIN_DOMAIN, $globalmsgtxt); } } else { $globalmsgtxt = null; $globalmsgdate = 1; } } return array($globalmsgtxt, $globalmsgdate); } ?>