Page: 1, 2  Next

"Your Computer" code
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
Can you post the code that outputs the "Your Computer" table on your page techpatterns.com/downloads/free_scripts.php
??

That's essentially how I'm trying to implement the full featured php browser detect code on my page, but I'm getting stuck.

Also, is there a way to distinguish between Windows 98 and ME? Even though these OSes suck (in my opinion) and will hopefully phase out, it would be nice if the script could differeniate them!

Thanks a bunch.

-rob

22nd.org
Back to top
bad link
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
sorry, the correct URL for the location of the "Your Computer" table i was referring to is:

techpatterns.com/downloads/php_browser_detection.php

darn frames!

-rob
Back to top
My Computer Script
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Hi Rob, welcome to the forums, and thanks for catching that Windows ME OS detection bug, we try to have this stuff be as accurate as possible, we'd forgotten to test Windows ME, it being the Worst Windows possibly ever released it had just slipped our minds. Found a windows me navigator user agent, it was getting id'ed as 98 because it says:
:: Code ::
Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)

Instead of Win ME or Windows ME, should have known, same as Windows 2000/ Windows XP, which are NT 5.0 and 5.1 respectively, and you never know which navigator UserAgent version the browser will declare. Windows OS detection is a pain.

That bug is now fixed, download the latest version, 4.5.4, and it will give you windows ME fine now.

Rather than post the whole script here, we added it to the download section. Personally, I wasn't going to do that, it makes it too easy on people, but I guess I'll just have to live with it.

You can download the ' Your Computer Information ' script here

It's in two parts, the first part is the basic javascript for display stuff, you'll also need the javascript cookies script if you want the cookies function to work, otherwise just cut it out.

:: Quote ::
darn frames!


LOL -- you'll be happy to hear that techpatterns.com is in the process of being converted to a non scrolling 3 column div layout, took a while to work out the bugs in the CSS, but it's almost worked out, next comes reprogramming the site, hope to have the new version up in a week or two.

By the way, it would really help us out, and help other people find this information, if you could add a link to our site in exchange for these scripts. Thanks.

:: Code ::
<a href="http://techpatterns.com/downloads/php_browser_detection.php">
PHP Browser Detection</a>


Jeff
Back to top
not working
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
hey, i will surely link pack to your page. i'm having trouble implementing the script. can you take a look at it at :

[dead link]22nd.org/computer.html[/dead link]

I put the new version of the detect script in the same directory (root), and I named it browser_detection.php. You said to make it a js library file. Is that just .js extension? Because I tried that, and it didn't work either.

Thanks a lot for your help.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
PHP files usually end in either php or inc, although with the right .htaccess modification you can run all your .htm or .html files as php too, those are server side things, javascript files end in .js. Javascript is run by the browser after the page files are downloaded, PHP runs on the server before the page files are delivered to the browser. The browser detection script is php, the your computer script has both php and javascript on it.

Sorry, I wasn't clear, the computer information script has two parts, one is the javascript, the other is the page php. You can just paste that exact file into the page itself and it should work fine as long as you have the correct include path for the php browser detection script, you'll also have to download the javascript cookies script as well if you want to include the cookies feature, if you don't just slice that out of the script.

The the main part of the javascript part of the script needs to be on the page, however the top section, the function, can be either put into a javascript library file or left on the page, it doesn't really matter which way you do it, the function will be loaded either way, it just has to be loaded before the function is called in the computer information section, that's always the case with javascript. This means that any function that is declared needs to have been defined before the function declaration on the page, either directly on the page, as in this case, or in a libary file called in the head tag (or anywhere, but the head tag is a good place to put in all the library files

<script type="text/javascript" src="path_to_your_js_library_folder.js"></script>

By the way, you're getting a parse error on your index page, you'll want to fix that ASAP, line 100 of the page code.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
I rechecked the code, the PHP isn't getting parsed.

Anything between the <?php and the ?> should get parsed by the server as php, none of that code should be visible at all if it were getting parsed.

Since you have a parse error on your index page I assume you have a working php server, but this particular page isn't getting run through the parser probably (my best guess) because while your home page is index.php, your computer page is computer.html

.htm or .html pages will not get parsed by php unless you explicitly tell it to do so.

If you want to run html as php follow the link above to the .htaccess method, you can't run php with the .html extension unless you add that line of code to the .htaccess file.

The javascript part is working fine, that's the screen dimensions and 'javascript is enabled' part, so it's just a problem with the page not being parsed in php.

Good luck, let me know how it turns out, Jeff
Back to top
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
turned out great. i may modify it a bit to make it look exactly how i want, but the tool is there. thank you so much for your help, and i will definitely give you credit and a link.

i'm working on another script that i adapted from another page. it's to auto-detect the language of the browser and then allow you to change language if you happen to want a different language. do you have any interest in working on this with me? you could post it on your site when your done, as i'm sure others would be interested in using such a script.

[I moved the rest to a new thread for PHP browser version language detection to keep the topics separate, jeffd
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
I'm glad it worked out for you Rob, I moved the language detector topic to a new thread since that is unrelated to the question of how to install the your computer browser information script.

Your index page is still returning a parse error, you want to fix that, or you have a misdirection, 22nd.org/ returns a parse error, but 22nd.org/index.html gives a page, I'm not sure what's up there, but it's not working right. You can change the default index page through .htaccess.
Back to top
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
:: jeffd wrote ::
I'm glad it worked out for you Rob, I moved the language detector topic to a new thread since that is unrelated to the question of how to install the your computer browser information script.

Your index page is still returning a parse error, you want to fix that, or you have a misdirection, 22nd.org/ returns a parse error, but 22nd.org/index.html gives a page, I'm not sure what's up there, but it's not working right. You can change the default index page through .htaccess.


Thanks. I'm aware of the parse error. The page index.php has the language detect script in it, and it's currently not working. I'm not sure how to fix it, but I've read the thread about the language detect, and I await your results on working with that script. Thanks for your help.
Back to top
display full browser name
guinness
Status: Interested
Joined: 05 Jul 2004
Posts: 12
Reply Quote
I'm modifying the browser detection script so that it displays the full browser name (i.e. "Internet Explorer" rather than "MSIE").

:: Code ::
<?php
include('browser_detection.php');
if ( ( browser_detection( 'browser' ) == 'ie' )
&&
( browser_detection( 'number' ) >= 5 ) )
{
echo 'Internet Explorer ' .
browser_detection( 'number' );
}

// Opera
else if ( ( browser_detection( 'browser' ) == 'op' ) )
{
echo 'Opera ' .
browser_detection( 'number' );
}
// Netscape
else if ( ( browser_detection( 'browser' ) == 'ns' ) )
{
echo 'Netscape ' .
browser_detection( 'number' );
}
// Safari
else if ( ( browser_detection( 'browser' ) == 'saf' ) )
{
echo 'Safari ' .
browser_detection( 'number' );
}
?>


Is there a more efficient way to do this using the browser_detection.php script? Also, do you know a good way to test this for all these browsers without downloading them and installing them all?
Back to top
Display posts from previous:   
Page: 1, 2  Next
All times are GMT - 8 Hours