Example #1
0
 function get_content()
 {
     global $email;
     global $passw;
     global $wsdl_url;
     global $proxy;
     global $days;
     global $maxcode;
     global $active;
     global $max_no_alerts;
     $asnames = array();
     // Now we make the call, to read the WSDL file
     //libxml_disable_entity_loader(false);
     //try {
     $client = new SoapClient($wsdl_url, $proxy);
     /**
     		}  catch (Exception $e) {
     			echo 'Error Caught';
     		}*/
     try {
         $content = false;
         $i = 0;
         foreach ($client->getAlerts($email, $passw, $days) as $key => $value) {
             // Cache ASnames
             if (!array_key_exists($value->monitored_AS, $this->asnames)) {
                 $this->asnames[$value->monitored_AS] = $client->getASName($email, $passw, $value->monitored_AS);
             }
             if ($value->alert_code != 97) {
                 if (!array_key_exists($value->origin_AS, $this->asnames)) {
                     $this->asnames[$value->origin_AS] = $client->getASName($email, $passw, $value->origin_AS);
                 }
             }
             $url = "https://portal.bgpmon.net/alerts.php?details&alert_id={$value->alert_id}";
             if ($value->alert_code != 97) {
                 $ttip2 = "Detected prefix: {$value->announced_prefix} AS{$value->origin_AS} (" . $this->asnames[$value->origin_AS] . ")<br>";
             } else {
                 $ttip2 = "AS{$value->monitored_AS} (" . $this->asnames[$value->monitored_AS] . ")<br>";
             }
             $ttip1 = $this->alert_desc[$value->alert_code];
             if ($value->cleared == true) {
                 $cleared = "Yes";
             } else {
                 $cleared = "No";
             }
             $content .= "<tr onclick=\"DoNav('{$url})\">";
             $content .= "<td <a class='tooltip' title='{$ttip1}'>" . htmlentities($this->alert_name[$value->alert_code]) . "</a></td>";
             $content .= "<td><a class='tooltip' title='{$ttip2}'>" . htmlentities("{$value->monitored_network} (AS{$value->monitored_AS})") . "</a></td>";
             $content .= "<td>" . htmlentities("{$value->date}") . "</td>";
             $content .= "<td>" . htmlentities("{$cleared}") . "</td>";
             $content .= "</tr>";
             // Check max number of alerts
             $i++;
             if ($i >= $max_no_alerts) {
                 break;
             }
         }
         if ($content) {
             return "<table class='' id='' >\r\n\t\t\t\t<tr><th>Alert Type</th><th>Prefix</th><th>Date</th><th>Cleared</th></tr>\r\n\t\t\t\t{$content}\r\n\t\t\t\t</table> ";
         } else {
             return "<b>No Alerts found</b>";
         }
     } catch (SoapFault $exception) {
         return "<b>SOAP Fault</b><br><pre> {$exception}</pre>";
     }
 }