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_266477.xml"; if (!file_exists($LOCAL_XML_FILENAME)) { die("Script error: {$LOCAL_XML_FILENAME} does not exist. Please create a blank file named {$LOCAL_XML_FILENAME}."); } if (!is_writable($LOCAL_XML_FILENAME)) { die("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=EDKWJ2RGVHJL58TRG3JT&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<ul>\n"; for ($i = 0; $i < count($arr_xml['URL']); $i++) { if (isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0) { continue; } echo "<li>" . $arr_xml['BeforeText'][$i] . " <a href=\"" . $arr_xml['URL'][$i] . "\">" . $arr_xml['Text'][$i] . "</a> " . $arr_xml['AfterText'][$i] . "</li>\n"; } echo "</ul>"; } }
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_46888.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=O1RIR8ZSZQC3KXARMS5J&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<ul style=\"border: 0px; border-spacing: 0px; width: 100%; overflow: hidden; list-style: none; margin: 0; padding: 0;\">\n"; for ($i = 0; $i < count($arr_xml['URL']); $i++) { echo "<li style=\"clear: none; float: left; width: 100%; margin: 0; padding: 0; display: inline;\"><span style=\"padding: 3px; display: block; font-size: 12px; color: #000000; width: 100%; margin: 0;line-height:7px;\">" . $arr_xml['BeforeText'][$i] . " <a style=\"font-size: 9px; color: 837E3C;\" href=\"" . $arr_xml['URL'][$i] . "\">" . $arr_xml['Text'][$i] . "</a> " . $arr_xml['AfterText'][$i] . "</span></li>\n"; } echo "</ul>"; } }
function tla_ads($xml_filename, $inventory_key, $box_type) { // Examples /* $xml_filename = 'local_222925.xml'; $inventory_key = 'I3XF0SPPQPJOOFR2WSS9'; */ // Number of seconds before connection to XML times out // (This can be left the way it is) $CONNECTION_TIMEOUT = 15; // 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 = IP_ROOT_PATH . 'files/' . $xml_filename; $ads_content = ''; if (!file_exists($LOCAL_XML_FILENAME)) { @touch($LOCAL_XML_FILENAME); @chmod($LOCAL_XML_FILENAME, 0666); } if (!file_exists($LOCAL_XML_FILENAME) || !is_writable($LOCAL_XML_FILENAME)) { $ads_content = 'File ' . htmlspecialchars($LOCAL_XML_FILENAME) . ' either doesn\'t exist or isn\'t writable.'; return $ads_content; } if (filemtime($LOCAL_XML_FILENAME) < time() - 3600 || filesize($LOCAL_XML_FILENAME) < 3) { $url = 'http://www.text-link-ads.com/xml.php?k=' . $inventory_key . '&l=php-tla-2.0.1'; if (function_exists('json_decode') && is_array(json_decode('{"a":1}', true))) { $url .= '&f=json'; } tla_updateLocal($url, $LOCAL_XML_FILENAME, $CONNECTION_TIMEOUT); } 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=' . $inventory_key . '&referer=' . urlencode($request_uri) . '&user_agent=' . urlencode($user_agent), $LOCAL_XML_FILENAME, $CONNECTION_TIMEOUT); } $xml = tla_getLocal($LOCAL_XML_FILENAME); $links = tla_decode($xml); if ($links && is_array($links)) { $ads_content .= empty($box_type) ? "\n<ul>\n" : ''; $ads_content .= empty($box_type) ? "\n</ul>\n" : ''; echo "\n<ul>\n"; foreach ($links as $link) { if (isset($link['PostID']) && $link['PostID'] > 0) { continue; } //echo '<li style="padding: 0; float: left; margin: 0; width: 25%; clear: none; display: block;">' . ($link['BeforeText'] ? $link['BeforeText'] . ' ' : '') . '<a href="' . $link['URL'] . '">' . $link['Text'] . '</a>' . ($link['AfterText'] ? ' ' . $link['AfterText'] : '') . '</li>' . "\n"; $ads_content .= (empty($box_type) ? '<li>' : ($ads_count > 0 ? ' • ' : '')) . $link['BeforeText'] . '<a href="' . $link['URL'] . '">' . $link['Text'] . '</a> ' . $link['AfterText'] . (empty($box_type) ? '</li>' . "\n" : ''); $ads_count++; if (isset($link['PostID']) && $link['PostID'] > 0) { continue; } } echo '</ul>'; } $ads_content = empty($box_type) ? $ads_content : '<div class="gensmall" style="text-align: center;">' . $ads_content . '</div>'; return $ads_content; }
function tla_ads($xml_filename, $inventory_key, $box_type) { // Examples /* $xml_filename = 'local_222925.xml'; $inventory_key = 'I3XF0SPPQPJOOFR2WSS9'; */ // 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 = IP_ROOT_PATH . 'files/' . $xml_filename; $ads_content = ''; if (!file_exists($LOCAL_XML_FILENAME) || !is_writable($LOCAL_XML_FILENAME)) { return $ads_content; } if (filemtime($LOCAL_XML_FILENAME) < time() - 3600 || filesize($LOCAL_XML_FILENAME) < 20) { $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $user_agent_ads = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; tla_updateLocalXML('http://www.text-link-ads.com/xml.php?inventory_key=' . $inventory_key . '&referer=' . urlencode($request_uri) . '&user_agent=' . urlencode($user_agent_ads), $LOCAL_XML_FILENAME, $CONNECTION_TIMEOUT); } $xml = tla_getLocalXML($LOCAL_XML_FILENAME); $arr_xml = tla_decodeXML($xml); if (is_array($arr_xml)) { $ads_count = 0; $ads_content .= empty($box_type) ? "\n<ul>\n" : ''; for ($i = 0; $i < count($arr_xml['URL']); $i++) { if (isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0) { continue; } $ads_content .= (empty($box_type) ? '<li>' : ($ads_count > 0 ? ' • ' : '')) . $arr_xml['BeforeText'][$i] . '<a href="' . $arr_xml['URL'][$i] . '">' . $arr_xml['Text'][$i] . '</a> ' . $arr_xml['AfterText'][$i] . (empty($box_type) ? '</li>' . "\n" : ''); $ads_count++; } $ads_content .= empty($box_type) ? "\n</ul>\n" : ''; } $ads_content = empty($box_type) ? $ads_content : '<div class="gensmall" style="text-align: center;">' . $ads_content . '</div>'; return $ads_content; }