equal
deleted
inserted
replaced
119 var $OS_FullName; |
119 var $OS_FullName; |
120 var $_eol_code; |
120 var $_eol_code; |
121 var $AutoAsciiExt; |
121 var $AutoAsciiExt; |
122 |
122 |
123 /* Constructor */ |
123 /* Constructor */ |
124 function ftp_base($port_mode=FALSE) { |
|
125 $this->__construct($port_mode); |
|
126 } |
|
127 |
|
128 function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) { |
124 function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) { |
129 $this->LocalEcho=$le; |
125 $this->LocalEcho=$le; |
130 $this->Verbose=$verb; |
126 $this->Verbose=$verb; |
131 $this->_lastaction=NULL; |
127 $this->_lastaction=NULL; |
132 $this->_error_array=array(); |
128 $this->_error_array=array(); |
153 $this->OS_local=FTP_OS_Unix; |
149 $this->OS_local=FTP_OS_Unix; |
154 $this->OS_remote=FTP_OS_Unix; |
150 $this->OS_remote=FTP_OS_Unix; |
155 $this->features=array(); |
151 $this->features=array(); |
156 if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; |
152 if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; |
157 elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; |
153 elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; |
|
154 } |
|
155 |
|
156 function ftp_base($port_mode=FALSE) { |
|
157 $this->__construct($port_mode); |
158 } |
158 } |
159 |
159 |
160 // <!-- --------------------------------------------------------------------------------------- --> |
160 // <!-- --------------------------------------------------------------------------------------- --> |
161 // <!-- Public functions --> |
161 // <!-- Public functions --> |
162 // <!-- --------------------------------------------------------------------------------------- --> |
162 // <!-- --------------------------------------------------------------------------------------- --> |
378 } |
378 } |
379 |
379 |
380 function pwd() { |
380 function pwd() { |
381 if(!$this->_exec("PWD", "pwd")) return FALSE; |
381 if(!$this->_exec("PWD", "pwd")) return FALSE; |
382 if(!$this->_checkCode()) return FALSE; |
382 if(!$this->_checkCode()) return FALSE; |
383 return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message); |
383 return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message); |
384 } |
384 } |
385 |
385 |
386 function cdup() { |
386 function cdup() { |
387 if(!$this->_exec("CDUP", "cdup")) return FALSE; |
387 if(!$this->_exec("CDUP", "cdup")) return FALSE; |
388 if(!$this->_checkCode()) return FALSE; |
388 if(!$this->_checkCode()) return FALSE; |
422 $this->PushError("filesize", "not supported by server"); |
422 $this->PushError("filesize", "not supported by server"); |
423 return FALSE; |
423 return FALSE; |
424 } |
424 } |
425 if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; |
425 if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; |
426 if(!$this->_checkCode()) return FALSE; |
426 if(!$this->_checkCode()) return FALSE; |
427 return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); |
427 return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message); |
428 } |
428 } |
429 |
429 |
430 function abort() { |
430 function abort() { |
431 if(!$this->_exec("ABOR", "abort")) return FALSE; |
431 if(!$this->_exec("ABOR", "abort")) return FALSE; |
432 if(!$this->_checkCode()) { |
432 if(!$this->_checkCode()) { |
442 $this->PushError("mdtm", "not supported by server"); |
442 $this->PushError("mdtm", "not supported by server"); |
443 return FALSE; |
443 return FALSE; |
444 } |
444 } |
445 if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; |
445 if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; |
446 if(!$this->_checkCode()) return FALSE; |
446 if(!$this->_checkCode()) return FALSE; |
447 $mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); |
447 $mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message); |
448 $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); |
448 $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); |
449 $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); |
449 $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); |
450 return $timestamp; |
450 return $timestamp; |
451 } |
451 } |
452 |
452 |
692 return FALSE; |
692 return FALSE; |
693 } |
693 } |
694 } |
694 } |
695 foreach($list as $k=>$v) { |
695 foreach($list as $k=>$v) { |
696 $list[$k]=$this->parselisting($v); |
696 $list[$k]=$this->parselisting($v); |
697 if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); |
697 if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); |
698 } |
698 } |
699 $ret=true; |
699 $ret=true; |
700 foreach($list as $el) { |
700 foreach($list as $el) { |
701 if($el["type"]=="d") { |
701 if($el["type"]=="d") { |
702 if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { |
702 if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { |
725 return false; |
725 return false; |
726 } |
726 } |
727 |
727 |
728 foreach($list as $k=>$v) { |
728 foreach($list as $k=>$v) { |
729 $list[$k]=$this->parselisting($v); |
729 $list[$k]=$this->parselisting($v); |
730 if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); |
730 if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); |
731 } |
731 } |
732 $ret=true; |
732 $ret=true; |
733 |
733 |
734 foreach($list as $el) { |
734 foreach($list as $el) { |
735 if ( empty($el) ) |
735 if ( empty($el) ) |
816 } |
816 } |
817 |
817 |
818 function glob_regexp($pattern,$probe) { |
818 function glob_regexp($pattern,$probe) { |
819 $sensitive=(PHP_OS!='WIN32'); |
819 $sensitive=(PHP_OS!='WIN32'); |
820 return ($sensitive? |
820 return ($sensitive? |
821 ereg($pattern,$probe): |
821 preg_match( '/' . preg_quote( $pattern, '/' ) . '/', $probe ) : |
822 eregi($pattern,$probe) |
822 preg_match( '/' . preg_quote( $pattern, '/' ) . '/i', $probe ) |
823 ); |
823 ); |
824 } |
824 } |
825 |
825 |
826 function dirlist($remote) { |
826 function dirlist($remote) { |
827 $list=$this->rawlist($remote, "-la"); |
827 $list=$this->rawlist($remote, "-la"); |
902 @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX ); |
902 @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX ); |
903 $mod_sockets = extension_loaded( 'sockets' ); |
903 $mod_sockets = extension_loaded( 'sockets' ); |
904 } |
904 } |
905 |
905 |
906 require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php"; |
906 require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php"; |
|
907 |
|
908 if ( $mod_sockets ) { |
|
909 class ftp extends ftp_sockets {} |
|
910 } else { |
|
911 class ftp extends ftp_pure {} |
|
912 } |