edouard37 Posted March 20, 2008 Posted March 20, 2008 Hi, I have in project to configure my filezilla server with autoit. I want to create a exe file that ask me the name, the password and the address on my futur ftp user. When I'll click on Launch, I want that my exe file write some lines in the xml file (Filezilla server.xml). I think that I must make my program like that : 1 - test if the user is already present. If yes, so a popup message appear else we continu. 2 - I search the line <Users>. After this line, I want to insert the username of the futur user ftp. I have this information to create : <User Name="test">; I replace test by the user I have enter <Option Name="Pass"/>; i crypt the password with a md5 function <Option Name="Group"/> <Option Name="Bypass server userlimit">0</Option> <Option Name="User Limit">0</Option> <Option Name="IP Limit">0</Option> <Option Name="Enabled">1</Option> <Option Name="Comments"/> <Option Name="ForceSsl">0</Option> <IpFilter> <Disallowed/> <Allowed/> </IpFilter> <Permissions> <Permission Dir="D:\OCS_ING"> <Option Name="FileRead">1</Option> <Option Name="FileWrite">0</Option> <Option Name="FileDelete">0</Option> <Option Name="FileAppend">0</Option> <Option Name="DirCreate">0</Option> <Option Name="DirDelete">0</Option> <Option Name="DirList">1</Option> <Option Name="DirSubdirs">1</Option> <Option Name="IsHome">1</Option> <Option Name="AutoCreate">0</Option> </Permission> </Permissions> <SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="0" UlType="0" UlLimit="10" ServerUlLimitBypass="0"> <Download/> <Upload/> </SpeedLimits> You can see my code before : expandcollapse popup;--------------------------------- ;---------- ;---------- Gestion des utilisateurs FTP vers fichier XML ;---------- ;--------------------------------- #include <GUIConstants.au3> #include <File.au3> #include <md5.au3> #include <Array.au3> Dim $aRecords Global $File = "c:\FileZilla Server.xml" ;saisi du nom du futur user FtpSetProxy $msg = GUICreate ("Création des utilisateurs FTP",400,220) GUICtrlCreateLabel("Merci de saisir le nom de la personne qui se connectera au ftp :",10,10) $ftpuserlogin = GUICtrlCreateInput ("", 10, 25, 300, 20); will not accept drag&drop files GUICtrlCreateLabel("Merci de saisir son mot de passe :",10,60) $ftpuserpass = GUICtrlCreateInput ("", 10, 75, 300, 20); will not accept drag&drop files GUICtrlCreateLabel("Merci de saisir son adresse mail :",10,110) $ftpusermail = GUICtrlCreateInput ("", 10, 125, 300, 20); will not accept drag&drop files GUICtrlCreateLabel("Merci de saisir VOTRE adresse mail :",10,160) $informecreateur = GUICtrlCreateInput ("", 10, 175, 300, 20); will not accept drag&drop files $RUN = GUICtrlCreateButton("Créer le compte !",300,200,100,20) ;This in the Run button GUISetState(@SW_SHOW) ;Boucle d'affichage de la fenêtre de saisie d'informations While 1 $msg = GUIGetMsg() Switch $msg case $gui_event_close Exit CASE $RUN ;_testuser($ftpuserlogin) _createuser($ftpuserlogin,$ftpuserpass) Exit EndSwitch WEnd ;-------------------------------------------------------------- ;test if user exist ;-------------------------------------------------------------- Func _testuser($ftpuserlogin) $verifftpuser = "<User Name=""" & GUICtrlRead($ftpuserlogin) &""">" Dim $aRecords ; le fichier s'est-il ouvert ???? Oui on continu, non, message d'erreur If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, @ScriptName, "There was an error reading file!") Exit EndIf ;début de la recherche For $i = 0 to $aRecords[0] step 1 if $verifftpuser = $aRecords[$i] Then MsgBox(0,"","L'utilisateur " &GUICtrlRead($ftpuserlogin) & " est déjà créé.") EndIf Next EndFunc ;----------------------------------------------------------- ;Create user by inserting informations in xml file ;----------------------------------------------------------- Func _createuser($ftpuserlogin,$ftpuserpass) ;Variables locales $passwordcrypt = md5($ftpuserpass) $debutpourcreer = "<Users>" ;Ouverture du fichier If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, @ScriptName, "There was an error reading file!") Exit EndIf ;Start of search for <users> For $i = 0 to $aRecords[0] step 1 ;Recherche valeur <user> pour créer l'utilisateur juste après if $aRecords[$i] = $debutpourcreer Then $i = $i + 1 FileWriteLine($File, _ArrayInsert($aRecords,$i,@CR)) ExitLoop ;MsgBox(0,"","L'utilisateur " &GUICtrlRead($ftpuserlogin) & " est déjà créé.") EndIf Next EndFunc With this line, the program insert the number "1" : FileWriteLine($File, _ArrayInsert($aRecords,$i,@CR)) How can i insert my different informations? Thanks
ofLight Posted March 20, 2008 Posted March 20, 2008 I use elltoro's XML UDF AutoIt Forum Link , Just doing strait filewrites gets confusing for me once I get very deep down a tree. There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly
edouard37 Posted March 21, 2008 Author Posted March 21, 2008 Hi, I have in project to configure my filezilla server with autoit. I want to create a exe file that ask me the name, the password and the address on my futur ftp user. When I'll click on Launch, I want that my exe file write some lines in the xml file (Filezilla server.xml). I think that I must make my program like that : 1 - test if the user is already present. If yes, so a popup message appear else we continu. 2 - I search the line <Users>. After this line, I want to insert the username of the futur user ftp. I have this information to create : <User Name="test">; I replace test by the user I have enter <Option Name="Pass"/>; i crypt the password with a md5 function <Option Name="Group"/> <Option Name="Bypass server userlimit">0</Option> <Option Name="User Limit">0</Option> <Option Name="IP Limit">0</Option> <Option Name="Enabled">1</Option> <Option Name="Comments"/> <Option Name="ForceSsl">0</Option> <IpFilter> <Disallowed/> <Allowed/> </IpFilter> <Permissions> <Permission Dir="D:\OCS_ING"> <Option Name="FileRead">1</Option> <Option Name="FileWrite">0</Option> <Option Name="FileDelete">0</Option> <Option Name="FileAppend">0</Option> <Option Name="DirCreate">0</Option> <Option Name="DirDelete">0</Option> <Option Name="DirList">1</Option> <Option Name="DirSubdirs">1</Option> <Option Name="IsHome">1</Option> <Option Name="AutoCreate">0</Option> </Permission> </Permissions> <SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="0" UlType="0" UlLimit="10" ServerUlLimitBypass="0"> <Download/> <Upload/> </SpeedLimits> You can see my code before : expandcollapse popup;--------------------------------- ;---------- ;---------- Gestion des utilisateurs FTP vers fichier XML ;---------- ;--------------------------------- #include <GUIConstants.au3> #include <File.au3> #include <md5.au3> #include <Array.au3> Dim $aRecords Global $File = "c:\FileZilla Server.xml" ;saisi du nom du futur user FtpSetProxy $msg = GUICreate ("Création des utilisateurs FTP",400,220) GUICtrlCreateLabel("Merci de saisir le nom de la personne qui se connectera au ftp :",10,10) $ftpuserlogin = GUICtrlCreateInput ("", 10, 25, 300, 20); will not accept drag&drop files GUICtrlCreateLabel("Merci de saisir son mot de passe :",10,60) $ftpuserpass = GUICtrlCreateInput ("", 10, 75, 300, 20); will not accept drag&drop files GUICtrlCreateLabel("Merci de saisir son adresse mail :",10,110) $ftpusermail = GUICtrlCreateInput ("", 10, 125, 300, 20); will not accept drag&drop files GUICtrlCreateLabel("Merci de saisir VOTRE adresse mail :",10,160) $informecreateur = GUICtrlCreateInput ("", 10, 175, 300, 20); will not accept drag&drop files $RUN = GUICtrlCreateButton("Créer le compte !",300,200,100,20);This in the Run button GUISetState(@SW_SHOW) ;Boucle d'affichage de la fenêtre de saisie d'informations While 1 $msg = GUIGetMsg() Switch $msg case $gui_event_close Exit CASE $RUN ;_testuser($ftpuserlogin) _createuser($ftpuserlogin,$ftpuserpass) Exit EndSwitch WEnd ;-------------------------------------------------------------- ;test if user exist ;-------------------------------------------------------------- Func _testuser($ftpuserlogin) $verifftpuser = "<User Name=""" & GUICtrlRead($ftpuserlogin) &""">" Dim $aRecords ; le fichier s'est-il ouvert ???? Oui on continu, non, message d'erreur If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, @ScriptName, "There was an error reading file!") Exit EndIf ;début de la recherche For $i = 0 to $aRecords[0] step 1 if $verifftpuser = $aRecords[$i] Then MsgBox(0,"","L'utilisateur " &GUICtrlRead($ftpuserlogin) & " est déjà créé.") EndIf Next EndFunc ;----------------------------------------------------------- ;Create user by inserting informations in xml file ;----------------------------------------------------------- Func _createuser($ftpuserlogin,$ftpuserpass) ;Variables locales $passwordcrypt = md5($ftpuserpass) $debutpourcreer = "<Users>" ;Ouverture du fichier If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, @ScriptName, "There was an error reading file!") Exit EndIf ;Start of search for <users> For $i = 0 to $aRecords[0] step 1 ;Recherche valeur <user> pour créer l'utilisateur juste après if $aRecords[$i] = $debutpourcreer Then $i = $i + 1 FileWriteLine($File, _ArrayInsert($aRecords,$i,@CR)) ExitLoop ;MsgBox(0,"","L'utilisateur " &GUICtrlRead($ftpuserlogin) & " est déjà créé.") EndIf Next EndFunc With this line, the program insert the number "1" : FileWriteLine($File, _ArrayInsert($aRecords,$i,@CR)) How can i insert my different informations? Thanks Pas mal du tout, merci pour l'info.....J'ai trouvé une autre méthode....qui n'est certe pas optimisé...mais ca devrait le faire.....je vous mettrai le code.
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