This is the start of what is going to be a small series on developing a modern approach to managing FileZilla through an API. Primarily, I will develop in PHP and will eventually port the code into Ruby.
It really is a work in progress and my primary goal is to get it to a point where I can manage users through an API. I chose XML to start with and will also port into JSON at a later time. It is important to note that while I prefer the *nix system, I needed to set this up on a MS box, not that I wanted to, believe me. The code is so rough it is bound to have some issues, if you see anything worth noting, please point it out!
Also, this work is to be released under the GPL so please feel free to use it as you like and give credit where credit is due.
To start, lets load the FileZilla server.xml file and parse the XML:
//XML location $serverFile="FileZilla server.xml"; //New XML Object $xmlobj = new SimpleXMLElement($serverFile, NULL, true);
At the moment, this will add a user based on pre-defined settings stored in an array, so lets set the variables and add the new children to the parent node:
$entryUserOption=array("Pass"=> $pid, "Group"=> "clients", "Bypass server userlimit"=> "2", "User Limit"=> "0", "IP Limit"=> "0", "Enabled"=> "2", "Comments"=> "none", "ForceSsl"=> "2"); //////////////////////////////////////////////////////// $entryPermOption=array("FileRead"=> "1", "FileWrite"=> "1", "FileDelete"=> "1", "FileAppend"=> "0", "DirCreate"=> "1", "DirDelete"=> "1", "DirList"=> "1", "DirSubdirs"=> "1", "IsHome"=> "1", "AutoCreate"=> "0"); $user = $xmlobj->Users->addChild("User"); $user->addAttribute("Name",$uid); foreach($entryUserOption as $key => $value){ $options = $user->addChild("Option",$value); $options->addAttribute("Name",$key); }
So we now have the Users node created, nested a child node called User and iterated through the options array and set the Option node attributes. Next up, create the remaining children nodes for User:
$options = $user->addChild("IpFilter"); $options->addChild("Disallowed"); $options->addChild("Allowed"); $options = $user->addChild("Permissions"); $option = $options->addChild("Permission"); $option->addAttribute("Dir",$homeDir); foreach($entryPermOption as $k => $v){ $option = $options->addChild("Option",$v); $option->addAttribute("Name",$k); } $options = $user->addChild("SpeedLimits"); $options->addAttribute("DlType","0"); $options->addAttribute("DlLimit","10"); $option = $options->addChild("Download"); $option->addChild("Upload");
Last but not least, lets print the XML so we can see what we are looking at:
print $xmlobj->asXML();
I’m not going to put the entire contents of the FileZilla server.xml file but you should have something similar to the below:
<User Name="testuser"> <Option Name="Pass">******</Option> <Option Name="Group">clients</Option> <Option Name="Bypass server userlimit">2</Option> <Option Name="User Limit">0</Option> <Option Name="IP Limit">0</Option> <Option Name="Enabled">2</Option> <Option Name="Comments"/> <Option Name="ForceSsl">2</Option> <IpFilter> <Disallowed/> <Allowed/> </IpFilter> <Permissions> <Permission Dir="C:\ftp\clients\testuser"> <Option Name="FileRead">1</Option> <Option Name="FileWrite">1</Option> <Option Name="FileDelete">1</Option> <Option Name="FileAppend">0</Option> <Option Name="DirCreate">1</Option> <Option Name="DirDelete">1</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="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2"> <Download/> <Upload/> </SpeedLimits> </User>
The above code only grabs the XML file adds a new child and prints the XML. My next post will include the code to then save to FileZilla’s config file and reload at runtime. Again, feel free to contribute or comment..




Hi John,
this article is exactly what i’m searching for, because i have to add/modify/delete Filezilla users frequently.
I would appreciate it a lot if you continue your work on this item. May be, you already did? In that case, it would be great if you publish your code.
Thanks in advance,
Achim
@Achim – I got to the point where a user can be created and added to Filezilla. However, I stopped before I finished the update and delete capabilities. I will package what I have and make it available. From what there is it shouldn’t be too hard to modify for complete CRUD functionality. – Cheers!
Hi,
This article is exactly what I am looking for, the only defference is I will be adding users through windows service.
Can you please tell the next step of code to save the XML config to FileZilla’s config file and reload at runtime?
Your help will be much appretiated.
Thanks a ton again
I hope, you will come to the correct decision. fake ciallis viva I have a fresh joke for you) What is a zebra? 26 sizes larger than an “A” bra.