Jump to content

Recommended Posts

Actually, here's the code for the whole thing I've got so far. It works, that's not the problem. I want it to write the location too:

 

<?php
function clean ($var)
{
return htmlspecialchars($var);
}
$ip = clean($_SERVER['REMOTE_ADDR']);
$entry = "<b>IP:</b> $ip<br /> \r\n";
$fp = fopen('iplog.html', "a") or die('Cannot open logfile');
fwrite($fp, $entry);
fclose($fp);
###OUTPUT IMAGE###
$file = "imagesource.gif";
$fp = fopen($file, "r") or die('Cannot grab image source');
$content = fread($fp, filesize($file));
header("Content-type: image/gif");
echo $content;
fclose($fp);
?>

 

 

Now, this is a .gif ip logger for use on forums and things. So don't really worry about the output image, I put the inside of a .gif file, and wrote this to .htaccess:

 

AddHandler application/x-httpd-php .gif

 

So that my server will handle .gif files as .php. Then I added imagesource.gif but none of that really matters, I need location  ???

Link to comment
https://forums.phpfreaks.com/topic/87843-php-traceroute/#findComment-449358
Share on other sites

use a system call to tracert, you can put the results in a string or array.

 

look at exec

 

should be easy, as long as your script has enough rights.

 

 

I'm hosting it locally. Now, my tracert command (I know, I could use passthru() ) But, it doesn't give me the location, here's an example of what I might come up with:

 

Tracing route to www.phpfreaks.com
over a maximum of 30 hops:

  1     8 ms     7 ms     6 ms  10.42.192.1
  2    19 ms    10 ms     8 ms  srp3-0.dytnoh1-rtr2.woh.rr.com [24.29.160.7]
  3    22 ms    21 ms    27 ms  network-024-095-081-217.columbus.rr.com [24.95.8
1.217]
  4    27 ms    30 ms    27 ms  ae-3-0.cr0.dca20.tbone.rr.com [66.109.6.70]
  5    28 ms    28 ms    28 ms  ae-1-0.pr0.dca10.tbone.rr.com [66.109.6.165]
  6    33 ms    27 ms    27 ms  64.132.69.61
  7    59 ms    61 ms    61 ms  64.128.245.106
  8    59 ms    59 ms    59 ms  64.128.245.106
  9    61 ms    60 ms    65 ms  204.8.178.42
10    69 ms    62 ms    61 ms  204-13-168-167.reverse.serverpowered.net [204.13
.168.167]
11    58 ms    62 ms    66 ms  66-97-171-5.reverse.serverpowered.net [66.97.171
.5]

Trace complete.

 

So no system commands really return a location  :-\

Link to comment
https://forums.phpfreaks.com/topic/87843-php-traceroute/#findComment-449368
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.