PDA

View Full Version : Ed, please tell me what I am doing wrong


06-22-2000, 10:42 AM
Hi Ed and congrats for the new appointment :)

I need your help please.

My BB members love smilies, it seems, and we have a nifty and useful collection of nice ones. However, I've discovered that the animated ones create problems aplenty for Netscape users.

So, I created a sub dir in the smilies dir, called netscape, and put there a copy of all the smilies, only not animated (same name though).

Then, I added a field to the smilie table in the database, called smiliepath2, and placed there the paths to the smilie/netscape/ images.

Then, I put the following in global.php, at around like 202 (where it says // smilies):


if (strstr($HTTP_USER_AGENT,"MSIE")) {
if ($allowsmilie==1 and $dosmilies==1) {
$smilies=$DB_site->query("SELECT smilietext,smiliepath FROM smilie");
while ($smilie=$DB_site->fetch_array($smilies)) {
if ($smilie[smilietext]!="") {
$bbcode=str_replace($smilie[smilietext],"<img src=\"$smilie[smiliepath]\" border=0>",$bbcode);
}
}
}
} else {
if ($allowsmilie==1 and $dosmilies==1) {
$smilies=$DB_site->query("SELECT smilietext,smiliepath2 FROM smilie");
while ($smilie=$DB_site->fetch_array($smilies)) {
if ($smilie[smilietext]!="") {
$bbcode=str_replace($smilie[smilietext],"<img src=\"$smilie[smiliepath2]\" border=0>",$bbcode);
}
}
}
}


But it doesn't work. Now all the smilies are coming from the smilies/netscape/ dir -- which means my "if (strstr($HTTP_USER_AGENT,"MSIE"))" is not working.

Can you please advise me what I am doing wrong, and what I should do to get it right?

Thanks,

Bira

06-22-2000, 10:49 AM
With that code you also take away smilies from Opera, Mozilla (probably has the same netscape problems), and etc users.

06-22-2000, 10:52 AM
rangersfan,

1) I am not taking it away - they will simply see a static smilie rather than an animated one.

2) I would love to know how I can determine someone is using Netscape, and do "if browser==netscape then use smiliepath2" (in which case only the Netscape users will be affected).

But right now, only the "else" works, regardless what browser you have, including MSIE :(

06-22-2000, 10:54 AM
bira - check out my smilies

http://www.hedgehogwheels.com/forums/index.php?action=showsmilies

I haven't had any complaints yet from any users about threads not loading though.

06-22-2000, 10:57 AM
I haven't picked up a PHP book but is the 'strstr' function a string match or a sub-string match function? I would think it would work if it is just searching for the ocurrence of "MSIE" in the string, otherwise you need to use a function that does that.

06-22-2000, 10:58 AM
rangersfan, well good for you I guess :)

The procedure I set to check if a user has Internet Explorer is the correct one. The why isn't it working? Could it be that global.php doesn't communicate with the user's browser or something like that? Maybe I should do something else?

Someone please help me :(

06-22-2000, 11:03 AM
As a test .... all you have to do is echo the string back to the screen to see if it has anything in it to see if it is being read.

06-22-2000, 11:07 AM
rangersfan, copy the bellow code to a text file, save it as browser.php and test it in IE and in Netscape:


<?php
if(strstr($HTTP_USER_AGENT,"MSIE")) {
echo "good";
} else {
echo "crap";
}
?>


You will see that it works just fine.

06-22-2000, 12:12 PM
I started playing around with your code in a separate file, and it works fine. It even works fine when I require global.php above it.

So what's the problem?

Well, we forgot to account for the fact that that smilies stuff is in a function. Functions have a local scope.

bira - just above your code, add:
global $HTTP_USER_AGENT;That will give you access to the variable.

06-22-2000, 12:22 PM
THANK YOU!!!!!!!

It works beautifully :) :) :)