如何检测安装在一个网页.NET框架(纯HTML或PHP) [英] How to detect .NET framework installed in a web page (pure HTML or PHP)

查看:131
本文介绍了如何检测安装在一个网页.NET框架(纯HTML或PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示一个网页(PHP)如果满足下列条件之一的附加信息:

I need to display additional information on a web page (PHP) if one of the following criteria is met:

  • 在低于3.5安装在客户端机器上的.NET Framework
  • 在无法确定是否.NET Framework 3.5的安装或者未在客户端计算机上

我知道有些浏览器(如果不是唯一的一个,IE)发送的信息在他的标签。

I know that some browser (if not only one, IE) is sending that information in his tag.

可以在任何你给我提供他的建议?

Can any of you provide me with his suggestions ?

网站构建在PHP。

谢谢!

编辑:

建议的答复是不完整和/或不给我提供一个强大的解决方案。

Proposed answers are incomplete and/or don't provide me with a robust solution.

推荐答案

下面是另外一个版本,我实际上是我的一个朋友提出和实现,有在此线程赏金等什么是地狱:)

Here is another version I actually made for a friend of mine and realised that there was a bounty on this thread so what the hell :)

这是完全正常的,但只有与用户代理字符串作为有这样做没有任何替代手段。

This is fully working but only with User-agent strings as there is no alternative means of doing so.

核心类:

class NETFrameworkChecker
{
    //General String / Array holders
    var $original_au,$ua_succesParse,$ua_componants,$ua_dotNetString,$CLRTag = "";

    //IsInstalled
    var $installed = false;

    //Version holders
    public $major = 0,$minor = 0,$build = 0;

    public function __construct($ua = false)
    {
        $this->original_au = $ua !== false ? $ua : $_SERVER['HTTP_USER_AGENT'];
        $this->ParserUserAgent();
    }

    public function Installed(){return (bool)$this->installed;}

    public function AUTag(){return $this->CLRTag;}

    //Version Getters
    public function getMajor(){return $this->major;}
    public function getMinor(){return $this->minor;}
    public function getBuild(){return $this->build;}

    private function ParserUserAgent()
    {
        $this->ua_succesParse = (bool) preg_match('/(?<browser>.+?)\s\((?<components>.*?)\)/',$this->original_au,$this->ua_componants);
        if($this->ua_succesParse)
        {
            $this->ua_componants = explode(';',$this->ua_componants['components']);
            foreach($this->ua_componants as $aComponant)
            {
                $aComponant = trim($aComponant);
                if(substr(strtoupper($aComponant),0,4) == ".NET")
                {
                    //We have .Net Installed
                    $this->installed = true;
                    $this->CLRTag = $aComponant;

                    //Lets make sure we can get the versions
                    $gotVersions = (bool)preg_match("/\.NET.CLR.+?(?<major>[0-9]{1})\.(?<minor>[0-9]{1})\.(?<build>[0-9]+)/si",$aComponant,$versions);
                    if($gotVersions)
                    {
                        $this->major = (int)$versions['major'];
                        $this->minor = (int)$versions['minor'];
                        $this->build = (int)$versions['build'];
                    }
                    break;
                }
            }
        }
    }
}

实例应用:

$Net = new NETFrameworkChecker(); //leave first param blank to detect current user agent

if($Net->Installed())
{
   if($Net->getMajor()> 2 && $Net->getMinor() >= 0)
   {
      //User is using a >NET system thats greater than 2.0.0000
      if($Net->GetBuild() >= 0200)
      {
         //We can do stuff with so that's only supported from this build up-words
      }
   }else
   {
      //Redirect them asking them to upgrade :) pretty please
   }
}

如果您还需要检查的自定义UA字符串从数据库可以说

If you also want to check custom UA Strings from DB lets say

$Net = new NETFrameworkChecker("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Pivim Multibar; GTB6.4; .NET CLR 2.0.50727)");

这篇关于如何检测安装在一个网页.NET框架(纯HTML或PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆