Letting users create ftp account.

Please post here if you have problems in using Wing FTP Server.

Letting users create ftp account.

Postby Andre » Tue Jan 05, 2010 6:37 am

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é.
Andre
 
posts 22
 
joined Mon Oct 05, 2009 7:12 am
Location: Oosterwolde, Friesland, the Netherlands

Re: Letting users create ftp account.

Postby FTP » Tue Jan 05, 2010 9:54 am

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.html?admin=demo&pass=demo123&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));
FTP
Site Admin
 
posts 1202
 
joined Tue Sep 29, 2009 6:09 am

Re: Letting users create ftp account.

Postby Andre » Tue Jan 05, 2010 10:13 am

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é.
Andre
 
posts 22
 
joined Mon Oct 05, 2009 7:12 am
Location: Oosterwolde, Friesland, the Netherlands

Re: Letting users create ftp account.

Postby Andre » Mon Jan 11, 2010 1:18 pm

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.
Andre
 
posts 22
 
joined Mon Oct 05, 2009 7:12 am
Location: Oosterwolde, Friesland, the Netherlands

Re: Letting users create ftp account.

Postby FTP » Mon Jan 11, 2010 2:01 pm

I think there may be two possibilities:
1. Parameter admin is a read-only adminstrator.
2. You have blocked this url caller's IP.
FTP
Site Admin
 
posts 1202
 
joined Tue Sep 29, 2009 6:09 am

Re: Letting users create ftp account.

Postby Andre » Mon Jan 11, 2010 2:12 pm

Regarding 1.:

How can i check this?

Regarding 2.:

Nope. I haven't blocked anything. Yet. :-)
Andre
 
posts 22
 
joined Mon Oct 05, 2009 7:12 am
Location: Oosterwolde, Friesland, the Netherlands

Re: Letting users create ftp account.

Postby FTP » Mon Jan 11, 2010 3:54 pm

Th URL http://127.0.0.1:5466/admin_webservice.html?admin=demo&pass=demo123&cmd=xxxxx

demo = Your login administrator name, replace it with your own.
demo123 = Your login administrator password, replace it with your own.
FTP
Site Admin
 
posts 1202
 
joined Tue Sep 29, 2009 6:09 am

Re: Letting users create ftp account.

Postby Andre » Tue Jan 12, 2010 5:56 am

admin wrote:Th URL http://127.0.0.1:5466/admin_webservice.html?admin=demo&pass=demo123&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 ''!
Andre
 
posts 22
 
joined Mon Oct 05, 2009 7:12 am
Location: Oosterwolde, Friesland, the Netherlands

Re: Letting users create ftp account.

Postby FTP » Tue Jan 12, 2010 6:43 am

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.
FTP
Site Admin
 
posts 1202
 
joined Tue Sep 29, 2009 6:09 am

Re: Letting users create ftp account.

Postby Andre » Thu Jan 14, 2010 7:52 am

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é.
Andre
 
posts 22
 
joined Mon Oct 05, 2009 7:12 am
Location: Oosterwolde, Friesland, the Netherlands

Next

Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest