[REWARD] Help With PHP (1 line)

Soki

Banned
Messages
857
Reaction score
1
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.

Fatal error: Class 'bannerAds' not found in /home/***/public_html/ads/js.php on line 16


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:

xPlozion

New Member
Messages
868
Reaction score
1
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:

Soki

Banned
Messages
857
Reaction score
1
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:

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
yea, you're trying to use classes when you don't have any defined.

http://us3.php.net/new
new

To create an instance of a class, a new object must be created and assigned to a variable. An object will always be assigned when creating a new object unless the object has a constructor defined that throws an exception on error. Classes should be defined before instantiation (and in some cases this is a requirement).

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:

Soki

Banned
Messages
857
Reaction score
1
Points
0
yea, you're trying to use classes when you don't have any defined.

http://us3.php.net/new
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).
 

xPlozion

New Member
Messages
868
Reaction score
1
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:

Soki

Banned
Messages
857
Reaction score
1
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
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).
 

xPlozion

New Member
Messages
868
Reaction score
1
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).
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 ;)
 

Soki

Banned
Messages
857
Reaction score
1
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 ;)
Nope, thanks anyways.
Small reward for effort was sent.
I'm going to try a different script instead.
 
Top