HNAP PHP script

Saturday, April 8, 2023 at 12:11 PM

I recently made a webpage that lists every device connected to our six Wi-Fi routers.

I worked for two days on the PHP script that extracts the list from the first router (the others where much easier).

http://code.philippe97.ca/HNAP1/

Download the base.xml and soap.php files and edit the password and IP address in soap.php.

I use it like this :

$names = $ips = array();
$one24 = $one5 = $one5g = $onelan = array();
foreach (soap('GetClientInfo')->ClientInfoLists->ClientInfo as $client) {
	$mac = strtoupper($client->MacAddress);
	if ($ip = $client->IPv4Address)
		$ips[$mac] = $ip;
	if ($name = $client->DeviceName and $name != '*')
		$names[$mac] = $name;
	$key = '';
	if ($client->Type == 'WiFi_2.4G')
		$key = '24';
	if ($client->Type == 'WiFi_5G')
		$key = '5';
	if ($client->Type == 'WiFi_5G_Guest')
		$key = '5g';
	if ($client->Type == 'LAN')
		$key = 'lan';
	if (!$key)
		continue;
	${'one' . $key}[$mac] = array($mac, null, null);
}

Name
Password

No need to register, just enter the same name and password every time.