[Easymod-cvs] easymod/install/em_files/includes/em em_methods_ftp_fsock.php,1.1,1.2
Status: Beta
Brought to you by:
wgeric
From: Eric F. <wg...@us...> - 2005-12-07 00:11:26
|
Update of /cvsroot/easymod/easymod/install/em_files/includes/em In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12652/includes/em Modified Files: em_methods_ftp_fsock.php Log Message: FTP fsock function should work now Index: em_methods_ftp_fsock.php =================================================================== RCS file: /cvsroot/easymod/easymod/install/em_files/includes/em/em_methods_ftp_fsock.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** em_methods_ftp_fsock.php 4 Dec 2005 03:12:30 -0000 1.1 --- em_methods_ftp_fsock.php 7 Dec 2005 00:11:18 -0000 1.2 *************** *** 49,54 **** function em_method_ftp_fsock() { ! global $board_config, $crypt; ! $key = ''; for($i = 1, $total = strlen($board_config['em_pass']); $i < $total; $i = round(($i+1)*2)) --- 49,54 ---- function em_method_ftp_fsock() { ! global $board_config, $crypt; ! $key = ''; for($i = 1, $total = strlen($board_config['em_pass']); $i < $total; $i = round(($i+1)*2)) *************** *** 56,60 **** $key .= md5($board_config['em_pass']{$i}); } - $this->host = $board_config['em_ftp_host']; $this->port = $board_config['em_ftp_port']; --- 56,59 ---- *************** *** 62,69 **** $this->password = $crypt->decrypt($board_config['em_ftp_password'], $key); $this->timeout = $board_config['em_ftp_timeout']; ! $this->root_path = $board_config['em_ftp_root_path']; $this->tmp_path = $board_config['em_tmp_path']; ! $this->file_perms = $board_config['em_file_perms']; ! $this->dir_perms = $board_config['em_dir_perms']; $this->debug = false; --- 61,68 ---- $this->password = $crypt->decrypt($board_config['em_ftp_password'], $key); $this->timeout = $board_config['em_ftp_timeout']; ! $this->root_path = (( $board_config['em_ftp_root_path']{0} != '/' ) ? '/' : '') . ( substr($board_config['em_ftp_root_path'], -1, 1) == '/' ) ? substr($board_config['em_ftp_root_path'], 0, -1) : $board_config['em_ftp_root_path']; $this->tmp_path = $board_config['em_tmp_path']; ! $this->file_perms = 644; ! $this->dir_perms = 777; $this->debug = false; *************** *** 108,151 **** return true; } - - function open_file($file = '') - { - if(file_exists($file)) - { - if(function_exists('file_get_contents')) - { - $contents = file_get_contents($file); - } - else - { - $contents = implode('', file($file)); - } - } - else - { - // ERROR, file doesn't exsist - } - - if(empty($contents)) - { - // ERROR, read error or file empty - } - else - { - return $contents; - } - } function write_file($file = '', $contents = '') { ! if ( empty($file) ) ! { ! $file = $this->cur_file; ! } ! ! if ( empty($contents) ) ! { ! $contents = $this->files[$file]; ! } // need to create a temp file and then move that temp file. --- 107,116 ---- return true; } function write_file($file = '', $contents = '') { ! global $phpbb_root_path; ! ! $file = $this->root_path . '/' .str_replace($phpbb_root_path, '', $file); // need to create a temp file and then move that temp file. *************** *** 155,167 **** // like the cache folder. If the user can't do either, then // he/she needs to use the fsock ftp method ! $temp_name = tempnam($this->tmp_path, 'em_'); ! $file_resource = fopen($temp_name, 'w'); ! fwrite($file_resource, $contents); ! fclose($file_resource); $err = $this->_put($temp_name, $file); $this->_chmod($file, $this->file_perms); ! unlink($temp_name); return $err; --- 120,132 ---- // like the cache folder. If the user can't do either, then // he/she needs to use the fsock ftp method ! $temp_name = @tempnam($this->tmp_path, 'em_'); ! $file_resource = @fopen($temp_name, 'w'); ! @fwrite($file_resource, $contents); ! @fclose($file_resource); $err = $this->_put($temp_name, $file); $this->_chmod($file, $this->file_perms); ! @unlink($temp_name); return $err; *************** *** 170,188 **** function make_dir($dir) { $dir = explode('/', $dir); for($i = 0, $total = count($dir); $i < count($dir); $i++) { $cur_dir = $dir[$i] . '/'; ! if ( !file_exists($cur_dir) ) { // make the directory ! @ftp_mkdir($this->connection, $dir[$i]); $this->_chmod($dir[$i], $this->dir_perms); } ! $this->_chdir($dir[$i]); } ! $this->_chdir(); ! ! return; } --- 135,161 ---- function make_dir($dir) { + global $phpbb_root_path; + $dir = explode('/', $dir); + $dirs = ''; for($i = 0, $total = count($dir); $i < count($dir); $i++) { + $result = true; + if ( $dir[$i] == '..' || $dir[$i] == '.' ) + { + continue; + } $cur_dir = $dir[$i] . '/'; ! if ( !file_exists($phpbb_root_path . $dirs . $cur_dir) ) { // make the directory ! $result = $this->_mkdir($dir[$i]); $this->_chmod($dir[$i], $this->dir_perms); } ! $this->_chdir($this->root_path . '/' . $dirs . $dir[$i]); ! $dirs .= $cur_dir; } ! $this->_chdir($this->root_path); ! return $result; } *************** *** 190,201 **** { global $phpbb_root_path; ! $to_loc = $this->root_path . '/' . str_replace($phpbb_root_path, '', $to_loc); ! $from_loc = $this->root_path . str_replace('//', '/', str_replace('./', '/', str_replace('../', '/', $from_loc))); ! // copy the file $err = $this->_put($from_loc, $to_loc); $this->_chmod($to_loc, $this->file_perms); ! return $err; } --- 163,175 ---- { global $phpbb_root_path; ! ! $from_loc = (( !strstr($from_loc, $phpbb_root_path) ) ? $phpbb_root_path : '') . $from_loc; $to_loc = $this->root_path . '/' . str_replace($phpbb_root_path, '', $to_loc); ! // copy the file + $this->_delete($to_loc); $err = $this->_put($from_loc, $to_loc); $this->_chmod($to_loc, $this->file_perms); ! return $err; } *************** *** 375,381 **** } - // delete the old file and then move on - $this->_delete($remotefile); - $this->_putcmd("STOR", $remotefile); --- 349,352 ---- |