function tla_ads() { // Number of seconds before connection to XML times out // (This can be left the way it is) $CONNECTION_TIMEOUT = 10; // Local file to store XML // This file MUST be writable by web server // You should create a blank file and CHMOD it to 666 $LOCAL_XML_FILENAME = "local_45208.xml"; if( !file_exists($LOCAL_XML_FILENAME) ) die("Text Link Ads script error: $LOCAL_XML_FILENAME does not exist. Please create a blank file named $LOCAL_XML_FILENAME."); if( !is_writable($LOCAL_XML_FILENAME) ) die("Text Link Ads script error: $LOCAL_XML_FILENAME is not writable. Please set write permissions on $LOCAL_XML_FILENAME."); if( filemtime($LOCAL_XML_FILENAME) < (time() - 3600) || filesize($LOCAL_XML_FILENAME) < 20) { $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ""; $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; tla_updateLocalXML("http://www.text-link-ads.com/xml.php?inventory_key=YKOIFQ099FIXEG9W1PAN&referer=" . urlencode($request_uri) . "&user_agent=" . urlencode($user_agent), $LOCAL_XML_FILENAME, $CONNECTION_TIMEOUT); } $xml = tla_getLocalXML($LOCAL_XML_FILENAME); $arr_xml = tla_decodeXML($xml); if ( is_array($arr_xml) ) { echo "\n"; } } function tla_updateLocalXML($url, $file, $time_out) { if($handle = fopen($file, "a")){ fwrite($handle, "\n"); fclose($handle); } if($xml = file_get_contents_tla($url, $time_out)) { $xml = substr($xml, strpos($xml,'(.*?)', '"'); $n = 0; while (isset($out[$n])) { $retarr[$out[$n][1]][] = str_replace($search_ar, $replace_ar,html_entity_decode(strip_tags($out[$n][0]))); $n++; } return $retarr; } ob_start(); tla_ads(); $tla_ads = ob_get_contents(); ob_end_clean();