Overview
Comment:Ne pas afficher de HTML pour les erreurs en CLI
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d5d70c514edf1b75547a176177f8589d53697ac2
User & Date: bohwaz on 2013-11-27 02:56:46
Other Links: manifest | tags
Context
2013-12-01
21:19
Mise à jour position des comptes 4* check-in: 2ab133b065 user: bohwaz tags: trunk
2013-11-27
02:56
Ne pas afficher de HTML pour les erreurs en CLI check-in: d5d70c514e user: bohwaz tags: trunk
2013-11-20
16:03
Répertoire, pas fichier check-in: ead8ce6b8d user: bohwaz tags: trunk
Changes

Modified src/include/init.php from [cb4312684b] to [a5cc19e4e9].

90
91
92
93
94
95
96



97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
    define('WWW_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $host . WWW_URI);
}

ini_set('error_log', GARRADIN_DATA_ROOT . '/error.log');
ini_set('log_errors', true);
ini_set('display_errors', true);
ini_set('html_errors', false);



ini_set('error_prepend_string', '<!DOCTYPE html><style type="text/css">body { font-family: sans-serif; } h3 { color: darkred; } 
    pre { text-shadow: 2px 2px 5px black; color: darkgreen; font-size: 2em; float: left; margin: 0 1em 0 0; padding: 1em; background: #cfc; border-radius: 50px; }</style>
    <pre> \__/<br /> (xx)<br />//||\\\\</pre>
    <h1>Erreur fatale</h1>
    <p>Une erreur fatale s\'est produite à l\'exécution de Garradin. Pour rapporter ce bug
    merci d\'inclure le message ci-dessous :</p>
    <h3>');
ini_set('error_append_string', '</h3><hr />
    <p><a href="http://dev.kd2.org/garradin/Rapporter%20un%20bug">Comment rapporter un bug</a></p>');


/*
 * Gestion des erreurs et exceptions
 */

class UserException extends \LogicException
{







>
>
>
|
|
|
|
|
|
|
|
|
>







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    define('WWW_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $host . WWW_URI);
}

ini_set('error_log', GARRADIN_DATA_ROOT . '/error.log');
ini_set('log_errors', true);
ini_set('display_errors', true);
ini_set('html_errors', false);

if (PHP_SAPI != 'cli')
{
    ini_set('error_prepend_string', '<!DOCTYPE html><style type="text/css">body { font-family: sans-serif; } h3 { color: darkred; } 
        pre { text-shadow: 2px 2px 5px black; color: darkgreen; font-size: 2em; float: left; margin: 0 1em 0 0; padding: 1em; background: #cfc; border-radius: 50px; }</style>
        <pre> \__/<br /> (xx)<br />//||\\\\</pre>
        <h1>Erreur fatale</h1>
        <p>Une erreur fatale s\'est produite à l\'exécution de Garradin. Pour rapporter ce bug
        merci d\'inclure le message ci-dessous :</p>
        <h3>');
    ini_set('error_append_string', '</h3><hr />
        <p><a href="http://dev.kd2.org/garradin/Rapporter%20un%20bug">Comment rapporter un bug</a></p>');
}

/*
 * Gestion des erreurs et exceptions
 */

class UserException extends \LogicException
{
153
154
155
156
157
158
159






160
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
    foreach ($_SERVER as $key=>$value)
    {
        $error .= $key . ': ' . $value . "\n";
    }
    
    $error = str_replace("\r", '', $error);
    






    echo '<!DOCTYPE html><style type="text/css">body { font-family: sans-serif; } h3 { color: darkred; }
    pre { text-shadow: 2px 2px 5px black; color: darkgreen; font-size: 2em; float: left; margin: 0 1em 0 0; padding: 1em; background: #cfc; border-radius: 50px; }</style>
    <pre> \__/<br /> (xx)<br />//||\\\\</pre>
    <h1>Erreur d\'exécution</h1>
    <p>Une erreur s\'est produite à l\'exécution de Garradin. Pour rapporter ce bug
    merci d\'inclure le message suivant :</p>
    <textarea cols="70" rows="'.substr_count($error, "\n").'">'.htmlspecialchars($error, ENT_QUOTES, 'UTF-8').'</textarea>
    <hr />
    <p><a href="http://dev.kd2.org/garradin/Rapporter%20un%20bug">Comment rapporter un bug</a></p>';


    exit;
}

set_error_handler('Garradin\exception_error_handler');
set_exception_handler('Garradin\exception_handler');








>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
>







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    foreach ($_SERVER as $key=>$value)
    {
        $error .= $key . ': ' . $value . "\n";
    }
    
    $error = str_replace("\r", '', $error);
    
    if (PHP_SAPI == 'cli')
    {
        echo $error;
    }
    else
    {
        echo '<!DOCTYPE html><style type="text/css">body { font-family: sans-serif; } h3 { color: darkred; }
        pre { text-shadow: 2px 2px 5px black; color: darkgreen; font-size: 2em; float: left; margin: 0 1em 0 0; padding: 1em; background: #cfc; border-radius: 50px; }</style>
        <pre> \__/<br /> (xx)<br />//||\\\\</pre>
        <h1>Erreur d\'exécution</h1>
        <p>Une erreur s\'est produite à l\'exécution de Garradin. Pour rapporter ce bug
        merci d\'inclure le message suivant :</p>
        <textarea cols="70" rows="'.substr_count($error, "\n").'">'.htmlspecialchars($error, ENT_QUOTES, 'UTF-8').'</textarea>
        <hr />
        <p><a href="http://dev.kd2.org/garradin/Rapporter%20un%20bug">Comment rapporter un bug</a></p>';
    }

    exit;
}

set_error_handler('Garradin\exception_error_handler');
set_exception_handler('Garradin\exception_handler');