[Easymod-cvs] easymod2/mods/easymod/em_includes em_ftp.php,1.5,1.6 em_modio.php,1.5,1.6
Status: Beta
Brought to you by:
wgeric
From: Eric F. <wg...@us...> - 2005-07-08 00:23:06
|
Update of /cvsroot/easymod/easymod2/mods/easymod/em_includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5248/mods/easymod/em_includes Modified Files: em_ftp.php em_modio.php Log Message: ftp bug fixes, ended up making it so that it deletes the file before moving it into place, this could cause problems Index: em_ftp.php =================================================================== RCS file: /cvsroot/easymod/easymod2/mods/easymod/em_includes/em_ftp.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** em_ftp.php 7 Jul 2005 17:14:14 -0000 1.5 --- em_ftp.php 8 Jul 2005 00:22:56 -0000 1.6 *************** *** 678,695 **** if (!$fp) { $this->_debug_print("Error : Cannot read file \"".$localfile."\"\n"); ! $this->_debug_print("Error : PUT command failed\n"); return FALSE; } if (!$this->_type($mode)) { ! $this->_debug_print("Error : PUT command failed\n"); return FALSE; } if (!($string = $this->_pasv())) { ! $this->_debug_print("Error : PUT command failed\n"); return FALSE; } $this->_putcmd("STOR", $remotefile); --- 678,698 ---- if (!$fp) { $this->_debug_print("Error : Cannot read file \"".$localfile."\"\n"); ! $this->_debug_print("Error : PUT1 command failed\n"); return FALSE; } if (!$this->_type($mode)) { ! $this->_debug_print("Error : PUT2 command failed\n"); return FALSE; } if (!($string = $this->_pasv())) { ! $this->_debug_print("Error : PUT3 command failed\n"); return FALSE; } + // delete the old file and then move on + $this->ftp_delete($remotefile); + $this->_putcmd("STOR", $remotefile); *************** *** 697,701 **** if (!$sock_data || !$this->_ok()) { $this->_debug_print("Error : Cannot connect to remote host\n"); ! $this->_debug_print("Error : PUT command failed\n"); return FALSE; } --- 700,704 ---- if (!$sock_data || !$this->_ok()) { $this->_debug_print("Error : Cannot connect to remote host\n"); ! $this->_debug_print("Error : PUT4 command failed\n"); return FALSE; } *************** *** 711,716 **** $response = $this->_ok(); if (!$response) { ! $this->_debug_print("Error : PUT command failed\n"); } return $response; } --- 714,734 ---- $response = $this->_ok(); if (!$response) { ! $this->_debug_print("Error : PUT5 command failed\n"); ! ! // try deleting the file and then moving it into place after that ! if ( $this->ftp_delete($remotefile) ) ! { ! $this->_putcmd("STOR", $remotefile); ! $response = $this->_ok(); ! if (!$response) { ! $this->_debug_print("Error : PUT6 command failed\n"); ! } ! } ! else ! { ! $this->_debug_print("Error : DELE command failed\n"); ! } } + return $response; } *************** *** 1051,1055 **** else { ! if ( @ftp_chmod($this->ftp_conn_id, $file, $perms) ) { return true; --- 1069,1074 ---- else { ! $perms = 0 . intval($perms); ! if ( ftp_chmod($this->ftp_conn_id, $perms, $file) ) { return true; *************** *** 1058,1062 **** { $chmod_cmd = 'CHMOD ' . $perms . ' ' .$file; ! return @ftp_site($this->ftp_conn_id, $chmod_cmd); } } --- 1077,1081 ---- { $chmod_cmd = 'CHMOD ' . $perms . ' ' .$file; ! return ftp_site($this->ftp_conn_id, $chmod_cmd); } } *************** *** 1083,1086 **** --- 1102,1115 ---- $result = ftp_put( $this->ftp_conn_id, $remote_filename, $local_filename, ($file_type==1) ? FTP_BINARY : FTP_ASCII ) ; + + // if did not work, attempt to delete the file and then move the new one in place + if ( !$result ) + { + if ( ftp_delete($this->ftp_conn_id, $remote_filename) ) + { + $result = ftp_put( $this->ftp_conn_id, $remote_filename, $local_filename, ($file_type==1) ? FTP_BINARY : FTP_ASCII ) ; + } + } + if ( $result ) { *************** *** 1097,1101 **** if ($this->ftp_type == 'fsock') { ! return $this->ftp->ftp_put_array( $to_file, $array_lines, 0) ; } else --- 1126,1135 ---- if ($this->ftp_type == 'fsock') { ! $result = $this->ftp->ftp_put_array( $to_file, $array_lines, 0) ; ! if ( $result ) ! { ! $this->emftp_chmod($to_file, '0644'); ! } ! return $result; } else |