Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function readLines($fp) {
- $buffer = '';
- $timeout = time() + $this->timeout;
- while (is_resource($fp) && !feof($fp)) {
- $str = @fgets($fp, 515);
- $buffer .= $str;
- // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
- // Thanks to https://github.com/PHPMailer/PHPMailer/blob/master/class.smtp.php#L1035
- if ((isset($str[3]) and $str[3] == ' ')) {
- break;
- }
- // Timed-out? Log and break
- $info = stream_get_meta_data($fp);
- if ($info['timed_out']) {
- break;
- }
- // Now check if reads took too long
- if ($endtime and time() > $endtime) {
- break;
- }
- }
- return $buffer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement