จัดการบล็อกของคุณ

สร้างบล็อกของคุณดี๋ยวนี้! ง่ายดายและฟรี

งานออนไลน์
hot web for free

25/04/2008 GMT 1

code

741147 @ 02:54

<%@ Language=VBScript %>
<%
' Local file to store XML
' You must create a blank file named "local_222440.xml" in the same
' directory as this script. It MUST be writable by the web
' server. On unix you would CHMOD 666 the file. On Windows
' you will need to access your custom control panel to set
' the permissions or contact your hosting company.

Const ForReading = 1, ForWriting = 2

Dim LOCAL_XML_FILENAME, sourceFile, FSO

LOCAL_XML_FILENAME = server.MapPath("local_222440.xml")
sourceFile = "http://www.text-link-ads.com/xml.php?inventory_key=DOCTPCM94J4OHJ8XBHZG&referer=" & Server.UrlEncode(Request.ServerVariables("HTTP_REFERER")) & "&user_agent=" & Server.UrlEncode(Request.ServerVariables("HTTP_USER_AGENT"))
Set FSO = server.createObject("Scripting.FileSystemObject")

' update local XML
Dim DateMod, MonthString, DayString, DateModFile, DateModLimit

DateMod = FSO.getFile(LOCAL_XML_FILENAME).DateLastModified

MonthString = Month(DateMod)
If (MonthString < 10) Then
MonthString = "0" & MonthString
End If

DayString = Day(DateMod)
If (DayString < 10) Then
DayString = "0" & DayString
End If

DateModFile = Year(DateMod) & "-" & MonthString & "-" & DayString & " " & Hour(DateMod) & ":" & Minute(DateMod) & ":" & Second(DateMod)

MonthString = Month(Date)
If (MonthString < 10) Then
MonthString = "0" & MonthString
End If

DayString = Day(Date)
If (DayString < 10) Then
DayString = "0" & DayString
End If

DateModLimit = Year(Date) & "-" & MonthString & "-" & DayString & " " & (Hour(Now)-1) & ":" & Minute(Now) & ":" & Second(Now)

Dim Contents, Result, xmlhttp, TextStream

' read local XML
Contents = ""
Set TextStream = FSO.OpenTextFile(LOCAL_XML_FILENAME, ForReading, False, -2)
Do While Not TextStream.AtEndOfStream
Contents = Contents & TextStream.ReadLine
Loop
TextStream.Close
Set TextStream = nothing

If (DateModFile < DateModLimit Or FSO.getFile(LOCAL_XML_FILENAME).size < 20) Then
' fetch remote XML
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "GET", sourceFile, False
xmlhttp.send ""
Result = xmlhttp.responseText
If (Result <> "") Then
Contents = Result
End If

' write new XML to local file
Set TextStream = FSO.OpenTextFile(LOCAL_XML_FILENAME, ForWriting, True)
TextStream.Write Contents
TextStream.Close
Set TextStream = nothing
End If

' parse local XML
Dim source
Set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.loadXML(Contents)

' Output links
Dim objLst, i, numLinks, objLink, objLinkChildren, linkNode, URL, Text, BeforeText, AfterText

Set objLst = source.getElementsByTagName("Link")
numLinks = objLst.length - 1

Response.Write("

    ")
    For i = 0 To numLinks
    Set objLink = objLst.item(i)
    Set objLinkChildren = objLink.childNodes
    URL = ""
    Text = ""
    BeforeText = ""
    AfterText = ""

    For Each linkNode In objLinkChildren
    If linkNode.nodeName = "URL" Then
    URL = linkNode.text
    End If
    If linkNode.nodeName = "Text" Then
    Text = linkNode.text
    End If
    If linkNode.nodeName = "BeforeText" Then
    BeforeText = linkNode.text
    End If
    If linkNode.nodeName = "AfterText" Then
    AfterText = linkNode.text
    End If
    Next

    Response.Write("

  • " & BeforeText & " " & Text & " " & AfterText & "
  • ")
    Next
    Response.Write("

")

%>
http://www.text-link-ads.com/xml_blogger.php?inventory_key=DOCTPCM94J4OHJ8XBHZG&feed=1
http://www.text-link-ads.com/xml_blogger.php?inventory_key=DOCTPCM94J4OHJ8XBHZG&feed=2

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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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;
}

tla_ads();

?><%@ page import="java.net.*"%>
<%@ page import="java.io.*"%>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory"%>
<%@ page import="javax.xml.parsers.ParserConfigurationException"%>
<%@ page import="org.xml.sax.SAXException"%>
<%@ page import="org.w3c.dom.*"%>
<%@ page import="java.util.*"%>
<%!
// The following code was graciously provided by Armond Avanes (http://www.armondavanes.com)

private String tla_ads( HttpServletRequest request, HttpServletResponse response ) throws IOException, ParserConfigurationException, SAXException
{
// Number of seconds before connection to XML times out
// (This can be left the way it is)
int 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
String LOCAL_XML_FILENAME = "local_222440.xml";
String INVENTORY_KEY = "DOCTPCM94J4OHJ8XBHZG";

File localXmlFile = new File( getServletConfig().getServletContext().getRealPath(LOCAL_XML_FILENAME ) );

if( !localXmlFile.exists() ) {
return( "Script error: " + localXmlFile.getName() + " does not exist. Please create a blank file named " + localXmlFile.getName() + "." );
}
if( !localXmlFile.canWrite() ) {
return( "Script error: " + localXmlFile.getName() + " is not writable. Please set write permissions on " + localXmlFile.getName() + "." );
}

if( localXmlFile.lastModified()<(new Date().getTime() - 3600*1000) || localXmlFile.length()<20 ) {
String request_uri = (request.getRequestURI()!=null) ? request.getRequestURI() : "";
String user_agent = (request.getHeader("User-Agent")!=null) ? request.getHeader("User-Agent") : "";
URL url = new URL("http://www.text-link-ads.com/xml.php?inventory_key=" + INVENTORY_KEY + "&referer=" + response.encodeURL( request_uri ) + "&user_agent=" + response.encodeURL( user_agent ));

tla_updateLocalXML(url, localXmlFile, CONNECTION_TIMEOUT);
}

Map[] arr_xml = tla_decodeXML(localXmlFile );
StringBuffer sb = new StringBuffer();

if( arr_xml!=null && arr_xml.length>0 ) {
sb.append( "\n

    \n" );
    for( int i=0; i Map map = arr_xml[i];

    sb.append( "

  • " );
    sb.append( map.get("BeforeText") );
    sb.append( " " + map.get("Text") + " " );
    sb.append( map.get("AfterText") + "
  • \n" );
    }
    sb.append("

");
}

return sb.toString();
}

private void tla_updateLocalXML(URL url, File file, int time_out) throws IOException
{
file.setLastModified( new Date().getTime() );

String xml = file_get_contents_tla(url, time_out);

if( xml!=null && !xml.trim().equals("") ) {
FileWriter fw = new FileWriter(file);

fw.write( xml );
fw.close();
}
}

private String file_get_contents_tla(URL url, int time_out) throws IOException
{
URLConnection urlConnection = url.openConnection();

//urlConnection.setConnectTimeout( time_out * 1000 );
//urlConnection.setReadTimeout( time_out * 1000 );

InputStream is = urlConnection.getInputStream();
StringBuffer content = new StringBuffer();
int ch;

while( (ch=is.read())!=-1 )
content.append( (char)ch );

is.close();
return content.toString();
}

private Map[] tla_decodeXML(File file) throws ParserConfigurationException, IOException, SAXException
{
Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( file );
Node linksRoot = dom.getFirstChild();
NodeList links = linksRoot.getChildNodes();
List result = new ArrayList();

for( int i=0; i
{
Node link = links.item(i);

if( link.getNodeType()==Node.TEXT_NODE )
continue;

NodeList linkAttributes = link.getChildNodes();
Map map = new HashMap();

for( int j=0; j {
Node linkAttr = linkAttributes.item(j);
Text textNode = (Text)linkAttr.getFirstChild();
String value = ( textNode!=null ) ? textNode.getNodeValue().trim() : "";

map.put( linkAttr.getNodeName(), value );
}
result.add(map);
}

return (Map[])result.toArray( new Map[0] );
}
%>
<%= tla_ads(request, response) %>

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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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;
}

tla_ads();

?>use CGI;
use XML::Simple;
use LWP::Simple;
use Data::Dumper;
use URI::Escape;

my $page = new CGI;
print $page->header( "text/html" );

# Local file to store XML
# You must create a blank file with this name in the same
# directory as this script. It MUST be writable by the web
# server. On unix you would CHMOD 666 the file. On Windows
# you will need to access your custom control panel to set
# the permissions or contact your hosting company.
my $LOCAL_XML_FILENAME = "local_222440.xml";

# update XML file
my ($file_size,$file_mod) = (stat ($LOCAL_XML_FILENAME) )[7,9];

if(($file_mod < time - 3600) || $file_size < 20){
$now = time;
utime $now, $now, ($LOCAL_XML_FILENAME);
my $xml = get("http://www.text-link-ads.com/xml.php?inventory_key=DOCTPCM94J4OHJ8XBHZG&referer=" . uri_escape($ENV{HTTP_REFERER}) . "&user_agent=" . uri_escape($ENV{HTTP_USER_AGENT}));
if($xml){
open (CACHE, "> $LOCAL_XML_FILENAME");
print CACHE $xml;
close(CACHE);
}
}

# create object
my $xml = new XML::Simple;

# read local XML file
my $data = $xml->XMLin($LOCAL_XML_FILENAME);

if ($data->{'Link'}) {

if(ref $data->{'Link'} eq "HASH"){
@$temp = ($data->{'Link'});
$data->{'Link'} = $temp;
}

if ($data->{'Link'}->[0]) {
print "\n

    \n";
    my $count = 0;
    while ($data->{'Link'}->[$count]) {
    print "
  • " . (( ref $data->{'Link'}->[$count]->{'BeforeText'} eq "HASH") ? "" : $data->{'Link'}->[$count]->{'BeforeText'} ) . " {'Link'}->[$count]->{'URL'}\">$data->{'Link'}->[$count]->{'Text'} " . (( ref $data->{'Link'}->[$count]->{'AfterText'} eq "HASH") ? "" : $data->{'Link'}->[$count]->{'AfterText'} ) . "
  • ";
    $count++;
    }
    print "

";
}
}

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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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;
}

tla_ads();

?>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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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;
}

tla_ads();require 'net/http'
require 'cgi'

def content
response.lifetime = 6.hour
url = "http://www.text-link-ads.com/xml.php?inventory_key=DOCTPCM94J4OHJ8XBHZG&referer="+CGI::escape(@requester.env['REQUEST_URI'])
agent = "&user_agent="+CGI::escape(@requester.env['HTTP_USER_AGENT'])
url_time, url_data = fragment_key(url)

#is it time to update the cache?
time = read_fragment(url_time)
if (time == nil) || (time.to_time < Time.now)
@links = requester(url+agent) rescue nil
#if we can get the latest, then update the cache
if @links != nil
expire_fragment(url_time)
expire_fragment(url_data)
write_fragment(url_time, Time.now+6.hour)
write_fragment(url_data, @links)
else
#otherwise try again in 1 hour
write_fragment(url_time, Time.now+1.hour)
@links = read_fragment(url_data)
end
else
#use the cache
@links = read_fragment(url_data)
end
end

def requester(url)
XmlSimple.xml_in (http_get(url))
end

def http_get(url)
Net::HTTP.get_response(URI.parse(url)).body.to_s
end

def fragment_key(name)
return "TLA/TIME/#{name}", "TLA/DATA/#{name}"
end

// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}

include_once dirname(__FILE__) . '/lang_en.inc.php';

@define('PLUGIN_EVENT_TEXTLINKADS_TITLE', 'TextLinkAds.com Ads');
@define('PLUGIN_EVENT_TEXTLINKADS_DESC', 'Embeds TextLinkAds.com advertisements into your page. You need to edit the Smarty .tpl file of your template to indicate where the ad should be placed, otherwise it will not appear on your site. Use this Smarty code to place the Ad: {serendipity_hookPlugin hook="external_service_tla" hookAll="true"}');
@define('PLUGIN_EVENT_TEXTLINKADS_HTMLID', '222440');
@define('PLUGIN_EVENT_TEXTLINKADS_XMLFILENAME', 'local_222440.xml');

class serendipity_event_textlinkads extends serendipity_event
{
var $title = PLUGIN_EVENT_TEXTLINKADS_TITLE;

function introspect(&$propbag) {
global $serendipity;

$propbag->add('name', PLUGIN_EVENT_TEXTLINKADS_TITLE);
$propbag->add('description', PLUGIN_EVENT_TEXTLINKADS_DESC);
$propbag->add('stackable', true);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('groups', array('EXTERNAL_SERVICES'));
$propbag->add('version', '0.9');
$propbag->add('configuration', array('htmlid', 'xmlfilename'));
$propbag->add('event_hooks', array(
'css' => true,
'external_service_tla' => true
));
}

function introspect_config_item($name, &$propbag) {
switch($name) {
case 'htmlid':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_TEXTLINKADS_HTMLID);
$propbag->add('description', '');
$propbag->add('default', '222440');
break;

case 'xmlfilename':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_TEXTLINKADS_XMLFILENAME);
$propbag->add('description', '');
$propbag->add('default', 'local_222440.xml');
break;

default:
return false;
}
return true;
}

/* BEGIN FOREIGN CODE */
function tla_ads() {
global $serendipity;

// 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 = $serendipity['serendipityPath'] . $this->get_config('xmlfilename');

if (!file_exists($LOCAL_XML_FILENAME)) {
echo "Script error: $LOCAL_XML_FILENAME does not exist. Please create a blank file named $LOCAL_XML_FILENAME.";
return false;
}

if (!is_writable($LOCAL_XML_FILENAME)) {
echo "Script error: $LOCAL_XML_FILENAME is not writable. Please set write permissions on $LOCAL_XML_FILENAME.";
return false;
}

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'] : "";
$this->tla_updateLocalXML("http://www.text-link-ads.com/xml.php?inventory_key=DOCTPCM94J4OHJ8XBHZG&referer=" . urlencode($request_uri) . "&user_agent=" . urlencode($user_agent), $LOCAL_XML_FILENAME, $CONNECTION_TIMEOUT);
}

$xml = $this->tla_getLocalXML($LOCAL_XML_FILENAME);
$arr_xml = $this->tla_decodeXML($xml);

if (!is_array($arr_xml)) {
return false;
}
echo "\n

    \n";

    for ($i = 0, $maxi = count($arr_xml['URL']); $i < $maxi; $i++) {
    echo "

  • " . $arr_xml['BeforeText'][$i] . " " . $arr_xml['Text'][$i] . " "
    . $arr_xml['AfterText'][$i] . "
  • \n";
    }

    echo "

";
}

function tla_updateLocalXML($url, $file, $time_out) {
if ($handle = fopen($file, "a")) {
fwrite($handle, "\n");
fclose($handle);
}

if ($xml = $this->file_get_contents_tla($url, $time_out)) {
$xml = substr($xml, strpos($xml, '

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file) {
$contents = "";
if ($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}

return $contents;
}

function file_get_contents_tla($url, $time_out) {
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if (function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function html_entity_decode($string) {
if (function_exists('html_entity_decode')) {
return html_entity_decode($string);
}

// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}

function tla_decodeXML($xmlstg) {
$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$n = 0;

while (isset($out[$n])) {
$retarr[$out[$n][1]][] = str_replace($search_ar, $replace_ar, $this->html_entity_decode(strip_tags($out[$n][0])));
$n++;
}

return $retarr;
}
/* END FOREIGN CODE */

function generate_content(&$title) {
$title = $this->title;
}

function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;

$hooks = &$bag->get('event_hooks');

if (isset($hooks[$event])) {
switch($event) {
case 'css':
$id = $this->get_config('htmlid');
return true;
break;

case 'external_service_tla':
$this->tla_ads();
return true;
break;

default:
return false;
break;
}
} else {
return false;
}
}
}
{serendipity_hookPlugin hook="external_service_tla" hookAll="true"}
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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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();

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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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();

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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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();

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_222440.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=DOCTPCM94J4OHJ8XBHZG&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

    \n";
    for ($i = 0; $i < count($arr_xml['URL']); $i++) {
    if( isset($arr_xml['PostID'][$i]) && $arr_xml['PostID'][$i] > 0 ) continue;
    echo "
  • ".$arr_xml['BeforeText'][$i]." ".$arr_xml['Text'][$i]." ".$arr_xml['AfterText'][$i]."
  • \n";
    }
    echo "

";
}

}

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,'

if ($handle = fopen($file, "w")) {
fwrite($handle, $xml);
fclose($handle);
}
}
}

function tla_getLocalXML($file)
{
$contents = "";
if($handle = fopen($file, "r")){
$contents = fread($handle, filesize($file)+1);
fclose($handle);
}
return $contents;
}

function file_get_contents_tla($url, $time_out)
{
$result = "";
$url = parse_url($url);

if ($handle = @fsockopen ($url["host"], 80)) {
if(function_exists("socket_set_timeout")) {
socket_set_timeout($handle,$time_out,0);
} else if(function_exists("stream_set_timeout")) {
stream_set_timeout($handle,$time_out,0);
}

fwrite ($handle, "GET $url[path]?$url[query] HTTP/1.0\r\nHost: $url[host]\r\nConnection: Close\r\n\r\n");
while (!feof($handle)) {
$result .= @fread($handle, 40960);
}
fclose($handle);
}

return $result;
}

function tla_decodeXML($xmlstg)
{

if( !function_exists('html_entity_decode') ){
function html_entity_decode($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
}

$out = "";
$retarr = "";

preg_match_all ("/<(.*?)>(.*?) $search_ar = array('<', '>', '"');
$replace_ar = array('<', '>', '"');
$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();

ความคิดเห็น

โฆษณา,โฆษณาออนไลน์,การโฆษณา,สื่อโฆษณา,การตลาด,บริษัทโฆษณา,ประชาสัมพันธ์,ลงโฆษณา,ประกาศ,ออนไลน์,online,online advertising,advertising,โปรโมทสินค้า,โปรโมทเว็บไซต์,promote website,seo,pay per click,ad per click,media,ค้นหาเว็บ,media,สื่อ

ยังไม่มีความคิดเห็น »

ส่งความคิดเห็น


<a href> <em> <blockquote> <strong> <cite> <code> <ul> <li> <dl> <dt> <dd>


โฆษณา,โฆษณาออนไลน์,การโฆษณา,สื่อโฆษณา,การตลาด,บริษัทโฆษณา,ประชาสัมพันธ์,ลงโฆษณา,ประกาศ,ออนไลน์,online,online advertising,advertising,โปรโมทสินค้า,โปรโมทเว็บไซต์,promote website,seo,pay per click,ad per click,media,ค้นหาเว็บ,media,สื่อ

ติดต่อผู้สร้าง | กรุ | สร้างบล็อกของคุณดี๋ยวนี้! ง่ายดายและฟรี