Advertisement
Guest User

Untitled

a guest
Feb 18th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1.     private function readLines($fp) {
  2.         $buffer = '';
  3.         $timeout = time() + $this->timeout;
  4.  
  5.         while (is_resource($fp) && !feof($fp)) {
  6.             $str = @fgets($fp, 515);
  7.             $buffer .= $str;
  8.  
  9.             // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
  10.             // Thanks to https://github.com/PHPMailer/PHPMailer/blob/master/class.smtp.php#L1035
  11.             if ((isset($str[3]) and $str[3] == ' ')) {
  12.                 break;
  13.             }
  14.  
  15.             // Timed-out? Log and break
  16.             $info = stream_get_meta_data($fp);
  17.             if ($info['timed_out']) {
  18.                 break;
  19.             }
  20.             // Now check if reads took too long
  21.             if ($endtime and time() > $endtime) {
  22.                 break;
  23.             }
  24.         }
  25.  
  26.         return $buffer;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement