Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. <?php
  2. $forumId = 51; // Par exemple 51 (18-25), trouvable dans l'URL du forum
  3. $forumSlug = "blabla-18-25-ans"; // Trouvable à la fin de l'URL de la liste des sujets d'un forum
  4. $username = "Votre pseudo";
  5. $userpassword = "Votre mot de passe";
  6. $message = <<<EOF
  7.  
  8. first
  9.  
  10. EOF;
  11.  
  12. function query(string $uri, array $args = [], string $method = "GET") {
  13. $ts = date("c");
  14. $signature = "550c04bf5cb2b\n$ts\n$method\napi.jeuxvideo.com\n/v4/$uri\n";
  15. $signature = hash_hmac("sha256", $signature, "d84e9e5f191ea4ffc39c22d11c77dd6c");
  16.  
  17. $header = "PartnerKey=550c04bf5cb2b, Signature=$signature, Timestamp=$ts";
  18.  
  19. $curl = curl_init();
  20. curl_setopt($curl, CURLOPT_URL, "https://api.jeuxvideo.com/v4/$uri");
  21. if (!empty($args))
  22. curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args));
  23. if ($method != "GET")
  24. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
  25. curl_setopt($curl, CURLOPT_HTTPHEADER, ["Jvc-Authorization: $header", "Content-Type: application/json"]);
  26. curl_setopt($curl, CURLOPT_USERAGENT, "JeuxVideo-Android/202");
  27. curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  28. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  29. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  30. curl_setopt($curl, CURLOPT_HEADER, true);
  31. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  32. $result = curl_exec($curl);
  33. curl_close($curl);
  34.  
  35. return $result;
  36. }
  37.  
  38. $page = query("accounts/login", ["alias" => $username, "password" => $userpassword], "POST");
  39. preg_match("`coniunctio=(.+);`isU", $page, $coniunctio);
  40. if (!isset($coniunctio[1]) || empty($coniunctio[1]))
  41. exit("Identifiants incorrects :(\n");
  42.  
  43. echo "Hello world.\n";
  44.  
  45. $curl = curl_init();
  46. curl_setopt($curl, CURLOPT_COOKIE, "coniunctio={$coniunctio[1]}");
  47. curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");
  48. curl_setopt($curl, CURLOPT_ENCODING, "gzip");
  49. curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  50. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  51.  
  52. $list = [];
  53.  
  54. while(1) {
  55. curl_setopt($curl, CURLOPT_POST, false);
  56. curl_setopt($curl, CURLOPT_URL, "http://api.jeuxvideo.com/forums/0-$forumId-0-1-0-1-0-$forumSlug.htm");
  57. $page = curl_exec($curl);
  58.  
  59. preg_match_all("`<a href=\"(.+)\" class=\"a-topic\">`isU", $page, $topics);
  60. $topics = $topics[1];
  61. unset($topics[0]);
  62. $topics = array_values($topics);
  63.  
  64. preg_match_all("`<span class=\"nb-comm-topic\">\((.+)\)</span>`isU", $page, $responses);
  65. $responses = $responses[1];
  66. unset($responses[0]);
  67. $responses = array_values($responses);
  68.  
  69. foreach ($topics as $id=>$topic) {
  70. if (!in_array($topic, $list) && $responses[$id] == 0) {
  71. $topicId = explode("-", $topic)[2];
  72. curl_setopt($curl, CURLOPT_URL, "http://api.jeuxvideo.com/forums/create_message.php?id_topic=$topicId");
  73. $page = curl_exec($curl);
  74. $tokens = [];
  75.  
  76. $tokens = [];
  77. preg_match_all("`name=\"fs_(.+)\" value=\"(.+)\"/>`isU", $page, $tokensArray);
  78. for ($i = 0; $i <= count($tokensArray[1])-1; $i++)
  79. $tokens["fs_{$tokensArray[1][$i]}"] = $tokensArray[2][$i];
  80.  
  81. $post = array_merge($tokens, ["form_alias_rang" => 1, "message_topic" => "first"]);
  82. curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
  83. curl_exec($curl);
  84. $list[] = $topic;
  85.  
  86. sleep(10); // Délai minimum entre chaque message
  87. break;
  88. }
  89. }
  90.  
  91. usleep(100000); // Pour éviter de dos jvc
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement