zeg1jeux/lib/Fred.class.php

212 lines
4.8 KiB
PHP
Raw Normal View History

2022-10-21 21:26:41 +02:00
<?php
class Fred {
private $gatewayProtocol = 'http';
private $gatewayDomain = 'libra.copylaradio.com';
2022-11-17 16:53:45 +01:00
// private $gatewayDomain = 'aries.copylaradio.com';
// private $gatewayDomain = 'astroport.localhost';
2022-10-21 21:26:41 +02:00
private $gatewayPort = '1234';
private $gatewayDelay = 3;
2022-11-17 16:53:45 +01:00
private $gatewayMaxRounds = 1;
2022-10-21 21:26:41 +02:00
public function __construct () {
}
2022-11-17 16:53:45 +01:00
public function donneMoiLAdresseIPDuServeurQuiHebergeMonTiddlyWiki ($salt, $pepper) {
}
2022-10-21 21:26:41 +02:00
public function donneMoiLaPutainDeClefIPNS ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
2022-11-15 19:30:43 +01:00
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper);
2022-10-21 21:26:41 +02:00
$page1 = file_get_contents($this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query);
2022-10-21 21:26:41 +02:00
if (empty($page1)) {
2022-11-15 20:04:38 +01:00
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
2022-10-21 21:26:41 +02:00
preg_match("`url='([^']+)'`isU", $page1, $matches);
$url = $matches[1];
2022-11-17 16:53:45 +01:00
$opts2 = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
2022-11-17 16:53:45 +01:00
$context2 = stream_context_create($opts2);
$page2 = false;
$rounds = 0;
while (($page2 === false) and $rounds < $this->gatewayMaxRounds) {
sleep($this->gatewayDelay);
// echo "\n\n\nround n°" . $rounds . "\n";
$page2 = @file_get_contents($url, false, $context2);
// echo '<pre>'. print_r(htmlspecialchars($page2), true) . '</pre>';
$rounds++;
}
if ($page2 === false) {
throw new Exception("J'ai pas pû me connecter à ". $url ." pour récupérer la putain de deuxième page.");
} else if (empty($page2)) {
2022-11-15 20:04:38 +01:00
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
}
2022-10-21 21:26:41 +02:00
preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches);
$ipnsKey = $matches[1];
return $ipnsKey;
}
public function donneMoiSesPutainDeMessagesGchange ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday, $gchangeName) {
2022-10-21 21:26:41 +02:00
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
$query = 'salt='. $salt .'&pepper='. $pepper . '&messaging=' . $gchangeName;
2022-10-21 21:26:41 +02:00
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
2022-10-21 21:26:41 +02:00
$page1 = file_get_contents($url);
if (empty($page1)) {
2022-11-15 20:04:38 +01:00
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
2022-10-21 21:26:41 +02:00
// echo '<pre>'; var_dump(htmlspecialchars($page1)); echo '</pre>';
2022-10-21 21:26:41 +02:00
preg_match("`url='([^']+)'`isU", $page1, $matches);
$url = $matches[1];
2022-10-21 21:26:41 +02:00
// echo '<pre>'; var_dump($url); echo '</pre>';
2022-10-21 21:26:41 +02:00
$page2 = '';
$rounds = 0;
2022-10-21 21:26:41 +02:00
2022-11-17 16:53:45 +01:00
while (empty($page2) and $rounds < $this->gatewayMaxRounds) {
2022-10-21 21:26:41 +02:00
sleep($this->gatewayDelay);
$page2 = file_get_contents($url);
2022-11-17 16:53:45 +01:00
$rounds++;
}
if (empty($page2)) {
2022-11-15 20:04:38 +01:00
throw new Exception("J'ai pas pû récupérer la putain de deuxième page.");
2022-10-21 21:26:41 +02:00
}
// echo '<pre>'; var_dump(htmlspecialchars($page2)); echo '</pre>';
2022-10-21 21:26:41 +02:00
$json = $page2;
return json_decode($json);
}
public function donneMoiSaPutaindeG1Pub ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday) {
$salt = $prenomNom;
$pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday;
$query = 'salt='. urlencode($salt) .'&pepper='. urlencode($pepper) . '&g1pub=on';
$url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query;
// echo '<pre>'; var_dump(htmlspecialchars($url)); echo '</pre>';
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
$context = stream_context_create($opts);
2022-11-14 15:45:55 +01:00
$page1 = file_get_contents($url, false, $context);
if (empty($page1)) {
2022-11-15 20:04:38 +01:00
throw new Exception("J'ai pas pû récupérer la putain de première page.");
}
// die('<pre>' . htmlspecialchars($page1) . '</pre>');
preg_match("`url='([^']+)'`isU", $page1, $matches);
// die(
// '<pre>' . htmlspecialchars($page1) . '</pre>' .
// '<pre>' . print_r($matches, true) . '</pre>'
// );
$url = $matches[1];
// die('<pre>' . var_dump($url, true) . '</pre>');
$opts2 = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: fr\r\n",
'follow_location' => 0
)
);
$context2 = stream_context_create($opts2);
$page2 = '';
$rounds = 0;
2022-11-17 16:53:45 +01:00
while (empty($page2) and $rounds < $this->gatewayMaxRounds) {
sleep($this->gatewayDelay);
2022-11-14 15:45:55 +01:00
$page2 = file_get_contents($url, false, $context2);
2022-11-17 16:53:45 +01:00
$rounds++;
}
if (empty($page2)) {
2022-11-15 20:04:38 +01:00
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];
2022-10-21 21:26:41 +02:00
return $gchangeId;
2022-10-21 21:26:41 +02:00
}
}