From 5ab3381d5fee08c0e366a234c014f4e435aabed1 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 14 Mar 2023 17:47:33 +0100 Subject: [PATCH] loop on PORT --- lib/Fred.class.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/Fred.class.php b/lib/Fred.class.php index 60ca291..50c793a 100644 --- a/lib/Fred.class.php +++ b/lib/Fred.class.php @@ -8,7 +8,7 @@ class Fred { private $gatewayPort = ''; // :1234 - private $gatewayDelay = 5; + private $gatewayDelay = 3; public function __construct () { @@ -32,15 +32,21 @@ class Fred { $url = $matches[1]; - sleep($this->gatewayDelay); + $page2 = ''; + $rounds = 0; - $page2 = file_get_contents($url); + while (empty($page2) and $rounds < 10) { + + sleep($this->gatewayDelay); + $page2 = file_get_contents($url); + } if (empty($page2)) { throw new Exception("J'ai pas pû récupérer la putain de deuxième page."); } + preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches); $ipnsKey = $matches[1]; @@ -138,15 +144,21 @@ class Fred { $url = $matches[1]; - sleep($this->gatewayDelay); + $page2 = ''; + $rounds = 0; - $page2 = file_get_contents($url); + while (empty($page2) and $rounds < 10) { + + sleep($this->gatewayDelay); + $page2 = file_get_contents($url); + } if (empty($page2)) { throw new Exception("J'ai pas pû récupérer la putain de deuxième page."); } + preg_match("`url='.*/user/([^']+)/'`isU", $page2, $matches); $gchangeId = $matches[1];