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