English 中文(简体)
如何检测。 联网框架安装在网页上(纯超文本或购买力平价)。
原标题:How to detect .NET framework installed in a web page (pure HTML or PHP)

如果达到以下标准之一,我需要在网页上展示更多信息:

  • .NET Framework Installed on the client machine in lower than 3.5
  • Impossible to determine if .NET Framework 3.5 is installed or not on the client machine

我知道,一些浏览器(如果不仅仅是一个,IE)正在他中间发送这一信息。

您能向我提出建议吗?

网站在PHP中建立。

感谢!

EDIT:

拟议的答复不完整,而且(或)没有向我提供有力的解决办法。

最佳回答

这里是另一个版本。 我实际上为一位地雷的朋友做了发言,并认识到,在座右边有 b,因此:

这完全是行之有效的,但只靠使用者的力量,因为没有其他办法这样做。

核心类别:

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
   }
}

如果你也想从非行检查美国关税同盟的产物,请说

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

获取这一信息的唯一途径是浏览器发送的<编码>用户代理人。 你们可以 par。 网上版本。 但是,我注意到,客户可以收集这种信息,或完全放弃这些信息,因此,我将不把任何关键功能作为基础。

我将尝试并在PHP(Example Below)的用户代理人上做一个插手。

A.NETuser Agent :Mozilla/4.0 (compatible;MSIE 6.0;Windows NT 5.1;SV1;Pivim Multibar;GSB6.4;NET CLR 2.0.50727)

PHP:

<?php
function DotNetInstalled($ua = false)
{
    $ua = $ua ? $ua : $_SERVER[ HTTP_USER_AGENT ];
    //return (strstr( .NET CLR ,$ua) !== false);
    $matches = preg_match( ^.NET CLR ([0-4]+.)?([0-9].)?(*|d+)$ ,$ua);
    if((int)$matches[1] > 0)
    {
       return array(
           (int)$matches[1],
           (int)$matches[2],
           (int)$matches[3],
       );
    }
    return false;
}

if(false !== ($version = DotNetInstalled()))
{
   //Show me the money
   //$version[0] = 2
   //$version[1] = 0
   //$version[2] = 50727
}
?>

I would also check out the following PEAR Package : http://pear.php.net/package/Net_UserAgent_Detect ?>





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签