Index: npl/syn3/webint/src/vpn/listtunnels.php
===================================================================
--- npl/syn3/webint/src/vpn/listtunnels.php	(revision a35989d1d54109e3359ab21b867e44437ecdf090)
+++ npl/syn3/webint/src/vpn/listtunnels.php	(revision 0b780b4d613c0f00031df145ed9d2fb31008489b)
@@ -65,5 +65,5 @@
         {
             //status NOT ok?
-            if ($status[$name][state] != "STATE_QUICK_I2" && $status[$name][state] != "STATE_QUICK_R2" && $status[$name][state] != "STATE_V2_IPSEC_R" && $status[$name][state] != "STATE_V2_IPSEC_I")
+            if ($status[$name][phase1] != "OK" || $status[$name][phase2] != "OK")
                 LinkDefault("testtunnel.php?name=$name&mode=down", _Started(), "<img src='../img/CAUTION.gif'>",_ConfirmDisable($name));
             else
@@ -87,28 +87,25 @@
 
 
+        //should be up?
         if ($data["auto"]=="up")
         {
-            //do we have actual status info?
-            if ($status[$name][state])
-            {
-                $statehtml=State_GetHtml("ipsec_$name",true);
-                echo "<a href='editvpnmon.php?tunnelName=$name'>";
-                if ($statehtml)
-                    echo $statehtml;
-                else
-                    echo "<img title='"._vpnMon()."' src='../img/mon.gif'>";
-                echo "</a>";
+            $statehtml=State_GetHtml("ipsec_$name",true);
+            echo "<a href='editvpnmon.php?tunnelName=$name'>";
+            if ($statehtml)
+                echo $statehtml;
+            else
+                echo "<img title='"._vpnMon()."' src='../img/mon.gif'>";
+            echo "</a>";
 
-                // if ($status[$name][state] != "STATE_QUICK_I2" &&
-                //         $status[$name][state] != "STATE_QUICK_R2" )
-                //     echo "<img src='../img/arrow_r.gif'>";
-                echo "<a href='tunnelstatus.php?name=$name'>";
-                echo $VPN_STATES[$status[$name][state]];
-                echo "</a>";
-            }
+            echo "<a href='tunnelstatus.php?name=$name'> ";
+
+            if ($status[$name][phase1]!="OK")
+                echo "Phase 1: ".$status[$name][phase1];
+            elseif ($status[$name][phase2]!="OK")
+                echo "Phase 2: ".$status[$name][phase2];
             else
-            {
-                echo "<b>Unknown</b>";
-            }
+                echo "OK";
+
+            echo "</a>";
         }
 
Index: npl/syn3/webint/src/vpn/openswan.php
===================================================================
--- npl/syn3/webint/src/vpn/openswan.php	(revision a35989d1d54109e3359ab21b867e44437ecdf090)
+++ npl/syn3/webint/src/vpn/openswan.php	(revision 0b780b4d613c0f00031df145ed9d2fb31008489b)
@@ -334,57 +334,74 @@
 
 
-	$VPN_STATES=array(
-		'Main'=>"Connecting...",
+	$VPN_STATES_1=array(
+		//ike v1
 		'STATE_MAIN_I1'=>"Connecting...",
-			'STATE_MAIN_R1'=>"Connection accepted...",
-		'STATE_MAIN_I2'=>"Connection complete...",
+		'STATE_MAIN_R1'=>"Connecting...",
+		'STATE_MAIN_I2'=>"Connecting...",
+
 		'STATE_MAIN_I3'=>"Checking keys...",
-			'STATE_MAIN_R2'=>"Checking keys...",
-		'STATE_MAIN_I4'=>"Keys accepted...",
-			'STATE_MAIN_R3'=>"Waiting for tunnel request...",
-		'Quick'=>"Requesting tunnel...",
-		'STATE_QUICK_I1'=>"Requesting tunnel...",
-			'STATE_QUICK_R1'=>"Tunnel request received...",
-		'STATE_QUICK_I2'=>"Tunnel established",
-			'STATE_QUICK_R2'=>"Tunnel established",
+		'STATE_MAIN_R2'=>"Checking keys...",
+
+		'STATE_MAIN_I4'=>"OK",
+		'STATE_MAIN_R3'=>"OK",
+
+
+		//ike v2
+		'STATE_PARENT_I2'=>"Negotiating...",
+
+		'STATE_PARENT_I3'=>"OK",
+		'STATE_PARENT_R2'=>"OK",
+
 	);
 
-
-	$VPN_PRIO=array(
-			'Main'=>0,
-		'STATE_MAIN_I1'=>1,
-			'STATE_MAIN_R1'=>2,
-		'STATE_MAIN_I2'=>3,
-		'STATE_MAIN_I3'=>4,
-			'STATE_MAIN_R2'=>5,
-		'STATE_MAIN_I4'=>6,
-			'STATE_MAIN_R3'=>7,
-		'Quick'=>8,
-		'STATE_QUICK_I1'=>9,
-			'STATE_QUICK_R1'=>10,
-		'STATE_QUICK_I2'=>11,
-			'STATE_QUICK_R2'=>12,
+	$VPN_STATES_2=array(
+		//ike v1
+		'STATE_QUICK_I1'=>"Negotiating tunnel...",
+		'STATE_QUICK_R1'=>"Negotiating tunnel...",
+
+		'STATE_QUICK_I2'=>"OK",
+		'STATE_QUICK_R2'=>"OK",
+
+
+		//ike v2
+		'STATE_V2_IPSEC_I'=>"OK",
+		'STATE_V2_IPSEC_R'=>"OK",
+
 	);
 
-	//tries to determine state from a logline.
-	//returns false on no state found
+	//
+	//
+	// $VPN_PRIO=array(
+	// 		'Main'=>0,
+	// 	'STATE_MAIN_I1'=>1,
+	// 		'STATE_MAIN_R1'=>2,
+	// 	'STATE_MAIN_I2'=>3,
+	// 	'STATE_MAIN_I3'=>4,
+	// 		'STATE_MAIN_R2'=>5,
+	// 	'STATE_MAIN_I4'=>6,
+	// 		'STATE_MAIN_R3'=>7,
+	// 	'Quick'=>8,
+	// 	'STATE_QUICK_I1'=>9,
+	// 		'STATE_QUICK_R1'=>10,
+	// 	'STATE_QUICK_I2'=>11,
+	// 		'STATE_QUICK_R2'=>12,
+	// );
+
+	//determines phase1 and phase2 state from logline
 	function vpn_LogToState($logline)
 	{
-		global $VPN_STATES;
-
-		if (preg_match("/to state (.*)$/",$logline,$matches))
-		{
-			if (isset($VPN_STATES[$matches[1]]))
-				return ($matches[1]);
-		}
-		elseif (preg_match("/initiating (.*) Mode/",$logline,$matches))
-		{
-			if (isset($VPN_STATES[$matches[1]]))
-				return ($matches[1]);
-		}
-		else
-		{
-			return false;
-		}
+		global $VPN_STATES_1;
+		global $VPN_STATES_2;
+
+		$ret=[];
+		if (preg_match("/(STATE_[0-9_A-Z]*)/",$logline,$matches))
+		{
+			$state=$matches[1];
+			if ($VPN_STATES_1[$state])
+				$ret['phase1']=$VPN_STATES_1[$state];
+			if ($VPN_STATES_2[$state])
+				$ret['phase2']=$VPN_STATES_2[$state];
+		}
+		return($ret);
 	}
 	//read logging output of a tunnel
@@ -393,9 +410,9 @@
 	{
 		global $VPN_LOG;
-		$lines=SafeExec("grep '\]: \"$name\"' '$VPN_LOG'|tail -1000");
+		$lines=SafeExec("grep 'pluto.*\"$name\"' '$VPN_LOG'|tail -1000");
 		foreach ($lines as $line)
 		{
-			preg_match("/\]: \".*?\".(.*)/",$line,$matches);
-			$ret[]=array(vpn_LogToState($matches[1]),$matches[1]);
+			// preg_match("/\]: \".*?\".(.*)/",$line,$matches);
+			$ret[]=array(vpn_LogToState($line),$line);
 		}
 		return $ret;
@@ -407,6 +424,7 @@
 	function vpn_GetStatus()
 	{
-		global $VPN_STATES;
-		global $VPN_PRIO;
+		global $VPN_STATES_1;
+		global $VPN_STATES_2;
+		// global $VPN_PRIO;
 
 		if (Cmd("ipsec whack --status",'',$output)<0)
@@ -419,28 +437,45 @@
 			foreach ($output as $line)
 			{
- 				if (preg_match('/^.*#([0-9])*:.*"(.*?)"[:0-9]* ([A-Z0-9_]+) /',$line,$matches))
-				{
-					$nr=$matches[1];
-					$name=$matches[2];
-					$state=$matches[3];
-					if (
-						$name &&
-						$state &&
-						$VPN_PRIO[$state]>=$VPN_PRIO[$ret[$name]['state']]
-					)
-					{
-						$ret[$name]['state']=$state;
-						$ret[$name]['info'][]=$line;
-					}
-				}
-				elseif (preg_match('/^.*"(.*?)": *(.*)$/',$line,$matches))
+				if (preg_match('/\"(.*)\"/',$line,$matches))
 				{
 					$name=$matches[1];
-					$info=$matches[2];
-					if ($name && $info)
-					{
-						$ret[$name]['info'][]=$info;
-					}
+					$ret[$name]['info'][]=$line;
+					$state=vpn_LogToState($line);
+					if ($state['phase1'])
+						$ret[$name]['phase1']=$state['phase1'];
+					if ($state['phase2'])
+						$ret[$name]['phase2']=$state['phase2'];
+
 				}
+
+				// //state + info
+ 			// 	if (preg_match('/^.*#([0-9])*:.*"(.*?)"[:0-9]* ([A-Z0-9_]+) /',$line,$matches))
+				// {
+				// 	$nr=$matches[1];
+				// 	$name=$matches[2];
+				// 	$state=$matches[3];
+				// 	if (
+				// 		$name &&
+				// 		$state
+				// 	)
+				// 	{
+				// 		if ($VPN_STATES_1[$state])
+				// 			$ret[$name]['phase1']=$VPN_STATES_1[$state];
+				// 		if ($VPN_STATES_2[$state])
+				// 			$ret[$name]['phase2']=$VPN_STATES_2[$state];
+				//
+				// 		$ret[$name]['info'][]=$line;
+				// 	}
+				// }
+				// //info only
+				// elseif (preg_match('/^.*"(.*?)": *(.*)$/',$line,$matches))
+				// {
+				// 	$name=$matches[1];
+				// 	$info=$matches[2];
+				// 	if ($name && $info)
+				// 	{
+				// 		$ret[$name]['info'][]=$info;
+				// 	}
+				// }
 			}
 
Index: npl/syn3/webint/src/vpn/tunnelstatus.php
===================================================================
--- npl/syn3/webint/src/vpn/tunnelstatus.php	(revision a35989d1d54109e3359ab21b867e44437ecdf090)
+++ npl/syn3/webint/src/vpn/tunnelstatus.php	(revision 0b780b4d613c0f00031df145ed9d2fb31008489b)
@@ -1,4 +1,4 @@
 <?
-/* 
+/*
 (C) 2004-2013 DatuX - info@datux.nl
 
@@ -17,10 +17,10 @@
 */
 
- 
+
 	$LEVEL=10;
 	include_once("../common.php");
 	require_once("openswan.php");
 	include_once("../form.php");
-		
+
 ?>
 
@@ -32,9 +32,9 @@
 
 <? Head(); ?>
- 
+
 <h1><?=$TITLE?></h1>
 
 <?
-/* 
+/*
 (C) 2004-2013 DatuX - info@datux.nl
 
@@ -60,5 +60,5 @@
 	<tr><th><?=_TechnicalInfoOpenswan() ?></tr>
 	<?
-	echo "<tr><td><b>State: ".$status[$name]['state']."</b> (".$VPN_STATES[$status[$name][state]].")";
+    echo "<tr><td><b>Phase 1: ".$status[$name]['phase1']."<br>"."Phase 2: ".$status[$name]['phase2']."</b></tr>";
 
 	foreach ($status[$name]['info'] as $info)
@@ -75,28 +75,23 @@
 		<th><?=_LogMessage()?></th>
 	</tr>
-			
+
 	<?
-	
+
 		foreach ($log as $logdata)
 		{
 			echo "<tr>";
 			echo "<td>";
-			if ($VPN_STATES[$logdata[0]])
-			{
-				/*if ($logdata[0] == "STATE_QUICK_I2" || $logdata[0] == "STATE_QUICK_R2")
-					echo "<img src='../img/enabled.gif'>";
-				else
-					echo "<img src='../img/disabled.gif'>";*/
-				echo $VPN_STATES[$logdata[0]];
-			}
+			if ($logdata[0]['phase1'])
+				echo "Phase 1: ".$logdata[0]['phase1'];
+
+			elseif ($logdata[0]['phase2'])
+				echo "Phase 2: ".$logdata[0]['phase2'];
 			else
-			{
 				echo "&nbsp;";
-			}
-			
+
 			echo "<td>$logdata[1]";
 			echo "</tr>";
 		}
-		
+
 		if (!$log)
 			echo "<tr colspan=5><td>"._NoLogMessagesForThisTunnel()."</tr>";
