Current location: Hot Scripts Forums » Programming Languages » PHP » A good tutorial or book


A good tutorial or book

Reply
  #1 (permalink)  
Old 12-21-03, 03:38 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
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
Reply With Quote
  #2 (permalink)  
Old 12-21-03, 03:43 PM
Beaver Beaver is offline
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:
PHP Code:

<?php

print_r
($_SERVER);
?>
Reply With Quote
  #3 (permalink)  
Old 12-21-03, 03:56 PM
mjac mjac is offline
Newbie Coder
 
Join Date: Dec 2003
Location: England
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation 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"11111,
             
11);
         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:

PHP Code:

 $user->os// Operating system.
 
$user->browser// Web browser.
 
$user->botname// If there is a bot, the name of it. 
I have not tried this version but it should work!
__________________
Michael J.A. Clark
My homepage, journal/blog; browser-based development; Solar Empire BBS game
Reply With Quote
  #4 (permalink)  
Old 12-21-03, 05:01 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
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.
Reply With Quote
  #5 (permalink)  
Old 12-21-03, 05:13 PM
blaw's Avatar
blaw blaw is offline
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 =|
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for a good CMS Riklaunim Script Requests 7 12-15-03 12:13 PM
Can you recommend a good book perleo JavaScript 5 12-11-03 01:55 AM
need help finding a good user online tutorial darkcarnival PHP 4 12-07-03 10:03 AM
Can you recommend a good MySQL book perleo PHP 2 11-26-03 04:01 AM
dynamic include tutorial nick_a PHP 1 10-28-03 12:30 AM


All times are GMT -5. The time now is 07:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.