FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need something quick.





[FuN]goku
Right i just need a few things:
Whats the php code for getting someones browser?
Is there a code for getting someones OS if so what is it?
The code to get the current time?

Just need this info so i can log everything that goes on, on my site.
jabapyth
Code:
<?PHP
$browser = $_SERVER['HTTP_USER_AGENT'];

if(strstr($browser,"NT 5.1"))
$os = "Microsoft WindowsXP";

if(strstr($browser,"NT 5.0"))
$os = "Microsoft Windows2000";

if (strstr($browser, 'Linux'))
$os = "Linux";

if(strstr($browser,"MSIE 5.0"))
$browser = "Microsoft Internet explorer v5.0";

if(strstr($browser,"MSIE 5.5"))
$browser = "Microsoft Internet explorer v5.5";

if(strstr($browser,"MSIE 6.0"))
$browser = "Microsoft Internet explorer v6.0";

if(strstr($browser,"Mozilla/5.0"))
$browser = "Mozilla Firefox 5.0";

if(strstr($browser,"Mozilla/4.0"))
$browser = "Mozilla Firefox 4.0";

?>

thats for os and browser

for date, a quick google will do: php date
[FuN]goku
right cheers mate just so other people can benefit from this, heres what i edited it to do.
Code:

<?php
$time = gmdate("d M Y H:i:s T",time());

$ip = $_SERVER['REMOTE_ADDR'];

$browser = $_SERVER['HTTP_USER_AGENT'];

if(strstr($browser,"NT 5.1"))
$os = "Microsoft WindowsXP";

if(strstr($browser,"NT 5.0"))
$os = "Microsoft Windows2000";

if (strstr($browser, 'Linux'))
$os = "Linux";

if(strstr($browser,"MSIE 5.0"))
$browser = "Microsoft Internet explorer v5.0";

if(strstr($browser,"MSIE 5.5"))
$browser = "Microsoft Internet explorer v5.5";

if(strstr($browser,"MSIE 6.0"))
$browser = "Microsoft Internet explorer v6.0";

if(strstr($browser,"Mozilla/5.0"))
$browser = "Mozilla Firefox 5.0";

if(strstr($browser,"Mozilla/4.0"))
$browser = "Mozilla Firefox 4.0";

$f = fopen("actions.log","a");
fwrite($f, "Time: $time\n");
fwrite($f, "IP: $ip\n");
fwrite($f, "Browser: $browser\n");
fwrite($f, "Operating System: $os\n\n");
fclose($f);

?>




EDIT: Is there code so u can get the current page your visiting. like for example if i were to go to like example.com/testpage.php how would i get it to log what page that was on, cuz what im doing on every page is an include'file.php'; so i dont have to put a long bit of code on every page so.
[FuN]goku
bump
please reply to the above edit.

EDIT: nm found the code ^^
Code:

$page = $_SERVER['SCRIPT_NAME'];
sonam
I am not sure are you geting right user time. How I know function time()show server time but not browser time. In that case all your visitors have dispalyed same time. For browser time you need to use part of JavaScript.

Sonam
[FuN]goku
well it dont matter... im getting the time right on the minute and i just take away 4 hours and i got my time ^^ cuz the host i got is uk based
Related topics
why not add quick reply
Quick Reply
Quick reply?
Quick Reply
[REQ] Quick Reply
a quick tip
a quick reply option
Quick start guide - ftp tagging (v n00b)
www.Syrnia.com
quick search
quick forum builder
Quick Cpanel Question
THE GET RICH QUICK CONTEST!!!
Quick Sketch
Quick Search Button
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.