Changeset 7631 for trunk/src/inc
- Timestamp:
- Mar 30, 2010, 8:51:44 PM (15 years ago)
- Location:
- trunk/src/inc
- Files:
-
- 1 deleted
- 4 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/inc/ErrorHandler.php
r7628 r7631 26 26 */ 27 27 28 class ErrorHandler { 29 /* 30 * Function: ErrorHandler 31 * Parameters: int $errno, string $errstr, string $errfile, int $errline, array $errcontext 32 * Function: Handling with errors, decides what to do with it 33 */ 34 public function ErrorHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext) { 35 switch ($errno) { 36 case E_ERROR: 37 echo 'E_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 38 // TODO 39 break; 40 case E_WARNING: 41 echo 'E_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 42 // TODO 43 break; 44 case E_PARSE: 45 echo 'E_PARSE: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 46 // TODO 47 break; 48 case E_NOTICE: 49 echo 'E_NOTICE: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 50 // TODO 51 break; 52 case E_CORE_ERROR: 53 echo 'E_CORE_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 54 // TODO 55 break; 56 case E_CORE_WARNING: 57 echo 'E_CORE_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 58 // TODO 59 break; 60 case E_COMPILE_ERROR: 61 echo 'E_COMPILE_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 62 // TODO 63 break; 64 case E_COMPILE_WARNING: 65 echo 'E_COMPILE_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 66 // TODO 67 break; 68 case E_USER_ERROR: 69 echo 'E_USER_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 70 // TODO 71 break; 72 case E_USER_WARNING: 73 echo 'E_USER_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 74 // TODO 75 break; 76 case E_USER_NOTICE: 77 echo 'E_USER_NOTICE: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 78 // TODO 79 break; 80 case E_STRICT: 81 echo 'E_STRICT: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 82 // TODO 83 break; 84 case E_RECOVERABLE_ERROR: 85 echo 'E_RECOVERABLE_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 86 // TODO 87 break; 88 case E_DEPRECATED: 89 echo 'E_DEPRECATED: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 90 // TODO 91 break; 92 case E_USER_DEPRECATED: 93 echo 'E_USER_DEPRECATED: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 94 // TODO 95 break; 96 default: 97 echo 'E_DEFAULT: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 98 // TODO 99 break; 100 } 28 /* 29 * Function: ErrorHandler 30 * Parameters: int $errno, string $errstr, string $errfile, int $errline, array $errcontext 31 * Function: Handling with errors, decides what to do with it 32 */ 33 function ErrorHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext) { 34 switch ($errno) { 35 case E_ERROR: 36 echo 'E_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 37 // TODO 38 break; 39 case E_WARNING: 40 echo 'E_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 41 // TODO 42 break; 43 case E_PARSE: 44 echo 'E_PARSE: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 45 // TODO 46 break; 47 case E_NOTICE: 48 echo 'E_NOTICE: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 49 // TODO 50 break; 51 case E_CORE_ERROR: 52 echo 'E_CORE_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 53 // TODO 54 break; 55 case E_CORE_WARNING: 56 echo 'E_CORE_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 57 // TODO 58 break; 59 case E_COMPILE_ERROR: 60 echo 'E_COMPILE_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 61 // TODO 62 break; 63 case E_COMPILE_WARNING: 64 echo 'E_COMPILE_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 65 // TODO 66 break; 67 case E_USER_ERROR: 68 echo 'E_USER_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 69 // TODO 70 break; 71 case E_USER_WARNING: 72 echo 'E_USER_WARNING: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 73 // TODO 74 break; 75 case E_USER_NOTICE: 76 echo 'E_USER_NOTICE: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 77 // TODO 78 break; 79 case E_STRICT: 80 echo 'E_STRICT: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 81 // TODO 82 break; 83 case E_RECOVERABLE_ERROR: 84 echo 'E_RECOVERABLE_ERROR: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 85 // TODO 86 break; 87 case E_DEPRECATED: 88 echo 'E_DEPRECATED: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 89 // TODO 90 break; 91 case E_USER_DEPRECATED: 92 echo 'E_USER_DEPRECATED: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 93 // TODO 94 break; 95 default: 96 echo 'E_DEFAULT: ' , $errno , ': ' , $errstr , '<br/>Bestand: ' , $errfile , '<br/>Regel: ' , $errline , '<br/>'; 97 // TODO 98 break; 99 } 101 100 102 /* Don't execute PHP internal error handler */ 103 return true; 104 } 101 /* Don't execute PHP internal error handler */ 102 return true; 105 103 } 106 104 107 set_exception_handler('ErrorHandler ::ErrorHandler');105 set_exception_handler('ErrorHandler'); -
trunk/src/inc/FileHandler.class.php
r7622 r7631 14 14 * Function: Handling with a node file 15 15 */ 16 public function __construct( string$filename) {16 public function __construct($filename) { 17 17 try { 18 $this->file = fopen($filename); 18 $handle = fopen($filename, 'r'); 19 $this->file = ''; 20 while (!feof($handle)) { 21 $this->file .= fread($handle, 8192); 22 } 23 fclose($handle); 19 24 } catch (Exception $err) { 20 25 // TODO: Better error description 21 26 trigger_error(); 22 27 } 28 } 23 29 24 // TODO: Needs to do something 30 public function getFile() { 31 return $this->file; 25 32 } 26 33 } -
trunk/src/inc/KMLFile.class.php
r7628 r7631 7 7 8 8 class KMLFile { 9 final$template = '9 private $template = ' 10 10 <?xml version="1.0" encoding="UTF-8"?> 11 11 <kml xmlns="http://www.opengis.net/kml/2.2"> 12 12 %CONTENT% 13 13 </kml>'; 14 private $fileFirst = 'type,host_name,has_been_checked,check_execution_time,current_state,last_hard_state,last_check,problem_has_been_acknowledged'; 15 private $fileContent = array('string', 'string', 'integer', 'double', 'integer', 'integer', 'integer', 'integer'); 14 16 15 17 private $KMLPlacemarks = array(); … … 20 22 * Function: Creating a new KMLFile 21 23 */ 22 function __construct() {24 public function __construct() { 23 25 } 24 26 25 function addPlacemark(KMLPlacemark $placemark) {27 public function addPlacemark(KMLPlacemark $placemark) { 26 28 $this->KMLPlacemarks[] = $placemark; 27 29 } 28 30 29 function addPlacemark(string $name, string $description, float $xcoordinate, float $ycoordinate) { 30 $placemark = new KMLPlacemark(); 31 $placemark->setName($name); 32 $placemark->setDescription($description); 33 $placemark->setXCoordinate($xcoordinate); 34 $placemark->setYCoordinate($ycoordinate); 35 36 $this->KMLPlacemarks[] = $placemark; 37 } 38 39 function toString() { 40 $toString = $template; 31 public function toString() { 32 $toString = $this->template; 41 33 42 34 $placemarkString = ''; 43 35 $placemarkCount = count($this->KMLPlacemarks); 44 36 for ($i = 0; $i < $placemarkCount; $i++) { 45 $placemarkString .= $this->KMLPlacemarks ->toString();37 $placemarkString .= $this->KMLPlacemarks[$i]->toString(); 46 38 } 47 39 48 $toString = preg_replace('%CONTENT%', $placemarkString, $toString);40 $toString = str_replace('%CONTENT%', $placemarkString, $toString); 49 41 50 42 return $toString; 51 43 } 52 44 53 function write(string$filename) {45 public function write($filename) { 54 46 // TODO: Write KMLFile to a KML file 47 } 48 49 public function parseFile($file) { 50 $fileContents = explode("\r\n", $nodeStatus->getFile()); 51 52 if ($fileContents[0] != $this->fileFirst) { 53 // TODO: Better error description 54 trigger_error(); 55 } 56 57 $lines = count($fileContents); 58 for ($i = 1; $i < count($lines); $i++) { 59 $lineContent = explode(',', $fileContents[$i]); 60 61 if (count($lineContent) != count($this->fileContent)) { 62 // TODO: Better error description 63 trigger_error(); 64 } 65 66 // TODO: Process all lines and create KMLPlacemark objects we can add to a new KMLFile object 67 } 55 68 } 56 69 } -
trunk/src/inc/KMLPlacemark.class.php
r7628 r7631 7 7 8 8 class KMLPlacemark { 9 final$template = '9 private $template = ' 10 10 <placemark> 11 11 <name>%NAME%</name> … … 29 29 } 30 30 31 function setName( string$newName) {31 function setName($newName) { 32 32 $this->name = $newName; 33 33 } 34 34 35 function setDescription( string$newDescription) {36 $this->description = $newDescription;35 function setDescription($newDescription) { 36 $this->description = (string) $newDescription; 37 37 } 38 38 39 function setXCoordinate( float$newXCoordinate) {40 $this->xCoordinate = $newXCoordinate;39 function setXCoordinate($newXCoordinate) { 40 $this->xCoordinate = (double) $newXCoordinate; 41 41 } 42 42 43 function setYCoordinate( float$newYCoordinate) {44 $this->yCoordinate = $newYCoordinate;43 function setYCoordinate($newYCoordinate) { 44 $this->yCoordinate = (double) $newYCoordinate; 45 45 } 46 46 47 47 function toString() { 48 $toString = $t emplate;48 $toString = $this->template; 49 49 50 $toString = preg_replace('%NAME%', $this->name, $toString);51 $toString = preg_replace('%DESCRIPTION%', $this->description, $toString);52 $toString = preg_replace('%XCOORDINATE%', $this->xCoordinate, $toString);53 $toString = preg_replace('%YCOORDINATE%', $this->yCoordinate, $toString);50 $toString = str_replace('%NAME%', $this->name, $toString); 51 $toString = str_replace('%DESCRIPTION%', $this->description, $toString); 52 $toString = str_replace('%XCOORDINATE%', $this->xCoordinate, $toString); 53 $toString = str_replace('%YCOORDINATE%', $this->yCoordinate, $toString); 54 54 55 55 return $toString; -
trunk/src/inc/LogHandler.class.php
r7627 r7631 17 17 * LOG_DEBUG Debug-level message 18 18 */ 19 20 define('LOG_EMERG', 0);21 define('LOG_ALERT', 1);22 define('LOG_CRIT', 2);23 define('LOG_ERR', 3);24 define('LOG_WARNING', 4);25 define('LOG_NOTICE', 5);26 define('LOG_INFO', 6);27 define('LOG_DEBUG', 7);28 19 29 20 class LogHandler {
Note:
See TracChangeset
for help on using the changeset viewer.