Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.60 KB | None | 0 0
  1. #RequireAdmin
  2. #include <FTPEx.au3>
  3. #include <GuiListBox.au3>
  4.  
  5. Global Const $sTitle = "Server"
  6. Global Const $iWidth = 500
  7. Global Const $iHeight = 300
  8.  
  9. Global $sFTP_Server = "##"
  10. Global $sFTP_User = "##"
  11. Global $sFTP_Pass = "##"
  12. Global $sFTP_Remote = "/daten/"
  13.  
  14. Global $hOpen = _FTP_Open($sTitle & "-Verbindung")
  15. Global $hConn = _FTP_Connect($hOpen, $sFTP_Server, $sFTP_User, $sFTP_Pass)
  16. If @error Then Exit
  17.  
  18. _FTP_DirSetCurrent($hConn, $sFTP_Remote)
  19.  
  20. Global $hGui = GUICreate($sTitle, $iWidth, $iHeight)
  21. Global $hList = GUICtrlCreateList("", 8, 8, $iWidth - 120, $iHeight - 16)
  22. Global $hDownload = GUICtrlCreateButton("Downloaden", 8 + $iWidth - 120 + 4, 8, $iWidth - 400, 25)
  23. Global $hUpload = GUICtrlCreateButton("Uploaden", 8 + $iWidth - 120 + 4, 33, $iWidth - 400, 25)
  24. Global $hDelete = GUICtrlCreateButton("Löschen", 8 + $iWidth - 120 + 4, 58, $iWidth - 400, 25)
  25. Global $hRename = GUICtrlCreateButton("Umbenennen", 8 + $iWidth - 120 + 4, 83, $iWidth - 400, 25)
  26.  
  27. _GetListFromServer($hConn)
  28. GUISetState()
  29.  
  30. While True
  31.     $hMsg = GUIGetMsg()
  32.     Switch $hMsg
  33.         Case -3
  34.             _FTP_Close($hOpen)
  35.             Exit
  36.         Case $hDownload
  37.             $sRead = GUICtrlRead($hList)
  38.             If $sRead = "" Then ContinueLoop
  39.             $vExtension = StringSplit($sRead, ".")
  40.             $vExtension = $vExtension[$vExtension[0]]
  41.             $sNewPathToSave = FileSaveDialog("Speichern unter", "", $vExtension & "-Datei (*." & $vExtension & ")", 2, $sRead, $hGui)
  42.             if @error or $sNewPathToSave = "" Then ContinueLoop
  43.             ProgressOn("Server-Download", $sRead & " downloaden", "0%")
  44.             _FTP_ProgressDownload($hConn, $sNewPathToSave, $sFTP_Remote & $sRead, "_Progress")
  45.             ProgressOff()
  46.             _GetListFromServer($hConn)
  47.         Case $hUpload
  48.             $sLocalFile = FileOpenDialog("Datei auswählen", "", "Alle Dateien (*.*)", 1 + 2, "", $hGui)
  49.             If @error or $sLocalFile = "" Then ContinueLoop
  50.             $sNewName = StringSplit($sLocalFile, "\")
  51.             $sNewName = $sNewName[$sNewName[0]]
  52.             ProgressOn("Server-Upload", $sNewName & " hochladen", "0%")
  53.             _FTP_ProgressUpload($hConn, $sLocalFile, $sFTP_Remote & $sNewName, "_Progress")
  54.             ProgressOff()
  55.             _GetListFromServer($hConn)
  56.     EndSwitch
  57. WEnd
  58.  
  59. Func _GetListFromServer($fhConnection)
  60.     _GUICtrlListBox_BeginUpdate($hList)
  61.     _GUICtrlListBox_ResetContent($hList)
  62.     _GUICtrlListBox_EndUpdate($hList)
  63.     Local $aReturn = _Ftp_ListToArray2D($fhConnection)
  64.     For $iX = 1 To $aReturn[0][0]
  65.         If ($aReturn[$iX][0] <> "." And $aReturn[$iX][0] <> "..") Then _GUICtrlListBox_AddString($hList, $aReturn[$iX][0])
  66.     Next
  67.     Return 1
  68. EndFunc   ;==>_GetListFromServer
  69.  
  70. Func _Progress($iPercent = 0)
  71.     ProgressSet($iPercent, $iPercent & "%")
  72.     Return 1
  73. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement