<?php

chdir("..");
chdir("..");
require_once "./includes/isgwtelnet.php";
include "./includes/variables.php";
if (show==yes){
$isgw = new isgwtelnet();	
$result=$isgw->isgw_login();
if ($result==false) echo "<font size='3' color='red'>ISGW must be started</font>";
$isdnresult=$isgw->isgw_isdnstate();
$rows = "";
		$rows = explode("\n", $isdnresult);
		
		echo  "<br><br>";
		echo "<table class='contenttoc' id='table1'>";
		echo "<th colspan=6>ISDN Status</th>";
		echo "<tr><td><b>Port</b></td><td><b>Type</b></td><td><b>Prot.</b></td>";
		echo "<td><b>L2Link</b></td><td><b>L1Link</b></tr>";
		$y = 1;
		

		foreach ($rows as $value){	
			$pos=strpos($value,"Port");
			if($pos !== false){
				echo "<tr>";
				$tmp = split("Port ", $value);
				$port = split(" Type", $tmp[1]);
				echo "<td>" . $port[0] . "</td>";
				$type = split(" Prot.", $port[1]);
				echo "<td>" . $type[0] . "</td>";
				$prot = split(" L2Link", $type[1]);
				echo "<td>" . $prot[0] . "</td>";
				$l2link = split(" L1Link:", $prot[1]);
				$l2link[0] = str_replace(" ", "", $l2link[0]);
				if ($l2link[0] == "UP") {
					echo "<td><img src='./includes/images/punkt_gruen.gif'></td>";
				} else {
					echo "<td><img src='./includes/images/punkt_rot.gif'></td>";
				}
				$l1link = split(" Blocked:", $l2link[1]);
				$l1link[0] = str_replace(" ", "", $l1link[0]);
				if ($l1link[0] == "UP") {
					echo "<td><img src='./includes/images/punkt_gruen.gif'></td>";
				} else {
					echo "<td><img src='./includes/images/punkt_rot.gif'></td>";
				}
				echo "</tr>";
				$y++;
			}//endif
		}//endforeach
		echo "</table>";
		
		}else{
			echo "<h2>Access Denied</h2>";
		}
?>
