root/modules/branches/2.4/dashboard/class.error.inc.php

Revision 4512, 4.2 kB (checked in by p_lindheimer, 5 years ago)

#2133 again, #2140 divide by 0, #2141 with temp log to determine real issue

Line 
1 <?php 
2 // phpSysInfo - A PHP System Information Script
3 // http://phpsysinfo.sourceforge.net/
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 // You should have received a copy of the GNU General Public License
13 // along with this program; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15 // $Id: class.error.inc.php,v 1.4 2006/02/27 21:01:44 bigmichi1 Exp $
16
17 class Error {
18
19   // Array which holds the error messages
20   var $arrErrorList   = array();
21   // current number of errors encountered
22   var $errors     = 0;
23
24   /**
25   *
26   *  addError()
27   * 
28   *  @param strCommand  string    Command, which cause the Error
29   *  @param strMessage  string    additional Message, to describe the Error
30   *  @param intLine   integer   on which line the Error occours
31   *  @param strFile   string    in which File the Error occours
32   *
33   *  @return  -
34   *
35   **/
36   function addError( $strCommand, $strMessage, $intLine, $strFile ) {
37     $this->arrErrorList[$this->errors]['command'] = $strCommand;
38     $this->arrErrorList[$this->errors]['message'] = $strMessage;
39     $this->arrErrorList[$this->errors]['line']    = $intLine;
40     $this->arrErrorList[$this->errors]['file']    = basename( $strFile );
41     $this->errors++;
42   }
43
44   /**
45   *
46   * ErrorsAsHTML()
47   *
48   * @param  -
49   *
50   * @return string    string which contains a HTML table which can be used to echo out the errors
51   *
52   **/
53   function ErrorsAsHTML() {
54     $strHTMLString = "";
55     $strWARNString = "";
56     $strHTMLhead = "<table width=\"100%\" border=\"0\">\n"
57      . " <tr>\n"
58      . "  <td><font size=\"-1\"><b>File</b></font></td>\n"
59      . "  <td><font size=\"-1\"><b>Line</b></font></td>\n"
60      . "  <td><font size=\"-1\"><b>Command</b></font></td>\n"
61      . "  <td><font size=\"-1\"><b>Message</b></font></td>\n"
62      . " </tr>\n";
63     $strHTMLfoot = "</table>";
64
65     if( $this->errors > 0 ) {
66       foreach( $this->arrErrorList as $arrLine ) {
67         if( $arrLine['command'] == "WARN" ) {
68           $strWARNString .= "<font size=\"-1\"><b>WARNING: " . htmlspecialchars( $arrLine['message'] ) . "</b></font><br/>\n";
69         } else {
70           $strHTMLString .= " <tr>\n"
71                           . "  <td><font size=\"-1\">" . htmlspecialchars( $arrLine['file'] ) . "</font></td>\n"
72                           . "  <td><font size=\"-1\">" . $arrLine['line'] . "</font></td>\n"
73                           . "  <td><font size=\"-1\">" . htmlspecialchars( $arrLine['command'] ) . "</font></td>\n"
74                           . "  <td><font size=\"-1\">" . htmlspecialchars( $arrLine['message'] ) . "</font></td>\n"
75                           . " </tr>\n";
76         }
77       }
78     }
79    
80     if( !empty( $strHTMLString ) ) {
81       $strHTMLString = $strWARNString . $strHTMLhead . $strHTMLString . $strHTMLfoot;
82     } else {
83       $strHTMLString = $strWARNString;
84     }
85
86     return $strHTMLString;
87   }
88
89   /**
90   *
91   * ErrorsAsText()
92   *
93   * @param  -
94   *
95   * @return string    string which contains a table which can be used to echo out the errors
96   *
97   **/
98   function ErrorsAsText() {
99     $strHTMLString = "";
100     $strWARNString = "";
101     $strHTMLhead = sprintf("%24s %6s %40s %s\n","File", "Line", "Command", "Message");
102     $strHTMLfoot = "\n";
103
104     if( $this->errors > 0 ) {
105       foreach( $this->arrErrorList as $arrLine ) {
106         if( $arrLine['command'] == "WARN" ) {
107           $strWARNString .= "WARNING: " . $arrLine['message'] . "\n";
108         } else {
109           $strHTMLString .= sprintf("%24s %6s %40s %s\n",$arrLine['file'], $arrLine['line'], $arrLine['command'], $arrLine['message'] );
110         }
111       }
112     }
113    
114     if( !empty( $strHTMLString ) ) {
115       $strHTMLString = $strWARNString . $strHTMLhead . $strHTMLString . $strHTMLfoot;
116     } else {
117       $strHTMLString = $strWARNString;
118     }
119    
120     return $strHTMLString;
121   }
122
123   /**
124   *
125   * ErrorsExist()
126   *
127   * @param  -
128   *
129   * @return   true  there are errors logged
130   *   false no errors logged
131   *
132   **/
133   function ErrorsExist() {
134     if( $this->errors > 0 ) {
135       return true;
136     } else {
137       return false;
138     }
139   }
140 }
141 ?>
Note: See TracBrowser for help on using the browser.