PHP Simple Function to Get Lots of Visitor Info
PHP Simple Function to Get Lots of Visitor Info Such as the Device the Visitor is Using, IP Address, Remote Host, Current Date and Time, UserAgent
Home
Short:
/* ------------------------------------------------- function to reveals lots of info about visitor -------------------------------------------------- */ function visitorInfo() { $devicetype = ""; $isMob = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile")); $isTab = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "tablet")); if($isMob) { if($isTab){ $devicetype = "Tablet";} else{$devicetype = "Mobile Phone";} } else { $deviceType = "Computer"; } $ipaddress = $_SERVER['REMOTE_ADDR']; $remotehost = @getHostByAddr($ipaddress); $monthName = date("F", mktime(0, 0, 0, date("m"))); $day = date("d"); $year = date("Y"); $time = date("h:i:s A"); $datetime = $monthName . " " . $day . ", " . $year . " at " . $time; return [ $deviceType, $ipaddress, $remotehost, $_SERVER["HTTP_REFERER"], $_SERVER["HTTP_USER_AGENT"], $datetime ]; }
Example on how to use this visitorInfo() function ...
[$devicetype, $remoteip, $remotehost, $referrer, $useragent, $datetime] = visitorInfo();
source code home