3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!isset($_SESSION)) { session_start(); } function dumpDOMnodeList($xml) { $docTmp = new DOMDocument(); foreach($xml as $n) $docTmp->appendChild($docTmp->importNode($n,true)); //echo '<pre>'; print_r($docTmp->saveHTML()); //echo '</pre>'; } class ipm { //BEGIN VARIABLES public $soapVersion; public $soapLocation; public $soapContext; public $soapParameters; public $soapClient; public $soapCookies; public $soapService; const groupID = '104362395629'; //MAIN GROUP NUMBER WITHIN IPM, NEVER CHANGES //END VARIABLES //BEGIN CONSTRUCTOR function __construct($soapService) { $this->soapService = $soapService; //STATUS OR CONFIG $this->soapVersion = '1.2'; $this->soapLocation = 'https://webservice.domain/soap/'.$this->soapService.'.asmx'; $this->soapContext = stream_context_create(array('ssl' => array('verify_peer' => TRUE))); $this->soapParameters = array ( 'location' => $this->soapLocation, 'login' => 'user', 'password' => 'password', 'stream_context' => $this->soapContext, 'trace' => 1, 'keep_alive' => 1, 'cache_wsdl' => WSDL_CACHE_NONE ); $this->soapClient = new SoapClient('./'.$this->soapService.'.wsdl',$this->soapParameters); } //END CONSTRUCTOR //BEGIN PRIVATE FUNCTIONS private function schemaOpen($fn='',$vars) { $tmp = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'; if(empty($vars)) { return $tmp.'<soap:Body><'.$fn.' xmlns="'.$this->schemaBase().'" />'; } else { return $tmp.'<soap:Body><'.$fn.' xmlns="'.$this->schemaBase().'">'; } } private function schemaClose($fn='',$vars) { if(empty($vars)) { return '</soap:Body></soap:Envelope>'; } else { return '</'.$fn.'></soap:Body></soap:Envelope>'; } } private function schemaBase($fn='') { return 'http://schemas.ipmonitor.com/ipm70/'.$fn; } private function dumpDOMnodeList($xml) { $docTmp = new DOMDocument(); foreach($xml as $n) $docTmp->appendChild($docTmp->importNode($n,true)); echo '<pre>'; print_r(htmlentities($docTmp->saveHTML())); echo '</pre>'; } private function debugSoap() { echo '<pre>'; echo $this->soapClient->__getLastRequestHeaders(); echo $this->soapClient->__getLastRequest(); echo $this->soapClient->__getLastResponseHeaders(); echo '</pre>'; } private function soapRequest($fn='',$vars=array()) { $xml=$this->schemaOpen($fn,$vars); foreach($vars as $key=>$val) { $xml .= '<'.$key.'>'.$val.'</'.$key.'>'; } $xml.=$this->schemaClose($fn,$vars); return $xml; } private function callMethod($fn,$vars=array()) { $soapRequest = $this->soapRequest($fn,$vars); $soapAction = $this->schemaBase($fn); $soapResponse = $this->soapClient->__doRequest($soapRequest, $this->soapLocation, $soapAction, $this->soapVersion,0); $this->logSoap($soapRequest, $this->soapLocation, $soapAction, $this->soapVersion, $soapResponse,$this->debugSoap()); return $soapResponse; } private function logSoap($request, $location, $action, $version, $reponse, $debug) { file_put_contents('soap_log', date('m-d-Y H:i:s')."\r\nRequest: $request\r\n\r\nLocation: $location\r\nAction: $action\r\nVersion: $version\r\nResponse: $response\r\nDebug: $debug\r\n\r\n"); } //END PRIVATE FUNCTIONS //BEGIN METHODS public function GetGroup($rtGroupID) { /* GetGroup returns the status and some minor details about a specific Monitor. */ return $this->callMethod(__FUNCTION__,array('id'=>$rtGroupID)); } public function GetGroups() { /* GetGroups returns the status of members and depends of a specific Group */ return $this->callMethod(__FUNCTION__,array()); } public function GetMonitors($rtGroupID) { /* GetMonitor returns the status of the members and depends of a specific Group. */ return $this->callMethod(__FUNCTION__,array('groupid'=>$rtGroupID,'bTroubleOnly'=>'TRUE')); } public function GetMonitor($rtMonitorID) { /* GetMonitor returns the status and some minor details about a specific Monitor. */ return $this->callMethod(__FUNCTION__,array('id'=>$rtMonitorID)); } public function MonitorView($rtMonitorID) { /* MonitorView retrieves an ipMonitor 7 Monitor objects's settings in xml format. */ return $this->callMethod(__FUNCTION__,array('mon_id'=>$rtMonitorID)); } public function GroupList() { /* GroupList retrieves the ID's of all the existing Group objects. */ return $this->callMethod(__FUNCTION__,array()); } public function GroupView($rtGroupID) { /* GroupView retrieves an ipMonitor 7 Group objects's settings in xml format. */ return $this->callMethod(__FUNCTION__,array('groupid'=>$rtGroupID)); } //END METHODS } /* BEGIN GET ALL DOWN MONITORS */ $ipm = new ipm('status'); $ipmGroups = $ipm->GetGroups(); if(!empty($ipmGroups)) { $doc = new DOMDocument(); $doc->LoadXML($ipmGroups); $xpath = new DOMXpath($doc); $xpath->registerNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $xpath->registerNamespace('def', 'http://schemas.ipmonitor.com/ipm70/'); $ipmGroupsAlarming = $xpath->query("/soap:Envelope/soap:Body/def:GetGroupsResponse/def:GetGroupsResult/def:rtGroup[(contains(def:status,'lost') or contains(def:status,'warn') or contains(def:status,'down')) and contains(def:isroot,'false')]"); $numGroupsAlarming = $ipmGroupsAlarming->length; if($numGroupsAlarming === 0) { echo '<div class="text-success">No issues</div>'."\r\n"; } else { unset($ipm,$ipmGroups,$doc,$xpath,$numGroupsAlarming); foreach($ipmGroupsAlarming as $ipmGroupAlarming) { $groupName = $ipmGroupAlarming->getElementsByTagName('name')->item(0)->nodeValue; $groupStatus = $ipmGroupAlarming->getElementsByTagName('status')->item(0)->nodeValue; $groupID = $ipmGroupAlarming->getElementsByTagName('id')->item(0)->nodeValue; echo $groupName.'<br/>'."\r\n"; $ipm = new ipm('status'); $ipmMonitors= $ipm->GetMonitors($groupID); $doc = new DOMDocument(); $doc->LoadXML($ipmMonitors); $xpath = new DOMXpath($doc); $xpath->registerNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $xpath->registerNamespace('def', 'http://schemas.ipmonitor.com/ipm70/'); $ipmMonitorsAlarming = $xpath->query("/soap:Envelope/soap:Body/def:GetMonitorsResponse/def:GetMonitorsResult/def:rtMonitor"); $numMonitorsAlarming = $ipmMonitorsAlarming->length; if($numMonitorsAlarming === 0) { echo 'No Monitors Down Under This Device<br/>'."\r\n"; } else { foreach($ipmMonitorsAlarming as $ipmMonitorAlarming) { $monitorName = $ipmMonitorAlarming->getElementsByTagName('name')->item(0)->nodeValue; $monitorStatus = $ipmMonitorAlarming->getElementsByTagName('status')->item(0)->nodeValue; $monitorID = $ipmMonitorAlarming->getElementsByTagName('id')->item(0)->nodeValue; echo '--&gt; '.$monitorStatus.' - '.$monitorName.'<br/>'."\r\n"; } } unset($ipm,$ipmMonitors,$doc,$xpath,$numMonitorsAlarming,$ipmMonitorsAlarming); echo '<br/>'; } } } elseif($ipmGroups == NULL) {echo 'NULL SOAP RESPONSE';} else { echo 'No issues'."\r\n"; } /* END GET ALL DOWN MONITORS */ ?>
Output for git.master, git.master_jit
Deprecated: ipm::schemaOpen(): Optional parameter $fn declared before required parameter $vars is implicitly treated as a required parameter in /in/jeSkS on line 49 Deprecated: ipm::schemaClose(): Optional parameter $fn declared before required parameter $vars is implicitly treated as a required parameter in /in/jeSkS on line 63 Warning: session_start(): Session cannot be started after headers have already been sent in /in/jeSkS on line 4 Fatal error: Uncaught Error: Undefined constant "WSDL_CACHE_NONE" in /in/jeSkS:42 Stack trace: #0 /in/jeSkS(183): ipm->__construct('status') #1 {main} thrown in /in/jeSkS on line 42
Process exited with code 255.
Output for rfc.property-hooks
Deprecated: Optional parameter $fn declared before required parameter $vars is implicitly treated as a required parameter in /in/jeSkS on line 49 Deprecated: Optional parameter $fn declared before required parameter $vars is implicitly treated as a required parameter in /in/jeSkS on line 63 Warning: session_start(): Session cannot be started after headers have already been sent in /in/jeSkS on line 4 Fatal error: Uncaught Error: Undefined constant "WSDL_CACHE_NONE" in /in/jeSkS:42 Stack trace: #0 /in/jeSkS(183): ipm->__construct('status') #1 {main} thrown in /in/jeSkS on line 42
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.29 ms | 401 KiB | 8 Q