PDA

View Full Version : Auto User Creation



Gadget
09-03-2003, 07:00 AM
Ok, here is the situation. I use paypal for users to buy my services. I have an IPN script that directs the user to a certain page based on if the payment meets specific requirements (or will be as soon as I can get it up). Is there a way I can use PHP maybe to store values on the paypal form (before you get to the actual paypal page where you submit payment) and use them on the successpayment page to automatically create the user's account using API? I know I have asked a lot of questions here, but im new to a lot of these things and you guys all seem like experts.

l0rdphi1
09-03-2003, 08:55 AM
Yes, you can. Check out the new create account API function (http://www.directadmin.com/features.php?id=167) (which accepts data the same as the old create account method (http://www.directadmin.com/api.html#create)) and my PHP class for communicating with DA (http://www.directadmin.com/forum/showthread.php?s=&threadid=258).

l0rdphi1
09-03-2003, 09:20 AM
Here. :D


<?php

$obj->request("/CMD_ACCOUNT_USER?username=<username>&email=<email>&passwd=<password>"
."&passwd2=<password>&domain=<primary_domain>&bandwidth=<megs_bandwidth>"
."&quota=<megs_storage>&uvdomains=ON&unsubdomains=ON&unemails=ON&unemailf=ON"
."&unemailml=ON&unemailr=ON&umysql=ON&udomainptr=ON&uftp=ON&aftp=ON&cgi=ON&ssl=ON"
."&suspend_at_limit=ON&skin=<skin>&ip=<server_ip>&add=Submit&action=create");

?>That's what I use to create actual accounts right now. It works great, however, it does need coverted over to the new CMP_API_CREATE_ACCOUNT method.

I think the below will work with the CMD_API (untested):


<?php

$obj->request("/CMD_API_ACCOUNT_USER?username=<username>&email=<email>&passwd=<password>"
."&passwd2=<password>&domain=<primary_domain>&bandwidth=<megs_bandwidth>"
."&quota=<megs_storage>&uvdomains=ON&unsubdomains=ON&unemails=ON&unemailf=ON"
."&unemailml=ON&unemailr=ON&umysql=ON&udomainptr=ON&uftp=ON&aftp=ON&cgi=ON&ssl=ON"
."&suspend_at_limit=ON&skin=<skin>&ip=<server_ip>&add=Submit&action=create");

$result = $obj->array_last_parsed();

if ($result[error]) {

echo "Woo. There was an error.<p>$result[details]";

exit;
}

echo $result[text];

?>
Note: Rememer to replace my <blah> tags with actual values/variables. :P

*Note: This example uses the version 1.xx of the communication class; you need the wrapper (http://www.l0rdphi1.com/tools/httpsocket/httpgetsocket.phps) to continue in this fashion*

DirectAdmin Support
09-03-2003, 09:27 AM
Yes, the CMD_API_ACCOUNT_* commands are exact copies of the regular verions... the only difference is the output it generates, which is nicer to parse.

John

wwwtactics
09-10-2003, 01:34 PM
Is there anyone here that can give a real script with a minimum of explanation ??

if yes don't be shy just help, the help on the api is not clear at all, and no exemple can be found, is there any documentation out there ?

thanks
william !

DirectAdmin Support
09-10-2003, 02:50 PM
Hello,

Check out http://www.directadmin.com/forum/showthread.php?s=&threadid=258... I'm not sure how much simpler it can get.

John

wwwtactics
09-10-2003, 05:25 PM
thanks but this doesn't seem to work for me, what a pitty.
thanks anywhat.
william !

l0rdphi1
09-11-2003, 06:40 AM
We are here to help if you want to tell us what is not working :)

wwwtactics
10-02-2003, 02:34 AM
Hi,

What Does not work for this URL creation.

Whatever I do

1-Using this URL in a browser to create a member shows me the login page

http://login:password@esecuresite3.com:2222/CMD_ACCOUNT_USER?username=$ndd&email=$alm_email&passwd=pass1234&passwd2=pass1234&domain=$primary_domain&package=aleapay&notify=yes&ip=66.98.138.15&add=Submit&action=create

2-Using this URL in a fsock results in an error
http://login:password@esecuresite3.com:2222/CMD_ACCOUNT_USER?username=$ndd&email=$alm_email&passwd=pass1234&passwd2=pass1234&domain=$primary_domain&package=aleapay&notify=yes&ip=66.98.138.15&add=Submit&action=create

The only possibility is to
a ) connect to my admin account
http://esecuresite3.com:2222
login
password

b ) copy the URL in the same browser and the accounts are created, but doing this way means that it is not automatic at all.
http://login:password@esecuresite3.com:2222/CMD_ACCOUNT_USER?username=$ndd&email=$alm_email&passwd=pass1234&passwd2=pass1234&domain=$primary_domain&package=aleapay&notify=yes&ip=66.98.138.15&add=Submit&action=create

So I don't understand why it works for everyone and not for me.
:confused:

thanks
william !

l0rdphi1
10-02-2003, 05:53 AM
I don't think you can login like that anymore. The session system doesn't allow for it.

Check out

dbarton
12-19-2003, 08:28 PM
I tried that script for 2.0 for account creations, seems it doesn't work correctly. For result, I keep getting Array, and yes I'm using CMD_API_ACCOUNT_USER. I use $sock->query("/CMD_API_ACCOUNT_USER?bahblahblah");

However, I've tried this remotely, to see if it blocks local connections, and it cannot even establish a connection remotely. I have no other idea on what to do.

DirectAdmin Support
12-20-2003, 02:44 PM
Hello,

Does it connect at all? try:

telnet localhost 2222
# or
telnet 1.2.3.4 2222and then press enter 3 times if it connects..

John

l0rdphi1
12-20-2003, 10:43 PM
You'll also want to be using
$sock->query("/CMD_API_ACCOUNT_USER","bahblahblah"); I do believe

graphicscompany
03-26-2009, 04:31 PM
Hello, I want to automate the user creation procces using the signup forms I use for new customers signing up for a hosting account.

I have found the PHP classes with user_create forms in them.
This seems very prommissing, but I keep getting the message that the password is not correct.

Now, I know that the password is correct, because i checked it. Also all other settings in the config.php file are correct...
But, for some reason all the forms from this php class have a problems with my admin password.

"Failed to add new user: Cannot Create Account
Invalid Password"

Can anybody help me?

DirectAdmin Support
03-26-2009, 05:17 PM
The password is not syntactically allowed by DA, for whatever reason.
Try a simpler password to give the user. (it's not your existing DA account password that DA is talking about)

Or if you've enabled the difficult password checking (http://www.directadmin.com/features.php?id=910), then you'd have to satisfy that.

John

graphicscompany
03-27-2009, 12:29 PM
Thanks for your reply. I tried a lot of different passwords, simple and hard, but none are accepted.

I did not enable the difficult passoword thingy, I'm not realy in to the API yet.
All I am able to do is copy and past php classes that do the job for me.
This is why I need that class to work...

Any other suggestions to what I could do?

DirectAdmin Support
03-27-2009, 02:22 PM
This is an example which works, perhaps you're simply not passing a required variable. Compare yours to this one:

http://www.directadmin.com/sample_api.txt

John

graphicscompany
03-27-2009, 02:57 PM
I checked the sample with the code I got in the 'da-api php class' package and it's all there. It's just a little bit diffirent



<?php

$username = $_POST[username];
$email = $_POST[email];
$passwd = $_POST[password1];
$passwd2 = $_POST[password2];
$domain = $_POST[domain];
$package = $_POST[package];
$notify = $_POST[notify];

include '../config/config.php';
include '../protocol/httpsocket.php';
$Socket = new HTTPSocket;

$Socket->connect($siteurl,$siteport);
$Socket->set_login($adminusername,$adminpassword);
// {admin_username} and {admin_password} are not specifically your administrative DA user,
// but rather the user that you want to own this new user.

$Socket->query('/CMD_API_ACCOUNT_USER',
array(
'username' => $username, // The User's username. 4-8 characters, alphanumeric
'email' => $email, // A valid email address
'passwd' => $password1, // The User's password. 5+ characters, ascii
'passwd2' => $password2, // Password double check. 5+ characters, ascii
'domain' => $domain, // A valid domain name in the form: domain.com
'package' => $package, // One of the User packages created by the Reseller
'ip' => $ipaddress, // One of the ips which is available for user creation. Only free or shared ips are allowed.
'notify' => $notify, // yes or no. If yes, an email will be sent to email
'action' => 'create',
'add' => 'Submit'
));
$result = $Socket->fetch_parsed_body();

if ( $Socket->get_status_code() != 200 || !empty($result['error']) )
{
// failure.
echo "Failed to add new user: {$result['text']}<br />{$result['details']}";
} else {
// new user added.
print_r('User '.$username.' created...');
}


?>


Then I pasted the code of your sample in a file on my server and tried if it actually is working... Unfortunatily, I got the following order trying:
"Fatal error: Class 'HTTPSocket' not found in graphicscompany.net/public_html/php/forms/sample.php on line 21"