Web Hosting Talk







View Full Version : Automated Account Creation For Plesk


championhost
12-11-2001, 01:33 AM
Any knows a program that will creat accounts automaticlly for plesk.

Thanks

awhost
12-11-2001, 10:52 AM
I understand they have a command line utility to do this. All you would have to do is call the command line from a short PHP/Perl script. If you use PHP or Perl for the signup forms/process itself, that task will actually be far more difficult then calling a program and passing parameters to it.

Neofree

davidb
12-11-2001, 01:38 PM
Acually, it wont work like that. Only root can execute the scripts and setuid dosent work for it. There are plent of other ways though

allending
12-11-2001, 01:52 PM
PHP wont work that way, since only root is able to execute the user creation scripts on most systems (good thing). What you could do is this:

1. A form grabs the username,password,fullname,etc. and stores them in a database (mysql,postgresql,anything). Of course do some checking on the variables to make sure that they are alphanumeric and valid :o

2. Have a PHP script that actually retrieves these values (if they are there) and executes the system("whatever commands you use to add user in plesk and the variables you retrieved") ( sorry, i dont know what the plesk command line tools are). Try naming this script adduser.php and putting it outside the web directory. Below this post will be something I cooked up right now, not sure if it will work for you exactly though. This is strictly for demonstration, it is NOT safe to use exactly this You should modify it to fit your needs ;)

3. Make sure you have a CGI php executable. If you dont, compile it (its not hard, and you just need a vanilla compile). Then as root, make a cronjob for * * * * * /pathtophpexecutable/php /pathtoadduserscript/adduser.php > dev/null

This will check for new users every minute, and if there are new users , add them to the system.

allending
12-11-2001, 02:00 PM
Ok , heres the lengthy post. Of course, modify to suit your needs. Works for raq too. You should add things like duplicate user checking, safe character checking, basically, stuff dealing with security.

Make a table in a database
#
# Table structure for table `newuserqueue`
#

CREATE TABLE newuserqueue (
username varchar(20) NOT NULL default '',
fullname varchar(20) NOT NULL default '',
password varchar(20) NOT NULL default ''
) TYPE=MyISAM;


Have a signup sheet for users
<?php

if ($register)
{
//put your own database connection here
$linkid=mysql_connect($dbhost, $dbusername, $dbuserpassword);
if(!$result=mysql_query("INSERT INTO newuserqueue VALUES('$username','$fullname','$password')")) die(sql_error());
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>

<title>mysite.com</title>
<style type="text/css">
@import "style.css";
</style>
</head>

<body>
<br><br>
Adduser2:<br>
<form action="<?php echo $PHP_SELF; ?>" method="POST">
Username: <input type="text" name="username"><br>
Full Name: <input type="text" name="fullname"><br>
Password: <input type="text" name="password"><br>
<input type="hidden" name="register" value="1">
<input type="submit">
</form>

</body></html>



Make a script that checks for new users and adds them to system
<?php

$linkid=mysql_connect($dbhost, $dbusername, $dbuserpassword);
if(!$result=mysql_query("SELECT username,fullname,password FROM newuserqueue")) die(sql_error());

for($i=0 ; $i<mysql_num_rows($result); $i++)
{
$data=mysql_fetch_array($result);
$uname=$data['username'];
$fname=$data['fullname'];
$pword=$data['password'];

//This part is the sytem execution - what i wrote is for a cobalt
//RAQ, but from what i have seen the plesk command line for
//adding users should be easy to replace here.
system("/usr/sbin/cobalt/adduser -d yourdomain.com -u $uname -f '$fname' -p $pword");
}

mysql_query("DELETE FROM newuserqueue");


?>



Make sure you have PHP as a CGI executable.
Run a cron job as ROOT (example: * * * * * /pathtophp/php /pathtoscript/adduser.php > /dev/null

This checks for user every minute and adds them if there are new users.

Hope that helps.

PaulC-ehosting
03-16-2002, 05:53 PM
The PSA client creation tools are a bit more complex than that....

Also, wouldn't the MySQL table want to store data such as bandwidth limits, clients name, and most importantly, a domain name??

Paul

Neo3Net
03-16-2002, 10:28 PM
Check Plesk.com's Forums there is someone selling the scripts and everything. I have used them and they work quite well.

PlanetDigita
04-05-2002, 12:41 AM
Not sure if anyone else has had any experience with easypsa.com (http://www.easypsa.com), I came across this site yesterday. They seem to be offering a way to get plesk and modern bill automated.