Вход Регистрация
»

Название : прокси-чекер


» Описание: прокси-чекер
» Добавил: * YOBA
» Время добавления: 7 Ноября 2014 в 18:15
» Посмотров: 821
» textarea
» Рейтинг: [+0 | -0]
Комментарии [0]
  1. <?php
  2.  
  3. // Ensure that the timeouts from fsockopen don't get reported as errors (possible, depends on the php server config)
  4. error_reporting(0);
  5. // Limit the amount of proxies that can be tested at any one time
  6. $maximum_proxies_to_test = 50;
  7. // Enter a password (if required) to protect the page
  8. $password = '';
  9.  
  10. // Actual proxyjudge part of the page
  11. function return_env_variables()
  12. {
  13. echo '<pre>'."\n";
  14. foreach ($_SERVER as $header => $value )
  15. {
  16. if ((strpos($header , 'REMOTE')!== false || strpos($header , 'HTTP')!== false || strpos($header , 'REQUEST')!== false) && ( strpos($header , 'HTTP_HOST') !== 0))
  17. {
  18. echo $header.' = '.$value."\n";
  19. }
  20. }
  21. echo '</pre>';
  22. }
  23.  
  24. // Function to go away and get the page (calls through the proxy back to itself)
  25. function get_judge_page($proxy)
  26. {
  27. // Depending on the server environment, this timeout setting may not be available.
  28. $timeout = 15;
  29. $proxy_cont = '';
  30. list($proxy_host, $proxy_port) = explode(":", $proxy);
  31. $proxy_fp = fsockopen($proxy_host, $proxy_port, $errornumber, $errorstring, $timeout);
  32. if ($proxy_fp)
  33. {
  34. stream_set_timeout($proxy_fp, $timeout);
  35. fputs($proxy_fp, "GET " . $_SERVER['SCRIPT_NAME'] . "?test HTTP/1.0\r\nHost: " . $_SERVER['SERVER_NAME'] . "\r\n\r\n");
  36. while(!feof($proxy_fp))
  37. {
  38. $proxy_cont .= fread($proxy_fp,4096);
  39. }
  40. fclose($proxy_fp);
  41. $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
  42. }
  43. return $proxy_cont;
  44. }
  45.  
  46. // Check for the control string to see if it's a valid fetch of the judge
  47. function check_valid_judge_response($page)
  48. {
  49. if(strlen($page) < 5)
  50. return false;
  51. return strpos($page, 'REMOTE_ADDR') !== false;
  52. }
  53.  
  54. // Check for the IP addresses
  55. function check_anonymity($page)
  56. {
  57. if(strpos($page, $_SERVER['LOCAL_ADDR']) !== false)
  58. return false;
  59. return true;
  60. }
  61.  
  62. // Takes and tests a proxy
  63. // 0 - Bad proxy
  64. // 1 - Good (non anon) proxy
  65. // 2 - Good (anonymous) proxy
  66. function test_proxy($proxy)
  67. {
  68. $page = get_judge_page($proxy);
  69. if(!check_valid_judge_response($page))
  70. return 0;
  71. if(!check_anonymity($page))
  72. return 1;
  73. return 2;
  74. }
  75.  
  76. ////////// Main Page ////////////
  77.  
  78. // If this is a judge request, just return the environmental variables
  79. if(getenv('QUERY_STRING') == "test")
  80. {
  81. return_env_variables();
  82. }
  83. // Else check whether we have been passed a list of proxies to test or not
  84. // Should really use $_POST but it's been left as $HTTP_POST_VARS for older versions of php (3.x)
  85. elseif( (isset($HTTP_POST_VARS['action']) && $HTTP_POST_VARS['action'] === 'fred') &&
  86. (isset($HTTP_POST_VARS['proxies']) && $HTTP_POST_VARS['proxies'] != '') &&
  87. ( (strlen($password) == 0) || (isset($HTTP_POST_VARS['password']) && $HTTP_POST_VARS['password'] === $password) ))
  88. {
  89. $proxies = explode("\n", str_replace("\r", "", $HTTP_POST_VARS['proxies']), $maximum_proxies_to_test + 1);
  90.  
  91. // Set the overall time limit for the page execution to 10 mins
  92. set_time_limit(600);
  93.  
  94. // Set up some arrays to hold the results
  95. $anon_proxies = array();
  96. $nonanon_proxies = array();
  97. $bad_proxies = array();
  98.  
  99. // Loop through and test the proxies
  100. for($thisproxy = 0; $thisproxy < ($maximum_proxies_to_test > count($proxies) ? count($proxies) : $maximum_proxies_to_test); $thisproxy += 1)
  101. {
  102. $draculalol = htmlspecialchars($proxies[$thisproxy]);
  103. echo '' . $draculalol . '';
  104. flush();
  105. switch(test_proxy($proxies[$thisproxy]))
  106. {
  107. case 2:
  108. echo ' - <font color="green">Анонимная</font><br>' . "\n";
  109. $anon_proxies[count($anon_proxies)] = $proxies[$thisproxy];
  110. break;
  111. case 1:
  112. echo ' - <font color="yellow">Не анонимная</font><br>' . "\n";
  113. $nonanon_proxies[count($nonanon_proxies)] = $proxies[$thisproxy];
  114. break;
  115. case 0:
  116. echo ' - <font color="red">Не рабочая</font><br>' . "\n";
  117. $bad_proxies[count($bad_proxies)] = $proxies[$thisproxy];
  118. break;
  119. }
  120. }
  121.  
  122. echo '<pre>';
  123. echo '<br><b><font color="green" size="2">Анонимные прокси:</font></b>' . "\n";
  124. for($thisproxy = 0; $thisproxy < count($anon_proxies); $thisproxy += 1)
  125. echo $anon_proxies[$thisproxy] . "\n";
  126. echo '<br><b><font color="yellow" size="2">Не анонимные прокси:</font></b>' . "\n";
  127. for($thisproxy = 0; $thisproxy < count($nonanon_proxies); $thisproxy += 1)
  128. echo $nonanon_proxies[$thisproxy] . "\n";
  129. echo '<br><b><font color="red" size="2">Не рабочие прокси:</font></b>' . "\n";
  130. for($thisproxy = 0; $thisproxy < count($bad_proxies); $thisproxy += 1)
  131. $xek = htmlspecialchars($bad_proxies[$thisproxy]);
  132. echo $xek . "\n";
  133. echo '</pre>';
  134. }
  135. // Just a blank call of the page - show the form for the user to fill in
  136. else
  137. {
  138.  
  139. echo '<form method="POST" action="' . $_SERVER['SCRIPT_NAME'] . '">' . "\n";
  140. echo '<input type="hidden" name="action" value="fred">' . "\n";
  141. echo '<textarea name="proxies" cols=50 rows=10></textarea><br>' . "\n";
  142. if(strlen($password) > 0)
  143. echo 'Password: <input type="password" name="password" size="15"><br>' . "\n";
  144. echo '<input type="submit" value="Старт">' . "\n";
  145. echo '</form>' . "\n";
  146. }
  147. ?>
Онлайн: 4
Реклама