Alternc  latest
Alternc logiel libre pour l'hébergement
m_debug_alternc.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  ----------------------------------------------------------------------
5  LICENSE
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License (GPL)
9  as published by the Free Software Foundation; either version 2
10  of the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  To read the license please visit http://www.gnu.org/copyleft/gpl.html
18  ----------------------------------------------------------------------
19 */
20 
21 /**
22  * This class manage debug. Available to admin account only
23  *
24  * @copyright AlternC-Team 2000-2017 https://alternc.com/
25  */
27 
28  var $infos = "";
29  var $status = false;
30  var $nb_sql_query = 0;
31  var $tps_sql_query = 0;
32  var $generation_started = null;
33 
34  /* --------------------------------------------------------------------------- */
35 
36  /** Constructor
37  */
38  function m_debug_alternc() {
39  if (isset($_COOKIE['alternc_debugme']) && $_COOKIE['alternc_debugme']) {
40  $this->status = true;
41  ini_set('display_errors', '1');
42  }
43  $this->nb_sql_query = 0;
44  $this->tps_sql_query = 0;
45  $this->generation_started = microtime(true);
46  }
47 
48  function activate() {
49  setcookie('alternc_debugme', '1', time() + 3600); // expire in 1 hour
50  $this->status = "";
51  return true;
52  }
53 
54  function desactivate() {
55  setcookie('alternc_debugme', '0');
56  $this->status = false;
57  return true;
58  }
59 
60  function add($txt) {
61  $this->infos .= "\n$txt";
62  return true;
63  }
64 
65  function dump() {
66  global $cuid;
67  if ($cuid != 2000) {
68  return false;
69  }
70  if (!$this->status) {
71  return false;
72  }
73 
74  $generation_time = (microtime(true) - $this->generation_started) * 1000;
75 
76  echo "<fieldset style='background-color: silver;'>";
77  echo "<pre>";
78  echo "+++ BEGIN Debug Mode+++\n";
79  echo "Total generation time : $generation_time ms\n";
80  print_r("\n--- Total SQL Query : " . $this->nb_sql_query . " req / " . $this->tps_sql_query . " ms ---\n");
81  print_r($this->infos);
82  echo "\n\n--- GET ---\n";
83  print_r($_GET);
84  echo "\n\n--- POST ---\n";
85  print_r($_POST);
86  echo "\n\n--- SESSION ---\n";
87  @print_r($_SESSION);
88  echo "\n\n--- COOKIE ---\n";
89  print_r($_COOKIE);
90  echo "\n\n--- SERVER ---\n";
91  print_r($_SERVER);
92  echo "\n\n+++ END Debug Mode+++";
93  echo "</pre>";
94  echo "</fieldset>";
95  return true;
96  }
97 
98 }
99 
100 /* Class debug_alternc */
$cuid
Definition: bootstrap.php:43
This class manage debug.
m_debug_alternc()
Constructor.