PageRenderTime 55ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/system/xdebug.php

https://github.com/asterix14/dolibarr
PHP | 103 lines | 64 code | 14 blank | 25 comment | 5 complexity | 910daf23f7a767725a83cb36764e053b MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2009 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 2 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 <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/system/xdebug.php
  19. * \brief Page administration XDebug
  20. */
  21. require("../../main.inc.php");
  22. $langs->load("admin");
  23. if (!$user->admin)
  24. accessforbidden();
  25. /*
  26. * View
  27. */
  28. llxHeader();
  29. print_fiche_titre("XDebug",'','setup');
  30. print "<br>\n";
  31. if (!function_exists('xdebug_is_enabled'))
  32. {
  33. print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.';
  34. llxFooter();
  35. exit;
  36. }
  37. if (function_exists('socket_create'))
  38. {
  39. $address = empty($conf->global->XDEBUG_SERVER)?'127.0.0.1':$conf->global->XDEBUG_SERVER;
  40. $port = empty($conf->global->XDEBUG_PORT)?9000:$conf->global->XDEBUG_PORT;
  41. print 'XDEBUG_SERVER: '.$address."<br>\n";
  42. print 'XDEBUG_PORT: '.$port."<br>\n";
  43. print "<br>\n";
  44. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  45. if (empty($socket)) die('Unable to preapre a socket');
  46. //socket_bind($sock, $address, $port) or die('Unable to bind on address='.$address.' port='.$port);
  47. //socket_listen($sock);
  48. //$client = socket_accept($sock);
  49. $client=socket_connect($socket, $address, $port);
  50. if ($client)
  51. {
  52. echo "Connection established: ".$client." - address=".$address." port=".$port."<br>\n";
  53. echo "There is a Remote debug server at this address.<br>\n";
  54. echo "<br>\n";
  55. echo "To be sure this debugger accepts input from your PHP server, be sure to have\n";
  56. echo "your php.ini file with this :<br>\n";
  57. echo 'xdebug.remote_enable=on<br>
  58. xdebug.remote_handle=dbgp<br>
  59. xdebug.remote_host=localhost<br>
  60. xdebug.remote_port=9000<br>
  61. xdebug.profiler_enable=1<br>
  62. xdebug.show_local_vars=off<br>
  63. xdebug.profiler_output_dir=/tmp/xdebug<br>
  64. xdebug.profiler_append=0<br>
  65. '."\n";
  66. print "<br>\n";
  67. echo 'Then check in your debug server (Eclipse), you have setup:<br>
  68. XDebug with same port than in php.ini<br>
  69. Allow Remote debug=yes or prompt<br>'."\n";
  70. print "<br>\n";
  71. echo "Then, to run a debug session, add parameter XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.\n";
  72. }
  73. else
  74. {
  75. print socket_strerror(socket_last_error());
  76. echo "Failed to connect to address=".$address." port=".$port."<br>\n";
  77. echo "There is no Remote debug server at this address.\n";
  78. }
  79. socket_close($client);
  80. socket_close($socket);
  81. }
  82. else
  83. {
  84. print "Can't test if PHPDebug is OK as PHP socket functions are not enabled.";
  85. }
  86. llxFooter();
  87. ?>