From 5adc180307264f56fd23701a81e4d1d150ed0da3 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 18 Nov 2022 01:42:39 +0100 Subject: [PATCH] =?UTF-8?q?Pour=20que=20=C3=A7a=20soit=20plus=20ou=20moins?= =?UTF-8?q?=20compatible=20en=20ligne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home.php | 22 ++++++++++++++++++---- lib/Fred.class.php | 23 ++++++++++++----------- lib/js/farfetched.js | 2 +- login.php | 15 ++++++++++++--- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/home.php b/home.php index c7d1606..636b264 100644 --- a/home.php +++ b/home.php @@ -3,6 +3,7 @@ require_once('config.php'); require_once('lib/Gchange.class.php'); require_once('lib/Keygen.class.php'); +require_once('lib/Fred.class.php'); $bodyIds = 'home'; include_once('header.php'); @@ -11,17 +12,30 @@ $gchange = new Gchange(); $keygen = new Keygen(); -$ipfsHost = 'http://astroport.localhost:8080'; +// $ipfsHost = 'http://astroport.localhost:8080'; +$ipfsHost = 'http://libra.copylaradio.com:8080'; + try { - $player = $gchange->getUser($_SESSION['player_pubkey']); + $player = $gchange->getUser($_SESSION['player_pubkey']); - $twLink = $ipfsHost . '/ipns/' . $keygen->getIPNSPub($_SESSION['salt'], $_SESSION['pepper']); } catch (Exception $errMsg) { - ErrorsHandler::kaput($errMsg); + ErrorsHandler::kaput($errMsg); +} + +try { + + $twLink = $ipfsHost . '/ipns/' . $keygen->getIPNSPub($_SESSION['salt'], $_SESSION['pepper']); + +} catch (Exception $errMsg) { + + $twLink = '#'; + $fred = new Fred(); + $twLink = $ipfsHost . '/ipns/' . $fred->donneMoiLaPutainDeClefIPNS($_SESSION['salt'], $_SESSION['pepper']); + } diff --git a/lib/Fred.class.php b/lib/Fred.class.php index 866881d..fcb1ffb 100644 --- a/lib/Fred.class.php +++ b/lib/Fred.class.php @@ -1,12 +1,12 @@ gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query); - + if (empty($page1)) { - throw new Exception("J'ai pas pû récupérer la putain de première page."); + throw new Exception("J'ai pas pû récupérer la putain de première page."); } preg_match("`url='([^']+)'`isU", $page1, $matches); $url = $matches[1]; + $url .= '/?'. $query; - die($url); + // die($url); $opts2 = array( 'http'=>array( 'method'=>"GET", @@ -49,7 +50,7 @@ class Fred { ) ); - echo 'fred 2'; + // echo 'fred 2'; $context2 = stream_context_create($opts2); @@ -77,7 +78,7 @@ class Fred { throw new Exception("J'ai pas pû récupérer la putain de deuxième page."); } - preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches); + preg_match("`/ipns/(.+)`is", $page2, $matches); $ipnsKey = $matches[1]; @@ -170,8 +171,8 @@ class Fred { preg_match("`url='([^']+)'`isU", $page1, $matches); // die( - // '
' . htmlspecialchars($page1) . '
' . - // '
' . print_r($matches, true) . '
' + // '
' . htmlspecialchars($page1) . '
' . + // '
' . print_r($matches, true) . '
' // ); $url = $matches[1]; diff --git a/lib/js/farfetched.js b/lib/js/farfetched.js index f3f2e86..c8623e8 100644 --- a/lib/js/farfetched.js +++ b/lib/js/farfetched.js @@ -1,6 +1,6 @@ const nodes = { gchange: [ - 'http://data.gchange.fr' + 'https://data.gchange.fr' ] } diff --git a/login.php b/login.php index cb4f24e..b1c9c87 100644 --- a/login.php +++ b/login.php @@ -11,17 +11,26 @@ $boris = '25zB1gSC7Qhwnx463cuDLDCKLRVieLAgFiPbYq6jVHG9'; $playerG1Id = null; if (isset($_POST['salt'], $_POST['pepper'])) { - - $keygen = new Keygen(); try { + $keygen = new Keygen(); + $playerG1Id = $keygen->getG1Pub($_POST['salt'], $_POST['pepper']); $keygen->generatePubsec($_POST['salt'], $_POST['pepper']); } catch (Exception $errMsg) { - ErrorsHandler::kaput($errMsg); + try { + + $fred = new Fred(); + + $playerG1Id = $fred->donneMoiSaPutainDeG1Pub($_POST['salt'], $_POST['pepper']); + + } catch (Exception $errMsg) { + + ErrorsHandler::kaput($errMsg); + } } $_SESSION['salt'] = $_POST['salt'];