[REWARD] Help With PHP (1 line)

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by Soki, Jan 30, 2009.

  1. Soki

    Soki Banned

    Messages:
    857
    Likes Received:
    1
    Trophy Points:
    0
    Alright. So, Installed this ad manager that manages my ads (obviously) and it said everything was install correctly. It does not use MySQL, just pure PHP. Well, I added an ad to test it out and it didn't shwo up. So, I check my PHP links and one gave me an error.



    I checked the file and I don't know much about PHP. So, here it is:

    Code:
    <?php
    $bannerAdsPath = '/home/***/public_html/ads/ads.dat';
    require '/home/***/public_html/ads/ads.inc.php';
    ///////////////////////////////////////
    // Don't Edit Anything Below This Line!
    ///////////////////////////////////////
    if (!isset($_GET['id']) || !ereg('^[0-9]+$', $_GET['id'])) {
        $_GET['id'] = null;
    }
    if (!isset($_GET['width']) || !ereg('^[0-9]+$', $_GET['width'])) {
        $_GET['width'] = 0;
    }
    if (!isset($_GET['width']) || !isset($_GET['height']) || !ereg('^[0-9]+$', $_GET['height'])) {
        $_GET['height'] = 0;
    }
    $buttons = new bannerAds($_GET['id'], 1, $_GET['width'], $_GET['height']);
    header('Content-type: application/x-javascript');
    echo "<!--\n";
    echo "document.write(\"" .addslashes($buttons->ad[0]). "\");\n";
    echo "//-->";
    ?>
    
    Line 16:
    Code:
    $buttons = new bannerAds($_GET['id'], 1, $_GET['width'], $_GET['height']);
    Anyone who helps me out will end up with a reward (if your solution works).
     
    Last edited: Jan 30, 2009
  2. xPlozion

    xPlozion New Member

    Messages:
    868
    Likes Received:
    1
    Trophy Points:
    0
    ok, here's the deal w/ classes.

    when you did new bannerAds, you created a new class. if there's no class named bannerAds in ads.inc.php, then it'll throw the error.

    do you mind posting ads.inc.php, as that may be the answer to our problems (no class bannerAds created ;))


    i'm very intrigued by this "reward" that you offer o_O
     
    Last edited: Jan 30, 2009
  3. Soki

    Soki Banned

    Messages:
    857
    Likes Received:
    1
    Trophy Points:
    0
    Here you go:

    Code:
    <?php
    $ads = array();
    $bannerAds = array();
    $bannerAdsTime = time();
    $lines = file($bannerAdsPath) or die();
    foreach ($lines as $line) {
        $line = chop($line);
        if (($line != '') && (!ereg('^#', $line))) {
            if (ereg('^[A-Za-z0-9]+\|\|', $line)) {
                $ads[] = $line;
            } else {
                list ($key, $val) = explode('=', $line);
                $bannerAds[$key] = $val;
            }
        }
    }
    function writeads()
    {
        global $bannerAdsPath, $ads, $bannerAds;
        $data = fopen($bannerAdsPath, 'w') or die();
        flock($data, 2) or die();
        fputs($data, @join("\n", $ads)."\n");
        while (list ($key, $val) = each ($bannerAds)) {
            if (($key != '') && ($val != '')) {
                fputs($data, $key.'='.$val."\n");
            }
        }
        flock($data, 3);
        fclose($data);
        reset($bannerAds);
    }
    ?>
     
    Last edited: Jan 30, 2009
  4. xPlozion

    xPlozion New Member

    Messages:
    868
    Likes Received:
    1
    Trophy Points:
    0
    yea, you're trying to use classes when you don't have any defined.

    http://us3.php.net/new
    the way
    PHP:
    echo "document.write(\"" .addslashes($buttons->ad[0]). "\");\n";
    is written is sorta confusing, cause they create a new class on line 16, then they use what appears to be an array ad[0] where there should be a function call.
     
    Last edited: Jan 30, 2009
  5. Soki

    Soki Banned

    Messages:
    857
    Likes Received:
    1
    Trophy Points:
    0
    I just don't have the time right now to read through it and figure out what is the exact solution (as in what to edit/add).
    Do you have any clue what I should add?

    Then, I'll give the reward as stated (if it works).
     
  6. xPlozion

    xPlozion New Member

    Messages:
    868
    Likes Received:
    1
    Trophy Points:
    0
    hmm, looking over the code, it became a bit more confusing. did you modify either of the code you posted, or just the contents in the .dat file?

    also, what script is this, so i can dl it and inspect it
     
    Last edited: Jan 30, 2009
  7. Soki

    Soki Banned

    Messages:
    857
    Likes Received:
    1
    Trophy Points:
    0
    No I didn't edit anything at all and this is the ads.inc.php not the .dat file.
    The .dat file just has my banner ad info that just added in the Admin cpanel of it (nothing special).
     
  8. xPlozion

    xPlozion New Member

    Messages:
    868
    Likes Received:
    1
    Trophy Points:
    0
    i was aware that it was the inc file, it was just a general knowledge q.

    i'm not sure what the
    Code:
    [COLOR=#000000][COLOR=#0000BB]$buttons[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]ad[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]][/COLOR][/COLOR]
    is for, but the only thing i can think of is replace it with `$bannerAds[0]`. depending on how the other side of the = in the dat file looks, it may be properly formatted already, and this is the only thing i can think of ;)
     
  9. Soki

    Soki Banned

    Messages:
    857
    Likes Received:
    1
    Trophy Points:
    0
    Nope, thanks anyways.
    Small reward for effort was sent.
    I'm going to try a different script instead.
     
  10. xPlozion

    xPlozion New Member

    Messages:
    868
    Likes Received:
    1
    Trophy Points:
    0
    ok, sorry i couldnt make it work. better luck w/ the next one ;)
     
  11. nightscream

    nightscream New Member

    Messages:
    948
    Likes Received:
    0
    Trophy Points:
    0
    Still the same error? if so are you sure js.php exists?
     
    Last edited: Jan 31, 2009

Share This Page