User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,572 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,817 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Apr 16th, 2005
Views: 4,697
php Syntax | 3 stars
  1. <?php
  2.  
  3. //visit www.corehackers.com to test it!!
  4. // Address error handling.
  5.  
  6. ini_set('display_errors', 1);
  7. error_reporting(E_ALL ^ E_NOTICE);
  8.  
  9. // Obtain POST data.
  10.  
  11. $trace_ip_addr = $_POST['trace_ip_addr']; // input
  12.  
  13. // Remove any slashes if Magic Quotes GPC is enabled.
  14.  
  15. if (get_magic_quotes_gpc())
  16. {
  17. $trace_ip_addr = stripslashes($trace_ip_addr);
  18. }
  19.  
  20. /******************************************************************************/
  21.  
  22. ?>
  23.  
  24.  
  25. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  26.  
  27. <head>
  28. <title>Trace</title>
  29. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  30. <meta name="author" content="dr0n3" />
  31. <style type="text/css">
  32.  
  33. body
  34. {
  35. margin: 0;
  36. padding: 10px;
  37. background-color: #ffffff;
  38. }
  39.  
  40. div.output
  41. {
  42. margin: 0;
  43. padding: 10px;
  44. background-color: #eeeeee;
  45. border-style: solid;
  46. border-width: 1px;
  47. border-color: #000000;
  48. }
  49.  
  50. </style>
  51. </head>
  52.  
  53. <body>
  54. <h1>Trace</h1>
  55. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  56. <p><label for="trace_ip_addr">IP address:</label><br />
  57. <input name="trace_ip_addr" id="trace_ip_addr" type="text" value="<?php echo $_POST['submit'] == 'Trace' ? htmlentities($trace_ip_addr, ENT_QUOTES) : '127.0.0.1'; ?>" size="40" maxlength="15" /></p>
  58. <p><input type="submit" name="submit" value="Trace" /></p>
  59. </form>
  60. <p>Trace may take a while, please be patient.</p>
  61. <?php
  62.  
  63. if ($_POST['submit'] == 'Trace') // Form has been submitted.
  64. {
  65. echo '<div class="output">' . "\n";
  66.  
  67. if (strlen($trace_ip_addr) <= 15) // Form submission was not spoofed.
  68. {
  69. if (ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $trace_ip_addr)) // Acquired data contains no problems.
  70. {
  71. // Display result.
  72.  
  73. echo '<pre>' . "\n" .
  74. 'traceroute ' . $trace_ip_addr . "\n\n";
  75.  
  76. system('traceroute ' . $trace_ip_addr); // Trace IP address.
  77.  
  78. echo '</pre>' . "\n" .
  79. '<p>Trace complete.</p>' . "\n";
  80. }
  81. else // Acquired data contains problems!
  82. {
  83. echo '<p>Please enter a valid IP address.</p>' . "\n";
  84. }
  85. }
  86. else // Form submission was spoofed!
  87. {
  88. echo '<p>An illegal operation was encountered.</p>' . "\n";
  89. }
  90.  
  91. echo '</div>' . "\n";
  92. }
  93.  
  94. ?>
  95. <!--http:/www.corehackers.com/ -->
  96. </body>
  97.  
  98. </html>
Comments (Newest First)
wonder_laptop | Junior Poster in Training | Jan 6th, 2008
Sorry, i forgot to give you my email address:

its wonder_laptop_1@windowslive.com

i reallly really appreciate your help.
wonder_laptop | Junior Poster in Training | Jan 6th, 2008
Sorry, i forgot to give you my email address:

its wonder_laptop_1@windowslive.com

i reallly really appreaciate your help.
wonder_laptop | Junior Poster in Training | Jan 6th, 2008
Hello,

can you PLEASE put a SIMPLE traceroute code in java.

i googled traceroute but i got a bunch of compicated codes.

im new in networking programming, i want to implement the traceroute command . i already managed to create a network and wrote a program for the laptops to send datagrams to each others.

can you PLEASE give me a code for the traceroute command implmentation?
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 5:56 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC