summaryrefslogtreecommitdiff
path: root/mirror.php
diff options
context:
space:
mode:
Diffstat (limited to 'mirror.php')
-rw-r--r--mirror.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/mirror.php b/mirror.php
index ff463f4..8a61747 100644
--- a/mirror.php
+++ b/mirror.php
@@ -8,6 +8,7 @@
$_SERVER["SCRIPT_NAME"] = '/.fancyindex/mirror.php';
// Configuration
+ini_set('default_socket_timeout', 2);
$tier0_url = 'https://repo.parabola.nu';
$mirrors_urls = [ 'https://www.parabola.nu/mirrors/status/tier/1/json'
//, 'https://www.parabola.nu/mirrors/status/tier/2/json'
@@ -40,7 +41,16 @@ if (!file_exists($root.'/'.$filename)) {
// TODO: weight by GeoIP or quality or something?
$mirrors = array();
foreach ($mirrors_urls as $mirrors_url) {
- $json = json_decode(file_get_contents($mirrors_url), true);
+ $str = file_get_contents($mirrors_url);
+ if ($str === false) {
+ error_log("REPOMIRROR Warning: read: ".$mirrors_url);
+ continue;
+ }
+ $json = json_decode($str, true);
+ if ($json === NULL) {
+ error_log("REPOMIRROR Warning: decode: ".$mirrors_url);
+ continue;
+ }
foreach ($json['urls'] as $urldata) {
if (!in_array($urldata['protocol'], ['http', 'https', 'ftp'])) { continue; }
if (strtotime($urldata['last_sync']) < $ctime) { continue; }