After adding a piece of code (you can see it below), I get the following error messages:
Warning: ad_rollingsl(rollingsl.php) [function.ad-rollingsl]: failed to open stream: No such file or directory in/.../.../.../.../.../.../index.php on line ....
Warning: ad_rollingsl() [function.include]: Failed opening 'rollingsl.php' for inclusion (include_path='.:/usr/php4/lib/php') in/.../.../.../.../.../.../index.php on line ....A tech who is preparing this code is telling me "
it looks like your server doesn’t accept fopen commands"
So I wonder, do LP servers accept fopen ?
(The code I added is as follows):
<?php
function rollingsl_plugin_activate() {
}
if ( !class_exists('AdBeans_RollingSL') ) :
class AdBeans_RollingSL{
//Constructor method
function AdBeans_RollingSL() {
include('rollingsl.php');
add_filter('the_content', 'adbeans_rsl_insert', 1);
}
}
endif;
if (class_exists('AdBeans_RollingSL')) :
$AdBeans_RollingSL = new AdBeans_RollingSL();
endif;
?>
<?php
function adbeans_rsl_insert($content) {
$original_content = $content;
$ad = adbeans_rsl_process_text();
if ($ad != '')
{
$separator = '';
if (stripos($ad, '<br>') !== false)
$separator = '<br>';
else if (stripos($ad, '<br />') !== false)
$separator = '<br />';
else if (stripos($ad, '<br/>') !== false)
$separator = '<br/>';
if ($separator != '')
{
// Separate Heading from Description
$ad_parts = explode($separator, $ad);
$heading = $ad_parts[0];
$description = $ad_parts[1];
// Get Keyword from the Heading
if (preg_match("@<a[^>]*href=[\"'](.*)[\"'][^>]*>([^<]*)</a>@siU", $heading, $matches))
{
$url = $matches[1];
$keyword = $matches[2];
$link = "<a href='" . $url . "' target='_blank'>" . $keyword . "</a>";
// Check if the URL is already in the description
if (stripos($description, $keyword))
{
if (preg_match("@<a[^>]*>[^>]*" . $keyword . "[^>]*</a>@siU", $description) == 0)
$description = preg_replace('@(' . $keyword . ')@siU', str_ireplace($keyword, '\\1', $link), $description);
}
else
$description = $link . " - " . $description;
}
$content .= "<p> </p><p> </p><p>" . $description;
}
}
return $content;
}
function adbeans_rsl_process_text() {
//Get the domain name of the calling page
$domainname = $_SERVER['SERVER_NAME'];
$domainname = str_replace("http://", "", $domainname);
$domainname = str_replace("www.", "", $domainname);
$pageurl = trim(preg_replace("/[&]/", "~", $_SERVER['REQUEST_URI']), "~");
$visitorip = $_SERVER['REMOTE_ADDR'];
$remote_path = "/RequestFormattedAds.aspx?DomainName=$domainname&Visitor=$visitorip&PageUrl=$pageurl";
$ad = adbeans_rsl_do_post_request($remote_path);
return $ad;
}
function adbeans_rsl_do_post_request($remote_path, $data = null, $optional_headers = null) {
$remote_domain = "http://dlaserv.com";
$remote_port = ":53195";
$params = array('http' => array(
'method' => 'GET',
'header' => array("Accept-language: en",)
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$url = $remote_domain . $remote_path;
$response = @file_get_contents($url, 0, $ctx); // Version < PHP5
if ($response == false) {
// If it fails, try alternative port
$url = $remote_domain . $remote_port . $remote_path;
$response = @file_get_contents($url, 0, $ctx);
if ($response == false)
$response = "";
}
return $response;
}
?>
Thanks,
Federico