Make WordPress Core

Ticket #10831: 10831.diff

File 10831.diff, 2.2 KB (added by dd32, 15 years ago)

patch from darkman82

  • wp-admin/includes/class-ftp-sockets.php

     
    2525 * @link http://www.phpclasses.org/browse/package/1743.html Site
    2626 * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
    2727 */
     28
     29/**
     30 * Patched by darkman82<at>interfree.it
     31 * against http://wordpress.org/support/topic/288093 issue
     32 *
     33 */
    2834class ftp extends ftp_base {
    2935
    3036        function ftp($verb=FALSE, $le=FALSE) {
     
    7076                return $sock;
    7177        }
    7278
     79        //patched by darkman82<at>interfree.it
    7380        function _readmsg($fnction="_readmsg"){
    7481                if(!$this->_connected) {
    7582                        $this->PushError($fnction,'Connect first');
     
    7885                $result=true;
    7986                $this->_message="";
    8087                $this->_code=0;
    81                 $go=true;
    82                 do {
     88                // Read until at least ONE line is available
     89                while ( ($pos = strpos($this->_buffz, CRLF))===false ) {
    8390                        $tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
    84                         if($tmp===false) {
    85                                 $go=$result=false;
     91                        if($tmp===false){
    8692                                $this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
    87                         } else {
    88                                 $this->_message.=$tmp;
    89                                 $go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
     93                                return false;
    9094                        }
    91                 } while($go);
     95                        $this->_buffz.=$tmp;
     96                }
     97                $this->_message = substr($this->_buffz,0,$pos).CRLF;
     98                $this->_buffz = substr($this->_buffz,$pos+strlen(CRLF));
     99                if( !preg_match("/^([0-9]{3})(-.+\\1)? .+$/Us",$this->_message, $regs))
     100                        return ($this->_readmsg($fnction));
    92101                if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
    93102                $this->_code=(int)$regs[1];
    94103                return $result;
     
    100109                        return FALSE;
    101110                }
    102111                if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
     112                $this->_buffz="";
    103113                $status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
    104114                if($status===false) {
    105115                        $this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
     
    247257                }
    248258        }
    249259}
    250 ?>
     260?>
     261 No newline at end of file