Reputation: 25
Okay, so i have filezilla server software setup, but i want a php script that would add a new user to the xml file that holds the username, password, and folders. i want it to add it to the existing xml file without deleting the current info inside of it. If you know of a available method or script to do this, please send me it or share your knowledge of it. Otherwise if there is another ftp server program that has individual xml or files for each user then please let me know. Thanks in advance, Matt.
Upvotes: 1
Views: 4381
Reputation: 321
$user = $xml->Users->addChild('User');
$user->addAttribute('Name', $user_name);
add_option($user,'Pass',md5($password));
add_option($user,'Group',null);
add_option($user,'Bypass server userlimit','0');
add_option($user,'User Limit','0');
add_option($user,'IP Limit','0');
add_option($user,'Enabled','1');
add_option($user,'Comments','none');
add_option($user,'ForceSsl','0');
$filter = $user->addChild('IpFilter');
$filter->addChild('Disallowed');
$filter->addChild('Allowed');
$permissions = $user->addChild('Permissions');
$permission = $permissions->addChild('Permission');
$permission->addAttribute('Dir', str_replace("/","\\",$ftpUserFolder));
add_option($permission,'FileRead','1');
add_option($permission,'FileWrite','1');
add_option($permission,'FileDelete','1');
add_option($permission,'FileAppend','1');
add_option($permission,'DirCreate','1');
add_option($permission,'DirDelete','1');
add_option($permission,'DirList','1');
add_option($permission,'DirSubdirs','1');
add_option($permission,'IsHome','1');
add_option($permission,'AutoCreate','1');
$speed = $user->addChild('SpeedLimits');
$speed->addAttribute('DlType', '1');
$speed->addAttribute('DlLimit', '10');
$speed->addAttribute('ServerDlLimitBypass', '0');
$speed->addAttribute('UlType', '1');
$speed->addAttribute('UlLimit', '10');
$speed->addAttribute('ServerUlLimitBypass', '0');
$speed->addChild('Download');
$speed->addChild('Upload');
if(!$rv = $xml->asXML($xmlfile)){
echo ('SimpleXML could not write file');
return false;
}
//Change file encoding from UTF8 to ISO-8859-1
$dom = new DOMDocument("1.0","ISO-8859-1");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
if(!$dom->load($xmlfile) || !$dom->save($xmlfile)){
echo ('DOMDocument could not change file enconding from UTF8 to ISO-8859-1');
full script from my blog : http://moshez.blogspot.co.il/2013/02/php-filezilla-ftp-server-auto-create.html
Upvotes: 1
Reputation: 33401
Your best bet would be to use SimpleXML to manipulate the XML file.
Upvotes: 2