$_SESSION['player_ipns'] #5

Open
qo-op wants to merge 2 commits from qo-op/zeg1jeux:fred into main
3 changed files with 200 additions and 190 deletions

View File

@ -10,52 +10,59 @@ $gchange = new Gchange();
try {
$player = $gchange->getUser($_SESSION['player_pubkey']);
$player = $gchange->getUser($_SESSION['player_pubkey']);
} catch (Exception $errMsg) {
ErrorsHandler::kaput($errMsg);
ErrorsHandler::kaput($errMsg);
}
echo '
<header>
Bienvenue '. $player->getUserName() . ' !
<!-- ('. substr($player->getUserGchangeId(), 0, 8) . ') -->
Bienvenue '. $player->getUserName() . ' !
<!-- ('. substr($player->getUserGchangeId(), 0, 8) . ') -->
</header>
<nav>
<ul>
<li id="dashboard-map">
<a href="map.php">
<span>
Carte
</span>
</a>
</li>
<li id="dashboard-map">
<a href="map.php">
<span>
Carte
</span>
</a>
</li>
<li id="dashboard-messenger">
<a href="messenger.php">
<span>
Messagerie
</span>
</a>
</li>
<li id="dashboard-messenger">
<a href="messenger.php">
<span>
Messagerie
</span>
</a>
</li>
<li id="dashboard-farfetched">
<a href="farfetched.php">
<span>
À distance ou en livraison
</span>
</a>
</li>
<li id="dashboard-farfetched">
<a href="farfetched.php">
<span>
À distance ou en livraison
</span>
</a>
</li>
<li id="dashboard-minelife">
<a href="minelife.html">
<span>
Manuel
</span>
</a>
</li>
<li id="dashboard-minelife">
<a href="minelife.html">
<span>
Manuel
</span>
</a>
</li>
<li id="dashboard-TW">
<a href="/ipns/'. $_SESSION['player_ipns'].'">
<span>
TW
</span>
</a>
</li>
</ul>

View File

@ -1,175 +1,175 @@
<?php
class Fred {
private $gatewayProtocol = 'http';
private $gatewayDomain = 'libra.copylaradio.com';
private $gatewayProtocol = 'http';
private $gatewayPort = '1234';
private $gatewayDomain = 'astroport.copylaradio.com';
private $gatewayDelay = 3;
private $gatewayPort = '1234';
public function __construct () {
private $gatewayDelay = 5;
}
public function __construct () {
public function donneMoiLaPutainDeClefIPNS ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
}
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
public function donneMoiLaPutainDeClefIPNS ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper);
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
$page1 = file_get_contents($this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query);
if (empty($page1)) {
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) .'&getipns=yes';
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
$page1 = file_get_contents($this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query);
preg_match("`url='([^']+)'`isU", $page1, $matches);
if (empty($page1)) {
$url = $matches[1];
sleep($this->gatewayDelay);
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
$page2 = file_get_contents($url);
preg_match("`url='([^']+)'`isU", $page1, $matches);
if (empty($page2)) {
$url = $matches[1];
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
}
sleep($this->gatewayDelay);
preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches);
$page2 = file_get_contents($url);
$ipnsKey = $matches[1];
if (empty($page2)) {
return $ipnsKey;
}
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
}
public function donneMoiSesPutainDeMessagesGchange ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday, $gchangeName) {
preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches);
$ipnsKey = $matches[1];
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
return $ipnsKey;
}
$query = 'salt='. $salt .'&pepper='. $pepper . '&messaging=' . $gchangeName;
public function donneMoiSesPutainDeMessagesGchange ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday, $gchangeName) {
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
$page1 = file_get_contents($url);
$query = 'salt='. $salt .'&pepper='. $pepper . '&messaging=' . $gchangeName;
if (empty($page1)) {
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
// echo '<pre>'; var_dump(htmlspecialchars($page1)); echo '</pre>';
$page1 = file_get_contents($url);
preg_match("`url='([^']+)'`isU", $page1, $matches);
if (empty($page1)) {
$url = $matches[1];
// echo '<pre>'; var_dump($url); echo '</pre>';
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
$page2 = '';
$rounds = 0;
// echo '<pre>'; var_dump(htmlspecialchars($page1)); echo '</pre>';
while (empty($page2) and $rounds < 10) {
preg_match("`url='([^']+)'`isU", $page1, $matches);
sleep($this->gatewayDelay);
$page2 = file_get_contents($url);
}
$url = $matches[1];
if (empty($page2)) {
// echo '<pre>'; var_dump($url); echo '</pre>';
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
}
// echo '<pre>'; var_dump(htmlspecialchars($page2)); echo '</pre>';
$page2 = '';
$rounds = 0;
$json = $page2;
return json_decode($json);
while (empty($page2) and $rounds < 10) {
}
public function donneMoiSaPutaindeG1Pub ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
sleep($this->gatewayDelay);
$page2 = file_get_contents($url);
}
if (empty($page2)) {
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
}
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) . '&g1pub=on';
// echo '<pre>'; var_dump(htmlspecialchars($page2)); echo '</pre>';
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
$json = $page2;
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
return json_decode($json);
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
}
$context = stream_context_create($opts);
public function donneMoiSaPutaindeG1Pub ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
$page1 = file_get_contents($url, false, $context);
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
if (empty($page1)) {
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) . '&getg1pub=yes';
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
// die('<pre>' . htmlspecialchars($page1) . '</pre>');
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
preg_match("`url='([^']+)'`isU", $page1, $matches);
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
// die(
// '<pre>' . htmlspecialchars($page1) . '</pre>' .
// '<pre>' . print_r($matches, true) . '</pre>'
// );
$context = stream_context_create($opts);
$url = $matches[1];
$page1 = file_get_contents($url, false, $context);
// die('<pre>' . var_dump($url, true) . '</pre>');
$opts2 = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
if (empty($page1)) {
$context2 = stream_context_create($opts2);
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
$page2 = '';
// die('<pre>' . htmlspecialchars($page1) . '</pre>');
$rounds = 0;
preg_match("`url='([^']+)'`isU", $page1, $matches);
while (empty($page2) and $rounds < 10) {
// die(
// '<pre>' . htmlspecialchars($page1) . '</pre>' .
// '<pre>' . print_r($matches, true) . '</pre>'
// );
sleep($this->gatewayDelay);
$url = $matches[1];
$page2 = file_get_contents($url, false, $context2);
}
// die('<pre>' . var_dump($url, true) . '</pre>');
if (empty($page2)) {
$opts2 = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
}
$context2 = stream_context_create($opts2);
preg_match("`url='.*/user/([^']+)/'`isU", $page2, $matches);
$page2 = '';
$gchangeId = $matches[1];
$rounds = 0;
return $gchangeId;
}
}
while (empty($page2) and $rounds < 10) {
sleep($this->gatewayDelay);
$page2 = file_get_contents($url, false, $context2);
}
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];
return $gchangeId;
}
}

105
login.php
View File

@ -12,76 +12,79 @@ $playerG1Id = null;
if (isset($_POST['salt'], $_POST['pepper'])) {
$fred = new Fred();
$keygen = new Keygen();
$fred = new Fred();
$keygen = new Keygen();
try {
try {
$playerG1Id = $fred->donneMoiSaPutaindeG1Pub($_POST['salt'], $_POST['pepper']);
$keygen->generatePubsec($_POST['salt'], $_POST['pepper']);
$playerG1Id = $fred->donneMoiSaPutaindeG1Pub($_POST['salt'], $_POST['pepper']);
$playerIPNS = $fred->donneMoiLaPutainDeClefIPNS($_POST['salt'], $_POST['pepper']);
} catch (Exception $errMsg) {
$keygen->generatePubsec($_POST['salt'], $_POST['pepper']);
ErrorsHandler::kaput($errMsg);
}
} catch (Exception $errMsg) {
$_SESSION['player_pubkey'] = $playerG1Id;
$gchange = new Gchange();
ErrorsHandler::kaput($errMsg);
}
try {
$_SESSION['player_pubkey'] = $playerG1Id;
$_SESSION['player_ipns'] = $playerIPNS;
$player = $gchange->getUser($_SESSION['player_pubkey']);
$gchange = new Gchange();
} catch (Exception $errMsg) {
try {
ErrorsHandler::kaput($errMsg);
}
$player = $gchange->getUser($_SESSION['player_pubkey']);
$_SESSION['player_lat'] = $player->_source->geoPoint->lat;
$_SESSION['player_lon'] = $player->_source->geoPoint->lon;
$_SESSION['radius'] = DEFAULT_RADIUS;
} catch (Exception $errMsg) {
$_SESSION['salt'] = $_POST['salt'];
$_SESSION['pepper'] = $_POST['pepper'];
ErrorsHandler::kaput($errMsg);
}
header('Location:home.php');
$_SESSION['player_lat'] = $player->_source->geoPoint->lat;
$_SESSION['player_lon'] = $player->_source->geoPoint->lon;
$_SESSION['radius'] = DEFAULT_RADIUS;
$_SESSION['salt'] = $_POST['salt'];
$_SESSION['pepper'] = $_POST['pepper'];
header('Location:home.php');
} else {
$bodyIds = 'login-page';
$webpageTitle = $games[$_SESSION['gameId']]['title'];
include_once('header.php');
$bodyIds = 'login-page';
$webpageTitle = $games[$_SESSION['gameId']]['title'];
echo '
<form method="post" action="">
include_once('header.php');
<fieldset>
<legend>Identification par Ğchange</legend>
echo '
<form method="post" action="">
<p>
<label>
Identifiant :
<input type="text" name="salt" />
</label>
</p>
<fieldset>
<legend>Identification par Ğchange</legend>
<p>
<label>
Mot de passe :
<input type="password" name="pepper" />
</label>
</p>
<p>
<label>
Identifiant :
<input type="text" name="salt" />
</label>
</p>
<p>
<input type="submit" value="Jouer" />
</p>
</fieldset>
</form>
';
include_once('footer.php');
<p>
<label>
Mot de passe :
<input type="password" name="pepper" />
</label>
</p>
<p>
<input type="submit" value="Jouer" />
</p>
</fieldset>
</form>
';
include_once('footer.php');
}