amnesiac
07-22-2003, 01:16 PM
Hello,
is it possible that somebody fills in a form on my website and that cpanel creates his account and mails him the account details. so that i don't have to do these things by hand. I know there is an certain risk of automated signups but i just want to explore the possibilities of it. I looked into modernbill and that sort of stuff, but i just want an script that only mails the details to the user and creates the account
I am using Cpanel 6
Thnx in advance
p.s if this is the wrong forum mods please move the thread to the appropriate forum
VNPIXEL
07-22-2003, 05:26 PM
phpmanager will do. Cheaper.
amnesiac
07-22-2003, 05:27 PM
i am not looking for such an program, just looking for a script that only adds the users inti the database and mails the users their details noting more, nothing less
DoMeric
07-22-2003, 06:01 PM
So you need something that doesn't gather any billing info? So is this for free hosting?
hdezela
07-23-2003, 12:10 AM
This'll do it:
signup page:
<?php
$pathtoconfig="config.php";
if(isset($newuser))
{
include($pathtoconfig);
$newemail = "$newuser@$domain";
$mpassword = $password2;
$link = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname) or die("Could not select database");
$query="SELECT username FROM $dbtable WHERE((username = '$newuser'))";
$result= mysql_query($query,$link);
if(mysql_num_rows($result) ==0)
{
$query="INSERT INTO $dbtable(name,username,password,email) VALUES ('$name','$newuser','$password2','$replymail');";
mysql_query($query,$link);
$socket = fsockopen($host,2082);
$authstr = "$cpaneluser:$cpanelpass";
$pass = base64_encode($authstr);
$in = "GET /frontend/$cpaneltheme/mail/doaddpop.html?email=$newemail&domain=$domain&password=$mpassword&a=$quota\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";
fputs($socket,$in);
fclose( $socket );
$sendto = $newuser."@YOURDOMAIN.COM,".$replymail;
$subject = "Welcome ".$name." to YOURDOMAIN.COM Webmail";
$message = "Hello ".$name."\n\n"."Your new email address is: ".$newuser."@YOURDOMAIN.COM\n\n"."Your password is: ".$password2;
$extra = "From: ADMIN@YOURDOMAIN.COM\r\nReply-To: ADMIN@YOURDOMAIN.COM\r\n";
mail ($sendto, $subject, $message, $extra);
?>Your account has been created
<?
}
else {
echo 'That username has already been selected, please choose another';
}
mysql_close($link);
}
else { ?>
<form name="orderform" method="post" action="THISPAGE.PHP">
Your Name:<input name="name" type="text">
Alternate email:<input name="replymail" type="text">
Your new email address:<input name="newuser" type="text">@YOURDOMAIN.COM
Password:<input name="password1" type="password">
Confirm Password<input name="password2" type="password">
<script language="JavaScript1.2">
function validateform()
{
if (checkEmailAddress(document.orderform.replymail))
{
if(document.orderform.password1.value == document.orderform.password2.value)
{
document.orderform.submit();
}
else
{
alert("The passwords don't match");
}
}
}
function checkEmailAddress(field) {
var good;
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){
good = true
} else {
alert('Please insert a valid email')
field.focus()
field.select()
good = false
}
return good;
}
</script>
<input name="signupbtn" type="button" id="signupbtn" value="Sign Up" onClick="validateform()">
</form>
<? }
?>
hdezela
07-23-2003, 12:12 AM
config.php:
<?
//before this will work you will need to make a database and then run signup.sql in phpmyadmin
//if you need any help email me at support@warwithboredom.com
//also once you have made the table you Must add any email addresses that you already have
//to the data base manually otherwise this script can overwrite mailboxes
$host = "";//your url
$domain = "";//your domain without the www
$cpaneluser = "";//your cpanel username
$cpanelpass = "";//your cpanel password
$cpaneltheme= ""; //this is the word after frontend/ and the next / when you login to cpanel
$dbhost=""; //Usually localhost
$dbuser="";//mysql username
$dbtable="";//only change this if you have access to only one database
$dbpass="";//mysql password
$dbname="";//The name of the database
$quota=;//how much space in k you want to give the user
$mailurl="";//The url for your web based mail program I use http://uebimiau.sourceforge.net but you can use anything
//see http://www.hotscripts.com/PHP/Scripts_and_Programs/Email_Systems
//End of settings! you should not need to change anything below this
?>
hdezela
07-23-2003, 12:16 AM
And you would need a mySQL table with the following:
name : The person's name
username : Their email login
password : Their password
email : Their alternate email address
The mySQL table is so that repeat usernames aren't signed up, since Cpanel sometimes likes to simply overwrite previous usernames for some odd reason, also, it's a nice way of keeping a log of the people who sign up for your email.
I've got a working copy of this here (http://www.quehacemos.com/registromail/index.php) if you'd like to look at it. I've added more things like address & other information plus more checking to ensure all fields are filled. Plus I've made a checkbox so that the user agrees to the conditions set on the page.
Email me if you'd like the complete script, as I can't post something that long.
amnesiac
07-23-2003, 02:24 AM
thnx a lot man.
I will look into this script and let you know how it works
amusive.com
07-23-2003, 09:36 AM
CPanel provides a perl module for interfacing directly with the system using a remote key, as opposed to putting your root (or reseller) password in plaintext.
Which is a bad idea.
amnesiac
07-23-2003, 10:52 AM
where can i find that perl module, becouse it has to be as safe as possible
amusive.com
07-23-2003, 10:56 AM
More info here (http://web.cpanel.net/manual/remoteaccess.html)