Page 1 of 2

Letting users create ftp account.

Posted: Tue Jan 05, 2010 6:37 am
by Andre
I read in the help-section that it's possible to implement a ftp-account-creation part for creating a ftp account in PHPBB. An interesting function but i am curious if it's possible to insert this technique in a regular webpage. So we can direct visitors to a part of our website where they can create their own ftp-account.

That would be cool. :-)

Kind regards,
André.

Re: Letting users create ftp account.

Posted: Tue Jan 05, 2010 9:54 am
by FTP
Hi, Andre

You can make it now! Wing FTP Server supports RESTful web service,you can call it for executing lua script in any external programming languages.

The RESTful web service URL may look like this: http://127.0.0.1:5466/admin_webservice. ... &cmd=xxxxx

There are three URL parameters in the above string, the first parameter "admin" means the administrator's username, the second parameter "pass" means the administrator's password, the third parameter "cmd" means the lua script with urlecoded. If the web service call failed, it will return a string start with "[ERROR RESULT]".

If you want to create a user account, I will show you a simple example with PHP code:

Code: Select all

$strUrl = "http://127.0.0.1:5466/admin_webservice.html"; 
$strUrlParam = "?admin=demo&pass=demo123&cmd="; 
$domain = $_REQUEST['domain'];         //which domain for storing accout
$username = $_REQUEST['username'];  //account name
$password = $_REQUEST['password'];   //account password
$homedir = $_REQUEST['homedir'];      //home directory, like D:/temp
$strLuaScript = <<<EOT 
c_AddUser('".$domain."','".$username."',md5('".$password."'),63,1,1) 
c_AddUserDirectory('".$domain."','".$username."','".$homedir."','/',true,true,false,false,false,true,false,false,false)
EOT; 
$strResult = file_get_contents($strUrl.$strUrlParam.rawurlencode($strLuaScript));

Re: Letting users create ftp account.

Posted: Tue Jan 05, 2010 10:13 am
by Andre
Thanx for your quick reply.

Cool that it's already possible although i think that it's a bit to difficult for a non-skilled-know-nothing-web-noob like me. But i will give it a try or ask someone who is more skilled in program language or technical website-design. :-)

Kind regards,
André.

Re: Letting users create ftp account.

Posted: Mon Jan 11, 2010 1:18 pm
by Andre
My brother is trying out the script you posted here but gets the following message:

[ERROR RESULT] no permission!

I gave him the right login details wich seem to work fine because he is able to login to the administrator section 'admin_login.html'. Any idea where we are going wrong?

Thanx for your time and help,
Andre.

Re: Letting users create ftp account.

Posted: Mon Jan 11, 2010 2:01 pm
by FTP
I think there may be two possibilities:
1. Parameter admin is a read-only adminstrator.
2. You have blocked this url caller's IP.

Re: Letting users create ftp account.

Posted: Mon Jan 11, 2010 2:12 pm
by Andre
Regarding 1.:

How can i check this?

Regarding 2.:

Nope. I haven't blocked anything. Yet. :-)

Re: Letting users create ftp account.

Posted: Mon Jan 11, 2010 3:54 pm
by FTP
Th URL http://127.0.0.1:5466/admin_webservice. ... &cmd=xxxxx

demo = Your login administrator name, replace it with your own.
demo123 = Your login administrator password, replace it with your own.

Re: Letting users create ftp account.

Posted: Tue Jan 12, 2010 5:56 am
by Andre
admin wrote:Th URL http://127.0.0.1:5466/admin_webservice. ... &cmd=xxxxx

demo = Your login administrator name, replace it with your own.
demo123 = Your login administrator password, replace it with your own.

I tried it behind the computer where WingFTP Server is running and i get the same result:

[ERROR RESULT] no permission!

:-S

*edit* I just tried it with a new admin-account wich had a much more simple login-name and password and then i get the message:

[ERROR RESULT] lua error in [string "xxxxx"]:1: '=' expected near ''!

Re: Letting users create ftp account.

Posted: Tue Jan 12, 2010 6:43 am
by FTP
Its your lua scirpt error, please check your lua code.
And I suggest you to use some URL encoding function to your parameters, like rawurlencode() in PHP, it can help you to avoid special characters problem.

Re: Letting users create ftp account.

Posted: Thu Jan 14, 2010 7:52 am
by Andre
My brother did a few more tests with the tips you provided and he didn't get any errors anymore. Strange thing is: nothing happens. He tried to make 2 user-accounts (test1 and test2) and it looks like it's going o.k. but on the server-side nothing happens.

The log-file only says:
[01] Wed, 13 Jan 2010 21:20:41 administrator 'test'(IP:194.109.22.66) executed a webservice script
[01] Wed, 13 Jan 2010 21:24:04 administrator 'test'(IP:194.109.22.66) executed a webservice script

That's all.

This is the script he used:

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);

$strUrl = "http://82.92.241.126:5466/admin_webservice.html";
$strUrlParam = '?admin=(removed for security purposes)&pass=(removed for security purposes)&cmd=';
$domain = "VDM"; //$_REQUEST['domain']; //which domain for storing accout
$username = $_REQUEST['username']; //account name
$password = $_REQUEST['password']; //account password
$homedir = $username; //$_REQUEST['homedir']; //home directory, like D:/temp
$strLuaScript = <<<EOT
c_AddUser('".$domain."','".$username."',md5('".$password."'),63,1,1)
c_AddUserDirectory('".$domain."','".$username."','".$homedir."','/',true,true,false,false,false,true,false,false,false)
EOT;
$strResult = file_get_contents($strUrl.$strUrlParam.rawurlencode($strLuaScript));

echo $strResult;
echo "<br>".$strLuaScript;
?>

I hope this will help you to solve our problem. :-)
Thanx for your time and service.

André.