示例#1
0
 /**
  * {@inheritDoc}
  */
 public function rename($sourceKey, $targetKey)
 {
     $sourcePath = $this->computePath($sourceKey);
     $targetPath = $this->computePath($targetKey);
     $this->ensureDirectoryExists(dirname($targetPath), true);
     return ftp_rename($this->getConnection(), $sourcePath, $targetPath);
 }
示例#2
0
 public function ftp_rename($old_file, $new_file)
 {
     if (!$this->ftp_conn) {
         return false;
     }
     return @ftp_rename($this->ftp_conn, $old_file, $new_file);
 }
示例#3
0
 public function rename(string $oldName, string $newName) : bool
 {
     if (ftp_rename($this->connect, $oldName, $newName)) {
         return true;
     } else {
         throw new FolderChangeNameException($oldName);
     }
 }
示例#4
0
 /**
  * {@inheritdoc}
  *
  * @param string $oldAssetFile
  * @param string $newAssetFile
  * @return bool
  * @throws AssetMoveException
  */
 protected function internalMove($oldAssetFile, $newAssetFile)
 {
     $this->reconnectIfNeeded();
     if (!ftp_rename($this->connection, $oldAssetFile, $newAssetFile)) {
         throw new AssetMoveException(sprintf("Unable to move '%s' to '%s'.", $oldAssetFile, $newAssetFile));
     }
     return $newAssetFile;
 }
示例#5
0
function RenombraArchivo($anterior, $nuevo, $servidor, $puerto, $usuario, $password)
{
    $id_ftp = ConectarFTP($servidor, $puerto, $usuario, $password);
    //Obtiene un manejador y se conecta al Servidor FTP
    $quepaso = ftp_rename($id_ftp, $anterior, $nuevo);
    ftp_quit($id_ftp);
    //Cierra la conexion FTP
    return $quepaso;
}
示例#6
0
 protected function ftpRename($old, $new)
 {
     $result;
     $conn_id = ftp_connect(FTP_SERVER);
     $login_result = ftp_login($conn_id, FTP_USER_NAME, FTP_USER_PASS);
     $result = ftp_rename($conn_id, $old, $new);
     ftp_close($conn_id);
     return $result;
 }
示例#7
0
 public function moveTo(MOXMAN_Vfs_IFile $dest)
 {
     if ($dest instanceof MOXMAN_Ftp_File) {
         ftp_rename($this->fileSystem->getConnection(), $this->getInternalPath(), $dest->getInternalPath());
     } else {
         $this->copyTo($dest);
         $this->delete(true);
     }
 }
示例#8
0
文件: Item.php 项目: robik/cFTP
 /**
  * Changes name of element
  * 
  * @param string $newName New name
  *
  * @throws cFTP_Exception
  * 
  * @return cFTP_Element 
  */
 public function rename($newName)
 {
     $success = @ftp_rename($this->handle, $this->name, $newName);
     
     if( !$success )
         throw new cFTP_Exception( "Could not rename", 36 );
     
     return $this;
 }
示例#9
0
 /**
  * 方法:移动文件 
  * @path    -- 原路径 
  * @newpath -- 新路径 
  * @type    -- 若目标目录不存在则新建 
  */
 function move_file($path, $newpath, $type = true)
 {
     if ($type) {
         $this->dir_mkdirs($newpath);
     }
     $this->off = @ftp_rename($this->conn_id, $path, $newpath);
     if (!$this->off) {
         echo "文件移动失败,请检查权限及原路径是否正确!";
     }
 }
示例#10
0
function atnevez($id, $hova, $reginev)
{
    if (isset($_POST["ujnev"])) {
        $uj = $_POST["ujnev"];
        ftp_rename($id, "{$hova}/{$reginev}", "{$hova}/{$uj}");
        return header("Location: {$PHP_SELF}?mit=" . urlencode($hova));
    } else {
        print "<form action=\"{$PHP_SELF}?mit={$hova}&csa=" . urlencode($reginev) . "\" method=\"POST\">" . "<center>Új Név:&nbsp;<input type=\"text\" name=\"ujnev\" value=\"{$reginev}\">&nbsp;" . "<input type=\"submit\" value=\"Átnevez\"></center>" . "</form><br>";
    }
}
示例#11
0
 public function rename($remotePath, $localPath)
 {
     if (@ftp_nlist($this->link, $localPath)) {
         if (!@ftp_rename($this->link, $localPath, $remotePath)) {
             $error = error_get_last();
             throw new Exception(sprintf('%s: Failed to %s file. Remote Path: %s, Local Path: %s, Error: %s', get_class($this), __FUNCTION__, $remotePath, $localPath, $error['message']));
         }
     }
     return $this;
 }
示例#12
0
 /** 
  * 方法:移动文件 
  * @path    -- 原路径 
  * @newpath -- 新路径 
  * @type    -- 若目标目录不存在则新建 
  */
 function move_file($path, $newpath, $type = true)
 {
     if ($type) {
         $this->dir_mkdirs($newpath);
     }
     $this->off = @ftp_rename($this->conn_id, $path, $newpath);
     if (!$this->off) {
         return false;
     } else {
         return true;
     }
 }
示例#13
0
 public static function moveFtpFile($filename, $process)
 {
     $ftp_dir = $process . '/';
     $final_destination = '/processed_feed/' . $filename;
     $ftp_conn = ftp_connect(config('monster.ftp_server'), 21);
     if ($ftp_conn) {
         $ftp_login = ftp_login($ftp_conn, config('monster.ftp_user'), config('monster.ftp_password'));
         if ($ftp_login) {
             $is_passive = ftp_pasv($ftp_conn, true);
             if ($is_passive) {
                 $is_dir_changed = ftp_chdir($ftp_conn, $ftp_dir);
                 if (!$is_dir_changed) {
                     ftp_close($ftp_conn);
                 } else {
                     // move ftp file
                     $ftp_files = ftp_nlist($ftp_conn, "");
                     if (in_array($filename, $ftp_files)) {
                         if ($process == 'test' || $process == 'processed_feed') {
                             // TO DO: keep it to test the export process
                             $is_deleted = ftp_delete($ftp_conn, '/' . $ftp_dir . $filename);
                             if ($is_deleted) {
                                 ExportLog::create(['process' => $process, 'filename' => $filename, 'message' => 'was deleted from FTP [' . $process . '] folder']);
                                 FileInProgress::where(['file_name' => $filename])->delete();
                             } else {
                                 ExportLog::create(['process' => $process, 'filename' => $filename, 'message' => 'cannot be deleted']);
                                 FileInProgress::where(['file_name' => $filename])->delete();
                             }
                         } else {
                             $is_moved = ftp_rename($ftp_conn, $filename, $final_destination);
                             if ($is_moved) {
                                 ExportLog::create(['process' => $process, 'filename' => $filename, 'message' => 'was moved to FTP [processed_feed] folder']);
                                 FileInProgress::where(['file_name' => $filename])->delete();
                             } else {
                                 ExportLog::create(['process' => $process, 'filename' => $filename, 'message' => 'cannot be moved to [' . $final_destination . ']']);
                             }
                         }
                     } else {
                         ExportLog::create(['process' => $process, 'filename' => $filename, 'message' => 'is not found on the FTP server']);
                     }
                 }
             }
         }
         ftp_close($ftp_conn);
     }
     //queue local file for deletion
     FileDeleteQueue::create(['file_name' => $filename]);
 }
示例#14
0
 /**
  *  preprocess Index action.
  *
  *  @access    public
  *  @return    string  Forward name (null if no errors.)
  */
 function prepare()
 {
     if ($this->af->validate() == 0) {
         $username = $this->af->get('ftp_username');
         $password = $this->af->get('ftp_password');
         $xoops_root_path = $this->af->get('root_path');
         var_dump($username, $password, $xoops_root_path);
         if ($conn_id = ftp_connect('localhost')) {
             $this->af->setApp($i++, $i++);
             if (ftp_login($conn_id, $username, $password)) {
                 $ftp_root = $this->seekFTPRoot($conn_id);
                 if ($ftp_root !== false) {
                     $install_dir = str_replace($ftp_root, '', $xoops_root_path) . '/install';
                     $install_dir_dest = $install_dir . '_' . Ethna_Util::getRandom(16);
                     ftp_rename($conn_id, $install_dir, $install_dir_dest);
                     $mainfile = str_replace($ftp_root, '', $xoops_root_path) . '/mainfile.php';
                     ftp_chmod($conn_id, 0644, $mainfile);
                     return null;
                 }
             }
         }
     }
     return 'json_error';
 }
示例#15
0
文件: Ftp.php 项目: stevedaddy/react
 /**
  * @inheritdoc
  */
 public function rename($path, $newpath)
 {
     return ftp_rename($this->getConnection(), $path, $newpath);
 }
 /**
  * Move file into another parent dir.
  * Return new file path or false.
  *
  * @param  string  $source  source file path
  * @param  string  $target  target dir path
  * @param  string  $name    file name
  * @return string|bool
  * @author Dmitry (dio) Levashov
  **/
 protected function _move($source, $targetDir, $name)
 {
     $target = $targetDir . DIRECTORY_SEPARATOR . $name;
     return ftp_rename($this->connect, $source, $target) ? $target : false;
 }
示例#17
0
 /**
  * Rename (or move) a file
  *
  * @access	public
  * @param	string
  * @param	string
  * @param	bool
  * @return	bool
  */
 function rename($old_file, $new_file, $move = FALSE)
 {
     if (!$this->_is_conn()) {
         return FALSE;
     }
     $result = @ftp_rename($this->conn_id, $old_file, $new_file);
     if ($result === FALSE) {
         if ($this->debug == TRUE) {
             $msg = $move == FALSE ? 'ftp_unable_to_rename' : 'ftp_unable_to_move';
             $this->_error($msg);
         }
         return FALSE;
     }
     return TRUE;
 }
示例#18
0
文件: ftp.php 项目: joebushi/joomla
 /**
  * Method to rename a file/folder on the FTP server
  *
  * @access public
  * @param string $from Path to change file/folder from
  * @param string $to Path to change file/folder to
  * @return boolean True if successful
  */
 function rename($from, $to)
 {
     // If native FTP support is enabled lets use it...
     if (FTP_NATIVE) {
         if (@ftp_rename($this->_conn, $from, $to) === false) {
             JError::raiseWarning('35', 'JFTP::rename: Bad response');
             return false;
         }
         return true;
     }
     // Send rename from command to the server
     if (!$this->_putCmd('RNFR ' . $from, 350)) {
         JError::raiseWarning('35', 'JFTP::rename: Bad response', 'Server response: ' . $this->_response . ' [Expected: 320] From path sent: ' . $from);
         return false;
     }
     // Send rename to command to the server
     if (!$this->_putCmd('RNTO ' . $to, 250)) {
         JError::raiseWarning('35', 'JFTP::rename: Bad response', 'Server response: ' . $this->_response . ' [Expected: 250] To path sent: ' . $to);
         return false;
     }
     return true;
 }
示例#19
0
            $ftp_server_array = $nv_Request->get_string('ftp_server_array', 'session');
            $ftp_server_array = unserialize($ftp_server_array);
        }
        if (isset($ftp_server_array['ftp_check_login']) and intval($ftp_server_array['ftp_check_login']) == 1) {
            // Set up basic connection
            $conn_id = ftp_connect($ftp_server_array['ftp_server'], $ftp_server_array['ftp_port'], 10);
            // Login with username and password
            $login_result = ftp_login($conn_id, $ftp_server_array['ftp_user_name'], $ftp_server_array['ftp_user_pass']);
            if (!$conn_id || !$login_result) {
                $ftp_check_login = 3;
            } elseif (ftp_chdir($conn_id, $ftp_server_array['ftp_path'])) {
                $ftp_check_login = 1;
            }
        }
        if ($ftp_check_login == 1) {
            ftp_rename($conn_id, NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME, NV_CONFIG_FILENAME);
            nv_chmod_dir($conn_id, NV_UPLOADS_DIR, true);
            ftp_chmod($conn_id, 0644, NV_CONFIG_FILENAME);
            ftp_close($conn_id);
        } else {
            @rename(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME, NV_ROOTDIR . '/' . NV_CONFIG_FILENAME);
        }
    }
    if (file_exists(NV_ROOTDIR . '/' . NV_CONFIG_FILENAME)) {
        $finish = 1;
    } else {
        $finish = 2;
    }
    $title = $lang_module['done'];
    $contents = nv_step_7($finish);
}
示例#20
0
 public function rename($oldname, $newname)
 {
     $oldname = $this->get_absolute_path($oldname);
     $newname = $this->get_absolute_path($newname);
     if ($this->debug) {
         echo "Renommage de {$oldname} en {$newname}\n<br>";
     }
     if (@ftp_rename($this->connexion, $oldname, $newname) === false) {
         throw new Exception('Impossible de renommer le dossier ou le fichier');
     }
     unset($this->cached_dirs[$oldname]);
     return $this;
 }
 /**
  * @param string $source
  * @param string $destination
  * @param bool $overwrite
  * @return bool
  */
 public function move($source, $destination, $overwrite = false)
 {
     return ftp_rename($this->link, $source, $destination);
 }
 /**
  * Move file into another parent dir.
  * Return new file path or false.
  *
  * @param  string $source source file path
  * @param $targetDir
  * @param  string $name file name
  * @return bool|string
  * @internal param string $target target dir path
  * @author Dmitry (dio) Levashov
  */
 protected function _move($source, $targetDir, $name)
 {
     $target = $this->_joinPath($targetDir, $name);
     return ftp_rename($this->connect, $source, $target) ? $target : false;
 }
示例#23
0
文件: File.php 项目: GHarutyunyan/cms
 public function moveTo(MOXMAN_Vfs_IFile $dest)
 {
     $this->fileSystem->getCache()->remove($this->getPath());
     ftp_rename($this->fileSystem->getConnection(), $this->getInternalPath(), $dest->getInternalPath());
 }
示例#24
0
             $retval = @ftp_rmdir($ftp, $olddir . '/' . $file);
         }
         if ($retval) {
             $GLOBALS['phpgw']->template->set_var("misc_data", lang('Successfully deleted %1', "{$olddir}/{$file}"), true);
         } else {
             $GLOBALS['phpgw']->template->set_var('misc_data', lang('failed to delete %1', "{$olddir}/{$file}"), true);
         }
     } else {
         if (!$_POST['cancel']) {
             $GLOBALS['phpgw']->template->set_var('misc_data', confirmDeleteForm($session, $file, $olddir), true);
         }
     }
 }
 if ($action == 'rename') {
     if ($confirm) {
         if (ftp_rename($ftp, $olddir . '/' . $filename, $olddir . '/' . $newfilename)) {
             $GLOBALS['phpgw']->template->set_var('misc_data', lang('renamed %1 to %2', "{$filename}", "{$newfilename}"), true);
         } else {
             $GLOBALS['phpgw']->template->set_var('misc_data', lang('failed to rename %1 to %2', "{$filename}", "{$newfilename}"), true);
         }
     } else {
         $GLOBALS['phpgw']->template->set_var('misc_data', renameForm($session, $file, $olddir), true);
     }
 }
 if ($action == 'get') {
     phpftp_get($ftp, $tempdir, $olddir, $file);
     $GLOBALS['phpgw']->common->phpgw_exit();
 }
 if ($action == 'view') {
     phpftp_view($ftp, $tempdir, $olddir, $file);
     $GLOBALS['phpgw']->common->phpgw_exit();
示例#25
0
function ftp_rename3($conn_id, $old, $new)
{
    // --------------
    // This function renames a directory or file
    // --------------
    $ftp_rename_result = ftp_rename($conn_id, $old, $new);
    if ($ftp_rename_result == false) {
        $errormessage = __("Unable to rename directory or file <b>%1\$s</b> into <b>%2\$s</b>", $old, $new);
        setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
        return false;
    }
}
 /**
  * Rename file
  * @access private
  */
 function _rename($old_handle, $new_handle)
 {
     return @ftp_rename($this->connection, $old_handle, $new_handle);
 }
示例#27
0
文件: ftp.php 项目: eduNeusoft/weixin
 /**
  * 重命名/移动
  *
  * @access 	public
  * @param 	string 	远程目录标识(ftp)
  * @param	string	新目录标识
  * @param	boolean	判断是重命名(FALSE)还是移动(TRUE)	
  * @return	boolean
  */
 public function rename($oldname, $newname, $move = FALSE)
 {
     if (!$this->_isconn()) {
         return FALSE;
     }
     $result = @ftp_rename($this->conn_id, $oldname, $newname);
     if ($result === FALSE) {
         if ($this->debug === TRUE) {
             $msg = $move == FALSE ? "ftp_unable_to_rename" : "ftp_unable_to_move";
             $this->_error($msg);
         }
         return FALSE;
     }
     return TRUE;
 }
示例#28
0
 /**
  * Rename or move a directory or a file
  *
  * @param string $src
  * @param string $dest
  * @return boolean
  */
 public function mv($src, $dest)
 {
     return @ftp_rename($this->_conn, $src, $dest);
 }
示例#29
0
 public function renombrar_dbf($file)
 {
     $archivoFtp = "1" . $file . ".tmp";
     $consulta = "SELECT * FROM parametros WHERE llave IN ('ftp_server', 'ftp_user', 'ftp_pass')";
     $comando = $this->dbConexion->createCommand($consulta);
     $param_ftp = $comando->query()->readAll();
     foreach ($param_ftp as $r) {
         ${$r}["llave"] = $r["valor"];
     }
     try {
         $conn_id = ftp_connect($ftp_server);
         $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
     } catch (Exception $e) {
         $this->ClientScript->registerEndScript("no_conectado", "alert('No se pudo conectar al FTP, archivo " . $file . "');\n");
     }
     ftp_rename($conn_id, $file, $archivoFtp);
 }
示例#30
0
 /**
  * เปลี่ยนชื่อไฟล์หรือโฟลเดอร์
  *
  * @param string $old_file ชื่อไฟล์หรือโฟลเดอร์
  * @param string $new_file ชื่อใหม่
  * @return boolean สำเร็จคืนค่า true
  */
 function rename($old_file, $new_file)
 {
     if (!is_file($new_file)) {
         $chk = dirname($new_file);
         if (!is_writable($chk)) {
             $chk = '';
         }
     } elseif (!is_writable($new_file)) {
         $chk = $new_file;
     }
     if (!empty($chk)) {
         $chmod = fileperms($chk);
         $this->chmod($chk, 0757);
     }
     $f = @rename($old_file, $new_file);
     if (!$f && $this->login()) {
         $f = @ftp_rename($this->connection, $old_file, $new_file);
     }
     if (!empty($chk)) {
         $this->chmod($chk, $chmod);
     }
     return $f;
 }