Created
March 6, 2019 13:55
-
-
Save TheYkk/06540bb4d42782e50bc60071a4db2456 to your computer and use it in GitHub Desktop.
Save user statics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Kullanicinin IP adresini aliyoruz | |
$remoteaddr = $_SERVER['REMOTE_ADDR']; | |
// Sonra ip-api sitesinden bilgi elde ediyoruz (Ulke kod, Ulke, Bolge adi, eyalet,sehir gibi seyler...) | |
$ipadress = json_decode(file_get_contents("http://ip-api.com/json/$remoteaddr")); | |
$countryCode = strtolower($ipadress->countryCode); // Ulke kodu (Buyuk harfler ile geldigi icin kuculttum (gerek var mi hic bir fikrim yok.)) | |
$country = $ipadress->country; // Ulke adi (Ingilizce olarak geliyor. (Turkey, United Stades gibi..)) | |
$regionName = $ipadress->regionName; // Bolge adi (Ingilizce olarak geliyor.) | |
$city = $ipadress->city; // Eyalet ya da Sehir adi (Ingilizce olarak geliyor.) | |
# Ustteki seyleri soyle siralayabilirsin: <?php echo "{$regionName}, {$city}, {$country}'de yasiyorum"; ? > | |
$os = $_SERVER['HTTP_USER_AGENT']; // Kullandigi isletim sistemi hakkinda bilgi verir (Windows 10, Windows 98 gibi... ancak bunu bir fonksiyon ile ne oldugunu belirtebilirsin) | |
function whatsMyOS($useragent) { | |
global $useragent; | |
$ostypes = array( | |
'Windows 311' => 'Win16', | |
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', | |
'Windows ME' => '(Windows 98)|(Win 9x 4.90)|(Windows ME)', | |
'Windows 98' => '(Windows 98)|(Win98)', | |
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)', | |
'Windows XP' => '(Windows NT 5.1)|(Windows XP)', | |
'Windows Server 2003' => '(Windows NT 5.2)', | |
'Windows Vista' => '(Windows NT 6.0)', | |
'Windows 7' => '(Windows NT 6.1)', | |
'Windows 8' => '(Windows NT 6.2)', | |
'Windows 10' => '(Windows NT 10.0)', | |
'Windows NT' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', | |
'OpenBSD' => 'OpenBSD', | |
'SunOS' => 'SunOS', | |
'Ubuntu' => 'Ubuntu', | |
'Android' => 'Android', | |
'Linux' => '(Linux)|(X11)', | |
'iPhone' => 'iPhone', | |
'iPad' => 'iPad', | |
'MacOS' => '(Mac_PowerPC)|(Macintosh)', | |
'QNX' => 'QNX', | |
'BeOS' => 'BeOS', | |
'OS2' => 'OS/2', | |
'Arama botu' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)' | |
); | |
$useragent = strtolower($useragent ? $useragent : $_SERVER['HTTP_USER_AGENT']); | |
foreach ($ostypes as $os => $pattern) | |
if (preg_match('/' . $pattern . '/i', $useragent)) | |
return $os; | |
return 'Bilinmiyor'; | |
} | |
echo whatsMyOS($os); // gibi... | |
// bunlarıda sonra sql sorgusuyla kaydedersin... | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment