[PHP] Simple Site/Server Info

Status
Not open for further replies.

Vick

Banned
Banned
297
2011
72
0
PHP:
 Simple Site/Server Info

I was going to try, and make the code neater, and turn it into a desktop app. But somewhere in the past 8 minutes I got tired. Small piece of code let's you pass through a domain via using $_GET, and x amount of ping's using $_GET.

Returns:
1. Server/Website IP Used
2. Pings (Windows based) x amount of times
3. CloudFlare Resolved DNS
4. Basic DNS info

I guess if you have the time you could use C#/VB.NET and design a lil desktop app, and use the webclient to download this PHP file with $_GET values passed from a in-app form to get results. You could also clean up the code, and make it neater if you like. 

[code]<?php
error_reporting(0);
$site = $_GET['url'];
if($site == '')
{
echo 'Please enter a domain.';
}
else
{
$ip = gethostbyname($site);

echo $site. ': Site/Server Info';

echo '<pre>IP: ' . $ip . '<br/>'."\n";

echo 'Ping: '."\n";
for($i = 0; $i < $_GET['p']; $i++){
echo exec("ping $ip").'<br />';
}
echo "\n";
echo 'CloudFlare DNS Records: <br />';
$ch = curl_init();

// 2. set the options, including the url
curl_setopt($ch, CURLOPT_URL, "http://socialengineered.net/getCF.php?url=$site");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);

// 3. execute and fetch the resulting HTML output
$output = curl_exec($ch);

// 4. free up the curl handle
curl_close($ch);
preg_match("/mail.$site = (.*)/i", $output, $match);

echo $match[1];
echo "\n";
echo 'Basic DNS_GET_RECORD<br />';
$dns = array(dns_get_record($site));
print_r($dns);
echo "\n";

echo '</pre>';
}[/code]

URL Usage Example(URL = Domain of Site, P = Count of Pings):
[code]http://localhost:85/lop.php?url=wjunction.com&p=3[/code]

Example Result:
[code]wjunction.com: Site/Server Info
IP: 108.162.199.189

Ping: 
Minimum = 26ms, Maximum = 29ms, Average = 27ms
Minimum = 26ms, Maximum = 35ms, Average = 29ms
Minimum = 26ms, Maximum = 27ms, Average = 26ms

CloudFlare DNS Records: 
74.125.132.121
direct.wjunction.com = 108.61.8.195
direct-connect.wjunction.com = 108.61.8.195
cpanel.wjunction.com = 108.61.8.195
ftp.wjunction.com = 108.61.8.195
email.wjunction.com = 108.61.8.195
server.wjunction.com = 108.61.8.195
status.wjunction.com = 108.61.8.195

Basic DNS_GET_RECORD
Array
(
[0] => Array
(
[0] => Array
(
[host] => wjunction.com
[class] => IN
[ttl] => 289
[type] => A
[ip] => 108.162.198.189
)

[1] => Array
(
[host] => wjunction.com
[class] => IN
[ttl] => 289
[type] => A
[ip] => 108.162.199.189
)

[2] => Array
(
[host] => wjunction.com
[class] => IN
[ttl] => 83156
[type] => NS
[target] => sam.ns.cloudflare.com
)

[3] => Array
(
[host] => wjunction.com
[class] => IN
[ttl] => 83156
[type] => NS
[target] => kara.ns.cloudflare.com
)

[4] => Array
(
[host] => wjunction.com
[class] => IN
[ttl] => 83156
[type] => SOA
[mname] => kara.ns.cloudflare.com
[rname] => dns.cloudflare.com
[serial] => 2013031103
[refresh] => 10000
[retry] => 2400
[expire] => 604800
[minimum-ttl] => 3600
)

)

)
[/code]

Please note, I wrote this on a Windows 7 64Bit OS, and seeing at uses "ping". I don't know if it'll work on linux environments. (hence, I need to get a vps soon). 

If you've got problems or want to criticize my share of this post, keep it to yourself. If you don't understand none of it => w3schools.com
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top