Changeset 7640 for trunk/src/inc
- Timestamp:
- Mar 31, 2010, 10:46:12 PM (15 years ago)
- Location:
- trunk/src/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/inc/FileHandler.class.php
r7637 r7640 30 30 trigger_log(SYSLOG_INFO, 'Reading from file "' . $filename . '" is done', __FILE__, __LINE__); 31 31 } catch (Exception $err) { 32 // TODO: Better error description33 32 trigger_log(SYSLOG_ERR, 'Reading from file "' . $filename . '" failed', __FILE__, __LINE__); 34 33 } -
trunk/src/inc/KMLFile.class.php
r7637 r7640 93 93 } 94 94 95 public function parseFile($file) { 95 public function parseLocationFile($file) { 96 //preg_match_all('#\[(^\/.+?)\]#is', $file, $matches); 97 $nodesCount = preg_match_all('/\[[a-zA-Z0-9]*\]/i', $file, $nodes, PREG_OFFSET_CAPTURE); 98 for ($i = 0; $i < $nodesCount; $i++) { 99 $location = $this->findInLocationFile($file, 'location', $nodes[0][$i][1]); 100 $status = $this->findInLocationFile($file, 'status', $nodes[0][$i][1]); 101 $latitude = $this->findInLocationFile($file, 'latitude', $nodes[0][$i][1]); 102 $longitude = $this->findInLocationFile($file, 'longitude', $nodes[0][$i][1]); 103 $interfaces = $this->findInLocationFile($file, 'interfaces', $nodes[0][$i][1]); 104 $masterip = $this->findInLocationFile($file, 'masterip', $nodes[0][$i][1]); 105 $nodetype = $this->findInLocationFile($file, 'nodetype', $nodes[0][$i][1]); 106 $name = $this->findInLocationFile($file, 'name', $nodes[0][$i][1]); 107 108 $placemark = new KMLPlacemark(); 109 $placemark->setName($name); 110 $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); 111 $placemark->setLongitude($longitude); 112 $placemark->setLatitude($latitude); 113 $placemark->setStyle($status == 'up' ? 'greenArrowIcon' : 'redArrowIcon'); 114 $this->addPlacemark($placemark); 115 } 116 } 117 118 private function findInLocationFile($file, $keyword, $offset) { 119 $start = strpos($file, $keyword, $offset) + strlen($keyword . ' = '); 120 $end = strpos($file, "\n", $start); 121 return substr($file, $start, $end - $start); 122 } 123 124 public function parseStatusFile($file) { 125 /* 126 * TODO: Needs to be rebuild so it doesn't create a new KMLFile object, 127 * but add the KMLPlacemarks to the current object. 128 */ 96 129 $fileContents = explode("\r\n", $file); 97 130
Note:
See TracChangeset
for help on using the changeset viewer.