|
|
@@ -7,15 +7,43 @@ class debug
|
|
|
private static $startTime;
|
|
|
private static $closeTime;
|
|
|
|
|
|
- public static function addFileSubmit()
|
|
|
+ private static function typeFile(string $_string){
|
|
|
+ switch ($_string) {
|
|
|
+ case 'debug':
|
|
|
+ return FILE_DEBUG;
|
|
|
+ break;
|
|
|
+ case 'maintenance':
|
|
|
+ return FILE_MAINTENANCE;
|
|
|
+ break;
|
|
|
+ case 'submit':
|
|
|
+ return FILE_DEBUG_SUBMIT;
|
|
|
+ break;
|
|
|
+ case 'sql':
|
|
|
+ return FILE_DEBUG_SQL;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return NULL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function addFile(string $_string = NULL)
|
|
|
+ {
|
|
|
+ if($_string != NULL){
|
|
|
+ $myfile = fopen(DOCUMENT_ROOT . self::typeFile($_string), "w");
|
|
|
+ fclose($myfile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function removeFile(string $_string = NULL)
|
|
|
{
|
|
|
- $myfile = fopen(DOCUMENT_ROOT . FILE_DEBUG_SUBMIT, "w");
|
|
|
- fclose($myfile);
|
|
|
+ unlink(DOCUMENT_ROOT . self::typeFile($_string));
|
|
|
}
|
|
|
|
|
|
- public static function removeFileSubmit()
|
|
|
+ public static function isFile(string $_string = NULL)
|
|
|
{
|
|
|
- unlink(DOCUMENT_ROOT . FILE_DEBUG_SUBMIT);
|
|
|
+ return (file_exists(DOCUMENT_ROOT . self::typeFile($_string))) ? TRUE : FALSE;
|
|
|
}
|
|
|
|
|
|
public static function isSubmit()
|
|
|
@@ -25,7 +53,7 @@ class debug
|
|
|
|
|
|
public static function includeDebug()
|
|
|
{
|
|
|
- if (core::isDebug()) {
|
|
|
+ if (debug::isFile("debug")) {
|
|
|
echo '<link rel="stylesheet" href="css/debug.css">';
|
|
|
}
|
|
|
}
|
|
|
@@ -139,6 +167,15 @@ class debug
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
+ public static function print_r(array $_array, int $_exit = NULL)
|
|
|
+ {
|
|
|
+ echo "<div>".debug::getTraces() . "</div>";
|
|
|
+ echo "<pre>";
|
|
|
+ print_r($_array);
|
|
|
+ echo "</pre>";
|
|
|
+ ($_exit != NULL) ? exit() : NULL;
|
|
|
+ }
|
|
|
+
|
|
|
public static function log($_message, $_mark = NULL)
|
|
|
{
|
|
|
$mark = "<div class='debug-head-console'>";
|
|
|
@@ -179,16 +216,20 @@ class debug
|
|
|
|
|
|
public static function renderLogs()
|
|
|
{
|
|
|
- //if (!empty(self::$logs)) {
|
|
|
-
|
|
|
echo "<div id='debugger-logs'>";
|
|
|
|
|
|
echo "<div class='debug-renderLogs-header'>";
|
|
|
- echo "PHP ". phpversion() . " | " . number_format(self::$closeTime, 4) . " secondes ";
|
|
|
+ echo "PHP ". phpversion() . " | MYSQL " . db::version() . " | " . number_format(self::$closeTime, 4) . " secondes ";
|
|
|
echo "</div>";
|
|
|
- echo "<div class=\"form-check form-switch\">
|
|
|
- <input class=\"form-check-input\" type=\"checkbox\" id=\"checkIsSubmit\" " . core::checkboxSelecter(self::isSubmit(), 0) . " >
|
|
|
- <label class=\"form-check-label\" for=\"checkIsSubmit\">Intercepter la validation</label>
|
|
|
+ echo "<div class=\"form-check form-switch\" style=\"margin-top: -30px;\">
|
|
|
+ <div>
|
|
|
+ <input class=\"form-check-input\" type=\"checkbox\" id=\"checkIsSubmit\" " . core::checkboxSelecter(self::isFile("submit"), 0) . " >
|
|
|
+ <label class=\"form-check-label\" for=\"checkIsSubmit\">Intercepter les Submit</label>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <input class=\"form-check-input\" type=\"checkbox\" id=\"checkIsSql\" " . core::checkboxSelecter(self::isFile("sql"), 0) . " >
|
|
|
+ <label class=\"form-check-label\" for=\"checkIsSql\">Intercepter les requêtes SQL</label>
|
|
|
+ </div>
|
|
|
</div>";
|
|
|
|
|
|
foreach (self::$logs as $log) {
|
|
|
@@ -202,30 +243,7 @@ class debug
|
|
|
}
|
|
|
|
|
|
echo "</div>";
|
|
|
-
|
|
|
- echo "
|
|
|
- <script>
|
|
|
- $(document).ready(function() {
|
|
|
-
|
|
|
- $('#checkIsSubmit').on('change', function() {
|
|
|
- window.location.href = '/submit.php?from=parametres-debug-submit-activation&actif=' + $('#checkIsSubmit').prop('checked');
|
|
|
- });
|
|
|
-
|
|
|
- $('.toggle-logs').click(function() {
|
|
|
- $('#debugger-logs').slideToggle();
|
|
|
- });
|
|
|
-
|
|
|
- // Apply syntax highlighting to log entries
|
|
|
- $('.log-entry').each(function() {
|
|
|
- var html = $(this).html();
|
|
|
- html = html.replace(/(\\$\\w+)/g, '<span class=\"variable\">$1</span>');
|
|
|
- html = html.replace(/(\\bfunction\\b)/g, '<span class=\"function\">$1</span>');
|
|
|
- $(this).html(html);
|
|
|
- });
|
|
|
- });
|
|
|
- </script>
|
|
|
- ";
|
|
|
- //}
|
|
|
+ get::javascript("debug");
|
|
|
}
|
|
|
|
|
|
public static function init()
|
|
|
@@ -256,13 +274,16 @@ class debug
|
|
|
|
|
|
public static function getBadges(){
|
|
|
$return = "";
|
|
|
- if(core::isMaintenance()){
|
|
|
+ if(debug::isFile("maintenance")){
|
|
|
$return .= "<a href=\"/parametsres.html\"><span class=\"badge\" style=\"background-color:red; margin:5px;\">SITE EN MODE MAINTENANCE</span></a>";
|
|
|
}
|
|
|
- if(core::isDebug()){
|
|
|
+ if(debug::isFile("debug")){
|
|
|
$return .= "<a href=\"#\"><span class=\"badge toggle-logs\" style=\"background-color:orange; color:black; margin:5px;\">MODE DEBUG</span></a>";
|
|
|
}
|
|
|
- if(self::isSubmit()){
|
|
|
+ if(self::isFile("sql")){
|
|
|
+ $return .= "<a href=\"#\"><span class=\"badge toggle-logs\" style=\"background-color:orange; color:black; margin:5px;\">MODE DEBUG SQL</span></a>";
|
|
|
+ }
|
|
|
+ if(self::isFile("submit")){
|
|
|
$return .= "<a href=\"#\"><span class=\"badge toggle-logs\" style=\"background-color:orange; color:black; margin:5px;\">MODE DEBUG SUBMIT</span></a>";
|
|
|
}
|
|
|
return $return;
|