2009-02-20 21:28:16 +01:00
< ? php
2014-05-01 16:26:57 +02:00
/* Copyright ( C ) 2009 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2009-02-20 21:28:16 +01:00
*
2012-04-18 15:16:34 +02:00
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-04-18 15:16:34 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2012-04-18 15:16:34 +02:00
*/
2009-02-20 21:28:16 +01:00
/**
2010-03-01 10:20:41 +01:00
* \file htdocs / admin / system / xdebug . php
* \brief Page administration XDebug
*/
2009-02-20 21:28:16 +01:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2009-02-20 21:28:16 +01:00
$langs -> load ( " admin " );
if ( ! $user -> admin )
2012-04-18 15:16:34 +02:00
accessforbidden ();
2009-02-20 21:28:16 +01:00
/*
2012-04-18 15:16:34 +02:00
* View
2009-02-20 21:28:16 +01:00
*/
llxHeader ();
2019-01-27 11:55:16 +01:00
print load_fiche_titre ( " XDebug " , '' , 'title_setup' );
2009-02-20 21:28:16 +01:00
print " <br> \n " ;
if ( ! function_exists ( 'xdebug_is_enabled' ))
{
2020-03-23 15:54:02 +01:00
print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.' ;
llxFooter ();
exit ;
2009-02-20 21:28:16 +01:00
}
if ( function_exists ( 'socket_create' ))
{
2020-04-10 10:59:32 +02:00
$address = ini_get ( 'xdebug.remote_host' ) ? ini_get ( 'xdebug.remote_host' ) : '127.0.0.1' ;
$port = ini_get ( 'xdebug.remote_port' ) ? ini_get ( 'xdebug.remote_port' ) : 9000 ;
2020-03-23 15:54:02 +01:00
print " <strong>Current xdebug setup:</strong><br> \n " ;
print " * Remote debug setup:<br> \n " ;
print 'xdebug.remote_enable = ' . ini_get ( 'xdebug.remote_enable' ) . " <br> \n " ;
print 'xdebug.remote_host = ' . $address . " <br> \n " ;
print 'xdebug.remote_port = ' . $port . " <br> \n " ;
print " * Profiler setup " ;
2020-04-10 10:59:32 +02:00
if ( function_exists ( 'xdebug_get_profiler_filename' )) print xdebug_get_profiler_filename () ? " (currently on into file " . xdebug_get_profiler_filename () . " ) " : " (currently off) " ;
2020-03-23 15:54:02 +01:00
else print " (currenlty not available) " ;
print " :<br> \n " ;
print 'xdebug.profiler_enable = ' . ini_get ( 'xdebug.profiler_enable' ) . " <br> \n " ;
print 'xdebug.profiler_enable_trigger = ' . ini_get ( 'xdebug.profiler_enable_trigger' ) . " <br> \n " ;
print 'xdebug.profiler_output_dir = ' . ini_get ( 'xdebug.profiler_output_dir' ) . " <br> \n " ;
print 'xdebug.profiler_output_name = ' . ini_get ( 'xdebug.profiler_output_name' ) . " <br> \n " ;
print 'xdebug.profiler_append = ' . ini_get ( 'xdebug.profiler_append' ) . " <br> \n " ;
print " <br> \n " ;
echo " To run a debug session, add parameter<br> " ;
echo " * XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.<br> \n " ;
echo " To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter<br> \n " ;
echo " * XDEBUG_PROFILE=aname on each URL.<br> " ;
print " <br> " ;
print " <strong>Test debugger server (Eclipse for example):</strong><br> \n " ;
$socket = socket_create ( AF_INET , SOCK_STREAM , SOL_TCP );
if ( empty ( $socket )) die ( 'Unable to prepare a socket' );
//socket_bind($sock, $address, $port) or die('Unable to bind on address='.$address.' port='.$port);
//socket_listen($sock);
//$client = socket_accept($sock);
2020-04-10 10:59:32 +02:00
$client = socket_connect ( $socket , $address , $port );
2020-03-23 15:54:02 +01:00
if ( $client )
{
echo " Connection established: " . $client . " - address= " . $address . " port= " . $port . " <br> \n " ;
echo " There is a Remote debug server at this address.<br> \n " ;
echo " <br> \n " ;
echo " To be sure this debugger accepts input from your PHP server and xdebug, be sure to have \n " ;
echo " your php.ini file with this :<br> \n " ;
echo '<textarea cols="80" rows="16">' . " xdebug.remote_enable=on
2014-02-17 16:30:22 +01:00
xdebug . remote_handle = dbgp
xdebug . remote_host = localhost
xdebug . remote_port = 9000
xdebug . profiler_enable = 0
xdebug . profiler_enable_trigger = 1
xdebug . show_local_vars = off
xdebug . profiler_output_dir =/ tmp / xdebug
xdebug . profiler_append = 0
; for xdebug 2.2 +
xdebug . trace_enable_trigger = 1
xdebug . show_mem_delta = 1
xdebug . trace_output_dir =/ tmp / trace
xdebug . auto_trace = 0
</ textarea > \n " ;
2020-03-23 15:54:02 +01:00
print " <br><br> \n " ;
echo ' Then check in your debug server ( Eclipse ), you have setup :< br >
2011-03-08 19:04:14 +01:00
XDebug with same port than in php . ini < br >
Allow Remote debug = yes or prompt < br > ' . " \n " ;
2020-03-23 15:54:02 +01:00
print " <br> \n " ;
2020-05-21 09:35:30 +02:00
} else {
2020-03-23 15:54:02 +01:00
print socket_strerror ( socket_last_error ());
echo " Failed to connect to address= " . $address . " port= " . $port . " <br> \n " ;
echo " There is no Remote debug server at this address. \n " ;
}
socket_close ( $socket );
2020-05-21 09:35:30 +02:00
} else {
2020-03-23 15:54:02 +01:00
print " Can't test if PHPDebug is OK as PHP socket functions are not enabled. " ;
2009-02-20 21:28:16 +01:00
}
2011-08-27 21:15:14 +02:00
llxFooter ();
2012-04-18 15:16:34 +02:00
$db -> close ();