Changeset 7765 for trunk/src/inc
- Timestamp:
- Apr 15, 2010, 12:00:44 PM (15 years ago)
- Location:
- trunk/src/inc
- Files:
-
- 1 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/inc/KMLFile.class.php
r7758 r7765 16 16 <IconStyle> 17 17 <Icon> 18 <href>% PLACEMARK_GREEN%</href>18 <href>%NODE_GREEN%</href> 19 19 </Icon> 20 20 </IconStyle> … … 23 23 <IconStyle> 24 24 <Icon> 25 <href>% PLACEMARK_ORANGE%</href>25 <href>%NODE_ORANGE%</href> 26 26 </Icon> 27 27 </IconStyle> … … 30 30 <IconStyle> 31 31 <Icon> 32 <href>% PLACEMARK_RED%</href>32 <href>%NODE_RED%</href> 33 33 </Icon> 34 34 </IconStyle> 35 35 </Style> 36 <Folder> 36 <Style id="blackLine"> 37 <LineStyle> 38 <color>%LINE_BLACK%</color> 39 <width>3</width> 40 </LineStyle> 41 </Style> 42 <Folder id="nodes"> 37 43 <name>Nodes</name> 38 44 <description>Nodes from the Wireless Leiden network</description> … … 40 46 <longitude>4.490153</longitude> 41 47 <latitude>52.161087</latitude> 42 <altitude> 0</altitude>48 <altitude>5</altitude> 43 49 <heading>0</heading> 44 50 <tilt>0</tilt> 45 51 <range>500</range> 46 52 </LookAt> 47 % CONTENT%53 %NODESCONTENT% 48 54 </Folder> 49 </Document> 55 <Folder id="lines"> 56 <name>Lines</name> 57 <description>Lines from nodes to nodes from the Wireless Leiden network</description> 58 <LookAt> 59 <longitude>4.490153</longitude> 60 <latitude>52.161087</latitude> 61 <altitude>5</altitude> 62 <heading>0</heading> 63 <tilt>0</tilt> 64 <range>500</range> 65 </LookAt> 66 %LINESCONTENT% 67 </Folder> 68 </Document> 50 69 </kml>'; 51 70 … … 55 74 private $fileContent = array('string', 'string', 'int', 'double', 'int', 'int', 'int', 'int'); 56 75 57 private $KMLPlacemarks; 58 76 private $KMLNodes; 77 private $KMLLines; 78 59 79 /* 60 80 * Function: __construct (constructor) … … 64 84 */ 65 85 public function __construct() { 66 $this->KMLPlacemarks = array(); 67 } 68 69 /* 70 * Function: addPlacemark 71 * Description: Add a placemark to the local placemark array 72 * Parameters: KMLPlacemark $placemark 86 $this->KMLNodes = array(); 87 $this->KMLLines = array(); 88 } 89 90 /* 91 * Function: addNode 92 * Description: Add a node to the local node array 93 * Parameters: KMLNode $node 73 94 * Returns: - 74 95 */ 75 public function addPlacemark(KMLPlacemark $placemark) { 76 $this->KMLPlacemarks[] = $placemark; 96 public function addNode(KMLNode $node) { 97 $this->KMLNodes[] = $node; 98 } 99 100 /* 101 * Function: addLIne 102 * Description: Add a line to the local line array 103 * Parameters: KMLLine $line 104 * Returns: - 105 */ 106 public function addLine(KMLLine $line) { 107 $this->KMLLines[] = $line; 77 108 } 78 109 … … 88 119 $toString = $this->template; 89 120 90 $placemarkString = ''; 91 $placemarkCount = count($this->KMLPlacemarks); 92 for ($i = 0; $i < $placemarkCount; $i++) { 93 $placemarkString .= $this->KMLPlacemarks[$i]->toString(); 94 } 95 96 $toString = str_replace('%PLACEMARK_GREEN%', $config['placemark_green'], $toString); 97 $toString = str_replace('%PLACEMARK_ORANGE%', $config['placemark_orange'], $toString); 98 $toString = str_replace('%PLACEMARK_RED%', $config['placemark_red'], $toString); 99 $toString = str_replace('%CONTENT%', $placemarkString, $toString); 100 121 $nodeString = ''; 122 $nodeCount = count($this->KMLNodes); 123 for ($i = 0; $i < $nodeCount; $i++) { 124 $nodeString .= $this->KMLNodes[$i]->toString(); 125 } 126 127 $lineString = ''; 128 $lineCount = count($this->KMLLines); 129 for ($i = 0; $i < $lineCount; $i++) { 130 $lineString .= $this->KMLLines[$i]->toString(); 131 } 132 133 $toString = str_replace('%NODE_GREEN%', $config['node_green'], $toString); 134 $toString = str_replace('%NODE_ORANGE%', $config['node_orange'], $toString); 135 $toString = str_replace('%NODE_RED%', $config['node_red'], $toString); 136 $toString = str_replace('%LINE_BLACK%', $config['line_black'], $toString); 137 $toString = str_replace('%NODESCONTENT%', $nodeString, $toString); 138 $toString = str_replace('%LINESCONTENT%', $lineString, $toString); 139 101 140 return $toString; 102 141 } … … 123 162 124 163 /* 125 * Function: get PlacemarkByName126 * Description: Find the first KML Placemarkwith the name $name and return its position. If not found, return false164 * Function: getNodeByName 165 * Description: Find the first KMLNode with the name $name and return its position. If not found, return false 127 166 * Parameters: string $name 128 * Returns: Position of placemarkin our array, if not found false129 */ 130 public function get PlacemarkByName($name) {131 $nodesCount = count($this->KML Placemarks);167 * Returns: Position of node in our array, if not found false 168 */ 169 public function getNodeByName($name) { 170 $nodesCount = count($this->KMLNodes); 132 171 for ($i = 0; $i < $nodesCount; $i++) { 133 if ($this->KML Placemarks[$i]->getName() == $name) {172 if ($this->KMLNodes[$i]->getName() == $name) { 134 173 return $i; 135 174 } … … 141 180 /* 142 181 * Function: parseLocationFile 143 * Description: Parse the node location file updating or adding KML Placemarkobjects to the current KMLFile object182 * Description: Parse the node location file updating or adding KMLNode objects to the current KMLFile object 144 183 * Parameters: string $file 145 184 * Returns: true is successfull, otherwise false … … 192 231 $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/>'; 193 232 194 if ($placemarkPosition = $this->get PlacemarkByName($name)) {233 if ($placemarkPosition = $this->getNodeByName($name)) { 195 234 // Updating an excisting placemark 196 $this->KML Placemarks[$placemarkPosition]->setDescriptionLocation($descriptionLocation);197 $this->KML Placemarks[$placemarkPosition]->setLongitude($longitude);198 $this->KML Placemarks[$placemarkPosition]->setLatitude($latitude);235 $this->KMLNodes[$placemarkPosition]->setDescriptionLocation($descriptionLocation); 236 $this->KMLNodes[$placemarkPosition]->setLongitude($longitude); 237 $this->KMLNodes[$placemarkPosition]->setLatitude($latitude); 199 238 } else { 200 239 // Adding a new placemark 201 $placemark = new KML Placemark();240 $placemark = new KMLNode(); 202 241 $placemark->setID($name); 203 242 $placemark->setName($name); … … 205 244 $placemark->setLongitude($longitude); 206 245 $placemark->setLatitude($latitude); 207 $this->add Placemark($placemark);246 $this->addNode($placemark); 208 247 } 209 248 } … … 229 268 /* 230 269 * Function: parseStatusFile 231 * Description: Parse the node status file updating or adding KML Placemarkobjects to the current KMLFile object270 * Description: Parse the node status file updating or adding KMLNode objects to the current KMLFile object 232 271 * Parameters: string $file 233 272 * Returns: true is successfull, otherwise false … … 275 314 $descriptionStatus = 'Type: ' . $lineContent[0] . '<br/>Host name: ' . $lineContent[1] . '<br/>Has been checked: ' . $lineContent[2] . '<br/>Check execution time: ' . $lineContent[3] . '<br/>Currenr state: ' . $lineContent[4] . '<br/>Last hard state: ' . $lineContent[5] . '<br/>Last check: ' . $lineContent[6] . '<br/>Problem has been acknowledged: ' . $lineContent[7] . '<br/><br/>'; 276 315 277 if ($placemarkPosition = $this->get PlacemarkByName($lineContent[1])) {316 if ($placemarkPosition = $this->getNodeByName($lineContent[1])) { 278 317 // Updating an excisting placemark 279 $this->KML Placemarks[$placemarkPosition]->setDescriptionStatus($descriptionStatus);318 $this->KMLNodes[$placemarkPosition]->setDescriptionStatus($descriptionStatus); 280 319 } else { 281 320 // Adding a new placemark 282 $placemark = new KML Placemark();321 $placemark = new KMLNode(); 283 322 $placemark->setID($lineContent[1]); 284 323 $placemark->setName($lineContent[1]); 285 324 $placemark->setDescriptionStatus($descriptionStatus); 286 $this->add Placemark($placemark);325 $this->addNode($placemark); 287 326 } 288 327 } -
trunk/src/inc/KMLNode.class.php
r7764 r7765 2 2 /* 3 3 * Project: NodeMap2.0 4 * File: KML Placemark.class.php5 * Purpose: Placemark used in KMLFile4 * File: KMLNode.class.php 5 * Purpose: Node placemark used in KMLFile 6 6 */ 7 7 8 define(' PLACEMARK_GREEN', 'greenArrowIcon');9 define(' PLACEMARK_ORANGE', 'orangeArrowIcon');10 define(' PLACEMARK_RED', 'redArrowIcon');8 define('NODE_GREEN', 'greenArrowIcon'); 9 define('NODE_ORANGE', 'orangeArrowIcon'); 10 define('NODE_RED', 'redArrowIcon'); 11 11 12 class KML Placemark{12 class KMLNode { 13 13 private $template = ' 14 14 <Placemark id="%ID%"> … … 41 41 private $longitude; // Longitude of the node 42 42 private $latitude; // Latitude of the node 43 private $style; // Style of the placemark43 private $style; // Style of the node 44 44 45 45 /* 46 46 * Function: __construct (constructor) 47 * Description: Creating a new KML File47 * Description: Creating a new KMLNode 48 48 * Parameters: - 49 49 * Returns: - … … 61 61 /* 62 62 * Function: setID 63 * Description: Setting the ID of the placemark63 * Description: Setting the ID of the node 64 64 * Parameters: string $newID 65 65 * Returns: - … … 71 71 /* 72 72 * Function: setName 73 * Description: Setting the name of the placemark73 * Description: Setting the name of the node 74 74 * Parameters: string $newName 75 75 * Returns: - … … 81 81 /* 82 82 * Function: getName 83 * Description: Getting the name of the placemark83 * Description: Getting the name of the node 84 84 * Parameters: - 85 * Returns: The name of the placemark85 * Returns: The name of the node 86 86 */ 87 87 function getName() { … … 91 91 /* 92 92 * Function: setDescriptionLocation 93 * Description: Setting the location description of the placemark93 * Description: Setting the location description of the node 94 94 * Parameters: string $newDescriptionLocation 95 95 * Returns: - … … 101 101 /* 102 102 * Function: setDescriptionStatus 103 * Description: Setting the status description of the placemark103 * Description: Setting the status description of the node 104 104 * Parameters: string $newDescriptionStatus 105 105 * Returns: - … … 111 111 /* 112 112 * Function: setLongitude 113 * Description: Setting the longitude of the placemark113 * Description: Setting the longitude of the node 114 114 * Parameters: string $newLongitude 115 115 * Returns: - … … 121 121 /* 122 122 * Function: setLatitude 123 * Description: Setting the latitude of the placemark123 * Description: Setting the latitude of the node 124 124 * Parameters: string $newLatitude 125 125 * Returns: - … … 131 131 /* 132 132 * Function: setStyle 133 * Description: Setting the style of the placemark133 * Description: Setting the style of the node 134 134 * Parameters: string $newStyle 135 135 * Returns: - … … 141 141 /* 142 142 * Function: toString 143 * Description: Converts the content of this placemarkto a KML valid string143 * Description: Converts the content of this node to a KML valid string 144 144 * Parameters: - 145 145 * Returns: KML valid string -
trunk/src/inc/LogHandler.class.php
r7753 r7765 88 88 echo '<!-- ' . $errorString . ' -->'; 89 89 } 90 if ( $logno <= LOG_LEVEL_WRITE) {90 if ((!defined('IGNORE_LOG_LEVEL_WRITE')) && ($logno <= LOG_LEVEL_WRITE)) { 91 91 $filename = 'logfile.txt'; 92 92 if (is_writable($filename)) { 93 93 94 94 //Check if the file can be opened 95 96 define('LOG_LEVEL_WRITE', LOG_LEVEL_NONE);97 98 95 if (!$handle = fopen($filename, 'w')) { 96 define('IGNORE_LOG_LEVEL_WRITE', true); 97 trigger_log(SYSLOG_EMERG, 'Cannot open file "' . $filename . '"', __FILE__, __LINE__); 98 exit; 99 99 } 100 100 101 101 // Write $errorString to file. 102 102 if (fwrite($handle, $errorString) === FALSE) { … … 105 105 exit; 106 106 } 107 107 108 108 fclose($handle); 109 109 110 110 } else { 111 define(' LOG_LEVEL_WRITE', LOG_LEVEL_NONE);112 111 define('IGNORE_LOG_LEVEL_WRITE', true); 112 trigger_log(SYSLOG_EMERG, 'Cannot write to "' . $filename . '"', __FILE__, __LINE__); 113 113 } 114 114 } 115 115 116 116 if ($logno <= LOG_LEVEL_MAIL) { 117 117 mail('test@test.com', 'Nodemap error', $errorString);
Note:
See TracChangeset
for help on using the changeset viewer.