-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsites.php
More file actions
63 lines (53 loc) · 1.9 KB
/
sites.php
File metadata and controls
63 lines (53 loc) · 1.9 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
// Only use via htmx include
$_SERVER['HTTP_HX_REQUEST'] ?? exit();
function multiCurl(array $urls): array {
$multi_handle = curl_multi_init();
$handles = [];
$options = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
CURLOPT_CONNECTTIMEOUT => 2, // Fail fast if the server doesn't respond
CURLOPT_TIMEOUT => 5, // Total limit for the request
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYSTATUS => false,
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4
];
foreach($urls as $i => $url) {
$handles[$i] = curl_init($url);
curl_setopt_array($handles[$i], $options);
curl_multi_add_handle($multi_handle, $handles[$i]);
}
$running = null;
do {
curl_multi_exec($multi_handle, $running);
curl_multi_select($multi_handle);
} while ($running > 0);
$url_status = [];
foreach ($urls as $i => $url) {
$url_status[] = [
'site' => $urls[$i],
'status' => curl_getinfo($handles[$i], CURLINFO_HTTP_CODE),
'nice_name' => parse_url($url, PHP_URL_HOST),
];
}
curl_multi_close($multi_handle);
return $url_status;
}
$urls = array_map(
fn($a) => "https://{$a}.mozfr.org",
['blog', 'firefoxos', 'forums', 'gandi', 'nightly', 'notreinternet', 'piwik',
'planete', 'tech', 'transvision', 'transvision-beta', 'wiki', 'www',]
);
?>
<?php foreach (multiCurl($urls) as $site): ?>
<li>
<span
class="<?php echo in_array($site['status'], [200, 301]) ? 'good' : 'bad' ; echo " " . $site['status'];?>"
title="Code : <?php echo (string) $site['status']; ?>"
>●</span>
<?=$site['nice_name']; ?>
</li>
<?php endforeach; ?>