This package can perform diagnostics of access to Internet services.
It provides a class that can access multiple types of Internet services to check their responses and display the responses on a Web page.
Currently, it can:
- Retrieve several types of DNS records for a domain: MX, A, TXT, PTR, CNAME, SOA, SPF.
- Connect to a given server using different protocols: TCP, HTTP, HTTPS, SMTP
- Send requests to given servers using different protocols: ping, traceroute, HTTPS, SSH, FTP, SMTP, DNS, POP3, IMAPS, POP3S, RDP, Telnet, SMTP submission, HTTP, MySQL.
In more detail, the NetworkTools class is a comprehensive PHP library designed for network and DNS diagnostic operations. It provides a unified interface for various network tests and DNS queries, with intelligent fallback mechanisms for restricted server environments.
The core features of the class automatically detect available PHP functions and system capabilities, implementing smart fallback strategies when certain functions are disabled. It offers both "real" system commands (ping, traceroute) and simulated alternatives using TCP connections when exec() is not available.
The class DNS functions support all major DNS record types, including MX records for email server configuration, A records for IP address resolution, TXT records for text-based DNS information, PTR records for reverse DNS lookups, CNAME records for aliases, SOA records for domain authority information, and SPF records for email authentication.
The class network connectivity tests provide TCP port testing to check open ports, SMTP server connectivity tests, HTTP/HTTPS availability checks with response time measurements, ping simulation using either ICMP or TCP-based alternatives, and traceroute simulation with intelligent path analysis.
When system commands are not available, the class provides intelligent fallbacks using creative alternatives.
The simulated ping tests multiple common ports (80, 443, 22, 25, etc.) to find an open connection and measures response times. The simulated traceroute analyzes DNS patterns and uses TCP connectivity tests to approximate network routing paths.
The universal lookup() function automatically detects input type, IP addresses trigger PTR lookups, email addresses trigger MX lookups for the domain portion, and domain names trigger A record lookups.
All functions return structured arrays with success and error status, timing information, and detailed results. The class includes formatting functions for HTML output and a comprehensive self-test function that generates a complete system capability report.
This class is ideal for network monitoring tools, server health checks, email deliverability testing, DNS troubleshooting, and general network diagnostics in web applications where system command access may be limited. |