From 04d951a1291e2c98701ede000a59a91503bf8d52 Mon Sep 17 00:00:00 2001 From: Boris Date: Tue, 15 Nov 2022 19:46:02 +0100 Subject: [PATCH] =?UTF-8?q?Ouch,=20c'=C3=A9tait=20sal=C3=A9=20(mais=20pas?= =?UTF-8?q?=20poivr=C3=A9,=20loool)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Fred.class.php | 57 ++++++++++++++++++++++++++++++++++------------ login.php | 2 +- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/lib/Fred.class.php b/lib/Fred.class.php index ce0da5b..d126531 100644 --- a/lib/Fred.class.php +++ b/lib/Fred.class.php @@ -21,17 +21,25 @@ class Fred { $query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper); - $page1 = @file_get_contents($this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query) - or die('

On a fait du sale.

'); + $page1 = file_get_contents($this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query); + if (empty($page1)) { + + throw Exception("J'ai pas pû récupérer la putain de première page."); + } + preg_match("`url='([^']+)'`isU", $page1, $matches); $url = $matches[1]; sleep($this->gatewayDelay); - $page2 = @file_get_contents($url) - or die('

On a chié dans la colle.

'); + $page2 = file_get_contents($url); + + if (empty($page2)) { + + throw Exception("J'ai pas pû récupérer la putain de deuxième page."); + } preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches); @@ -52,8 +60,12 @@ class Fred { // echo '
'; var_dump(htmlspecialchars($url)); echo '
'; - $page1 = file_get_contents($url) - or die('

On a fait du sale.

'); + $page1 = file_get_contents($url); + + if (empty($page1)) { + + throw Exception("J'ai pas pû récupérer la putain de première page."); + } // echo '
'; var_dump(htmlspecialchars($page1)); echo '
'; @@ -64,11 +76,17 @@ class Fred { // echo '
'; var_dump($url); echo '
'; $page2 = ''; + $rounds = 0; - while (empty($page2)) { + while (empty($page2) and $rounds < 10) { sleep($this->gatewayDelay); - $page2 = @file_get_contents($url); + $page2 = file_get_contents($url); + } + + if (empty($page2)) { + + throw Exception("J'ai pas pû récupérer la putain de deuxième page."); } // echo '
'; var_dump(htmlspecialchars($page2)); echo '
'; @@ -85,7 +103,7 @@ class Fred { $salt = $prenomNom; $pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday; - $query = 'salt='. $salt .'&pepper='. $pepper . '&g1pub=on'; + $query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) . '&g1pub=on'; $url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query; @@ -101,9 +119,14 @@ class Fred { $context = stream_context_create($opts); - $page1 = file_get_contents($url, false, $context); + + if (empty($page1)) { + + throw Exception("J'ai pas pû récupérer la putain de première page."); + } + // die('
' . htmlspecialchars($page1) . '
'); preg_match("`url='([^']+)'`isU", $page1, $matches); @@ -117,8 +140,6 @@ class Fred { // die('
' . var_dump($url, true) . '
'); - $page2 = ''; - $opts2 = array( 'http'=>array( 'method'=>"GET", @@ -129,20 +150,26 @@ class Fred { $context2 = stream_context_create($opts2); - sleep(3); + $page2 = ''; - while (empty($page2)) { + $rounds = 0; + + while (empty($page2) and $rounds < 10) { sleep($this->gatewayDelay); $page2 = file_get_contents($url, false, $context2); } + if (empty($page2)) { + + throw Exception("J'ai pas pû récupérer la putain de deuxième page."); + } + preg_match("`url='.*/user/([^']+)/'`isU", $page2, $matches); $gchangeId = $matches[1]; return $gchangeId; - } } \ No newline at end of file diff --git a/login.php b/login.php index 55f5498..40d56bd 100644 --- a/login.php +++ b/login.php @@ -20,7 +20,7 @@ if (isset($_POST['salt'], $_POST['pepper'])) { $playerG1Id = $fred->donneMoiSaPutaindeG1Pub($_POST['salt'], $_POST['pepper']); } catch (Exception $errMsg) { - + ErrorsHandler::kaput($errMsg); }