-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSD_Network.php
More file actions
33 lines (33 loc) · 974 Bytes
/
SD_Network.php
File metadata and controls
33 lines (33 loc) · 974 Bytes
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
<?php
function checkHost($host, $port) {
$check = @fsockopen($host, $port, $errorCode, $errorMessage, 1);
if ($check) {
fclose($check);
return true;
} else {
return false;
}
}
function getHostTitle($host) {
$title = '';
$url = 'http://' . $host;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode == 200) {
$matches = array();
preg_match('/<title>(.*?)<\/title>/', $response, $matches);
if (isset($matches[1])) {
$title = $matches[1];
}
}
curl_close($ch);
return $title;
}
?>