WP Random ad plugin Problem - HELP?

Discussion in 'Blogging' started by w123, Dec 5, 2008.

  1. #1
    OK, any WP/PHP/Plugin/Script problem solvers out their?

    I want to use a random ad plugin on several of my blogs to display some banners. Here's the problem I have:

    The plugin is designed to hold all the banners and the text file that has the banner info in ONE blog (in the wp-contents folder). However, I want the same banners to display on ALL of my blogs, so I'd like to store all of the banners in one central place (preferably NOT in ANY of the blogs, but rather on a totally different website). I don't want to have to upload every single banner to each different blog (seems like a waste of time & space to do so). It'd be more convenient to access just one folder & one file to add or delete banners as needed.

    I've tried everything I can think of to modify the plugin itself, to retrieve the .txt file that it uses to display the ads, (and the text file calls the ad info to actually display the banners). I've also tried modifying the code used to display the ads.

    I'm trying to use the adrotater plugin.

    Here's what you're suppose to paste into the spot where you want the ads to actually appear:
    < ?php echo getad('bannerad') ?>
    (wherein 'bannerad' is the name of the text file [bannerad.txt] where the info is stored that is used to get the banner ads from).

    Info in text file (bannerad.txt) is like:
    <a href="site.com"><img src="bannerad1.jpg">

    And here's the plugin:

    <?php
    /*
    Plugin Name: Ad Rotator
    */
    /* Usage: echo getad('Ad File Name'); */
    function getad($ad = '') {
    $ad = trim($ad);
    if(strlen($ad) > 0) {
    $ad = ABSPATH . "wp-content/" . $ad . '.txt';
    if(file_exists($ad)) {
    $ads = file($ad);
    return $ads[rand(0, sizeof($ads)-1)];
    }
    }
    }
    ?>


    So what do I need to modify to get this to work? (NOT the real sites below)
    I want the .txt file stored at: www.site1.com/bannerad.txt (NOT a blog).
    I want the folder to actually hold the banners at: www.site1.com/bannerad/
    The plugin is on the blogs (and will display the banners) at:
    www.site2.com - www.site3.com - www.site4.com


    Or maybe there's a better random ad script/plugin available to accomplish this?

    I have everything installed already, but no matter what I've tried to get this to work, it just displays nothing in the spots where the banners are suppose to be. (I didn't try putting the .txt file & banners in wp-content, because thats not how I would like this to work).

    I figured changing this line:
    $ad = ABSPATH . "wp-content/" . $ad . '.txt';
    to:
    $ad = "http://www.site1.com/" . $ad . '.txt';
    would work, or even:
    $ad = "http://www.site1.com/bannerad.txt";
    but no...

    What am I missing?

    Any help/suggestions would be most appreciated!
     
    w123, Dec 5, 2008 IP