main #6
71
home.php
71
home.php
|
@ -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>
|
||||
|
||||
|
||||
|
|
|
@ -2,63 +2,63 @@
|
|||
|
||||
class ErrorsHandler {
|
||||
|
||||
public function __construct () {
|
||||
public function __construct () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static public function kaput ($errorMsgs) {
|
||||
static public function kaput ($errorMsgs) {
|
||||
|
||||
|
||||
ob_get_clean(); // to prevent error message to display inside an HTML container (case of error generated by get method calls)
|
||||
ob_get_clean(); // to prevent error message to display inside an HTML container (case of error generated by get method calls)
|
||||
|
||||
|
||||
if (!is_array($errorMsgs)) {
|
||||
if (!is_array($errorMsgs)) {
|
||||
|
||||
$errorMsgs = explode("\n", $errorMsgs);
|
||||
}
|
||||
$errorMsgs = explode("\n", $errorMsgs);
|
||||
}
|
||||
|
||||
echo '<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>'. _('Erreur critique') . '</title>
|
||||
echo '<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>'. ('Erreur critique') . '</title>
|
||||
|
||||
<style>
|
||||
<style>
|
||||
|
||||
div {
|
||||
div {
|
||||
|
||||
overflow: auto;
|
||||
word-wrap: break-word;
|
||||
background-color: hsl(0, 100%, 69%);
|
||||
color: hsl(0, 100%, 19%);
|
||||
margin: 1em;
|
||||
padding: 1em;
|
||||
border-radius: 1em;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: calc(100% - 4em);
|
||||
max-height: calc(100vh - 4em);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
overflow: auto;
|
||||
word-wrap: break-word;
|
||||
background-color: hsl(0, 100%, 69%);
|
||||
color: hsl(0, 100%, 19%);
|
||||
margin: 1em;
|
||||
padding: 1em;
|
||||
border-radius: 1em;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: calc(100% - 4em);
|
||||
max-height: calc(100vh - 4em);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>';
|
||||
<body>
|
||||
<div>';
|
||||
|
||||
|
||||
foreach ($errorMsgs as $msg) {
|
||||
foreach ($errorMsgs as $msg) {
|
||||
|
||||
echo '<pre>' . print_r($msg, true) . '</pre>';
|
||||
}
|
||||
echo '<pre>' . print_r($msg, true) . '</pre>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
echo '
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
die;
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,175 +1,159 @@
|
|||
<?php
|
||||
|
||||
class Fred {
|
||||
|
||||
private $gatewayProtocol = 'http';
|
||||
|
||||
private $gatewayDomain = 'libra.copylaradio.com';
|
||||
private $gatewayProtocol = 'https';
|
||||
|
||||
private $gatewayPort = '1234';
|
||||
private $gatewayDomain = 'astroport.copylaradio.com';
|
||||
|
||||
private $gatewayDelay = 3;
|
||||
private $gatewayPort = ''; // :1234
|
||||
|
||||
public function __construct () {
|
||||
private $gatewayDelay = 6;
|
||||
|
||||
}
|
||||
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)) {
|
||||
$urlipns = $matches[1];
|
||||
|
||||
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
|
||||
}
|
||||
$page2 = '';
|
||||
$rounds = 0;
|
||||
|
||||
preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches);
|
||||
while (empty($page2) and $rounds < 10) {
|
||||
|
||||
$ipnsKey = $matches[1];
|
||||
sleep($this->gatewayDelay);
|
||||
$page2 = file_get_contents($urlipns);
|
||||
}
|
||||
|
||||
return $ipnsKey;
|
||||
}
|
||||
if (empty($page2)) {
|
||||
|
||||
public function donneMoiSesPutainDeMessagesGchange ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday, $gchangeName) {
|
||||
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
|
||||
}
|
||||
|
||||
$ClearText = preg_replace( "/\n\s+/", "\n", rtrim(html_entity_decode(strip_tags($page2))) );
|
||||
preg_match("`url='([^']+)'`isU", $ClearText, $matches);
|
||||
|
||||
$salt = $prenomNom;
|
||||
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
|
||||
$ipnsKey = $matches[1];
|
||||
|
||||
$query = 'salt='. $salt .'&pepper='. $pepper . '&messaging=' . $gchangeName;
|
||||
return $ipnsKey;
|
||||
}
|
||||
|
||||
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
|
||||
public function donneMoiSesPutainDeMessagesGchange ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday, $gchangeName) {
|
||||
|
||||
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
|
||||
|
||||
$page1 = file_get_contents($url);
|
||||
$salt = $prenomNom;
|
||||
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
|
||||
|
||||
if (empty($page1)) {
|
||||
$query = 'salt='. $salt .'&pepper='. $pepper . '&messaging=' . $gchangeName;
|
||||
|
||||
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);
|
||||
|
||||
// echo '<pre>'; var_dump(htmlspecialchars($page1)); echo '</pre>';
|
||||
if (empty($page1)) {
|
||||
|
||||
preg_match("`url='([^']+)'`isU", $page1, $matches);
|
||||
throw new Exception("J'ai pas pû récupérer la putain de première page.");
|
||||
}
|
||||
|
||||
$url = $matches[1];
|
||||
|
||||
// echo '<pre>'; var_dump($url); echo '</pre>';
|
||||
// echo '<pre>'; var_dump(htmlspecialchars($page1)); echo '</pre>';
|
||||
|
||||
$page2 = '';
|
||||
$rounds = 0;
|
||||
preg_match("`url='([^']+)'`isU", $page1, $matches);
|
||||
|
||||
while (empty($page2) and $rounds < 10) {
|
||||
$urlmessages = $matches[1];
|
||||
|
||||
sleep($this->gatewayDelay);
|
||||
$page2 = file_get_contents($url);
|
||||
}
|
||||
// echo '<pre>'; var_dump($urli); echo '</pre>';
|
||||
|
||||
if (empty($page2)) {
|
||||
$page2 = '';
|
||||
$rounds = 0;
|
||||
|
||||
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
|
||||
}
|
||||
|
||||
// echo '<pre>'; var_dump(htmlspecialchars($page2)); echo '</pre>';
|
||||
while (empty($page2) and $rounds < 10) {
|
||||
|
||||
$json = $page2;
|
||||
|
||||
return json_decode($json);
|
||||
sleep($this->gatewayDelay);
|
||||
$page2 = file_get_contents($urlmessages);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function donneMoiSaPutaindeG1Pub ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
|
||||
if (empty($page2)) {
|
||||
|
||||
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
|
||||
}
|
||||
|
||||
$salt = $prenomNom;
|
||||
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
|
||||
// echo '<pre>'; var_dump(htmlspecialchars($page2)); echo '</pre>';
|
||||
|
||||
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) . '&g1pub=on';
|
||||
$json = $page2;
|
||||
|
||||
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
|
||||
return json_decode($json);
|
||||
|
||||
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
|
||||
}
|
||||
|
||||
$opts = array(
|
||||
'http'=>array(
|
||||
'method'=>"GET",
|
||||
'header'=>"Accept-language: fr\r\n",
|
||||
'follow_location' => 0
|
||||
)
|
||||
);
|
||||
public function donneMoiSaPutaindeG1Pub ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
$page1 = file_get_contents($url, false, $context);
|
||||
$salt = $prenomNom;
|
||||
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
|
||||
|
||||
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) . '&getg1pub=yes';
|
||||
|
||||
if (empty($page1)) {
|
||||
$urlj = $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($urlj)); echo '</pre>';
|
||||
|
||||
// die('<pre>' . htmlspecialchars($page1) . '</pre>');
|
||||
$opts = array(
|
||||
'http'=>array(
|
||||
'method'=>"GET",
|
||||
'header'=>"Accept-language: fr\r\n",
|
||||
'follow_location' => 0
|
||||
)
|
||||
);
|
||||
|
||||
preg_match("`url='([^']+)'`isU", $page1, $matches);
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
// die(
|
||||
// '<pre>' . htmlspecialchars($page1) . '</pre>' .
|
||||
// '<pre>' . print_r($matches, true) . '</pre>'
|
||||
// );
|
||||
$page1 = file_get_contents($urlj, false, $context);
|
||||
|
||||
$url = $matches[1];
|
||||
|
||||
// die('<pre>' . var_dump($url, true) . '</pre>');
|
||||
if (empty($page1)) {
|
||||
|
||||
$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 première page.");
|
||||
}
|
||||
|
||||
$context2 = stream_context_create($opts2);
|
||||
// die('<pre>' . htmlspecialchars($page1) . '</pre>');
|
||||
|
||||
$page2 = '';
|
||||
preg_match("`url='([^']+)'`isU", $page1, $matches);
|
||||
|
||||
$rounds = 0;
|
||||
// die(
|
||||
// '<pre>' . htmlspecialchars($page1) . '</pre>' .
|
||||
// '<pre>' . print_r($matches, true) . '</pre>'
|
||||
// );
|
||||
|
||||
while (empty($page2) and $rounds < 10) {
|
||||
$urlg1pub = $matches[1];
|
||||
|
||||
sleep($this->gatewayDelay);
|
||||
$page2 = '';
|
||||
sleep($this->gatewayDelay);
|
||||
$page2 = file_get_contents($urlg1pub);
|
||||
|
||||
$page2 = file_get_contents($url, false, $context2);
|
||||
}
|
||||
if (empty($page2)) {
|
||||
|
||||
if (empty($page2)) {
|
||||
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
|
||||
}
|
||||
|
||||
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
|
||||
}
|
||||
$ClearText = preg_replace( "/\n\s+/", "\n", rtrim(html_entity_decode(strip_tags($page2))) );
|
||||
preg_match("`url='([^']+)'`isU", $ClearText, $matches);
|
||||
|
||||
preg_match("`url='.*/user/([^']+)/'`isU", $page2, $matches);
|
||||
$gchangeId = $matches[1];
|
||||
|
||||
$gchangeId = $matches[1];
|
||||
|
||||
return $gchangeId;
|
||||
}
|
||||
}
|
||||
return $gchangeId;
|
||||
}
|
||||
}
|
||||
|
|
106
login.php
106
login.php
|
@ -12,76 +12,80 @@ $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']);
|
||||
sleep(3);
|
||||
$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');
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue