Advertisement
Ostap34PHP

Untitled

Jul 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1.     /**
  2.      * Get current proxy
  3.      */
  4.     public static function getProxy()
  5.     {
  6.         $last_line = file_get_contents(__DIR__ . '/../config/current_proxy_line.txt');
  7.         $allow_next_line = false;
  8.  
  9.         $handle = fopen(__DIR__ . "/../config/proxy_list.txt", "r");
  10.  
  11.         $line_number = 0;
  12.         //check any lines of file
  13.         while (($line = fgets($handle))) {
  14.             $line_number++;
  15.  
  16.             if (empty($line)) {
  17.                 $last_line = 0;
  18.             }
  19.  
  20.             //bug fix with 0
  21.             if ($last_line == 0) {
  22.                 $allow_next_line = true;
  23.             }
  24.  
  25.  
  26.             if ($allow_next_line) {
  27.                 return $line;
  28.                 file_put_contents(__DIR__ . '/../config/current_proxy_line.txt', $line_number);
  29.                 break;
  30.             }
  31.  
  32.             //if line = current line from file
  33.             if ($line_number == $last_line) {
  34.                 $allow_next_line = true;
  35.             }
  36.         }
  37.  
  38.         fclose($handle);
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement