Guest User

Untitled

a guest
Feb 4th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 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 $id => $proxy) {
  28. $proxy = trim( $proxy );
  29. $tmp = explode( ':', $proxy );
  30. $ipaddr = $tmp[0];
  31. $port = $tmp[1];
  32. $s = non_blocking_connect( $ipaddr, $port, $errno = '', $errstr = '', $async_connect_timeout );
  33.  
  34. if ($s) {
  35. $sockets[$id] = $s;
  36. }
  37.  
  38. usleep( 5000 );
  39. }
  40.  
  41.  
  42. while (count( $sockets )) {
  43. $read = $write = $sockets;
  44. $n = socket_select( $read = null, $write, $_e = null, 0, $async_connect_timeout );
  45.  
  46. if ($n === false) {
  47. break;
  48. }
  49.  
  50.  
  51. if (0 < $n) {
  52. foreach ($write as $w) {
  53. $id = array_search( $w, $sockets );
  54. $str = '';
  55. @socket_set_option( $w, SOL_SOCKET, SO_SNDTIMEO, array( 'sec' => 0, 'usec' => 0 ) );
  56. $sent = @socket_write( $w, $str, 1 );
  57.  
  58. if ($sent === false) {
  59. $errno = socket_last_error( $w );
  60. $errstr = socket_strerror( $errno );
  61. $status[$id] = ( . '[' ) . $errno . '] ' . $errstr;
  62. } else {
  63. $status[$id] = 'OK';
  64. }
  65.  
  66. socket_close( $w );
  67. unset( $sockets[$id] );
  68. }
  69. } else {
  70. $id = 0;
  71. foreach ($sockets as $id => $s) {
  72. $status[$id] = 'timed out';
  73. }
  74.  
  75. break;
  76. }
  77. }
  78.  
  79. $sub_process = array( );
  80. $id = 0;
  81. foreach ($proxies as $id => $proxy) {
  82. $proxy = trim( $proxy );
  83.  
  84. if ($debug_mode == 'Y') {
  85. echo ( . 'connect() ' . $proxy . ' ' ) . $status[$id] . '<br>';
  86. ob_flush( );
  87. flush( );
  88. }
  89.  
  90.  
  91. if ($status[$id] == 'OK') {
  92. $sub_process[] = $proxy;
  93. }
  94. }
  95.  
  96. return $sub_process;
  97. }
  98.  
  99. function non_blocking_connect($ip, &$port, &$errno, $errstr, $async_connect_timeout) {
  100. $sock = socket_create( AF_INET, SOCK_STREAM, 6 );
  101.  
  102. if (socket_set_nonblock( $sock )) {
  103. socket_set_option( $sock, SOL_SOCKET, SO_SNDTIMEO, array( 'sec' => 0, 'usec' => $async_connect_timeout ) );
  104. $s = @socket_connect( $sock, $ip, $port );
  105.  
  106. if (( $s || socket_last_error( ) == EINPROGRESS )) {
  107. $errno = EINPROGRESS;
  108. return $sock;
  109. }
  110. }
  111.  
  112. $errno = socket_last_error( $sock );
  113. $errstr = socket_strerror( $errno );
  114. socket_close( $sock );
  115. return false;
  116. }
  117. ....................................................
  118. .............................
  119. .............
Advertisement
Add Comment
Please, Sign In to add comment