I have created some functions responsible for getting the IP of the user (and ISP, parents, browser, OS) in order to keep a control of who accesses, how many times he accessed in a minute but do not know where to insert in the content pages of the site. Another question is the best way to get these kinds of information?
Code that takes information
<?php
class ClientData{
public $ip;
public $isp;
public $browser;
public $so;
public $city;
public $country;
public $referrer;
/**
*StartCatchData()
*Este método tem o objetivo de realizar todas as chamadas a métodos, obtendo
*assim todos os dados dos cliente.
*/
public function StartCatchData(){
$this->CatchIP();
}
public function CatchIP(){
if(array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)){
$this->ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}else if(array_key_exists('REMOTE_ADDR', $_SERVER)) {
$this->ip = $_SERVER["REMOTE_ADDR"];
}else if(array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
$this->ip = $_SERVER["HTTP_CLIENT_IP"];
}else{
$this->ip = false;
}
}
}
?>
Content page
<html>
<head>
<title>
Teste
</title>
</head>
<body>
<?php
require_once 'ClientData.php';
$clientData = new ClientData();
$clientData->StartCatchData();
?>
Hello World!
</body> de exemplo: