Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 11:34 am EST

Geeklog Forums

Advert Block


Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
OK so I found possibly the best advert program on the internethttp://www.openads.org/
and I'm trying to get an advert block to work in geeklog,
so far I have a block and annoyningly it just displays the word "Array"
does anyone else use openads ?
my code as generated by openads it's self and slightly altered by me is below...
any help apreciated, but the wider community could well do with help getting this on their sites...
Text Formatted Code

 /*
  * As the PHP script below tries to set cookies, it must be called
  * before any output is sent to the user's browser. Once the script
  * has finished running, the HTML code needed to display the ad is
  * stored in the $adArray array (so that multiple ads can be obtained
  * by using mulitple tags). Once all ads have been obtained, and all
  * cookies set, then you can send output to the user's browser, and
  * print out the contents of $adArray where appropriate.
  *
  * Example code for printing from $adArray is at the end of the tag -
  * you will need to remove this before using the tag in production.
  * Remember to ensure that the PEAR::XML-RPC package is installed
  * and available to this script. You may need to alter the
  * 'include_path' value immediately below.
  */
function phpblock_advert() {
 ini_set('include_path', '/Library/WebServer/lightspace/geeklog/system/pear');
    require_once 'XML/RPC.php';

    global $XML_RPC_String, $XML_RPC_Boolean;
    global $XML_RPC_Array, $XML_RPC_Struct;

    // Create an XML-RPC client to talk to the XML-RPC server
    $client = new XML_RPC_Client('/max/www/delivery/axmlrpc.php', 'www.tenanttalk.co.uk');

    // A function to serialise cookie data
    function serialiseCookies($cookies = array())
    {
        global $XML_RPC_Struct;
        $array = array();
        foreach ($cookies as $key => $value) {
            if (is_array($value)) {
                $innerArray = serialiseCookies($value);
                $array[$key] = new XML_RPC_Value($innerArray, $XML_RPC_Struct);
            } else {
                $array[$key] = new XML_RPC_Value($value);
            }
        }
        return $array;
    }

    // Create the XML-RPC message
    $message = new XML_RPC_Message('max.view', array());

    // Package the cookies into an array as XML_RPC_Values
    $cookiesStruct = serialiseCookies($_COOKIE);
    // Add the parameters to the message
    $message->addParam(new XML_RPC_Value('zone:1', $XML_RPC_String));
    $message->addParam(new XML_RPC_Value('', $XML_RPC_String));
    $message->addParam(new XML_RPC_Value('', $XML_RPC_String));
    $message->addParam(new XML_RPC_Value('0', $XML_RPC_Boolean));
    $message->addParam(new XML_RPC_Value($_SERVER['REMOTE_ADDR'], $XML_RPC_String));
    $message->addParam(new XML_RPC_Value($cookiesStruct, $XML_RPC_Struct));

    // Send the XML-RPC message to the server
    $response = $client->send($message, 15, 'http');

    // Was a response received?
    if (!$response) {
        echo 'Error: No XML-RPC response';
    }

    // Was a response an error?
    if ($response->faultCode() != 0) {
        echo 'Error: ' . $response->faultString();
    } else {
        // Ensure the response is an array
        $value = $response->value();
        if ($value->kindOf() != $XML_RPC_Array) {
            echo 'Error: Unexpected response value';
        }
        // Store any cookies sent in the response
        $cookies = $value->arraymem(1);
        if ($cookies->kindOf() == $XML_RPC_Array) {
            $numCookies = $cookies->arraysize();
            // For each cookie...
            for ($counter = 0; $counter < $numCookies; $counter++) {
                $cookie = $cookies->arraymem($counter);
                if (($cookie->kindOf() == $XML_RPC_Array) && ($cookie->arraysize() == 3)) {
                    $cookieName  = $cookie->arraymem(0);
                    $cookieValue = $cookie->arraymem(1);
                    $cookieTime  = $cookie->arraymem(2);
                    setcookie($cookieName->scalarval(), $cookieValue->scalarval(), $cookieTime->scalarval());
                }
            }
        }
        // Store the ad in the ad array
        $advertisement = $value->arraymem(0);
        if ($advertisement->kindOf() == $XML_RPC_Struct) {
            $htmlValue = $advertisement->structmem('html');
            $adArray[] = $htmlValue->scalarval();
        }
        // Example display code - remove before use
 
      // if (isset($adArray)) {
         //   foreach ($adArray as $value) {
         //      echo $value;
         //  }
     //  }
        return $adArray;
    }
 
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
phpblocks have to return valid HTML. You are returning an Array.

I would suggest that you borrow the COM_rdfImport foreach loop you just looked up with your other question and adapt it for this array in the location of the Example display in the function you posted.
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Quote by: jmucchiello

phpblocks have to return valid HTML. You are returning an Array.

I would suggest that you borrow the COM_rdfImport foreach loop you just looked up with your other question and adapt it for this array in the location of the Example display in the function you posted.



EEk I 've just swam out of my depth and now i've got cramp in my legs...
However I definately want this working, this advert programe is the bees knees.
I understand I altered something earlier in my last question that used the COM_rdfimport function and you are suggesting I use this with the example code given ...
do you mean...
Text Formatted Code
 
// Example display code - remove before use
 
      // if (isset($adArray)) {
         //   foreach ($adArray as $value) {
         //      echo $value;
         //  }
     //  }
 

????
If so at least I get that bit, however I am stumped I know some people use this program with Geeklog so it is possible...
again any help most apreciated.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
I don't know what the $adArray variable contains. Try this.
Text Formatted Code
       // this might work
       if (isset($adArray)) {
            return COM_makeList($adArray);
       }
       return '';
 
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Quote by: jmucchiello

I don't know what the $adArray variable contains. Try this.

Text Formatted Code
       // this might work
       if (isset($adArray)) {
            return COM_makeList($adArray);
       }
       return '';
 



The $adArray contains all the adverts for a block,
The output from advert manager for a "Zone" ( pop up window or side block or banner advert)
I will try this
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Quote by: trampoline

Quote by: jmucchiello

I don't know what the $adArray variable contains. Try this.

Text Formatted Code
       // this might work
       if (isset($adArray)) {
            return COM_makeList($adArray);
       }
       return '';
 



The $adArray contains all the adverts for a block,
The output from advert manager for a "Zone" ( pop up window or side block or banner advert)
I will try this



You know it works ! Thanks....
One minor Issue I don't know why but a "•" is printed with the advert ? well it looks like that it's a dot anyway, so now all I have to do is creat a sting of say 3 adverts and return that
to produce a block of 3 adverts.

so
For Advertising on a Geeklog Site I think Open Ads [/url] http://www.openads.org/[url] is probably the answer.
It allows, complete management of adverts, you can incoportae google ads or any other system and most importantly you can have your own cost structure based on
Cost Per Click or monthly premium anual subscription etc, it servers ads up in many ways by key work etc by domain. It allows for advertisers to actually upload their own adverts (subject to aproval) and also alows
agencies to post adverts in a way which completely conforms to their contract with you....
Very good peice of Software. and thanks to help from the community here we can now all use this on our sites.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
That's because com_makeList makes a < UL>< LI> ....< /LI>< /UL> style list.

If you don't like that replace everything from the "if (isset($adArray))" to the "return ''; " inclusive with:
Text Formatted Code
    $display = '';
    if (isset($adArray)) {
        foreach ($adArray as $ad) {
            $display .= $ad . "<br>";
        }
    }
    return $display;
 
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Quote by: jmucchiello

That's because com_makeList makes a < UL>< LI> ....< /LI>< /UL> style list.

If you don't like that replace everything from the "if (isset($adArray))" to the "return ''; " inclusive with:

Text Formatted Code
    $display = '';
    if (isset($adArray)) {
        foreach ($adArray as $ad) {
            $display .= $ad . "<br>";
        }
    }
    return $display;
 



The above is perfect thanks...

anyone can look at this at
http://www.tenanttalk.co.uk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Well this works in Camino & Firefox but not IE and safari

have alook anyone
http://www.tenanttalk.co.uk

seems to break my weather block as well.... In those browsers only... ???
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Actually I'm not seeing any ads in Firefox. There's nothing in the source code. How many ads are normally returned?
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Quote by: jmucchiello

Actually I'm not seeing any ads in Firefox. There's nothing in the source code. How many ads are normally returned?


Wow you are right it only works in Camino on a mac...., however it does work in that, they are meant to be top right hand side....
possibly there is a fault with the advert software but it does show in camino...
I get these errors in apache to do with the ad software...

[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcString in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 40
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcString in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 41
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcString in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 41
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcString in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 41
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcBoolean in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 42
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcString in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 42
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: xmlrpcStruct in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 42
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined index: MAXZBLOCK in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/limitations.php on line 101
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined index: MAXZCAP in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/limitations.php on line 117
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined index: MAXSZCAP in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/limitations.php on line 117
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined variable: zoneid in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/adSelect.php on line 374
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined index: contenttype in /Library/WebServer/lightspace/Documents/max/lib/max/Delivery/XML-RPC.php on line 113
[Tue May 15 21:27:11 2007] [error] PHP Notice: Undefined offset: 0 in /Library/WebServer/lightspace/Documents/max/lib/pear/XML/RPC.php on line 1625
[Tue May 15 21:27:11 2007] [error] PHP Warning: Header may not contain more than a single header, new line detected. in /Library/WebServer/lightspace/Documents/max/lib/pear/XML/RPC/Server.php on line 394


Not great but why does it work in Camino ?
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Ok so now I have found possibly a more simple coding
it also does not work in lib-custom.php....


Text Formatted Code

function phpblock_advert() {
  define('MAX_PATH', '/Library/WebServer/lightspace/Documents/max');
  if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {
    if (!isset($phpAds_context)) {
      $phpAds_context = array();
    }
    $phpAds_raw = view_local('', 1, 0, 0, '', '', '0', $phpAds_context);
    echo $phpAds_raw['html'];
  }
return $phpAds_raw;
}


any help most apreciated, opnce I get this working I will do an easy how to for everyone.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
You're going to have to give some error messages if you want help. Get rid of the @ in front of include_once so errors are reported.
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
I got thi all working and have adverts allover my sites EASY,
I used the java script call for the adverts, I would prefer the php call but will look at it later, this program works....
 Quote

sentinel

Anonymous
awake
I have openads, and a fully functioning (atleast for a newbie) GL site. I just don't know where to put the code that is generated by openads into my GL files to get it to display the ad. I know this is probably a reaaaal stupid problem.
Please help.
What file should I insert the generated code into?
A real basic rundown of how to generate a banner ad using openads and then inserting it into Geeklog would be much appreciated.

 Quote

Arlen Coupland

Anonymous
In Openads, after you create a banner and add this banner to a zone, go to the zone properties. There is a tab called 'invocation code'

The simplest Code to use is the Javascript Invocation code. Copy the Code in the textbox.

A quick start guide for Openads: http://docs.openads.org/openads-2.3-guide/quick-start-guide.html

Now, you must paste this code into your GeekLog template, wherever you want this banner to appear. I'm afraid I don't have any experience with Geeklog itself, so one of the resident members here will have to help you with that.


~ Arlen Coupland
Openads.org
 Quote

Sentinel

Anonymous
Thanks alot, Arlen. I gather that the code should be pasted in the lib-custom file, but I'm not sure that is the only place, and I'm not sure if it matter where in the particular file.

Also, I get a parse error whenever I try to post in lib-custom.

This is what I posted :

function phpblock_advert
{
if (@include(getenv('DOCUMENT_ROOT'Wink.'/Openads-2.0.11-pr1/phpadsnew.inc.php'Wink) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:1', 0, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}

Something is goofed up. I know I am getting the syntax wrong, I just don't know where.

..........any thoughts?

 Quote

All times are EST. The time is now 11:34 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content