am632 Posted May 12, 2012 Share Posted May 12, 2012 Hi, I want a combo box to display a list of directories from an ftp in a combo box and found this in the help file 'FUNCTION _FTP_ListToArray' which gives the example... #include <FTPEx.au3> Local $server = 'ftp.csx.cam.ac.uk' Local $username = '' Local $pass = '' Local $Open = _FTP_Open('MyFTP Control') Local $Conn = _FTP_Connect($Open, $server, $username, $pass) Local $aFile = _FTP_ListToArray($Conn, 2) ConsoleWrite('$NbFound = ' & $aFile[0] & ' -> Error code: ' & @error & @CRLF) ConsoleWrite('$Filename = ' & $aFile[1] & @CRLF) Local $Ftpc = _FTP_Close($Open) My questions are, do i need to create a new ftp user as the app will be for the public? and will the user details be able to access all folders on the server? because i obviously dont want people being able to browse folders which contain other peoples websites hosted on the server. I was thinking something like this... #include <FTPEx.au3> #NoTrayIcon #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> $MAIN = GUICreate("main", 400, 400, -1, -1) GUISetState(@SW_SHOW) Local $server = 'my server ip' Local $username = 'publicusername' Local $pass = 'publicpassword' Local $Open = _FTP_Open('is this the name of the base folder??') Local $Conn = _FTP_Connect($Open, $server, $username, $pass) Local $aFile = _FTP_ListToArray($Conn, 1) $COMBO = GUICtrlCreateCombo("", 150, 136, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GuiCtrlSetData($COMBO, "|" &_ArrayToString($aFile, "|", 1)) Local $Ftpc = _FTP_Close($Open) While 1 Sleep(0) WEnd is this correct, and would this be secure? thanks Link to comment Share on other sites More sharing options...
am632 Posted May 12, 2012 Author Share Posted May 12, 2012 Hi, I have actually got the combo box displaying the folders on the ftp using the following code.. #include <FTPEx.au3> #NoTrayIcon #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> $MAIN = GUICreate("main", 400, 400, -1, -1) GUISetState(@SW_SHOW) Local $server = 'myip' Local $username = 'username' Local $pass = 'password' Local $Open = _FTP_Open('') Local $Conn = _FTP_Connect($Open, $server, $username, $pass) Local $aFile = _FTP_ListToArray($Conn, 1) $COMBO = GUICtrlCreateCombo("", 150, 136, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GuiCtrlSetData($COMBO, "|" &_ArrayToString($aFile, "|", 1)) Local $Ftpc = _FTP_Close($Open) While 1 Sleep(0) WEnd and it works perfectly but I just have 2 questions. my combo box displays like this - . .. folder1 folder2 etc How do I get the combo box not to display the . ..'s? also the user details provided in the script which obviously allow the script to connect to the ftp - theres nothing to stop people using these details to login via an ftp client and uploading the the server. how can I stop this? thanks Link to comment Share on other sites More sharing options...
qsek Posted May 13, 2012 Share Posted May 13, 2012 For the dots you can do this (not tested): For $i = 0 To UBound($aFile)-1 Switch $aFile[$i] Case ".",".." _ArrayDelete($aFile,$i) EndSwitch next On the security question i think the whole method of accessing FTP through an decompileable script language is not very secure. Even if you would left this issue aside, you could packet sniff the login details or abuse the server. Some possible ways to improve your security (from easy to hard): - obfuscate your compiled exe - limit the user rights of the FTP account (no uploading, just browsing) - switch to https FTP access - dont use FTP at all. Use a php script which does the folder browsing and returns the data. This is just what my common sense is telling me. Im no expert on these things. Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
am632 Posted May 14, 2012 Author Share Posted May 14, 2012 Hi, thanks for your reply, I will probably finish the script since i started, more for learning purposes but as for the security your prob right - think ill look at alternative methods. I havn't done any php before, can this be intergrated into my autoit script and can i find an example anywhere? or should I drop autoit for this particular project and use something else? thanks Link to comment Share on other sites More sharing options...
qsek Posted May 14, 2012 Share Posted May 14, 2012 I havn't done any php before, can this be intergrated into my autoit scriptno, the php site have to be on the server.You only access the php site with autoit and recieve the output.Example: Cant help you with the php but it should be very simple. Query the local server file system and echo the directories. Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
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