0
I created some functions responsible for taking the user’s IP (and ISP, parents, browser, OS) in order to keep a control of who accesses, how many times in a given minute I do not know where to insert in the pages of content of the site. Another question is the best way to get these kinds of information?
Code that picks up the 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:
"however do not know where to insert into the pages of content of the site"? Insert what? The information handles or the code? You want to display the data to the user?
– Guilherme Nascimento
insert the code that triggers the methods that capture user information, in my example I put just below the tag
<body>
– Ricardo