PDA

View Full Version : سوال: مشکل در بدست اوردن اطلاعات سيستم با php . مثلا Browser History,Ip. Win User Name, Pc name



hamidhassas
جمعه 14 شهریور 1393, 10:15 صبح
چطوری میتونم به کد زیر قسمتی اضافه کنم که ورژن مورگر رو هم برام به نمایش بگزاره


$user_agent = $_SERVER['HTTP_USER_AGENT'];
function getOS()
{
global $user_agent;
$os_platform = "Unknown OS Platform";
$os_array = array(
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);
foreach ($os_array as $regex => $value)
{
if (preg_match($regex, $user_agent))
{
$os_platform = $value;
}
}
return $os_platform;
}
function getBrowser()
{
global $user_agent;
$browser = "Unknown Browser";
$browser_array = array(
'/msie/i' => 'Internet Explorer',
'/trident/i' => 'Internet Explorer',
'/firefox/i' => 'Firefox',
'/safari/i' => 'Safari',
'/chrome/i' => 'Chrome',
'/opera/i' => 'Opera',
'/netscape/i' => 'Netscape',
'/maxthon/i' => 'Maxthon',
'/konqueror/i' => 'Konqueror',
'/mobile/i' => 'Handheld Browser'
);
foreach ($browser_array as $regex => $value)
{
if (preg_match($regex, $user_agent))
{
$browser = $value;
}
}
return $browser;
}
$user_os = getOS();
$user_browser = getBrowser();
$device_details = "<strong>Browser: </strong>".$user_browser."<strong>Operating System: </strong>".$user_os."";
print_r($device_details);
echo("".$_SERVER['HTTP_USER_AGENT']."");

arash691
جمعه 14 شهریور 1393, 10:33 صبح
دو تا پروژه opensource برات میذارم از اینا استفاده بکن ...


http://linfo.sourceforge.net/

http://phpsysinfo.github.io/phpsysinfo/

hamidhassas
جمعه 14 شهریور 1393, 15:37 عصر
ای دوتا که مشخصات سرور رو فقط میدن خوبه ممنون
ولی من میخوام کاری کنم که تو کد بالا نسخه مرورگر رو هم بهم بده

shahriyar3
جمعه 14 شهریور 1393, 16:28 عصر
browscap نصب کنی اطلاعات کاملی برمیگردونه.


[browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$
[browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
[parent] => Firefox 0.9
[platform] => WinXP
[browser] => Firefox
[version] => 0.9
[majorver] => 0
[minorver] => 9
[cssversion] => 2
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] =>
[vbscript] =>
[javascript] => 1
[javaapplets] => 1
[activexcontrols] =>
[cdf] =>
[aol] =>
[beta] => 1
[win16] =>
[crawler] =>
[stripper] =>
[wap] =>
[netclr] =>

hamidhassas
جمعه 14 شهریور 1393, 16:54 عصر
من میخوام عددی که در قسمت rv نوشته رو چاپ کنم جطوری میشه با preg_match این کارو کرد


Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0)

abolfazl-z
جمعه 14 شهریور 1393, 17:52 عصر
https://github.com/ornicar/php-user-agent