Inserting Text Link Ads using php

Register an Account
Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2008, 01:07 AM
New Pligger
Pligg Version: 1 RC 4
Pligg Template: wistie
 
Join Date: Oct 2007
Posts: 17
HI, im trying to insert the php code provided by text link ads on the template sidebar, but i keep getting error messages. is there a special way to insert php code?

any help will be much appreciated

thanks
  #2 (permalink)  
Old 12-24-2008, 01:12 AM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Social Pro Kit
 
Join Date: Jun 2006
Posts: 5,448
You need to change <?php to {php} and ?> to {/php}
So it should be
Code:
{php}
code here
{/php}
And not this way
Code:
<?php
code here
?>
  #3 (permalink)  
Old 12-24-2008, 01:19 AM
New Pligger
Pligg Version: 1 RC 4
Pligg Template: wistie
 
Join Date: Oct 2007
Posts: 17
Thanks, tried it, get this error

Parse error: syntax error, unexpected '?' in /home/.joyful/domain/class.template.php(745) : eval()'d code on line 57


any help?
  #4 (permalink)  
Old 12-24-2008, 01:55 AM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Social Pro Kit
 
Join Date: Jun 2006
Posts: 5,448
paste the code here
  #5 (permalink)  
Old 12-24-2008, 02:07 AM
New Pligger
Pligg Version: 1 RC 4
Pligg Template: wistie
 
Join Date: Oct 2007
Posts: 17
Quote:
Originally Posted by chuckroast View Post
paste the code here
This is my sidebar.tpl code
Quote:
{if $user_authenticated ne true} {* show only if NOT logged in *}
{assign var=sidebar_module value="about_box"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}
{/if}

{checkActionsTpl location="tpl_sidebar_top"}


<div align="center">
{php}
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_279430.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=V4XRG43CPK4E5FGIS5OF&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_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 ("/<(.*?)>(.*?)</", $xmlstg, $out, PREG_SET_ORDER);
$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();

{/php}



</div>

{if $user_authenticated ne true} {assign var=sidebar_module value="login"}{include file=$the_template_sidebar_modules."/wrapper2.tpl"} {/if}

{assign var=sidebar_module value="sidebar_stories_u"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}

{assign var=sidebar_module value="sidebar_stories"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}

{assign var=sidebar_module value="categories"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}

{assign var=sidebar_module value="sidebar_comments"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}

{if $Enable_Tags eq 'true'} {assign var=sidebar_module value="tags"}{include file=$the_template_sidebar_modules."/wrapper.tpl"} {/if}
  #6 (permalink)  
Old 12-24-2008, 02:14 AM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Social Pro Kit
 
Join Date: Jun 2006
Posts: 5,448
Wow, that's a lot of code. I thought it was a little snippet..
A better way would be to make a file, lets call it ads.php and inside it you paste your php code.

Upload it somewhere on your server and remember the location.

Then in your sidebar.tpl add something like this. Using absolute path.

{php}include('/home/yourpath/public_html/ads.php');{/php}
  #7 (permalink)  
Old 12-24-2008, 02:31 AM
New Pligger
Pligg Version: 1 RC 4
Pligg Template: wistie
 
Join Date: Oct 2007
Posts: 17
thanks will try that and let you know
very helpful forum, wish you all a very Merry Christmas and a very happy new year!
  #8 (permalink)  
Old 12-23-2011, 01:49 AM
PainnaSok's Avatar
New Pligger
Pligg Template: PainnaSokSU
 
Join Date: Dec 2011
Location: Peru
Posts: 1
Send a message via ICQ to PainnaSok
скачать the movies stunts effects скачать саундтрек к фильму гладиатор скачать сергеё зверев дольче габбана скачать песню мы дети солнца скачать самоучитель по бухгалтерскому учету скачать бесплатные темы на сотку скачать фильм фредди против джейсона скачать обучение брейк дансу видео скачать эротика видео для телефонов скачать qip на телефон samsung скачать песню город сочи трофимов atheros ar5b95 wireless network adapter скачать презентацию на тему германия скачать сохранение для diablo 2 скачать кал оф дьюти 5

gifmoviegear скачать песню РёР· фильма хенкок бесплатные игры скачать red alert скачать песню наш звездный час скачать counter strike sours v34 сокровища монтесумы скачать полную версию скачать игра том и джерри история пианино скачать бесплатную игры о рыбалке скачать РїСЂРѕРіСѓ для взлома мыла

скачать bearpaw 1200cu plus драйвер скачать мультфильмы чип и дейл скачать фильмы в avi формате скачать игровой автомат crazy monkey скачать программу для создания аниме скачать песню булановой старшая сестра скачать драйвера для вебкамер logitech скачать игра отчаянные домохозяйки торрент скачать библия в электронном виде Жека. Все альбомы

скачать там где клен шумит скачать песню лолиты ориентация север ea download manager скачать программу фильм петербургские тайны GSRoot.dll скачать РІСЃРµ картинки СЃ сайта скачать новую версию mail ru скачать openoffice для windows xp Устройство парной скачать драйвера РЅР° монитор lg

скачать три белых коня минус скачать игры на ps2 безплатно скачать книга красное и чёрное игры онлайн скачать counter strike скачать скайп для windows xp
Closed Thread

Tags
ads, php code, text link

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
/var/log/httpd/error_log messages gr8rcake Questions and Comments 4 06-01-2010 12:25 PM
Pligg Errors tcritic Questions and Comments 4 09-01-2009 10:40 AM
How to show category keywords as text on the site? gnalkit Questions and Comments 4 11-26-2008 06:17 AM
cann't vote in pligg (buliding 802) haxhax Questions and Comments 27 03-10-2007 07:53 AM
dreamhost and validation image problem Xanatos Questions and Comments 17 01-17-2007 02:14 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development