binarydigit0101 Posted July 13, 2011 Posted July 13, 2011 I tryed to make a simple FTP manager with user login not togheter. I needed to make more connections because the function added for ftp doesn't support only a connection. in another path i maked a file called "key" in text format that allow me to know informations about the client. I designed this for a game, but it is okay for everything, I think. the login panel is this: expandcollapse popup#include <GUIConstants.au3> #include <GUIEdit.au3> #include <EditConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Log-iN into your personal panel.", 482, 170, 192, 201) $Label1 = GUICtrlCreateLabel("You will could have access to your q3ut4 folder only after having given your access details.", 24, 24, 433, 17) $nomeutente = GUICtrlCreateEdit("", 24, 56, 433, 17, $ES_READONLY) GUICtrlSetData(-1, "") ; here put the username. $password = GUICtrlCreateEdit("", 24, 80, 433, 17, BitOR($ES_PASSWORD,$ES_AUTOVSCROLL,$ES_NOHIDESEL)); $conferma = GUICtrlCreateButton("LOG-IN.", 344, 112, 113, 25, 0) $M = GUICtrlCreateMenu("About.") $informazioni = GUICtrlCreateMenuItem("Informations.", $M) $aggiornamenti = GUICtrlCreateMenuItem("Check for updates.", $M) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlEdit_SetPasswordChar($password, "*") _GUICtrlEdit_ShowBalloonTip($password, "", "insert here your personal password.", 0) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $informazioni MsgBox(0, "", "") ; here insert your information. Case $conferma If GUICtrlRead($password) = "" Then ; here you can choose a password for the user. MsgBox(0, "OKay!", "Your password is right!") Else MsgBox(0, "Attention, please!", "Your password is wrong!") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd the control panel is this: expandcollapse popup#Include <File.au3> #Include <Array.au3> #Include <FTPex.au3> #include <GUIConstants.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <String.au3> #include <Date.au3> ; VARIABILI GLOBALI PER L'APPLICAZIONE. $numero_del_servizio = xxx ; the number of service. $percorso_del_servizio = "" ; the service path. ; VARIABILI GLOBALI PER L'APPLICAZIONE. #Region ### START Koda GUI section ### Form=c:\users\alberto\desktop\moment\install\examples\koda_1.7.0.1\forms\urt.kxf $panel = GUICreate("Control Panel by P3LL3L4ND - version 1,0", 625, 443, 193, 125) $etichetta = GUICtrlCreateLabel("Here, there are the files of your q3ut4 folder. Make your folder unparalleled!", 24, 24, 500, 17) $lista = GUICtrlCreateList("", 24, 56, 577, 318, $WS_VSCROLL+$LBS_EXTENDEDSEL) $delete = GUICtrlCreateButton("Delete selected file(s)", 24, 392, 121, 33, 0) $download = GUICtrlCreateButton("Download selected file(s)", 148, 392, 129, 33, 0) $upload = GUICtrlCreateButton("Upload file(s)", 480, 392, 121, 33, 0) $informazioni = GUICtrlCreateButton("AbouT your game", 480, 16, 121, 30, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Refresh() ; pratico il rinfrescamento iniziale per avere dalla connessione iniziale l'elenco dei files specifici nella lista. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $informazioni informazioni() Case $delete cancellare() Case $download scaricare() Case $upload caricare() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func informazioni() $aperto = _FTP_Open("controllo cartella q3ut4!") $connessione2 = _FTP_Connect($aperto, "ip", "username", "password") _FTP_DirSetCurrent($connessione2, "yourinformationpath") $file = _FTP_FileOpen($connessione2, "key.txt") $dati = _HexToString(_FTP_FileRead($file, xxx)) _FTP_FileClose($file) $connessione2 = _FTP_Connect($aperto, "ip", "username", "password") _FTP_DirSetCurrent($connessione2, "servicepath") $dati = StringSplit($dati, @CRLF) $nome = $dati[1] $daysleft = $dati[3] MsgBox(65, "the title", "Ehi " & $nome & "!" & @CR & "Service number: " & StringMid(_FTP_DirGetCurrent($connessione2), 9, 3) & @CRLF & "You can still control this server for " & _DateDiff("d", _NowCalcDate(), $daysleft) & " days.") EndFunc Func cancellare() $selecteditems = _GUICtrlListBox_GetSelItems($lista) For $j = 1 To UBound($selecteditems)-1 _FTP_FileDelete($connessione2, _GUICtrlListBox_GetText($lista, $selecteditems[$j])) Next Refresh() EndFunc Func scaricare() $selecteditems = _GUICtrlListBox_GetSelItems($lista) If $selecteditems[0] = 0 Then MsgBox(0, "No elements selected.", "You didn't select any file.") Else $cartella = FileSelectFolder("Select where you would save this\these file(s).", Default, Default, @DesktopDir) If $cartella <> "" Then For $j = 1 To UBound($selecteditems)-1 _FTP_FileGet($connessione2, _GUICtrlListBox_GetText($lista, $selecteditems[$j]), $cartella & "\" & _GUICtrlListBox_GetText($lista, $selecteditems[$j])) Next EndIf EndIf EndFunc Func caricare() $files = FileOpenDialog("Select the file(s) for the upload.", @HomeDrive, "Configuration files (*.cfg)| Map files (*.pk3)| Text files (*.txt)", 1+4) If Not (@error = 1 Or @error = 2) Then $files = StringSplit($files, "|") If Not (UBound($files) = 2) Then For $j = 2 To UBound($files)-1 MsgBox(0, "What it is uploading.", "Now it is uploading " & $files[1] & "\" & $files[$j] & "; file name: " & $files[$j]) _FTP_ProgressUpload($connessione2, $files[1] & "\" & $files[$j], $files[$j]) Next Refresh() Else _ArrayDelete($files, 0) $files = _ArrayToString($files) $files = StringSplit($files, "\") $percorso = "" For $j = 1 To UBound($files)-2 $percorso = $percorso & "\" & $files[$j] Next $percorso = StringTrimLeft($percorso, 1) MsgBox(0, "", $percorso & "\" & $files[UBound($files)-1]) _FTP_ProgressUpload($connessione2, $percorso & "\" & $files[UBound($files)-1], $files[UBound($files)-1]) EndIf Refresh() EndIf EndFunc Func Refresh() $aperto = _FTP_Open("controllo cartella q3ut4!") Global $connessione = _FTP_Connect($aperto, "ip", "username", "password") Global $connessione2 = _FTP_Connect($aperto, "ip", "username", "password") Global $connessione3 = _FTP_Connect($aperto, "ip", "username", "password") _FTP_DirSetCurrent($connessione, $percorso_del_servizio & "/q3ut4") _FTP_DirSetCurrent($connessione3, $percorso_del_servizio & "/q3ut4") _FTP_DirSetCurrent($connessione2, $percorso_del_servizio) $file = _FTP_FileOpen($connessione2, "key.txt") $dati = _HexToString(_FTP_FileRead($file, 19)) _FTP_FileClose($connessione2) $dati = StringSplit($dati, @CRLF) $daysleft = $dati[3] If _DateDiff("d", _NowCalcDate(), $daysleft) <= 0 Then _GUICtrlListBox_AddString($lista, "You can't control this server anymore, 'cause your invoice is expired.") Else $connessione2 = _FTP_Connect($aperto, "ip", "username", "password") _FTP_DirSetCurrent($connessione2, $percorso_del_servizio & "/q3ut4") ; feel free to show only files you want. $folder = _Ftp_ListToArrayPlus($connessione, "*.cfg") $folder2 = _Ftp_ListToArrayPlus($connessione2, "*.pk3") $folder3 = _Ftp_ListToArrayPlus($connessione3, "*.txt") $folder2start = UBound($folder) $folder3start = $folder2start + UBound($folder2) _ArrayConcatenate($folder, $folder2) _ArrayConcatenate($folder, $folder3) For $j = UBound($folder)-3 To 0 Step -1 _GUICtrlListBox_DeleteString($lista, $j) Next For $j = 1 To $folder2start-1 _GUICtrlListBox_AddString($Lista, String($folder[$j])) Next For $j = $folder2start+1 To $folder3start-1 _GUICtrlListBox_AddString($Lista, String($folder[$j])) Next For $j = $folder3start+1 To UBound($folder)-1 _GUICtrlListBox_AddString($Lista, String($folder[$j])) Next EndIf $chiuso = _FTP_Close($aperto) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _FTP_ListToArrayPlus ; Description ...: Get Filenames, Directories or Both of current remote directory with the possibility of using extension filters. ; Syntax.........: _FTP_ListToArrayPlus($FTPconnectionhandle[, $sFilter = "*", $Return_type = 0]]) ; Parameters ....: $l_FTPSession - as returned by _FTP_Connect(). ; $sFilter - Optional, Name or extension of files, example: (index.htm; *.html) ; $Return_type - Optional, 0 = Both Files and Directories, 1 = Directories, 2 = Files. ; Return values .: Success - An array containing the names. Array[0] contain the number of found entries. ; Failure - Return @error ; Author ........: Golfinhu ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _FTP_ListToArrayPlus($FTPconnectionhandle, $sFilter = "*", $Return_type = 0) Local $hSearch, $sFile, $sFileList, $h_Handle, $sPath = _FTP_DirGetCurrent($FTPconnectionhandle), $sDelim = "|" $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "/" If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(1, 1, "") If Not ($Return_type = 0 Or $Return_type = 1 Or $Return_type = 2) Then Return SetError(2, 2, "") $hSearch = _FTP_FindFileFirst($FTPconnectionhandle, $sPath & $sFilter, $h_Handle, $INTERNET_FLAG_RESYNCHRONIZE) If @error Then Return SetError(3, 3, "") If Not ($Return_type = 1 And $hSearch[1] = 16) And Not ($Return_type = 2 And $hSearch[1] <> 16) Then $sFileList &= $sDelim & $hSearch[10] While 1 $sFile = _FTP_FindFileNext($h_Handle) If @error Then ExitLoop If ($Return_type = 1 And $sFile[1] = 16) Or ($Return_type = 2 And $sFile[1] <> 16) Then ContinueLoop $sFileList &= $sDelim & $sFile[10] WEnd FileClose($hSearch) If Not $sFileList Then Return SetError(4, 4, "") Return StringSplit(StringTrimLeft($sFileList, 1), "|") EndFunc ;==>_FTP_ListToArrayPlus how is it? please, tell me if you like it or if there are some bugs and you would give me some suggestions. have a good day! ehi ehi ehi, what is your name?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now