Advertisement
Guest User

Untitled

a guest
Sep 16th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for SourceGuardian & phpSHIELD)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. function multi_thread($proxies) {
  15. global $async_connect_timeout;
  16. global $sub_process;
  17. global $debug_mode;
  18.  
  19. $status = array( );
  20. $sockets = array( );
  21.  
  22. if (( !is_array( $proxies ) || count( $proxies ) < 1 )) {
  23. return false;
  24. }
  25.  
  26. $id = 0;
  27. foreach ($proxies as $proxy) {
  28. $id = ;
  29. $proxy = trim( $proxy );
  30. $tmp = explode( ':', $proxy );
  31. $ipaddr = $tmp[0];
  32. $port = $tmp[1];
  33. $s = non_blocking_connect( $ipaddr, $port, $errno = '', $errstr = '', $async_connect_timeout );
  34.  
  35. if ($s) {
  36. $sockets[$id] = $s;
  37. }
  38.  
  39. usleep( 5000 );
  40. }
  41.  
  42.  
  43. while (count( $sockets )) {
  44. $read = $write = $sockets;
  45. $n = socket_select( $read = null, $write, $_e = null, 0, $async_connect_timeout );
  46.  
  47. if ($n === false) {
  48. break;
  49. }
  50.  
  51.  
  52. if (0 < $n) {
  53. foreach ($write as $w) {
  54. $id = array_search( $w, $sockets );
  55. $str = '';
  56. @socket_set_option( $w, SOL_SOCKET, SO_SNDTIMEO, array( 'sec' => 0, 'usec' => 0 ) );
  57. $sent = @socket_write( $w, $str, 1 );
  58.  
  59. if ($sent === false) {
  60. $errno = socket_last_error( $w );
  61. $errstr = socket_strerror( $errno );
  62. $status[$id] = ( . '[' ) . $errno . '] ' . $errstr;
  63. } else {
  64. $status[$id] = 'OK';
  65. }
  66.  
  67. socket_close( $w );
  68. unset( $sockets[$id] );
  69. }
  70. } else {
  71. $id = 0;
  72. foreach ($sockets as $s) {
  73. $id = ;
  74. $status[$id] = 'timed out';
  75. }
  76.  
  77. break;
  78. }
  79. }
  80.  
  81. $sub_process = array( );
  82. $id = 0;
  83. foreach ($proxies as $proxy) {
  84. $id = ;
  85. $proxy = trim( $proxy );
  86.  
  87. if ($debug_mode == 'Y') {
  88. echo ( . 'connect() ' . $proxy . ' ' ) . $status[$id] . '<br>';
  89. ob_flush( );
  90. flush( );
  91. }
  92.  
  93.  
  94. if ($status[$id] == 'OK') {
  95. $sub_process[] = $proxy;
  96. }
  97. }
  98.  
  99. return $sub_process;
  100. }
  101.  
  102. function non_blocking_connect($ip, &$port, &$errno, $errstr, $async_connect_timeout) {
  103. $sock = socket_create( AF_INET, SOCK_STREAM, 6 );
  104.  
  105. if (socket_set_nonblock( $sock )) {
  106. socket_set_option( $sock, SOL_SOCKET, SO_SNDTIMEO, array( 'sec' => 0, 'usec' => $async_connect_timeout ) );
  107. $s = @socket_connect( $sock, $ip, $port );
  108.  
  109. if (( $s || socket_last_error( ) == EINPROGRESS )) {
  110. $errno = EINPROGRESS;
  111. return $sock;
  112. }
  113. }
  114.  
  115. $errno = socket_last_error( $sock );
  116. $errstr = socket_strerror( $errno );
  117. socket_close( $sock );
  118. return false;
  119. }
  120. ...............................................................
  121. ....................................
  122. .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement