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."); } preg_match("`url='([^']+)'`isU", $page1, $matches); $url = $matches[1]; $opts2 = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: fr\r\n", 'follow_location' => 0 ) ); $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 '
'. print_r(htmlspecialchars($page2), true) . '
'; $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)) { throw new Exception("J'ai pas pû récupérer la putain de deuxième page."); } preg_match("`url='.*/ipns/([^']+)'`isU", $page2, $matches); $ipnsKey = $matches[1]; return $ipnsKey; } public function donneMoiSesPutainDeMessagesGchange ($prenomNom, $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday, $gchangeName) { $salt = $prenomNom; $pepper = $nomDuChienSuivieDeLaDateDeNaissanceDeJohnnyHallyday; $query = 'salt='. $salt .'&pepper='. $pepper . '&messaging=' . $gchangeName; $url = $this->gatewayProtocol . '://'. $this->gatewayDomain .':' . $this->gatewayPort . '/?' . $query; // echo '
'; var_dump(htmlspecialchars($url)); echo '
'; $page1 = file_get_contents($url); if (empty($page1)) { throw new Exception("J'ai pas pû récupérer la putain de première page."); } // echo '
'; var_dump(htmlspecialchars($page1)); echo '
'; preg_match("`url='([^']+)'`isU", $page1, $matches); $url = $matches[1]; // echo '
'; var_dump($url); echo '
'; $page2 = ''; $rounds = 0; while (empty($page2) and $rounds < $this->gatewayMaxRounds) { sleep($this->gatewayDelay); $page2 = file_get_contents($url); $rounds++; } if (empty($page2)) { throw new Exception("J'ai pas pû récupérer la putain de deuxième page."); } // echo '
'; var_dump(htmlspecialchars($page2)); echo '
'; $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 '
'; var_dump(htmlspecialchars($url)); echo '
'; $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: fr\r\n", 'follow_location' => 0 ) ); $context = stream_context_create($opts); $page1 = file_get_contents($url, false, $context); if (empty($page1)) { throw new Exception("J'ai pas pû récupérer la putain de première page."); } // die('
' . htmlspecialchars($page1) . '
'); preg_match("`url='([^']+)'`isU", $page1, $matches); // die( // '
' . htmlspecialchars($page1) . '
' . // '
' . print_r($matches, true) . '
' // ); $url = $matches[1]; // die('
' . var_dump($url, true) . '
'); $opts2 = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: fr\r\n", 'follow_location' => 0 ) ); $context2 = stream_context_create($opts2); $page2 = ''; $rounds = 0; while (empty($page2) and $rounds < $this->gatewayMaxRounds) { sleep($this->gatewayDelay); $page2 = file_get_contents($url, false, $context2); $rounds++; } 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; } }