ja sam napravio PHP(2 skripte) jedna detekcija.php, druga index1.php
u detekciji se kriju podatci koji ce da iscitaju info o ip broju i o ip adresi......
dakle da prikazu korisniku sta koristi.....
e sad ja hocu da mi info o ip-u i o os-u cuva u jedan log fajl.....dakle da imam uvid kakvi posetioci sve dolaze , sa kojim os-om i ip-om.
kako ovo da odradim.....
evo oba koda:
detekcija.php
<?php
class Browser {
var $os; // Operating System (Linux, Solaris, Windows)
var $remote_ip;
function Browser() {
global $teststring;
if ($teststring != "" ) {
$agentstring = $teststring;
$testwarn = "yes";
} else {
$agentstring = $_SERVER['HTTP_USER_AGENT'];
}
$http_lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
# get some values from the $HTTP_USER_AGENT variables
$luser_agent0=explode("(",$agentstring);
$luser_agent1=explode(")",$luser_agent0[1]);
$luser_agent2=explode(";",$luser_agent1[0]);
# Which operating systems do we want to detect?
# How do we want to call them?
$det_os = array (
array("Linux","Linux"), // Some prefer "GNU/Linux"
array("FreeBSD","FreeBSD"),
array("OpenBSD","OpenBSD"),
array("NetBSD","NetBSD"),
array("Windows 2000","Windows","2000","Microsoft"),
array("Windows NT 5.0","Windows","2000","Microsoft"),
array("Windows NT 5.1","Windows","XP","Microsoft"),
array("Windows NT 5.2","Windows","2003","Microsoft"),
array("Windows NT","Windows","NT 4.0","Microsoft"),
array("Windows XP","Windows","XP","Microsoft"),
array("Windows 95","Windows","95","Microsoft"),
array("Windows 98","Windows","98","Microsoft"),
array("Windows ME","Windows","ME","Microsoft"),
array("WinNT4.0","Windows","NT 4.0","Microsoft"),
array("Win98","Windows","98","Microsoft"),
array("Win95","Windows","95","Microsoft"),
array("mac os x","MacOS","X","Apple"),
array("Mac OS X","MacOS","X","Apple"),
array("MacOS X","MacOS","X","Apple"),
array("Mac_PowerPC","MacOS","","Apple"),
array("Macintosh","MacOS","","Apple"),
array("macintosh","MacOS","","Apple"),
array("OS/2","OS/2","","IBM"),
array("SunOS 5.7","Solaris","5.7","Sun"),
array("SunOS 5.8","Solaris","5.8","Sun"),
array("SunOS 5.9","Solaris","5.9","Sun"),
array("SunOS","Solaris","","Sun"),
array("AIX","AIX","","IBM"),
array("HP-UX","HP-UX","","HP"),
array("IRIX","IRIX","","Sgi"),
array("BeOS","BeOS","","Be"),
array("Unix","UNIX","",""),
array("UNIX","UNIX","",""),
array("unix_sv","UNIX","","SCO"),
array("X11","UNIX","","")
);
#####################
##### FUNCTIONS #####
#####################
# function to give the $os variable the right string.
# $arg1 is where to look.
# $arg2 is the list we want to search with.
function testos ($arg1,$arg2)
{
for ($i = 0; $i <= sizeof($arg2); $i++){
if ((strpos($arg1,$arg2[$i][0])) || ($arg1 == $arg2[$i][0])){
$os=$arg2[$i][1];
if ($arg2[$i][2] != ""){
$os_ver=$arg2[$i][2];
}
if ($arg2[$i][3] != ""){
$os_vendor=$arg2[$i][3];
}
return array($os,$os_ver,$os_vendor);
}
}
}
# give the $os variable the right string.
$os=testos($luser_agent2[2],$det_os);
if (($os == NULL) && ($luser_agent2[0] == "Macintosh")){
$os[0]="MacOS";
}
// remote ip
$this -> remote_ip = $_SERVER["REMOTE_ADDR"];
$remote_ip = $this -> remote_ip;
#####################################################
##### If they're not detected, they're unknown. #####
#####################################################
if ($os[0] == NULL) $os[0]="nepoznato";
if ($remote_ip == NULL) $remote_ip="nepoznato";
########################################
##### put results into member vars #####
########################################
$this -> os = $os[0];
$this -> remote_ip = $remote_ip;
}
#########################
##### test function #####
#########################
function test()
{
$os = $this -> os;
$remote_ip = $this -> remote_ip;
echo "Vi koristite:<b> $os </b> ";
echo "<br>";
echo "Sa trenutnim IP brojem: <b>$remote_ip</b>";
}
}
$os=fopen('log.txt' , 'w');
$remote_ip=fopen('log.txt' , 'w+');
fwrite($os,$remote_ip);
?> evo ja sam ovde dodao ovo, ali ne radi.....napravi log fajl, ali ne upise informacije u njega.
index1.php
<?php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<title>Detekcija OS-a i IP broja</title>
</head>
<body>
<?php
include("detekcija.php");
$b = new Browser;
// uncomment to log user agent strings.
// $b -> logger("agentstrings.txt");
$b -> teststring = $teststring;
$b -> test();
?>
</body>
</html>
dakle ako neko zna kako da ovo izvedem neka javi......
Pozdrav....