FTP gestion

« Older   Newer »
  Share  
lollofieretto
view post Posted on 4/7/2010, 15:46




ecco un client per la gestione dei file di un nostro server....
crea una prima form per il server l'username e la password(ovviamente)
e poi se riesce a contattare il server ti apre una seconda form con i vari comandi
CODICE
#include <ftpex.au3>
#include <buttonconstants.au3>
#include <editconstants.au3>
#include <guiconstantsex.au3>
#include <staticconstants.au3>
#include <windowsconstants.au3>

HotKeySet ("{ENTER}", "login")

$Form1 = GUICreate("Login FTP gestion 2.0", 308, 217, 192, 124)
GUISetBkColor(0x0000FF)
$Label1 = GUICtrlCreateLabel("USER =", 16, 32, 58, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$user = GUICtrlCreateInput( @UserName , 104, 24, 185, 21)
$Label2 = GUICtrlCreateLabel("SERVER =", 16, 80, 78, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$server = GUICtrlCreateInput( @IPAddress1 , 104, 72, 185, 21)
$Label3 = GUICtrlCreateLabel("PASSWORD", 16, 128, 75, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$pass = GUICtrlCreateInput("", 104, 120, 185, 21)
$login = GUICtrlCreateButton("LOGIN", 16, 160, 273, 49)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

case $login
$server = guictrlread ($server)
$user = guictrlread ($user)
$pass = guictrlread ($pass)

$Open = _FTP_Open("MyFTP")
$Conn = _FTP_Connect($Open, $server, $user, $pass)

if @error Then
msgbox (16, "ERROR", "ERROR CONNECTING")
$Close = _FTP_Close ($Open)
exit
Else
msgbox (64, "CONNECT", "you are connect")
_CONN ()
exit
EndIf

func login ()
$server = guictrlread ($server)
$user = guictrlread ($user)
$pass = guictrlread ($pass)

$Open = _FTP_Open("MyFTP")
$Conn = _FTP_Connect($Open, $server, $user, $pass)

if @error Then
msgbox (16, "ERROR", "ERROR CONNECTING")
$Close = _FTP_Close ($Open)
Else
msgbox (64, "CONNECT", "you are connect")
_CONN ()
exit
EndIf
EndFunc
EndSwitch
Wend
func _CONN ()
$Form1 = GUICreate("FTP gestion 2.0 by lollofieretto", 467, 374, 317, 164)
$Label1 = GUICtrlCreateLabel("YOU ARE CONNECT ", 120, 24, 194, 27)
GUICtrlSetFont(-1, 12, 400, 0, "Gill Sans Ultra Bold")
$Group1 = GUICtrlCreateGroup("DIR", 232, 256, 225, 97)
$dir_create = GUICtrlCreateButton("DIR.create", 240, 272, 57, 33)
$N_dir_create = GUICtrlCreateInput("", 304, 280, 145, 21)
$dir_del = GUICtrlCreateButton("DIR.delite", 240, 312, 57, 33)
$N_dir_del = GUICtrlCreateInput("", 304, 320, 145, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Upload", 232, 64, 225, 185)
$Label2 = GUICtrlCreateLabel("file da caricare:", 280, 80, 127, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$loc_file_up = GUICtrlCreateInput("", 240, 112, 129, 21)
$upload = GUICtrlCreateButton("Upload", 240, 208, 209, 33)
$sfoglia = GUICtrlCreateButton("Sfoglia", 376, 112, 73, 25)
$Label3 = GUICtrlCreateLabel("posizione in cui caricare", 248, 144, 196, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$loc_carica = GUICtrlCreateInput("", 240, 176, 209, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("FILE", 8, 64, 217, 289)
$F_rename = GUICtrlCreateButton("File Rename", 16, 80, 201, 33)
$Label4 = GUICtrlCreateLabel("vechio", 16, 128, 36, 17)
$O_N = GUICtrlCreateInput("", 56, 120, 57, 21)
$F_delete = GUICtrlCreateButton("File Delite", 16, 152, 201, 33)
$loc_file_del = GUICtrlCreateInput("", 63, 194, 153, 21)
$Label5 = GUICtrlCreateLabel("nome file", 14, 199, 46, 17)
$F_open = GUICtrlCreateButton("File Open", 16, 224, 201, 33)
$Label6 = GUICtrlCreateLabel("nome file", 15, 265, 46, 17)
$F_close= GUICtrlCreateButton("File Close", 16, 288, 201, 33)
$Label7 = GUICtrlCreateLabel("nome file", 16, 335, 46, 17)
$Loc_file_open = GUICtrlCreateInput("", 64, 264, 153, 21)
$Loc_file_close = GUICtrlCreateInput("", 64, 328, 153, 21)
$Label8 = GUICtrlCreateLabel("nuovo", 120, 128, 34, 17)
$N_N = GUICtrlCreateInput("", 160, 120, 57, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)



While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $dir_create
$N_D_C = GUICtrlRead ($N_dir_create)
$dir_rc = _FTP_DirCreate ($Conn, $N_D_C)

if @error Then
msgbox (16, "ERROR", "error, the directory is not created")
$Close = _FTP_Close ($Open)
exit
else
msgbox (64, "DIRECTORY", "the name of the directory is: " & $N_D_C)
EndIf
case $dir_del
$N_dir = GUICtrlRead ($N_dir_del)
$dir_dele = _FTP_DirDelete ($Conn, $N_dir)

if @error Then
msgbox (16, "ERROR", "error, the directory is not deleted")
$Close = _FTP_Close ($Open)
exit
else
msgbox (64, "DIRECTORY", $N_dir & " è stata eliminata")
EndIf
case $F_rename

$O_N = GUICtrlRead ($O_N)
$N_N = GUICtrlRead ($N_N)

$rename = _FTP_FileRename ($Conn, $O_N , $N_N)

if @error Then
msgbox (16, "ERROR", "error, the file is not renamed")
$Close = _FTP_Close ($Open)
exit
else
msgbox (64, "renamed", "the new name is: " & $N_N)
EndIf

case $F_delete

$N_F_D = GUICtrlRead ($loc_file_del)

$file_delete = _FTP_FileDelete ($Conn, $N_F_D)

if @error Then
msgbox (16, "ERROR", "error, the file is not deleted")
$Close = _FTP_Close ($Open)
exit
else
msgbox (64, "DIRECTORY", $N_F_D & " was deleted")
EndIf

case $F_open

$N_F_O = GUICtrlRead ($Loc_file_open)

$FILE_OPEN = _FTP_FileOpen ($Conn,$N_F_O)

if @error Then
msgbox (16, "ERROR", "error, the file is not opened")
$Close = _FTP_Close ($Open)
exit
else
msgbox (64, "DIRECTORY", $N_F_O & " was open")
EndIf

case $F_close

$N_F_C = GUICtrlRead ($Loc_file_close)

$FILE_OPEN = _FTP_FileOpen ($Conn,$N_F_C)

if @error Then
msgbox (16, "ERROR", "error, the file is not closed")
$Close = _FTP_Close ($Open)
exit
else
msgbox (64, "DIRECTORY", $N_F_C & " was closed")
EndIf

case $sfoglia
$file=FileOpenDialog("","","ALL(*.*)")
GUICtrlSetData($loc_file_up,$file)
case $upload
If BitOR(guictrlread($loc_carica) = "",guictrlread($loc_file_up) = "") <> 1 Then
$loc_in = GUICtrlRead ($loc_file_up)
$loc_out = GUICtrlRead ($loc_carica)
$up = _FTP_FilePut($Conn,$loc_in,$loc_out)
If Not @error Then
MsgBox(64,"Upload","Upload completato!")
Else
MsgBox(16,"Errore","Errore")
exit
EndIf

endif
EndFunc
EndSwitch
WEnd



download:

http://lollofieretto.altervista.org/FTP_gestion_2.5.exe
 
Top
0 replies since 4/7/2010, 15:46   41 views
  Share