Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:36
Conditional menu display based on browser via PHP
Poster: pavia
Dated: Sunday March 21 2004 - 21:17:01 GMT
I hope it's okay to start a new topic based on a prior one? The discussion originated with this one
(http://www.milonic.com/forum/viewtopic.php?t=3692)
but it has, um...evolved.
In a nutshell, I'm seeking to to circumvent some browser-specific problems which crop up in older versions of Netscape. Consequently, I'd like to be able to accomplish the following with the relative-positioned-in-a-table version of the Milonic menu:
If the browser IS NOT Netscape 4.XX, load Version 5 of the Milonic menu
If the browser IS Netscape 4.XX, load Version 3 of the Milonic menu
Haven't had any luck thus far and then Kevin introduced the idea of doing the foregoing server side using PHP and I thought WOW! Great idea!! Why didn't I think of that?!? I bet it can be done...
...just as soon as I learn PHP.
I've been trying to sort this out on my own for several days now but I didn't get very far and was wondering if someone with more experience might be able to lend some assistance.
I know this is lame but the only thing I could find that might be useful dates back to November 2001--an article titled "When Browsers Suck: PHP to the Rescue!" located here: http://www.sitepoint.com/article/619.
It demonstrates server-side browser detection, provides a script for same and then gives an example for implementation that looks promising. Here's the example:
Code:
<?php include(browserdetect.php); ?>
<?php if ($browser == 'ns6'): ?>
<!-- Netscape 6 specific code -->
<?php else: ?>
<!-- Code for other browsers -->
<?php endif; ?>
<?php if ($browser == 'ns6'): ?>
<!-- Netscape 6 specific code -->
<?php else: ?>
<!-- Code for other browsers -->
<?php endif; ?>
At the end of the explanation, the writer states that one could use include files for each browser-dependent segment of the page and I thought perhaps there would be a way then to address the fact that the method for positioning Version 5 of the Milonic menu in a table is quite different from that used in Version 3.
Anyone up for tackling this? It might end up being extremely useful to a lot of Milonic users...and, of course, I would be eternally grateful for the help.
Poster: Ruth
Dated: Monday March 22 2004 - 16:30:10 GMT
I am NOT a code person. But, I am interested in much of this. I had a thought when you mentioned that version 5 and 3 use different methods for placing in a table. Wouldn't you just put both the menu [version5] and the placemenu [version 3] in the same cell because wouldn't the code you use tell it which to show? Well, you're talking about include files, so wouldn't you just put the include call for each since the code you're talking about would tell it which to include depending on which browser?
Ruth
Poster: pavia
Dated: Tuesday March 23 2004 - 14:55:38 GMT
Hi Ruth--
Yes, I think you would put the include in the table to call the code to display either menu but I have spent hours trying to figure out how to accomplish this to no avail.
I'm about to throw in the towel on this whole Milonic thing
What stymies me is that you basically have two pieces of code to contend with...the code to get the menu into the table cell and the code to get the menu to show up in the first place. That's probably not a good way of referring to the latter--what I mean is this:
For Version 3:
Code:
<script language=JavaScript src="menu_array.js" type=text/javascript></script>
<script language=JavaScript src="mmenu.js" type=text/javascript></script>
<script language=JavaScript src="mmenu.js" type=text/javascript></script>
For Version 5:
Code:
<script language=JavaScript src="milonic_src.js" type=text/javascript></script>
<script language=JavaScript src=mmenudom.js type=text/javascript></script>
<script language=JavaScript src="menu_data.js" type=text/javascript></script>
<script language=JavaScript src=mmenudom.js type=text/javascript></script>
<script language=JavaScript src="menu_data.js" type=text/javascript></script>
Both of these would go right after the body tag, right?
But the other javascript needed to show the menu in the table--which is also dependent upon whether the browser is NS 4.XX--needs to go in a different location within the HTML.
I don't know how to write the PHP code--or maybe SPLIT UP THE PHP CODE(?)--in order to get this to work.
Poster: Ruth
Dated: Tuesday March 23 2004 - 22:21:01 GMT
Disclaimer:: I AM NOT A CODE PERSON
I don't know anything about writing calls and such, but let's take the code for the menu in the table for version 3 and version 5.
Code:
whatever table you have. <table><tr><td>call for version 3
<script>PlaceMenu("mainmenu")</script>
then call for version 5
<script>with(milonic=new menuname("Main")){
style=menuStyle;
etc.
position="relative";
aI("text= Home;url=whatever/;status=;");
}
drawMenus();</script>
</td></tr></table>
Ok so now you have version 3 and 5 in their own little script tags in the table cell. Neither will do a thing if they don't have the files to tell them to do something, the menu files and that's the code you gave an example of up above. I guess you put it just below the body since that's where version 3 needs to be to be called. <script>PlaceMenu("mainmenu")</script>
then call for version 5
<script>with(milonic=new menuname("Main")){
style=menuStyle;
etc.
position="relative";
aI("text= Home;url=whatever/;status=;");
}
drawMenus();</script>
</td></tr></table>
Code:
<body><?php include(browserdetect.php); ?>
<?php if ($browser == 'ns4'): ?>
<!-- Netscape 4 specific code --> [call the version 3]
<?php else: ?>
<!-- Code for other browsers --> [call the version 5]
<?php endif; ?>
<?php if ($browser == 'ns4'): ?>
<!-- Netscape 4 specific code --> [call the version 3]
<?php else: ?>
<!-- Code for other browsers --> [call the version 5]
<?php endif; ?>
Now, I have absolutely NO clue if this is a correct assumption since I do not do codes, calls and such and I thought php was some kind of acid content in soaps or something! But, if you have a call that says find the browser and if ns4 use 'this call' or else use 'that call' Then if your php thingees are working correctly when it detects ns4 it will put up the code for the menu_array.js and the mmenu.js and when it detects anything else it will put up the 3 files for version 5. Remember I dont' know how php works. if it's files you have to include then I would take it that the things I have in the script tags for the placemenu and the other one for the version 6 with menu then I would think you put the codes in their little separate files and in the table cell you put the include calls for each file. Since again, even if they 'include' both files none will function unless they have their own triggering files.
And I have one last question, can you see the milonic menu on the homepage here, does your 'browser' crash, if so have you tried a reinstall because there haven't been any other comments that I can find about ns4 and a mac crashing the milonic homesite?
Alternatively, and I can't play with this with any idea of what it will look like since you don't have a page nor have placed at least the table layout with it's sizes and such so we can get a visual on how the page is going to look, but check at this page http://www.citytech.cuny.edu/ first using the netsacpe 4. See if the browser crashes on it. That's calling a 'text' menu for netscape 4. If that crashes also, there has to be something in your browser I would think.
Ruth
Poster: pavia
Dated: Wednesday March 24 2004 - 0:34:41 GMT
Ruth--
I'm gonna have to skip addressing the PHP stuff in your last post because when it comes right down to it, neither of us know what we are doing. And I'm not saying that to be rude so PLEASE don't take it that way. I'm saying it because we know what should be done and how it should be done but we're no closer to getting it done. Or something like that.
Regarding the second part of your post...Netscape 4.79 on the Mac doesn't crash when viewing the Milonic home page. The menus do, however, stop functioning. Can't think of a way to describe it...hmmm...it's like they lock up and refuse to keep working. The only way to keep navigating the page is to click on menu items rather than hover with your mouse. It's like the entire menu turns itself into one of those "open-on'click" type of menus (but not a well-functioning one). The same thing occurs in Netscape 4.8 in Windows.
Tepidarium's menu doesn't do anything "bad" to Netscape on the Mac. I've read his posts and it would seem he has taken this route for exactly the same reasons I am seeking to load Version 3 for older Netscape browsers--Netscape 4.XX just doesn't play nice with Version 5 of the menu.
Poster: kevin3442
Dated: Wednesday March 24 2004 - 2:27:46 GMT
Hi Pavia,
I am not a PHP user. Never tried it even once and I don't have PHP on our server to test. But, if you're willing to try a little more of the blind leading the blind, I'll give it a shot.
I assume that you have the other site's browser detect code in a file called browserdetect.php and that their browser detection actually works. If it's like other server-side stuff, there's probably some sort of "Include Path" in the PHP configuration, so might want to have that file in whatever your include path is. Note that the path may be relative. If you are in doubt, you can probably override the Include Path by specifying the path in the argument to include(). E.g., if browserdetect.php is in your site's root directory, you could probably do this:
Code:
<?php include('/browserdetect.php'); ?>
Or, you could probably also specify the exact location like this
Code:
<?php include('http://www.yoursite.com/php/browserdetect.php'); ?>
which I imagine would look for the file in http://www.yoursite.com/php/ -- of course, this is mostly guess work on my part. You may have to play with line 1 of the following code example to get the include file loaded.
As far as loading the scripts and running functions, you will definitely need to distinguish between ns4 and not-ns4 in loading the menu scripts, as well as in the table where you display your main menu.
(1) You should be able to load the menu code for either version at the top of the <body>. Try this at the top of <body>:
Code:
<?php include('browserdetect.php'); ?>
<?php
if ($browser == 'ns4') {
echo '<script language="JavaScript" src="menu_array.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="mmenu.js" type="text/javascript"></script>';
} else {
echo '<script language="JavaScript" src="milonic_src.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="mmenudom.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu_data.js" type="text/javascript"></script>';
}
?>
<?php
if ($browser == 'ns4') {
echo '<script language="JavaScript" src="menu_array.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="mmenu.js" type="text/javascript"></script>';
} else {
echo '<script language="JavaScript" src="milonic_src.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="mmenudom.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu_data.js" type="text/javascript"></script>';
}
?>
(2) To open the main menu, try this in your table cell:
Code:
<?php
if ($browser == 'ns4') {
echo 'PlaceMenu("mainmenu");'
} else {
echo <<<END
<script language="Javascript">
with(milonic=new menuname("Main Menu")){
style=menuStyle;
alwaysvisible=1;
orientation="horizontal";
position="relative";
aI("text=Home;url=http://www.milonic.com/;status=Back To Home Page;");
aI("text=Menu Samples;showmenu=Samples;");
aI("text=Milonic;showmenu=Milonic;");
aI("text=Partners;showmenu=Partners;");
aI("text=Links;showmenu=Links;");
aI("text=My Milonic;showmenu=My Milonic;");
}
drawMenus();
</script>
END;
}
?>
if ($browser == 'ns4') {
echo 'PlaceMenu("mainmenu");'
} else {
echo <<<END
<script language="Javascript">
with(milonic=new menuname("Main Menu")){
style=menuStyle;
alwaysvisible=1;
orientation="horizontal";
position="relative";
aI("text=Home;url=http://www.milonic.com/;status=Back To Home Page;");
aI("text=Menu Samples;showmenu=Samples;");
aI("text=Milonic;showmenu=Milonic;");
aI("text=Partners;showmenu=Partners;");
aI("text=Links;showmenu=Links;");
aI("text=My Milonic;showmenu=My Milonic;");
}
drawMenus();
</script>
END;
}
?>
The echo <<<END construct seems to be a good one for outputting multiple lines to the page. I think you have to make sure that END; appears flush left, on a line by itself, with no extra whitespace. If that doesn't work, you could try echoing each line of code separately, as in the first code example.
Note also that I used "mainmenu" in the PlaceMenu() call... substitute your own v3 main menu name. Also, for the v5 menu, I used the 'Main Menu' code from the v5 table-bound example... substitute your own code.
Don't give up if this doesn't work! Maybe some kind php guru will step in or, if nothing else, we'll muddle through. Let us know how it goes.
Kevin
Poster: Ruth
Dated: Wednesday March 24 2004 - 2:43:57 GMT
Nope, I didn't take offense, after all I put a disclaimer at the beginning of the post I have NS 4.79, win98se and I have no problem on the main site [except the search, but that's cause it's a static browser] All the rest of the menu works just fine, mouseover and everything.
Ruth
Poster: pavia
Dated: Wednesday March 24 2004 - 3:34:50 GMT
Hiya Kevin...
Thanks for giving this a shot.
Right off the bat, I got this error:
Parse error: parse error, unexpected T_ECHO -- on this line:
Code:
echo '<script language="JavaScript" src="menu/menu_array.js" type="text/javascript"></script>';
Poster: kevin3442
Dated: Wednesday March 24 2004 - 3:57:40 GMT
Hi Pavia,
Is the echo all on one line of code, or split across two lines like the examples we both posted?
Kevin
Poster: pavia
Dated: Wednesday March 24 2004 - 4:11:04 GMT
Here's the code (note--browserdetect.php calls for "nsmac" not "ns4")
Code:
<body bgcolor="#FFFFFF" text="#000000">
<?php include(browserdetect.php); ?>
<?php
if ($browser == 'nsmac') {
echo '<script language="JavaScript" src="menu/menu_array.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu/mmenu.js" type="text/javascript"></script>';
} else {
echo '<script language="JavaScript" src="menu/milonic_src.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu/mmenudom.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu/menu_data.js" type="text/javascript"></script>';
}
?>
<?php include(browserdetect.php); ?>
<?php
if ($browser == 'nsmac') {
echo '<script language="JavaScript" src="menu/menu_array.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu/mmenu.js" type="text/javascript"></script>';
} else {
echo '<script language="JavaScript" src="menu/milonic_src.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu/mmenudom.js" type="text/javascript"></script>';
echo '<script language="JavaScript" src="menu/menu_data.js" type="text/javascript"></script>';
}
?>
Hey wait--I didn't answer your question, did I? I mean, does the above display correctly?? I'm confused.
Poster: pavia
Dated: Wednesday March 24 2004 - 4:16:06 GMT
Ruth--
Re viewing the Milonic home page in Netscape on Windows...I have NS 4.8 and here's a screen shot from it. I think this should show the problem I have explained (about the menus locking up) because if you think about it, I don't think you can achieve what this shows under normal circumstances. Like, look at where my mouse cursor is...--waaaaay up to the right...and there's no submenu showing from the "samples" menu item...
This is because the menu stopped working and just sat there staring at me.
Poster: kevin3442
Dated: Wednesday March 24 2004 - 4:19:08 GMT
pavia wrote:
...Hey wait--I didn't answer your question, did I? I mean, does the above display correctly?? I'm confused.
I guess that's what I'm getting at. When placed in a code block on this forum, the line in question wraps (at least w/ my res of 1024x768). Are you putting the code in like that, or is the echo all on one line?
echo '<script language="JavaScript" src="menu/menu_array.js" type="text/javascript"></script>';
(The line above displays on one line, no wrapping, at 1024x768, maximized, on IE6).
I only ask because of a gut feeling that having it split across two lines without some sort of concatenation character might cause the error.
If we can't get past this, I have another idea (and it does not involve doing violence to a computer).
Kevin
Poster: pavia
Dated: Wednesday March 24 2004 - 4:31:24 GMT
Ahhhh...the old' maximize-the-window trick. Now why didn't I think of that???
To answer your question...every echo statement is on its own line.
Poster: Ruth
Dated: Wednesday March 24 2004 - 4:34:17 GMT
Pavia, just out of curiosity have you tried reinstalling your 4.8? Truly, I get everything, submenus and all on 4.79 so I'm wondering, at least on the windows if there's something corrupted?
Ruth
Poster: kevin3442
Dated: Wednesday March 24 2004 - 4:55:49 GMT
pavia wrote:
...To answer your question...every echo statement is on its own line.
Drat!
I wonder if > needs to be /> in the echos? Try this:
Code:
<?php include(browserdetect.php); ?>
<?php
if ($browser == 'nsmac') {
echo '<script language="JavaScript" src="menu/menu_array.js" type="text/javascript"/></script/>';
echo '<script language="JavaScript" src="menu/mmenu.js" type="text/javascript"/></script/>';
} else {
echo '<script language="JavaScript" src="menu/milonic_src.js" type="text/javascript"/></script/>';
echo '<script language="JavaScript" src="menu/mmenudom.js" type="text/javascript"/></script/>';
echo '<script language="JavaScript" src="menu/menu_data.js" type="text/javascript"/></script/>';
}
?>
<?php
if ($browser == 'nsmac') {
echo '<script language="JavaScript" src="menu/menu_array.js" type="text/javascript"/></script/>';
echo '<script language="JavaScript" src="menu/mmenu.js" type="text/javascript"/></script/>';
} else {
echo '<script language="JavaScript" src="menu/milonic_src.js" type="text/javascript"/></script/>';
echo '<script language="JavaScript" src="menu/mmenudom.js" type="text/javascript"/></script/>';
echo '<script language="JavaScript" src="menu/menu_data.js" type="text/javascript"/></script/>';
}
?>
Kevin
Poster: kevin3442
Dated: Wednesday March 24 2004 - 5:00:58 GMT
Hey Pavia,
You could try this instead:
Code:
<?php include('browserdetect.php'); ?>
<?php if ($browser == 'nsmac'): ?>
<script language="JavaScript" src="menu_array.js" "type=text/javascript"></script>
<script language="JavaScript" src="mmenu.js" type="text/javascript"></script>
<?php else: ?>
<script language="JavaScript" src="milonic_src.js" type="text/javascript"></script>
<script language="JavaScript" src="mmenudom.js" type="text/javascript"></script>
<script language="JavaScript" src="menu_data.js" type="text/javascript"></script>
<?php endif; ?>
<?php if ($browser == 'nsmac'): ?>
<script language="JavaScript" src="menu_array.js" "type=text/javascript"></script>
<script language="JavaScript" src="mmenu.js" type="text/javascript"></script>
<?php else: ?>
<script language="JavaScript" src="milonic_src.js" type="text/javascript"></script>
<script language="JavaScript" src="mmenudom.js" type="text/javascript"></script>
<script language="JavaScript" src="menu_data.js" type="text/javascript"></script>
<?php endif; ?>
If that doesn't cause a choke, we'll tackle the rest tomorrow.
Kevin
Poster: pavia
Dated: Wednesday March 24 2004 - 13:27:29 GMT
G'morning...
Both pieces of code give this error: Parse error: parse error, unexpected T_ECHO--on this line:
Code:
echo 'PlaceMenu("mainmenu");'
Hey, we're making it a little farther before it chokes!!
Ruth--Netscape 4.8 on Windows is a new re-install as of about 5 days ago. I get submenus and everything too but they just fizzle out and stop working. I'm pretty sure Tepidarium complained of the same problem.
Poster: Maz
Dated: Wednesday March 24 2004 - 16:14:10 GMT
I don't know backend, none of this makes much sense to me, I can't use includes because of my templating system that won't allow anything through for SSI.
Then I found a forum mod that created the javascript for me to place in any page, and it works beautifully. Now I can use the forum for adding news to my pages.
Maybe something similar to ssi via js would work great with the menu?
maz
Poster: kevin3442
Dated: Wednesday March 24 2004 - 16:45:51 GMT
Hey,
pavia wrote:
...Hey, we're making it a little farther before it chokes!!
Progress
OK, since my understanding of PHP echos seems to be flawed seems to be flawed (little joke there), and since I forgot the <script> tags around PlaceMenu() anyway, why don't we go with the second approach. Try the following to get the scripts to load (just a reiteration of an earlier post):
Code:
<?php include('browserdetect.php'); ?>
<?php if ($browser == 'nsmac'): ?>
<script language="JavaScript" src="menu_array.js" "type=text/javascript"></script>
<script language="JavaScript" src="mmenu.js" type="text/javascript"></script>
<?php else: ?>
<script language="JavaScript" src="milonic_src.js" type="text/javascript"></script>
<script language="JavaScript" src="mmenudom.js" type="text/javascript"></script>
<script language="JavaScript" src="menu_data.js" type="text/javascript"></script>
<?php endif; ?>
<?php if ($browser == 'nsmac'): ?>
<script language="JavaScript" src="menu_array.js" "type=text/javascript"></script>
<script language="JavaScript" src="mmenu.js" type="text/javascript"></script>
<?php else: ?>
<script language="JavaScript" src="milonic_src.js" type="text/javascript"></script>
<script language="JavaScript" src="mmenudom.js" type="text/javascript"></script>
<script language="JavaScript" src="menu_data.js" type="text/javascript"></script>
<?php endif; ?>
And try the following in the table cell, to get the main menu to appear (with appropriate substitutions for your own menu items and menu names).
Code:
<?php if ($browser == 'nsmac'): ?>
<script language="JavaScript">
PlaceMenu("mainmenu");
</script>
<?php else: ?>
<script language="JavaScript">
with(milonic=new menuname("Main Menu")){
style=menuStyle;
alwaysvisible=1;
orientation="horizontal";
position="relative";
aI("text=Home;url=http://www.milonic.com/;status=Back To Home Page;");
aI("text=Menu Samples;showmenu=Samples;");
aI("text=Milonic;showmenu=Milonic;");
aI("text=Partners;showmenu=Partners;");
aI("text=Links;showmenu=Links;");
aI("text=My Milonic;showmenu=My Milonic;");
}
drawMenus();
</script>
<?php endif; ?>
<script language="JavaScript">
PlaceMenu("mainmenu");
</script>
<?php else: ?>
<script language="JavaScript">
with(milonic=new menuname("Main Menu")){
style=menuStyle;
alwaysvisible=1;
orientation="horizontal";
position="relative";
aI("text=Home;url=http://www.milonic.com/;status=Back To Home Page;");
aI("text=Menu Samples;showmenu=Samples;");
aI("text=Milonic;showmenu=Milonic;");
aI("text=Partners;showmenu=Partners;");
aI("text=Links;showmenu=Links;");
aI("text=My Milonic;showmenu=My Milonic;");
}
drawMenus();
</script>
<?php endif; ?>
Let us know what happens.
Kevin
Poster: pavia
Dated: Wednesday March 24 2004 - 18:44:08 GMT
! __at__ $#^* __at__ !!!
I get the following: Parse error: parse error, unexpected T_STRING in browserdetect.php on line 15:
Code:
1 <?php
2
3 /**
4 * $browser will contain one of the following values:
5 * 'iewin' : IE 4+ for Windows
6 * 'iemac' : IE 4 for Macintosh
7 * 'ie5mac' : IE 5 Macintosh
8 * 'nswin' : Netscape 4.x Windows
9 * 'nsunix' : Netscape 4.x Unix
10 * 'nsmac' : Netscape 4.x Mac
11 * 'ns6' : Netscape 6 / Mozilla
12 */
13
14 function inAgent($agent) {
15 global $HTTP_USER_AGENT;
16 $notAgent = strpos($HTTP_USER_AGENT,$agent) === false;
17 return !$notAgent;
18 }
19
20 if ( inAgent('MSIE 4') or inAgent('MSIE 5') ) {
21 if ( inAgent('Mac') )
22 $browser = inAgent('MSIE 5') ? 'ie5mac' : 'ie4mac';
23 elseif ( inAgent('Win') ) $browser = 'iewin';
24 } elseif ( !inAgent('MSIE') ) {
25 if ( inAgent('Mozilla/5') or inAgent('Mozilla/6') ) {
26 $browser = 'ns6';
27 } elseif ( inAgent('Mozilla/4') ) {
28 if ( inAgent('Mac') ) $browser = 'nsmac';
29 elseif ( inAgent('Win') ) $browser = 'nswin';
30 else $browser = 'nsunix';
31 }
32 } else $browser = "unknown";
33
34 ?>
2
3 /**
4 * $browser will contain one of the following values:
5 * 'iewin' : IE 4+ for Windows
6 * 'iemac' : IE 4 for Macintosh
7 * 'ie5mac' : IE 5 Macintosh
8 * 'nswin' : Netscape 4.x Windows
9 * 'nsunix' : Netscape 4.x Unix
10 * 'nsmac' : Netscape 4.x Mac
11 * 'ns6' : Netscape 6 / Mozilla
12 */
13
14 function inAgent($agent) {
15 global $HTTP_USER_AGENT;
16 $notAgent = strpos($HTTP_USER_AGENT,$agent) === false;
17 return !$notAgent;
18 }
19
20 if ( inAgent('MSIE 4') or inAgent('MSIE 5') ) {
21 if ( inAgent('Mac') )
22 $browser = inAgent('MSIE 5') ? 'ie5mac' : 'ie4mac';
23 elseif ( inAgent('Win') ) $browser = 'iewin';
24 } elseif ( !inAgent('MSIE') ) {
25 if ( inAgent('Mozilla/5') or inAgent('Mozilla/6') ) {
26 $browser = 'ns6';
27 } elseif ( inAgent('Mozilla/4') ) {
28 if ( inAgent('Mac') ) $browser = 'nsmac';
29 elseif ( inAgent('Win') ) $browser = 'nswin';
30 else $browser = 'nsunix';
31 }
32 } else $browser = "unknown";
33
34 ?>
Well, this sucks, huh? How am I supposed to know if your hard work has paid off when this miserable browser detect script is getting in the way???
Poster: kevin3442
Dated: Wednesday March 24 2004 - 21:11:07 GMT
But you weren't getting that before right? I'm wondering if it's a misleading error message. What happens if you remove our second block of code (from the table cell) and try it with just the first block (after the <body> tag)?
Kevin
Poster: pavia
Dated: Wednesday March 24 2004 - 22:14:28 GMT
Quote:
What happens if you remove our second block of code...
*Sigh*...the same exact error from browserdetect.php shows up and says "hi!"
Poster: kevin3442
Dated: Wednesday March 24 2004 - 22:41:59 GMT
Can you email me your main page's .php source file, along with the browserdetect.php file? Just so we are both looking at the exact same code.
Kevin
Poster: kevin3442
Dated: Wednesday March 24 2004 - 23:10:22 GMT
Hey Pavia,
What version of PHP is on your server?
Kevin
Poster: kevin3442
Dated: Wednesday March 24 2004 - 23:30:26 GMT
One more thing...
In the browser detection script, try replacing the inAgent() function with:
Code:
function inAgent($agent) {
$notAgent = strpos($_SERVER['HTTP_USER_AGENT'],$agent) === false;
return !$notAgent;
}
$notAgent = strpos($_SERVER['HTTP_USER_AGENT'],$agent) === false;
return !$notAgent;
}
This is based on a hunch that $HTTP_USER_AGENT is depreciated in newer versions of PHP... you did mention that the browser detection script you found was posted in 2001. Figured it was worth a shot.
Kevin
Poster: pavia
Dated: Thursday March 25 2004 - 0:01:12 GMT
Kevin--
I don't know your e-mal address..
Have PHP Version 4.2.2 on my server...
Not ready to give in yet, huh?
Poster: kevin3442
Dated: Thursday March 25 2004 - 0:28:32 GMT
pavia wrote:
...I don't know your e-mal address...
Just click the "email" button at the bottom of my posts.
Quote:
Not ready to give in yet, huh?
Not if you aren't... and not until a PHP person shows up (who would probably be able to do this in five seconds).
Kevin
Poster: pavia
Dated: Thursday March 25 2004 - 0:38:58 GMT
Am I crazy? There's no e-mail button at the bottom of your posts...?
Poster: kevin3442
Dated: Thursday March 25 2004 - 0:54:52 GMT
Yeah... I think you're crazy. Do you view the posts while you're logged in? (If you aren't logged in when viewing the posts, the email button won't show up). In any case, I'll send it to your yahoo account. I don't want to post it here because I'm paranoid about it appearing in text anywhere.
Kevin
Poster: Ruth
Dated: Friday March 26 2004 - 16:54:59 GMT
I'm crazy, too. I'm logged in and there's no email button and PM is disabled.
Ruth
Poster: Maz
Dated: Friday March 26 2004 - 18:47:18 GMT
Maybe email was disabled because of all the viruses?
maz
Poster: Ruth
Dated: Saturday March 27 2004 - 0:25:32 GMT
It's strange, because yours shows and John's and Andy's.
Ruth
Poster: John
Dated: Saturday March 27 2004 - 2:27:17 GMT
Kevin and Maz show 4 buttons each, and Ruth shows 5 - all including e-mail (which has not been disabled - all the button does is bring up a mailto in your own mail program - has nothing to do with the Forum).
Ruth, speaking of mail, the address you show here is not the same as the address I've been sending to, which was simply a reply to the message you sent me earlier this week. What is your correct address (send it to my "email button" if you prefer).
Also - notice anything new around your Avatar...
Poster: kevin3442
Dated: Saturday March 27 2004 - 4:02:36 GMT
John wrote:
...Also - notice anything new around your Avatar...
Very nice... let me say an official "welcome to the team!"... even though you've really been a team member for quite some time! You Milonic Machine you!
Kevin
Poster: Ruth
Dated: Saturday March 27 2004 - 4:29:17 GMT
Well, something must over-ride for you on the board John. I see only 3 on Kevin, 4 on you and Maz and there were only 4 on mine, but I eliminated AIM since I never use it. So, now there should be only 3 on mine. But, maybe you see the email even though I have it marked as do not show address? I sent an email reply to you.
Quote:
Also - notice anything new around your Avatar...
Sure do. Maz and I have been crowned
Ruth
Poster: kevin3442
Dated: Saturday March 27 2004 - 4:57:19 GMT
Hmmm... I see email buttons for all y'all (a throwback phrase to my years in Virginia). Mine probably doesn't show because of something in my profile. I'll go have a look....
OK. "Always show email address" was set to "no". Just changed it to "yes", so maybe that'll add the button for me. When it was "no", I guess the button still showed up for me when I was logged in, just in case I wanted to email myself.
Ruth wrote:
Maz and I have been crowned
"Crowned Ruth"... isn't that an expensive kind of booze or something?
Kevin
Poster: Ruth
Dated: Saturday March 27 2004 - 5:35:30 GMT
Yep, it's Royal for we who have been crowned
And, ya'll have email buttons now, but if you see one for me that's strange 'cause my profile has it set to no and it's not there for me! I have nun'tall, throwback to my still days in NC and sure hoping to be leaving soon
Ruth
Poster: John
Dated: Saturday March 27 2004 - 17:12:08 GMT
Where in Virginia, Kevin? I went to school in Salem.
Ruth, maybe I can see the buttons because of my Admin setting.
As to your address, whisper3 is where I'd been sending all the messages you never got this past week. That is not the address you have set here.
Poster: kevin3442
Dated: Sunday March 28 2004 - 6:27:20 BST
John wrote:
Where in Virginia, Kevin? I went to school in Salem....
Undergrad at James Madison University, in Harrisonburg, VA.
Hey Ruth... you see my email button now?
Kevin
Poster: Ruth
Dated: Sunday March 28 2004 - 8:44:33 BST
Kevin: yep, my new big specs must be working
John... it's the one posted that you can see. I just found out the one you see is 'linked' to that whisper3 account, but if it's addressed as whisper3 instead of ruth it goes to a different box which is where all the spam is sent, which I never read just delete. Sorry....
Wondering if Pavia's code is fixable.....
Ruth
Poster: kevin3442
Dated: Sunday March 28 2004 - 12:23:27 BST
Hi Ruth,
Ruth wrote:
...Wondering if Pavia's code is fixable.....
Well... sort of. We've been working on it off-line. The main problem we had earlier was that the php browser sniffer that we tried didn't work. I hacked together a new one and that worked fine ("hacked" because I'm completely new to PHP). We got a test working just fine for ns4/win, but ran into a snag with ns4/mac. That's where we've left it for now. We'll probably regroup soon.
I'll post a link to a test page at some point, but I'll be pretty busy this week with work, so I don't know when I'll get to it... hopefully soon.
Cheers,
Kevin