PHP] get the client (browser) information, access to client information system, access to server information

* Information acquisition client browser
* @param null
* @author https://blog.jjonline.cn/phptech/168.html
* @return String
* /
function get_broswer ()
{
$ $ _SERVER SYS = [ 'the HTTP_USER_AGENT'] ; // Get the user agent string
IF (stripos (SYS $, "Firefox /")> 0) {
the preg_match ( "/ Firefox \ / ([^;)] +) + / I", SYS $, $ B) ;
$ exp [0] = "Firefox";
$ exp [. 1] = $ B [. 1]; // Get Firefox browser version
} ELSEIF (stripos (SYS $, "Maxthon")> 0) {
the preg_match ( "/Maxthon\/([\d\.]+)/", SYS $, $ aoyou);
$ exp [0] = "aoyou";
$ exp [. 1] = $ aoyou [. 1];
} ELSEIF (stripos ($ SYS, "MSIE")> 0) {
the preg_match ( "/ MSIE \ S + ([^;)] +) + / I", SYS $, $ IE);
exp $ [0] = "IE";
$ exp [. 1] IE = $ [. 1]; // get the version number of IE
} ELSEIF (stripos ($ SYS, "the OPR")> 0) {
the preg_match ( "/ the OPR \ / ([\ D \.] +) /", $ SYS, $ Opera);
$ exp [0] = "Opera ";
$ exp [. 1] = Opera $ [. 1];
} ELSEIF (stripos (SYS $," Edge ")> 0) {
// win10 Edge browser chrome core tag matches added before determining the chrome
the preg_match (" / Edge \ / ([. \ D \] +) / ", $ SYS, $ Edge);
$ exp [0] =" Edge ";
$ exp [. 1] = $ Edge [. 1];
} ELSEIF (stripos ($ SYS, "the Chrome")> 0) {
the preg_match ( "/ the Chrome \ / ([\ D \.] +) /", $ SYS, $ Google);
$ exp [0] = "the Chrome";
$ exp [. 1 ] = $ google [1]; // google chrome version number acquired
} ELSEIF (stripos (SYS $, 'RV:')> 0 && stripos (SYS $, 'the Gecko')> 0) {
the preg_match ( "/ RV : / ", $ sys, ( + [\ d \.])$IE);
$exp[0] = "IE";
$exp[1] = $IE[1];
}else {
$ exp [0] = "Unknown Browser";
$ exp [. 1] = "";
}
return $ exp [0] '(' $ exp [. 1].. ')';.
}
Second, obtaining client system information www.cdxsxbx.com

/**
* 获取客户端操作系统信息,包括win10
* @param null
* @author https://blog.jjonline.cn/phptech/168.html
* @return string
*/
function get_os(){
    $agent = $_SERVER['HTTP_USER_AGENT'];
$os = false;

if (preg_match('/win/i', $agent) && strpos($agent, '95'))
{
$os = 'Windows 95';
}
else if (preg_match('/win 9x/i', $agent) && strpos($agent, '4.90'))
{
$os = 'Windows ME';
}
else if (preg_match('/win/i', $agent) && preg_match('/98/i', $agent))
{
$os = 'Windows 98';
}
else if (preg_match('/win/i', $agent) && preg_match('/nt 6.0/i', $agent))
{






































































































Third, access to basic information about the server

public function OSINFO ()
{
$ info = Array (
'OS' => PHP_OS,
'operating environment' => $ _SERVER [ "SERVER_SOFTWARE"],
'host name' => $ _SERVER [ 'the SERVER_NAME'],
'the WEB service port '=> $ _SERVER [' SERVER_PORT '],
' site document directory '=> $ _SERVER [ "DOCUMENT_ROOT"],
' browser information '=> substr ($ _ SERVER [' HTTP_USER_AGENT '], 0, 40),
' communication protocol '=> $ _SERVER [' SERVER_PROTOCOL The '],
' request method '=> $ _SERVER [' REQUEST_METHOD '],
//' ThinkPHP version '=> THINK_VERSION,
' the PHP version '=> PHP_VERSION,
' upload attachment limits' => the ini_get ( 'the upload_max_filesize'),
'execution time limit' => ini_get ( 'max_execution_time' ).'S',
'server time' => date ( "Y j of n dated May H: I: S"),
"GMT '=> gmdate (" Y j of n dated May H: i: s ", time () + 8 * 3600),
'Domain name server / the IP' => $ _SERVER [ 'the SERVER_NAME']. '[' .Gethostbyname ($ _ SERVER [ 'the SERVER_NAME']). ']',
'Free space' => round ((disk_free_space ( ".") /(1024*1024)),2).'M ',
' this user's IP address' => $ _SERVER [ 'REMOTE_ADDR'],
);

return $ info;

}

Guess you like

Origin www.cnblogs.com/fuoryao/p/11606991.html