Merge branch 'fred' into main

This commit is contained in:
fred 2023-03-14 14:37:32 +01:00
commit 32432e93ee
1 changed files with 107 additions and 107 deletions

View File

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