Check for HPE iLO

				
					// Every HPE iLO will provide basic details without even logging in.
// http://[iLO IP Address]/xmldata?item=All
// iLO 7 onwards can use https
// I ran this against every IP on the iLO subnet

public function Get_ILO_Data($IPv4Addr)
    {
        $ProsessedOutput = '';
        $curl = curl_init();
        curl_setopt_array($curl, Array(
        CURLOPT_URL            => 'http://' . $IPv4Addr . '/xmldata?item=All',
        CURLOPT_USERAGENT      => 'spider',
        CURLOPT_TIMEOUT        => 15,
        CURLOPT_CONNECTTIMEOUT => 10,
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_ENCODING       => 'UTF-8'
        ));
        $Server_XML = curl_exec($curl);
        curl_close($curl);

        if(! $Server_XML)
        {
            // Use this to do what you want when no XMLdate returned.
            // Mark this IP as not HPE iLO
        }else{
            // Use this to do what you want when XMLdate returned.
            // Mark this IP as HPE iLO
        }
    }

public function Prosess_Server_Output($Server_XML, $IPv4Addr)
        {
            // Reset values so that they do not report false info.
            $HTML = '';
            $Product_Type = "";
            $Hardware_Type = "";
            $Serial =  "";
            $Product_ID =  "";
            $Description =  "";
            $Enclosure =  "";
            $Firmware =  "";
            $Hardware_Name  =  "";
            $ILO_Type =  "";
            $IRS =  "";
            $bay =  "";
            $sstatus = "";
            $isilo = "";
            $gen = 0;

            $Product_Type = getTextBetweenTags($Server_XML,"PN");
            $Hardware_Type = getTextBetweenTags($Server_XML,"SPN");
            $Description = getTextBetweenTags($Server_XML,"DESCRIPTION");

            if (strpos($Product_Type, 'c7000') !== false){
                $isilo = "True";
                $gen =2;
                $Serial = trim(getTextBetweenTags($Server_XML,"ENCL_SN"));
                $Hardware_Type = getTextBetweenTags($Server_XML,"PN");
                $Firmware = getTextBetweenTags($Server_XML,"FWRI");
                $Hardware_Name  = getTextBetweenTags($Server_XML,"ENCL");
                $ILO_Type = getTextBetweenTags($Server_XML,"PN");
                $IRS = getTextBetweenTags($Server_XML,"IRS");
                $Enclosure = getTextBetweenTags($Server_XML,"ENCL");
                $sstatus = getTextBetweenTags($Server_XML,"STATUS");

            }elseif (strpos($Hardware_Type, 'Gen9') !== false){
                $isilo = "True";
                $gen =9;
                $Serial =  trim($this->getTextBetweenTags($Server_XML,"SBSN"));
                $Hardware_Type = getTextBetweenTags($Server_XML,"SPN");
                $Product_ID = getTextBetweenTags($Server_XML,"PRODUCTID");
                $Description = getTextBetweenTags($Server_XML,"DESCRIPTION");
                $Enclosure = getTextBetweenTags($Server_XML,"ENCL");
                $Firmware = getTextBetweenTags($Server_XML,"FWRI");
                $Hardware_Name  = getTextBetweenTags($Server_XML,"SN");
                $IP_Address = getTextBetweenTags($Server_XML,"IPADDR");
                $ILO_Type = getTextBetweenTags($Server_XML,"PN");
                $IRS = getTextBetweenTags($Server_XML,"IRS");
                $bay = getTextBetweenTags($Server_XML,"BAY");
                $sstatus = getTextBetweenTags($Server_XML,"STATUS");
            }elseif (strpos($Hardware_Type, 'Gen8') !== false){
                $isilo = "True";
                $gen =8;
                $Serial = trim(getTextBetweenTags($Server_XML,"SBSN"));
                $Hardware_Type = getTextBetweenTags($Server_XML,"SPN");
                $Product_ID = getTextBetweenTags($Server_XML,"PRODUCTID");
                $Description = getTextBetweenTags($Server_XML,"DESCRIPTION");
                $Enclosure = getTextBetweenTags($Server_XML,"ENCL");
                $Firmware = getTextBetweenTags($Server_XML,"FWRI");
                $Hardware_Name  = getTextBetweenTags($Server_XML,"SN");
                $IP_Address = getTextBetweenTags($Server_XML,"IPADDR");
                $ILO_Type = getTextBetweenTags($Server_XML,"PN");
                $IRS = getTextBetweenTags($Server_XML,"IRS");
                $bay = getTextBetweenTags($Server_XML,"BAY");
                $sstatus = getTextBetweenTags($Server_XML,"STATUS");


            }elseif (strpos($Hardware_Type, 'G7') !== false){
                $isilo = "True";
                $gen =7;
                $Serial = trim(getTextBetweenTags($Server_XML,"SBSN"));
                $Hardware_Type = getTextBetweenTags($Server_XML,"SPN");
                $Firmware = getTextBetweenTags($Server_XML,"FWRI");
                $sstatus = getTextBetweenTags($Server_XML,"STATUS");
                $Description = "iLO 3";

            }elseif (strpos($Hardware_Type, 'G6') !== false){
                $isilo = "True";
                $gen =6;
                $Serial = trim(getTextBetweenTags($Server_XML,"SBSN"));
                $Hardware_Type = getTextBetweenTags($Server_XML,"SPN");
                $Firmware = getTextBetweenTags($Server_XML,"FWRI");
                $sstatus = getTextBetweenTags($Server_XML,"STATUS");
                $Description = "iLO 2";

            }elseif (strpos($Description, 'iLO 5') !== false){
                $isilo = "True";
                $gen =10;
                $Serial = trim(getTextBetweenTags($Server_XML,"SBSN"));
                $Hardware_Type = getTextBetweenTags($Server_XML,"SPN");
                $Firmware = getTextBetweenTags($Server_XML,"FWRI");
                $sstatus = getTextBetweenTags($Server_XML,"STATUS");

            }
        }

// This will return the content between tag <TAG>content</TAG>
// <SN>ILOCZ12345678</SN>

public function getTextBetweenTags($string, $tagname)
{
    $pattern = "/<$tagname>(.*?)<\/$tagname>/";
    preg_match($pattern, $string, $matches);
    if(!empty($matches))
    {
        $RTN = $matches[1];
    }else{
        $RTN = '';
    }
    return $RTN;
}