Jump to content



Photo

help listing directories from ftp in combo box


  • Please log in to reply
4 replies to this topic

#1 am632

am632

    Adventurer

  • Active Members
  • PipPip
  • 148 posts

Posted 12 May 2012 - 11:18 PM

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





#2 am632

am632

    Adventurer

  • Active Members
  • PipPip
  • 148 posts

Posted 12 May 2012 - 11:49 PM

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

#3 qsek

qsek

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 256 posts

Posted 13 May 2012 - 11:08 PM

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

#4 am632

am632

    Adventurer

  • Active Members
  • PipPip
  • 148 posts

Posted 14 May 2012 - 09:51 AM

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

#5 qsek

qsek

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 256 posts

Posted 14 May 2012 - 03:23 PM

I havn't done any php before, can this be intergrated into my autoit script

no, the php site have to be on the server.
You only access the php site with autoit and recieve the output.
Example: http://www.autoitscript.com/forum/topic/139605-help-run-aplication-after-verification/page__view__findpost__p__979286

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users