PclErrorString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
// --------------------------------------------------------------------------------
3
// PhpConcept Library (PCL) Error 1.0
4
// --------------------------------------------------------------------------------
5
// License GNU/GPL - Vincent Blavet - Mars 2001
6
// http://www.phpconcept.net & http://phpconcept.free.fr
7
// --------------------------------------------------------------------------------
8
// Français :
9
//   La description de l'usage de la librairie PCL Error 1.0 n'est pas encore
10
//   disponible. Celle-ci n'est pour le moment distribuée qu'avec les
11
//   développements applicatifs de PhpConcept.
12
//   Une version indépendante sera bientot disponible sur http://www.phpconcept.net
13
//
14
// English :
15
//   The PCL Error 1.0 library description is not available yet. This library is
16
//   released only with PhpConcept application and libraries.
17
//   An independant release will be soon available on http://www.phpconcept.net
18
//
19
// --------------------------------------------------------------------------------
20
//
21
//   * Avertissement :
22
//
23
//   Cette librairie a été créée de façon non professionnelle.
24
//   Son usage est au risque et péril de celui qui l'utilise, en aucun cas l'auteur
25
//   de ce code ne pourra être tenu pour responsable des éventuels dégats qu'il pourrait
26
//   engendrer.
27
//   Il est entendu cependant que l'auteur a réalisé ce code par plaisir et n'y a
28
//   caché aucun virus, ni malveillance.
29
//   Cette libairie est distribuée sous la license GNU/GPL (https://www.gnu.org)
30
//
31
//   * Auteur :
32
//
33
//   Ce code a été écrit par Vincent Blavet ([email protected]) sur son temps
34
//   de loisir.
35
//
36
// --------------------------------------------------------------------------------
37
38
// ----- Look for double include
39
if (!defined('PCLERROR_LIB')) {
40
    define('PCLERROR_LIB', 1);
41
42
    // ----- Version
43
    $g_pcl_error_version = '1.0';
44
45
    // ----- Internal variables
46
    // These values must only be change by PclError library functions
47
    $g_pcl_error_string = '';
48
    $g_pcl_error_code   = 1;
49
50
    // --------------------------------------------------------------------------------
51
    // Function : PclErrorLog()
52
    // Description :
53
    // Parameters :
54
    // --------------------------------------------------------------------------------
55
    /**
56
     * @param int    $p_error_code
57
     * @param string $p_error_string
58
     */
59
    function PclErrorLog($p_error_code = 0, $p_error_string = '')
60
    {
61
        global $g_pcl_error_string;
62
        global $g_pcl_error_code;
63
64
        $g_pcl_error_code   = $p_error_code;
65
        $g_pcl_error_string = $p_error_string;
66
    }
67
68
    // --------------------------------------------------------------------------------
69
70
    // --------------------------------------------------------------------------------
71
    // Function : PclErrorFatal()
72
    // Description :
73
    // Parameters :
74
    // --------------------------------------------------------------------------------
75
    /**
76
     * @param        $p_file
77
     * @param        $p_line
78
     * @param string $p_error_string
79
     */
80
    function PclErrorFatal($p_file, $p_line, $p_error_string = '')
81
    {
82
        global $g_pcl_error_string;
83
        global $g_pcl_error_code;
84
85
        $v_message = '<html><body>';
86
        $v_message .= "<p align=center><span style='font-weight: bold; color: #ff0000; background-color: #ffffff; '>PclError Library has detected a fatal error on file '$p_file', line $p_line</span></p>";
87
        $v_message .= "<p align=center><span style='font-weight: bold; color: #ff0000; background-color: #ffffff;'>$p_error_string</span></p>";
88
        $v_message .= '</body></html>';
89
        exit($v_message);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
90
    }
91
92
    // --------------------------------------------------------------------------------
93
94
    // --------------------------------------------------------------------------------
95
    // Function : PclErrorReset()
96
    // Description :
97
    // Parameters :
98
    // --------------------------------------------------------------------------------
99
    function PclErrorReset()
100
    {
101
        global $g_pcl_error_string;
102
        global $g_pcl_error_code;
103
104
        $g_pcl_error_code   = 1;
105
        $g_pcl_error_string = '';
106
    }
107
108
    // --------------------------------------------------------------------------------
109
110
    // --------------------------------------------------------------------------------
111
    // Function : PclErrorCode()
112
    // Description :
113
    // Parameters :
114
    // --------------------------------------------------------------------------------
115
    /**
116
     * @return int
117
     */
118
    function PclErrorCode()
119
    {
120
        global $g_pcl_error_string;
121
        global $g_pcl_error_code;
122
123
        return $g_pcl_error_code;
124
    }
125
126
    // --------------------------------------------------------------------------------
127
128
    // --------------------------------------------------------------------------------
129
    // Function : PclErrorString()
130
    // Description :
131
    // Parameters :
132
    // --------------------------------------------------------------------------------
133
    /**
134
     * @return string
135
     */
136
    function PclErrorString()
137
    {
138
        global $g_pcl_error_string;
139
        global $g_pcl_error_code;
140
141
        return $g_pcl_error_string . " [code $g_pcl_error_code]";
142
    }
143
144
    // --------------------------------------------------------------------------------
145
146
    // ----- End of double include look
147
}
148