-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiosdiscover.php
More file actions
44 lines (39 loc) · 1.07 KB
/
iosdiscover.php
File metadata and controls
44 lines (39 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
chdir(dirname(__FILE__));
include_once("config.php");
include_once("lib/db.php");
include_once("lib/ping.php");
include_once("lib/arp.php");
include_once("lib/domain/domain.php");
date_default_timezone_set("UTC");
echo date("l jS \of F Y h:i:s A\n");
$ips = getNetworkIps();
foreach($ips as $ip) {
$found = tcp_conn($ip, 62078);
if (true==$found) {
echo "ip: ".$ip."\n";
$ipObj = new Ip();
$ipObj->ip=$ip;
$ipObj->ping=0;
$ipObj->laststatus=1;
$ipObj->hostname = gethostbyaddr($ip);
$ipObj->source = "ios";
saveIp($ipObj);
}
}
function tcp_conn($ip, $service_port) {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
return false;
} else {
$result = socket_connect($socket, $ip, $service_port);
if ($result === false) {
return false;
} else {
return true;
}
socket_close($socket);
}
}
?>