Web Hosting Talk







View Full Version : PHP bug with the word "sponsor"?


MGCJerry
01-06-2008, 02:33 PM
I have this bit of code that I'm using to create an admin control panel for a CMS but I have encountered something really aggrivating. Is this normal behavior under PHP or is there something funny going on.

I've setup a PHPNuke admin style "links" "modules" file structure but it appears anything with the name "sponsor" or "sponsors" is unset when I try echoing it... However, the behavior is odd since I can echo the variable by itself, but it will not echo with the rest of the content.

Heres my code:
admin/links/links.sponsors.php <--- admin panel info only...

* First input variable is the link to that particular admin module... Which when set to "Sponsor" or "Sponsors", becomes null.
* 2nd variable is the "title", or the name that shows up in the admin panel.. Which when set to "Sponsor" or "Sponsors", becomes null.
* 3rd variable is the icon. Also of which if the image is named "Sponsor" or "sponsors", is also NULLED out.
* 4th variable is the admin module version


<?php

adminlink("admin.php?action=sponsors", "Sponsors", "banners.gif", "1.0");

?>


now the main bit of code is this....


function adminlink($url, $xtitle, $image, $ver='') {
global $counter;
if(file_exists("images/admin/".$image)) {
$img = "<img src=\"images/admin/$image\" border=\"0\" alt=\"$xtitle\" title=\"$xtitle\"><br>";
}
// I can echo $url, $img, $xtitle here just fine by itself if it is set as sponsor or sponsors...
if($ver) {
$ver = "<br>v$ver";
}


echo " <td class=\"admin\" align=\"center\" valign=\"top\" width=\"16%\"> <a href=\"$url\">\n"
." $img<b>$xtitle</b></a>$ver</td>\n";

// HOWEVER, it will not echo in the above line.. it is NULL...
//If it is set as sponsor or sponsors, only the version shows up

if ($counter == 5) {
echo " </tr><tr>";
$counter = 0;
} else {
$counter++;
}
}



Everything else works fine when I assign any other text. So its nothing else in the code...

Any ideas? I'm lost.

Paul-M
01-06-2008, 02:49 PM
<?php

function adminlink($url, $xtitle, $image, $ver='') {
global $counter;
if(file_exists("images/admin/".$image)) {
$img = "<img src=\"images/admin/$image\" border=\"0\" alt=\"$xtitle\" title=\"$xtitle\"><br>";
} else {
echo("Error: Image does not exist");
exit;
}

// I can echo $url, $img, $xtitle here just fine by itself if it is set as sponsor or sponsors...
if($ver) {
$ver = "<br>v$ver";
}

if($img != "") || if(isset($img)) {
echo " <td class=\"admin\" align=\"center\" valign=\"top\" width=\"16%\"> <a href=\"$url\">\n"
." $img<b>$xtitle</b></a>$ver</td>\n";
}
else {
echo("Error: Image does not exist");
exit;
}
// HOWEVER, it will not echo in the above line.. it is NULL...
//If it is set as sponsor or sponsors, only the version shows up

if ($counter == 5) {
echo " </tr><tr>";
$counter = 0;
} else {
$counter++;
}
}

?>

See if it returns the error message.

MGCJerry
01-06-2008, 05:56 PM
It returns no error. The image does exist in this location.

This problem is also cropping up everywhere else in this bit of the sponsorship code. I can get by this by renaming anything that says "sponsor" to "supporter" or whatever. No, I havent used the word "sponsor" anywhere else in code.

foobic
01-06-2008, 06:15 PM
Could be mod_security blocking urls containing "sponsor", though it would be a weird and paranoid rule...

MGCJerry
01-06-2008, 06:22 PM
Nope...

I'm developing this on a local server who doesnt have mod_security installed. Plus, this issue turns up on pages where "sponsor" is not in the current request URL.

I'm going to aimlessly recompile php and see what happens...

foobic
01-06-2008, 07:40 PM
When you're done, try running just that isolated code fragment from the command line (ie. eliminate all apache modules) and see if it still does it. FWIW on my current dev machine running PHP 5.2.4 it works...