Jump to content

Question about a PHP trace script.


HHawk

Recommended Posts

I was searching for a PHP script which is able to show a traceroute from our server to various locations.
Apparently, there are not many out there. :S

Anyways I did find one out there, though very simple, it does (sorta) what I want it to do.
Except for one thing... Instead of entering an IP manually, I want a pulldown menu with like 10 addresses e.g. telia.net (for Sweden), etc.

Is this easy to change with the following code?
(it's just one file)

[code]
!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>The WorldsEnd.NET - Free Traceroute Script, written in PHP</title>
</head>
<?php
//  This script was writen by webmaster@theworldsend.net, Aug.2001
//  http://www.theworldsend.net
//  This is my first script. Enjoy.
// 
// Put it into whatever directory and call it. That's all.
// Updated to 4.2 code in 2002
// Get Variable from form via register globals on/off
//-------------------------
$unix      =  1; //set this to 1 if you are on a *unix system     
$windows  =  0; //set this to 1 if you are on a windows system
// -------------------------
// nothing more to be done.
// -------------------------
//globals on or off ?
$register_globals = (bool) ini_get('register_gobals');
$system = ini_get('system');
$unix = (bool) $unix;
$win  = (bool)  $windows;
//
If ($register_globals)
{
  $ip = getenv(REMOTE_ADDR);
  $self = $PHP_SELF;
}
else
{
  $submit = $_GET['submit'];
  $host  = $_GET['host'];
  $ip    = $_SERVER['REMOTE_ADDR'];
  $self  = $_SERVER['PHP_SELF'];
};
// form submitted ?
If ($submit == "Traceroute!")
{
      // replace bad chars
      $host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
      echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
      echo("Trace Output:<br>");
      echo '<pre>';         
      //check target IP or domain
      if ($unix)
      {
        system ("traceroute $host");
        system("killall -q traceroute");// kill all traceroute processes in case there are some stalled ones or use echo 'traceroute' to execute without shell
      }
      else
      {
        system("tracert $host");
      }
      echo '</pre>';
      echo 'done ...'; 
}
else
{
    echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
    echo '<p><font size="2">Your IP is: '.$ip.'</font></p>';
    echo '<form methode="post" action="'.$self.'">';
    echo '  Enter IP or Host <input type="text" name="host" value="'.$ip.'"></input>';
    echo '  <input type="submit" name="submit" value="Traceroute!"></input>';
    echo '</form>';
    echo '<br><b>'.$system.'</b>';
    echo '</body></html>';
}
?>
[/code]

Or if anyone knows a better script, then please tell... Thanks.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.