پیدا کردن مرورگر و سیستم عامل کاربر

amir01

Well-Known Member
سلام بچه ها من دو تا چیز میخواستم:
1- من وقتی با کد
کد:
$_SERVER['HTTP_USER_AGENT']
وقتی مرورگر کاربر رو خروجی میگیرم یه چیز طولانی میده که اول همشون هم Mozilla مینویسه میخواستم ببینم چجوری میتونم دستور بدم که فقط مثلا بنویسه : IE6 یا Firefox2 اینجوری. ممنون.
2- اینکه کدی که سیستم عامل کاربر رو میده رو هم میخواستم اگه ممکنه. ممنون. یاحق
 

ooghry

Member
از راهنمای php

اینو تو خود راهنماش نوشته:

<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
echo 'You are using Internet Explorer.<br />';
}
?>
 

mosi20

Active Member
PHP:
<?php
//#####################################################################################################
/*/ 010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 \*\
\*\ 01010101010101010101010         I N   T H E   N A M E   O F   G O D      10101010101010101010101 /*/
/*/ 01010101010101010101010      A U T H O R  :  M O H S E N  D A V A R I    10101010101010101010101 \*\
\*\ 010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 /*/
//#####################################################################################################
//$GLOBALS['b_n'][1]='IE';
//$GLOBALS['b_n'][2]='FIREFOX';
//$GLOBALS['b_n'][3]='Netscape';
//$GLOBALS['b_n'][4]='Safari';
//$GLOBALS['b_n'][5]='Galeon';
//$GLOBALS['b_n'][6]='Konqueror';
//$GLOBALS['b_n'][7]='Opera';
//$GLOBALS['b_n'][8]='Lynx';
//$GLOBALS['b_n'][9]='bot';
//$GLOBALS['b_n'][10]='WebTV';
//$GLOBALS['b_n'][11]='other';
////////////////////////////
//$GLOBALS['o_n'][1]='windows';
//$GLOBALS['o_n'][2]='mac';
//$GLOBALS['o_n'][3]='Linux';
//$GLOBALS['o_n'][4]='Free BSD';
//$GLOBALS['o_n'][5]='Symbian';
//$GLOBALS['o_n'][6]='SunOS';
//$GLOBALS['o_n'][7]='IRIX';
//$GLOBALS['o_n'][8]='BeOS';
//$GLOBALS['o_n'][9]='OS/2';
//$GLOBALS['o_n'][10]='AIX';
//$GLOBALS['o_n'][11]='other';

class stat_find {
var $this_browser_k='';
var $this_browser_v='';
var $this_os_k='';
var $this_os_v='';
var $v_n='notfind';
var $this_ref_base='';
var $this_ref_next='';
	
	function find_browser($M01)	{
			$M01 = strtolower($M01);
			if(preg_match("/msie ([0-9]{1}\.[0-9]{1,2})/",$M01,$mathes1)){
			$this->this_browser_v=$mathes1[1];
			$this->this_browser_k=1;
			}else
			if(preg_match("/firefox\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/",$M01,$mathes2)){
			$this->this_browser_k=2;
			$this->this_browser_v=$mathes2[1];
			}else
			if(preg_match("/netscape\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/",$M01,$mathes3)){
			$this->this_browser_k=3;
			$this->this_browser_v=$mathes3[1];
			}else
			if(preg_match("/safari\/([0-9]{2,3}(\.[0-9])?)/",$M01,$mathes4)){
			$this->this_browser_k=4;
			$this->this_browser_v=$mathes4[1];
			}else
			if(preg_match("/galeon\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/",$M01,$mathes5)){
			$this->this_browser_k=5;
			$this->this_browser_v=$mathes[1];
			}else
			if(preg_match("/konqueror\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/",$M01,$mathes6)){
			$this->this_browser_k=6;
			$this->this_browser_v=$mathes6[1];
			}else
			if(preg_match("/opera[\/ ]([0-9]{1}\.[0-9]{1}([0-9])?)/",$M01,$mathes7)){
			$this->this_browser_k=7;
			$this->this_browser_v=$mathes7[1];
			}else
			if(preg_match("/lynx\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/",$M01,$mathes8)){
			$this->this_browser_k=8;
			$this->this_browser_v=$mathes8[1];
            }elseif (strpos("$M01","google") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="google";
            }elseif (strpos("$M01","yahoo") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="yahoo";
            }elseif (strpos("$M01","msn") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Msn";
            }elseif (strpos("$M01","slurp") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Slurp";
            }elseif (strpos("$M01","scooter") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Scooter";
            }elseif (strpos("$M01","spider") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Spider";
            }elseif (strpos("$M01","infoseek") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="infoseek";
            }elseif (strpos("$M01","findlinks") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="findlinks";
            }elseif (strpos("$M01","link checker") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Link Checker";
            }elseif (strpos("$M01","eEye2003") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="eeye2003";
            }elseif (strpos("$M01","exabotr") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Exabot";
            }elseif (strpos("$M01","jyxobot") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Jyxobot";
            }elseif (strpos("$M01","monit") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="monit";
            }elseif (strpos("$M01","aboutusbot") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="AboutUsBot";
            }elseif (strpos("$M01","pingdom") !== false)		{
			$this->this_browser_k=9;
			$this->this_browser_v="Pingdom";
            }elseif (strpos("$M01","webtv") !== false)		{
			$this->this_browser_k=10;
            }elseif (strpos("$M01","bot") !== false)		{
			$this->this_browser_k=9;
            }elseif (strpos("$M01","nav") !== false)		{
			$this->this_browser_k=3;
			$this->this_browser_v="Nav";
            }elseif (strpos("$M01","gold") !== false)		{
			$this->this_browser_k=3;
			$this->this_browser_v="Gold";
            }elseif (strpos("$M01","x11") !== false)		{
			$this->this_browser_k=3;
			$this->this_browser_v="X11";
            }elseif (strpos("$M01","mozilla") !== false)		{
			$this->this_browser_k=3;
			$this->this_browser_v="Mozilla";
           }elseif (strpos("$M01","gecko") !== false)		{
			$this->this_browser_k=2;
			}else{
			$this->this_browser_v=$this->v_n;
			$this->this_browser_k=11;
			}
			if ( $this->this_browser_v =='' ){
			$this->this_browser_v=$this->v_n;
			}
			
			
	}
	
	function find_os($M01)
	{		
		$M01 = strtolower($M01);
		if(strpos("$M01","windows nt 5.1") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="XP";
		}
		elseif (strpos("$M01","windows 98") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="98";
		}
		elseif (strpos("$M01","windows nt 5.0") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="2000";
		}
		elseif (strpos("$M01","windows nt 5.2") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="2003 server";
		}
		elseif (strpos("$M01","windows nt 6.0") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="vista";
		}
		elseif (strpos("$M01","windows nt") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="NT";
		}
		elseif (strpos("$M01","win 9x 4.90") !== false && strpos("$M01","win me"))		{
			$this->this_os_k=1;
			$this->this_os_v="ME";
		}
		elseif (strpos("$M01","win ce") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="CE";
		}
		elseif (strpos("$M01","win 9x 4.90") !== false)		{
			$this->this_os_k=1;
			$this->this_os_v="ME";
		}
		elseif (strpos("$M01","mac os x") !== false)		{
			$this->this_os_k=2;
			$this->this_os_v="OS X";
		}
		elseif (strpos("$M01","macintosh") !== false)		{
			$this->this_os_k=2;
		}
		elseif (strpos("$M01","PPC") !== false)		{
			$this->this_os_k=2;
		}
		elseif (strpos("$M01","linux i686") !== false)		{
			$this->this_os_k=3;
			$this->this_os_v="i686";
		}
		elseif (strpos("$M01","linux") !== false)		{
			$this->this_os_k=3;
		}
		elseif (strpos("$M01","freebsd") !== false)		{
			$this->this_os_k=4;
		}
		elseif (strpos("$M01","symbian") !== false)		{
			$this->this_os_k=5;
		}
		elseif (strpos("$M01","SunOS") !== false)		{
			$this->this_os_k=6;
		}
		elseif (strpos("$M01","IRIX") !== false)		{
			$this->this_os_k=7;
		}
		elseif (strpos("$M01","BeOS") !== false)		{
			$this->this_os_k=8;
		}
		elseif (strpos("$M01","OS/2") !== false)		{
			$this->this_os_k=9;
		}
		elseif (strpos("$M01","AIX") !== false)		{
			$this->this_os_k=10;
		}
		elseif (strpos("$M01","win") !== false)		{
			$this->this_os_k=1;
		}
		else{
			$this->this_os_k=11;
			$this->this_os_v=$this->v_n;
		}
		if( $this->this_os_v==''){
			$this->this_os_v=$this->v_n;
		}
	}
	
}
?>
 
آخرین ویرایش:

irdavidnet

Banned
برای بدست آوردن os سیستم طرف باید
از دستور u_name استفاده کنی (استادم تو کلاس php گفت)
یه دستور دیگه هم داره که می تونی صفحه قبلی که کاربر بوده و بعد وارد اون صفحه شده رو پیدا کنی و سیستم عامل و مرورگر و سرویس پک ویندوز پیدا کنی ، اونو می ذارم همینجا چون باید تو دفترم نگاه کنم
 

amir01

Well-Known Member
ببخشید آقای mosi20 من این کد رو توی یه فایل ذخیره کردم و از کد زیر برای خروجی استفاده کردم ولی جواب نداد. اگه میشه ببینید مشکلش چیه ممنون.
کد:
<?php

include "./ag.class.php";

$Find = new stat_find();
$os = $_SERVER['HTTP_USER_AGENT'];
echo $Find-> find_browser($os);

?>
 

mosi20

Active Member
خوب اینکه return نداره

print $Find->this_browser_v;
print $Find->this_browser_k;

اینم عدد بر میگردونه و با استفاده از کامنتهایی که بالای کلاس نوشتم میتونی به i e و... تبدیلش کنی
 

جدیدترین ارسال ها

بالا