dolibarr  16.0.5
xdebug.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2009-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
23 require '../../main.inc.php';
24 
25 $langs->load("admin");
26 
27 if (!$user->admin) {
29 }
30 
31 
32 /*
33  * View
34 */
35 
36 llxHeader();
37 
38 print load_fiche_titre("XDebug", '', 'title_setup');
39 
40 if (!function_exists('xdebug_is_enabled')) {
41  print "<br>\n";
42  print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.';
43  llxFooter();
44  exit;
45 }
46 
47 print '<span class="opacitymedium">';
48 print $langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug"));
49 print '</span>';
50 
51 print '<br><br>';
52 
53 if (function_exists('socket_create')) {
54  $address = ini_get('xdebug.remote_host') ?ini_get('xdebug.remote_host') : '127.0.0.1';
55  $port = ini_get('xdebug.remote_port') ?ini_get('xdebug.remote_port') : 9000;
56 
57  print "<strong>Current xdebug setup:</strong><br>\n";
58  print "* Remote debug setup:<br>\n";
59  print 'xdebug.remote_enable = '.ini_get('xdebug.remote_enable')."<br>\n";
60  print 'xdebug.remote_host = '.$address."<br>\n";
61  print 'xdebug.remote_port = '.$port."<br>\n";
62  print "* Profiler setup ";
63  if (function_exists('xdebug_get_profiler_filename')) {
64  print xdebug_get_profiler_filename() ? "(currently on into file ".xdebug_get_profiler_filename().")" : "(currently off)";
65  } else {
66  print "(currenlty not available)";
67  }
68  print ":<br>\n";
69  print 'xdebug.profiler_enable = '.ini_get('xdebug.profiler_enable')."<br>\n";
70  print 'xdebug.profiler_enable_trigger = '.ini_get('xdebug.profiler_enable_trigger')."<br>\n";
71  print 'xdebug.profiler_output_dir = '.ini_get('xdebug.profiler_output_dir')."<br>\n";
72  print 'xdebug.profiler_output_name = '.ini_get('xdebug.profiler_output_name')."<br>\n";
73  print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."<br>\n";
74  print "<br>\n";
75 
76  print "To run a debug session, add parameter<br>";
77  print "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.<br>\n";
78  print "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter<br>\n";
79  print "* XDEBUG_PROFILE=aname on each URL.<br>";
80  print "<br>";
81 
82  print "<strong>Test debugger server (Eclipse for example):</strong><br>\n";
83  $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
84  if (empty($socket)) {
85  die('Unable to prepare a socket');
86  }
87  //socket_bind($sock, $address, $port) or die('Unable to bind on address='.$address.' port='.$port);
88  //socket_listen($sock);
89  //$client = socket_accept($sock);
90  $client = socket_connect($socket, $address, $port);
91  if ($client) {
92  print "Connection established: ".$client." - address=".$address." port=".$port."<br>\n";
93  print "There is a Remote debug server at this address.<br>\n";
94  print "<br>\n";
95  print "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n";
96  print "your php.ini file with this :<br>\n";
97  print '<textarea cols="80" rows="16">'."xdebug.remote_enable=on
98 xdebug.remote_handle=dbgp
99 xdebug.remote_host=localhost
100 xdebug.remote_port=9000
101 xdebug.profiler_enable=0
102 xdebug.profiler_enable_trigger=1
103 xdebug.show_local_vars=off
104 xdebug.profiler_output_dir=/tmp/xdebug
105 xdebug.profiler_append=0
106 ; for xdebug 2.2+
107 xdebug.trace_enable_trigger=1
108 xdebug.show_mem_delta=1
109 xdebug.trace_output_dir=/tmp/trace
110 xdebug.auto_trace=0
111 </textarea>\n";
112  print "<br><br>\n";
113  print 'Then check in your debug server (Eclipse), you have setup:<br>
114  XDebug with same port than in php.ini<br>
115  Allow Remote debug=yes or prompt<br>'."\n";
116  print "<br>\n";
117  } else {
118  print socket_strerror(socket_last_error());
119  print " - Failed to connect to address=".$address." port=".$port."<br>\n";
120  print "There is no Remote debug server at this address.\n";
121  }
122  socket_close($socket);
123 } else {
124  print "Can't test if PHPDebug is OK as PHP socket functions are not enabled.";
125 }
126 
127 
128 llxFooter();
129 
130 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59