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

Revision 7633, 4.3 kB (checked in by mickecarlsson, 4 years ago)

Re #3494 adds license info to various files

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 // Copyright 2006 phpSysInfo
18
19 class Error {
20
21     // Array which holds the error messages
22     var $arrErrorList     = array();
23     // current number of errors encountered
24     var $errors         = 0;
25
26     /**
27     *
28     *  addError()
29     * 
30     *  @param    strCommand    string        Command, which cause the Error
31     *  @param    strMessage    string        additional Message, to describe the Error
32     *  @param    intLine        integer        on which line the Error occours
33     *  @param    strFile        string        in which File the Error occours
34     *
35     *  @return    -
36     *
37     **/
38     function addError( $strCommand, $strMessage, $intLine, $strFile ) {
39         $this->arrErrorList[$this->errors]['command'] = $strCommand;
40         $this->arrErrorList[$this->errors]['message'] = $strMessage;
41         $this->arrErrorList[$this->errors]['line']    = $intLine;
42         $this->arrErrorList[$this->errors]['file']    = basename( $strFile );
43         $this->errors++;
44     }
45
46     /**
47     *
48     * ErrorsAsHTML()
49     *
50     * @param    -
51     *
52     * @return    string        string which contains a HTML table which can be used to echo out the errors
53     *
54     **/
55     function ErrorsAsHTML() {
56         $strHTMLString = "";
57         $strWARNString = "";
58         $strHTMLhead = "<table width=\"100%\" border=\"0\">\n"
59          . " <tr>\n"
60          . "  <td><font size=\"-1\"><b>File</b></font></td>\n"
61          . "  <td><font size=\"-1\"><b>Line</b></font></td>\n"
62          . "  <td><font size=\"-1\"><b>Command</b></font></td>\n"
63          . "  <td><font size=\"-1\"><b>Message</b></font></td>\n"
64          . " </tr>\n";
65         $strHTMLfoot = "</table>";
66
67         if( $this->errors > 0 ) {
68             foreach( $this->arrErrorList as $arrLine ) {
69                 if( $arrLine['command'] == "WARN" ) {
70                     $strWARNString .= "<font size=\"-1\"><b>WARNING: " . htmlspecialchars( $arrLine['message'] ) . "</b></font><br/>\n";
71                 } else {
72                     $strHTMLString .= " <tr>\n"
73                           . "  <td><font size=\"-1\">" . htmlspecialchars( $arrLine['file'] ) . "</font></td>\n"
74                                     . "  <td><font size=\"-1\">" . $arrLine['line'] . "</font></td>\n"
75                                     . "  <td><font size=\"-1\">" . htmlspecialchars( $arrLine['command'] ) . "</font></td>\n"
76                                     . "  <td><font size=\"-1\">" . htmlspecialchars( $arrLine['message'] ) . "</font></td>\n"
77                                     . " </tr>\n";
78                 }
79             }
80         }
81     
82         if( !empty( $strHTMLString ) ) {
83             $strHTMLString = $strWARNString . $strHTMLhead . $strHTMLString . $strHTMLfoot;
84         } else {
85             $strHTMLString = $strWARNString;
86         }
87
88         return $strHTMLString;
89     }
90
91     /**
92     *
93     * ErrorsAsText()
94     *
95     * @param    -
96     *
97     * @return    string        string which contains a table which can be used to echo out the errors
98     *
99     **/
100     function ErrorsAsText() {
101         $strHTMLString = "";
102         $strWARNString = "";
103         $strHTMLhead = sprintf("%24s %6s %40s %s\n","File", "Line", "Command", "Message");
104         $strHTMLfoot = "\n";
105
106         if( $this->errors > 0 ) {
107              foreach( $this->arrErrorList as $arrLine ) {
108                 if( $arrLine['command'] == "WARN" ) {
109                     $strWARNString .= "WARNING: " . $arrLine['message'] . "\n";
110                 } else {
111                     $strHTMLString .= sprintf("%24s %6s %40s %s\n",$arrLine['file'], $arrLine['line'], $arrLine['command'], $arrLine['message'] );
112                 }
113             }
114         }
115     
116     if( !empty( $strHTMLString ) ) {
117       $strHTMLString = $strWARNString . $strHTMLhead . $strHTMLString . $strHTMLfoot;
118     } else {
119       $strHTMLString = $strWARNString;
120     }
121     
122     return $strHTMLString;
123   }
124
125     /**
126     *
127     * ErrorsExist()
128     *
129     * @param    -
130     *
131     * @return     true    there are errors logged
132     *        false    no errors logged
133     *
134     **/
135     function ErrorsExist() {
136         if( $this->errors > 0 ) {
137             return true;
138         } else {
139             return false;
140         }
141     }
142 }
143 ?>
144
Note: See TracBrowser for help on using the browser.