I am looking at creating a website which can preform some basic networking tests on servers/clients.
I am using php to run the following test:
- Ping
- Traceroute
- Dig
- Curl
With curl for example, if I was troubleshooting a networking problem from the command line I usually use the command:
curl -Ik <website-url/ip-address>
This returns:
HTTP/1.1 200 OK
Date: Wed, 01 Jan 2014 14:30:13 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
X-Pingback: http://<ip-address>/xmlrpc.php
Link: <http://<ip-address>/?p=83>; rel=shortlink
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
So far I have created a basic curl function that just curls a website and displays that website:
public static function curl($host) {
$ch = curl_init($host);
$fp = fopen("index.html", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
Is there any simple method to display similar information that is returned with the command line example listed above?
Just to clarify I would like to create a php function that can curl a website and if possible be passed arguments in a similar manner to the command line. So by default it just does what the above PHP code does, but if a certain parameter is checked it then returns the HTTP headers or allows curl to perform "insecure" SSL connections and transfers in as if the -I or -k parameters were passed to curl on the command line.
Also any good ideas on other networking tools to include within this tool would be great.