Index: /trunk/src/inc/KMLFile.class.php
===================================================================
--- /trunk/src/inc/KMLFile.class.php	(revision 7640)
+++ /trunk/src/inc/KMLFile.class.php	(revision 7642)
@@ -93,8 +93,28 @@
 	}
 
+	/*
+	 * Function: getPlacemarkByName
+	 * Parameters: string $name
+	 * Function: Find the first KMLPlacemark with the name $name and return its position. If not found, return false
+	 */
+	public function getPlacemarkByName($name) {
+		$nodesCount = count($this->KMLPlacemarks);
+		for ($i = 0; $i < $nodesCount; $i++) {
+			if ($this->KMLPlacemarks[$i]->getName() == $name) {
+				return $i;
+			}
+		}
+		return false;
+	}
+
+	/*
+	 * Function: parseLocationFile
+	 * Parameters: string $file
+	 * Function: Parse the node location file updating or adding KMLPlacemark objects to the current KMLFile object
+	 */
 	public function parseLocationFile($file) {
-		//preg_match_all('#\[(^\/.+?)\]#is', $file, $matches);
 		$nodesCount = preg_match_all('/\[[a-zA-Z0-9]*\]/i', $file, $nodes, PREG_OFFSET_CAPTURE);
 		for ($i = 0; $i < $nodesCount; $i++) {
+			// TODO: Needs checking for parsing errors
 			$location	= $this->findInLocationFile($file, 'location', $nodes[0][$i][1]);
 			$status		= $this->findInLocationFile($file, 'status', $nodes[0][$i][1]);
@@ -106,25 +126,43 @@
 			$name		= $this->findInLocationFile($file, 'name', $nodes[0][$i][1]);
 
-			$placemark = new KMLPlacemark();
-			$placemark->setName($name);
-			$placemark->setDescription('Naam: ' . $name . '<br/>Locatie: ' . $location . '<br/>Status: ' . $status . '<br/>Latitude: ' . $latitude . '<br/>Longitude: ' . $longitude . '<br/>Interfaces: ' . $interfaces . '<br/>Master IP: ' . $masterip . '<br/>Node type: ' . $nodetype);
-			$placemark->setLongitude($longitude);
-			$placemark->setLatitude($latitude);
-			$placemark->setStyle($status == 'up' ? 'greenArrowIcon' : 'redArrowIcon');
-			$this->addPlacemark($placemark);
-		}
-	}
-
+			$descriptionLocation = 'Naam: ' . $name . '<br/>Locatie: ' . $location . '<br/>Status: ' . $status . '<br/>Latitude: ' . $latitude . '<br/>Longitude: ' . $longitude . '<br/>Interfaces: ' . $interfaces . '<br/>Master IP: ' . $masterip . '<br/>Node type: ' . $nodetype . '<br/><br/>';
+
+			if ($placemarkPosition = $this->getPlacemarkByName($name)) {
+				$this->KMLPlacemarks[$placemarkPosition]->setDescriptionLocation($descriptionLocation);
+				$this->KMLPlacemarks[$placemarkPosition]->setLongitude($longitude);
+				$this->KMLPlacemarks[$placemarkPosition]->setLatitude($latitude);
+			} else {
+				$placemark = new KMLPlacemark();
+				$placemark->setName($name);
+				$placemark->setDescriptionLocation($descriptionLocation);
+				$placemark->setLongitude($longitude);
+				$placemark->setLatitude($latitude);
+				$this->addPlacemark($placemark);
+			}
+		}
+	}
+
+	/*
+	 * Function: findInLocationFile
+	 * Parameters: string $file, string $keyword, integer $offset
+	 * Function: Find the $keyword in $file and return the value of $keyword, starting at $offset, on error return false
+	 */
 	private function findInLocationFile($file, $keyword, $offset) {
-		$start	= strpos($file, $keyword, $offset) + strlen($keyword . ' = ');
+		$start = strpos($file, $keyword, $offset) + strlen($keyword . ' = ');
 		$end	= strpos($file, "\n", $start);
-		return substr($file, $start, $end - $start);
-	}
-
+
+		if ($start && $end && ($start < $end)) {
+			return substr($file, $start, $end - $start);
+		} else {
+			return false;
+		}
+	}
+
+	/*
+	 * Function: parseStatusFile
+	 * Parameters: string $file
+	 * Function: Parse the node status file updating or adding KMLPlacemark objects to the current KMLFile object
+	 */
 	public function parseStatusFile($file) {
-		/*
-		 * TODO: Needs to be rebuild so it doesn't create a new KMLFile object,
-		 * but add the KMLPlacemarks to the current object.
-		 */
 		$fileContents = explode("\r\n", $file);
 
@@ -133,6 +171,6 @@
 		}
 
-		$lines = count($fileContents);
-		for ($i = 1; $i < count($lines); $i++) {
+		$linesCount = count($fileContents);
+		for ($i = 1; $i < $linesCount - 1; $i++) {
 			$lineContent = explode(',', $fileContents[$i]);
 
@@ -141,5 +179,24 @@
 			}
 
-			// TODO: Process all lines and create KMLPlacemark objects we can add to a new KMLFile object
+			// TODO: Process all lines and update KMLPlacemark objects we already have in the current object
+			$type = $lineContent[0];
+			$host_name = str_replace('CNode', '', $lineContent[1]);
+			$has_been_checked = $lineContent[2];
+			$check_execution_time = $lineContent[3];
+			$current_state = $lineContent[4];
+			$last_hard_state = $lineContent[5];
+			$last_check = $lineContent[6];
+			$problem_has_been_acknowledged = $lineContent[7];
+
+			$descriptionStatus = 'Type: ' . $type . '<br/>Host name: ' . $host_name . '<br/>Has been checked: ' . $has_been_checked . '<br/>Check execution time: ' . $check_execution_time . '<br/>Currenr state: ' . $current_state . '<br/>Last hard state: ' . $last_hard_state . '<br/>Last check: ' . $last_check . '<br/>Problem has been acknowledged: ' . $problem_has_been_acknowledged . '<br/><br/>';
+
+			if ($placemarkPosition = $this->getPlacemarkByName($host_name)) {
+				$this->KMLPlacemarks[$placemarkPosition]->setDescriptionStatus($descriptionStatus);
+			} else {
+				$placemark = new KMLPlacemark();
+				$placemark->setName($host_name);
+				$placemark->setDescriptionStatus($descriptionStatus);
+				$this->addPlacemark($placemark);
+			}
 		}
 	}
Index: /trunk/src/inc/KMLPlacemark.class.php
===================================================================
--- /trunk/src/inc/KMLPlacemark.class.php	(revision 7640)
+++ /trunk/src/inc/KMLPlacemark.class.php	(revision 7642)
@@ -27,9 +27,10 @@
 		</Placemark>';
 
-	private $name;
-	private $description;
-	private $longitude;
-	private $latitude;
-	private $style;
+	private $name;					// Name of the node
+	private $descriptionLocation;	// Location information of the node
+	private $descriptionStatus;		// Status information of the node
+	private $longitude;				// Longitude of the node
+	private $latitude;				// Latitude of the node
+	private $style;					// Style of the placemark
 
 	/*
@@ -39,4 +40,10 @@
 	 */
 	function __construct() {
+		$this->name = '';
+		$this->descriptionLocation = '';
+		$this->descriptionStatus = '';
+		$this->longitude = 0;
+		$this->latitude = 0;
+		$this->style = 'orangeArrowIcon';
 	}
 
@@ -45,6 +52,14 @@
 	}
 
-	function setDescription($newDescription) {
-		$this->description = (string) $newDescription;
+	function getName() {
+		return $this->name;
+	}
+
+	function setDescriptionLocation($newDescriptionLocation) {
+		$this->descriptionLocation = (string) $newDescriptionLocation;
+	}
+
+	function setDescriptionStatus($newDescriptionStatus) {
+		$this->descriptionStatus = (string) $newDescriptionStatus;
 	}
 
@@ -65,5 +80,5 @@
 
 		$toString = str_replace('%NAME%', $this->name, $toString);
-		$toString = str_replace('%DESCRIPTION%', $this->description, $toString);
+		$toString = str_replace('%DESCRIPTION%', $this->descriptionLocation . $this->descriptionStatus, $toString);
 		$toString = str_replace('%LONGITUDE%', $this->longitude, $toString);
 		$toString = str_replace('%LATITUDE%', $this->latitude, $toString);
Index: /trunk/src/index.php
===================================================================
--- /trunk/src/index.php	(revision 7640)
+++ /trunk/src/index.php	(revision 7642)
@@ -12,5 +12,6 @@
 $kmlPlacemark1 = new KMLPlacemark();
 $kmlPlacemark1->setName('Test name');
-$kmlPlacemark1->setDescription('Test description');
+$kmlPlacemark1->setDescriptionLocation('Test location description');
+$kmlPlacemark1->setDescriptionStatus('Test status description');
 $kmlPlacemark1->setLatitude(52.138476);
 $kmlPlacemark1->setLongitude(4.463046);
@@ -20,5 +21,6 @@
 $kmlPlacemark2 = new KMLPlacemark();
 $kmlPlacemark2->setName('Placemark 2 name');
-$kmlPlacemark2->setDescription('This is the second placemark description');
+$kmlPlacemark2->setDescriptionLocation('This is the second placemark location description');
+$kmlPlacemark2->setDescriptionStatus('This is the second placemark status description');
 $kmlPlacemark2->setLatitude(52.638476);
 $kmlPlacemark2->setLongitude(4.063046);
@@ -31,4 +33,6 @@
 echo $kml->toString();
 
+echo "\r\n\r\n\r\n\r\n\r\n -------------------------------------------------- \r\n\r\n\r\n\r\n\r\n";
+
 // Now let's try reading from files and parsing the data in the files.
 // First off, we create a new KMLFile object
@@ -40,7 +44,10 @@
 echo $kmlFile->toString();
 
+echo "\r\n\r\n\r\n\r\n\r\n -------------------------------------------------- \r\n\r\n\r\n\r\n\r\n";
+
 // Let's try to read the node status file
 $nodeStatus = new FileHandler($config['node_status_file']);
 $kmlFile->parseStatusFile($nodeStatus->getFile());
+echo $kmlFile->toString();
 /*
  * TODO: Needs better parsing of the file now we have two seperate
