12-21-03, 03:38 PM
PHP/MySQL coder
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
A good tutorial or book
Hi,
i plan to make a stat system and i cant find any good tutorials on them anywhere! >
so does anyonw know of a good book or tutorial site that shows:
OS
Broswer
Revolutions
Referalls
top pages
now i dont care if its a book or a tutorial its from i just want to get it from one of these sources. thx in advance
12-21-03, 03:43 PM
Newbie Coder
Join Date: Dec 2003
Location: Anaheim CA
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Check out the predefined global variable $_SERVER. It is an array that contains most of the info you request.
Check it out and put the following in a page:
12-21-03, 03:56 PM
Newbie Coder
Join Date: Dec 2003
Location: England
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Check this
Try this script, it is similar to the one I use on
Good Scripts
PHP Code:
class getuserinfo { function getuserinfo () { /* This gets info about the user's system: Browser, OS, Bots etc. */ if ( is_array ( $_SERVER )) { $ua = $_SERVER [ "HTTP_USER_AGENT" ]; } else { global $HTTP_SERVER_VARS ; $ua = $HTTP_SERVER_VARS [ "HTTP_USER_AGENT" ]; } /* Bot Check */ $this -> botname = '' ; $bots = Array( 'Google' , 'Slurp' , 'Scooter' , 'Spider' , 'Infoseek' , 'Ask Jeeves' , 'slurp@inktomi' , 'whatuseek' , 'Is_Archiver' ); for( $i = 0 ; $i < count ( $bots ); $i ++) { if ( eregi ( $bots [ $i ], $ua )) { $this -> botname = $bots [ $i ]; break; } } if ( eregi ( "bot" , $ua ) && empty( $this -> botname )) { $this -> botname = "Other" ; } /* No bot? Then check what the user's browser is */ if (!empty( $this -> botname )) { $this -> browser = "Bot" ; } elseif (( ereg ( "Nav" , $ua )) || ( ereg ( "Gold" , $ua )) || ( ereg ( "X11" , $ua )) || ( ereg ( "Mozilla" , $ua )) || ( ereg ( "Netscape" , $ua )) AND (! ereg ( "MSIE" , $ua ) AND (! ereg ( "Konqueror" , $ua )))) { $this -> browser = "Netscape" ; } else { $browsers = Array( "MSIE" , "Lynx" , "Opera" , "WebTV" , "Konqueror" , "Other" ); for( $j = 0 ; $j < count ( $browsers ); $j ++) { if ( eregi ( $browsers [ $j ], $ua )) { $this -> browser = $browsers [ $j ]; break; } else { $this -> browser = "Other" ; } } } /* Check what the OS is */ $n_os = Array( "Win" , "Mac" , "PPC" , "Linux" , "FreeBSD" , "SunOS" , "IRIX" , "BeOS" , "OS/2" , "AIX" ); $r_os = Array( "Windows" , "Mac" , "Mac" , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); for( $i = 0 ; $i < count ( $n_os ); $i ++) { if ( eregi ( $n_os [ $i ], $ua )) { $this -> os = ( $r_os [ $i ] == 1 ) ? $n_os [ $i ] : $r_os [ $i ]; break; } else { $this -> os = "Other" ; } } return true ; } } $user = new getuserinfo ();
The variables can then be accessed through:
I have not tried this version but it should work!
12-21-03, 05:01 PM
PHP/MySQL coder
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
thx all i really wanted to know was how to detect broswers and stuff and this will help me out. if u know of a book or somthing i would still like to see that.
12-21-03, 05:13 PM
Junior Code Guru
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,
If you are seriously eager to learn about these stats things, I would recommend that you try a book about HTTP. Here's one by
C. Shiflett that I use:
HTTP DEVELOPER'S HANDBOOK
http://shiflett.org/books/http-developers-handbook
I admit that this book will be an "overkill" if all you need is identifying the users' browser, referer, etc. BUT if you are to continue web developing further, sooner or later, you may find this book helpful.
__________________
Blavv =|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off