topical media & game development
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

portal-classes-core.error.php



  <?PHP
  error_reporting(E_ALL);
  
  class Error {
  
          var core;
          var arrErrors = array();
          var numberErrors;
  
          function Error (&core) {
                  this->setErrorHandler();
                  this->core = &core;
                  this->numberErrors = 0;
          }
          
          function setErrorHandler () {
                  set_error_handler(array(this, 'errorHandler'), E_ALL);
          }
          
          function errorHandler (p_nType, p_sMessage, p_sFile, p_nLine) {
          
                  // Alle errors uit spider-markov.class.php eruit halen
                  if (preg_match("/spider-markov.class.php/", p_sFile)) {
                          return;
                  }
                  
                  // Alle errors van ftp_chdir() eruit halen
                  if (preg_match("/ftp_chdir\(\)/", p_sMessage)) {
                          return;
                  }
  
                  sMessage = addslashes(p_sMessage);
                  
                  // dit is nog voor ajax functies waarbij anders de error niet te zien is
                  //echo '<br><br>'.sMessage.'<br><br>';
                  
                  // numberErrors toch gebruiken omdat we de array met errors stoppen bij 100, en we toch wel willen weten
                  // hoeveel errors er nu echt zijn
                  this->numberErrors++;
                  
                  sql = "INSERT INTO bsu_errors (type, message, file, line, submit_date)
                                  VALUES ('".p_nType."', '".sMessage."', '".p_sFile."', '".p_nLine."', NOW() ) ";                                
                  //this->core->Db->doQuery(sql);
                  //errorId = this->core->Db->getLastInsertedId();
                  errorId = 0;
                  
                  if (this->getNumberErrors() < 100) {
                          this->arrErrors[] = array(        "type"                => p_nType,
                                                                                  "message"        => sMessage,
                                                                                  "file"                => p_sFile,
                                                                                  "line"                => p_nLine,
                                                                                  "error_id"        => errorId);
                  }
                  
                  res = fopen('errors.txt', 'a');
                  fwrite(res, 'message: '.sMessage.' - file: '.p_sFile.' - line: '.p_nLine."\n\r");
                  fclose(res);                
                  
          }
          
          function getNumberErrors () {
                  return this->numberErrors;
          }
          
          function getArrErrors () {
                  return this->arrErrors;
          }
          
          
          
          
          
          
          
          
          
  }
  ?>


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.