|
28 | 28 | die("Address is not an IP and I can't resolve it. Doing nothing"); |
29 | 29 | } |
30 | 30 |
|
| 31 | +# Cap ping count to 20 |
| 32 | +if ( isset($_REQUEST['ping_count']) and is_numeric($_REQUEST['ping_count']) and $_REQUEST['ping_count'] > 0 and $_REQUEST['ping_count'] <= 20 ) { |
| 33 | + $ping_count = intval($_REQUEST['ping_count']); |
| 34 | +} else { |
| 35 | + $ping_count = 10; |
| 36 | +} |
| 37 | + |
31 | 38 | $site_id = is_numeric($_REQUEST['site_id']) ? $_REQUEST['site_id'] : -1; |
32 | 39 |
|
33 | 40 | $conf['remote_exe'] = "get_mtr.php"; |
|
45 | 52 | <pre> |
46 | 53 | <?php |
47 | 54 | if ( filter_var($user['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { |
48 | | - passthru($conf['ping6_bin'] . " -c 4 " . $user['ip']); |
| 55 | + passthru($conf['ping6_bin'] . " -i 0.2 -c " . $ping_count . " " . $user['ip']); |
49 | 56 | } else { |
50 | | - passthru($conf['ping_bin'] . " -c 4 " . $user['ip']); |
| 57 | + passthru($conf['ping_bin'] . " -i 0.2 -c " . $ping_count . " " . $user['ip']); |
51 | 58 | } |
52 | 59 | ?> |
53 | 60 | </pre> |
|
72 | 79 |
|
73 | 80 | // Get results from all remotes |
74 | 81 | foreach ( $conf['remotes'] as $index => $remote ) { |
75 | | - |
76 | | - print "<div id='remote_" . ${index} . "'> |
77 | | - <button onClick='$(\"#mtrping_results_" . ${index} . "\").toggle();'>" .$conf['remotes'][$index]['name']. "</button></div>"; |
78 | | - |
79 | | - print "<div id='mtrping_results_" . ${index} ."'>"; |
80 | | - |
| 82 | + |
| 83 | + print "<div id='remote_" . $index . "'> |
| 84 | + <button onClick='$(\"#mtrping_results_" . $index . "\").toggle();'>" .$conf['remotes'][$index]['name']. "</button></div>"; |
| 85 | + |
| 86 | + print "<div id='mtrping_results_" . $index ."'>"; |
| 87 | + |
81 | 88 | #print (file_get_contents($conf['remotes'][$index]['base_url'] . "get_mtr.php?site_id=-1" . |
82 | 89 | #"&hostname=" . $_REQUEST['hostname'] )); |
83 | 90 | print "<img src=\"img/spinner.gif\"></div>"; |
84 | | - |
| 91 | + |
| 92 | + $args[] = 'hostname=' . htmlentities($_REQUEST['hostname']); |
| 93 | + $args[] = 'ping_count=' . $ping_count; |
| 94 | + |
85 | 95 | print ' |
86 | 96 | <script> |
87 | | - $.get("' . $conf['remote_exe'] . '", "site_id=' . $index . '&hostname=' . htmlentities($_REQUEST['hostname']) . '", function(data) { |
88 | | - $("#mtrping_results_' . ${index} .'").html(data); |
| 97 | + $.get("' . $conf['remote_exe'] . '", "site_id=' . $index . '&' . join("&", $args) . '", function(data) { |
| 98 | + $("#mtrping_results_' . $index .'").html(data); |
89 | 99 | }); |
90 | 100 | </script> |
91 | 101 | <p></p>'; |
|
100 | 110 |
|
101 | 111 | print "<div><h3>" .$conf['remotes'][$site_id]['name']. "</h3></div>"; |
102 | 112 | print "<div class=dns_results>"; |
103 | | - print (file_get_contents($conf['remotes'][$site_id]['base_url'] . $conf['remote_exe'] . "?site_id=-1" . |
104 | | - "&hostname=" . $_REQUEST['hostname'] )); |
| 113 | + $args[] = 'hostname=' . htmlentities($_REQUEST['hostname']); |
| 114 | + $args[] = 'ping_count=' . $ping_count; |
| 115 | + $url = $conf['remotes'][$site_id]['base_url'] . $conf['remote_exe'] . "?site_id=-1&" . join("&", $args); |
| 116 | + print (file_get_contents($url)); |
105 | 117 | print "</div>"; |
106 | 118 |
|
107 | 119 |
|
|
0 commit comments