PHP Code:
<?
include("config.php");
$email=strtolower($email);
$cp_email="$email@$domain";
$conn = mysql_connect($dbhost, $dbusername, $dbpass) or die(mysql_error( ));
mysql_select_db($dbname,$conn) or die(mysql_error( ));
$get_items="SELECT * FROM email_users WHERE user_ip='$user_ip'";
$get_items_res=mysql_query($get_items) or die(mysql_error( ));
if ($first_name=="") {
echo "First Name is blank. Go <a href=addpop.php>Back</a>";
}elseif($last_name=="") {
echo "Last Name is blank. Go <a href=addpop.php>Back</a>";
}elseif($alt_email=="") {
echo "Alternate Email is blank. Go <a href=addpop.php>Back</a>";
}elseif($email=="") {
echo "User Name is blank. Go <a href=addpop.php>Back</a>";
}elseif($password=="") {
echo "Password is blank. Go <a href=addpop.php>Back</a>";
}elseif($quota=="") {
echo "Script Error. Go <a href=addpop.php>Back</a>";
} elseif(strpos($alt_email, "@") == false ) {
echo "You have enter an invalid email address. Go <a href=addpop.php>Back</a>";
} elseif(strpos($alt_email, $free1) == true or strpos($alt_email, $free2) == true or strpos($alt_email, $free3) == true ) {
echo "You must not use an alternate email address from a free service. Go <a href=addpop.php>Back</a>";
}elseif(mysql_num_rows($get_items_res)>=1) {
echo "You may not have more than one free account. Your IP has already been used to register another account.";
} else {
// Add POP account
$request = "/frontend/$cpmod/mail/doaddpop.html?email=$email&domain=$domain&password=$password"a=$quota";
$result = cprq($host,$port,$ownername,$reseller_pass,$request);
// cPanel confirm Added to fail duplicate emails
$show = strip_tags($result);
if (strpos($show, "already") !== false && strpos($show, "exists") !== false) {
echo "Account was NOT Created. Email user already exists.<a href=addpop.php>Go Back</a><br>";
// End Duplicate
} else {
// Add Sub Domain
if($add_sub==1) {
// The base domain (sub domain) to add a sub domain to. Note: This must already exist and the FTP user must be assigned to the
// appropriate directory. Uncomment the appropriate line here and in the 'Add FTP User' section.
$members_domain="members";
$base_domain="$members_domain.$domain";
//$base_domain=$domain;
$request = "/frontend/$cpmod/subdomain/doadddomain.html?rootdomain=$base_domain&domain=$email";
$result = cprq($host,$port,$ownername,$reseller_pass,$request);
$show = strip_tags($result);
if ($debugon==1) {
echo "$show<br><br>";
}
}
// Add FTP User
if($add_ftp==1) {
// If this will point to a sub domain created by this script uncomment the $homedir="$/email"; line.
// Otherwise if the script is creating an FTP user only, uncomment and define the first two lines.
//$members_domain="members";
//$homedir="/$members_domain/$email";
$homedir="/$email";
$request = "/frontend/$cpmod/ftp/doaddftp.html?login=$email&password=$password&homedir=$homedir";
$result = cprq($host,$port,$ownername,$reseller_pass,$request);
$show = strip_tags($result);
if ($debugon==1) {
echo "$show<br><br>";
}
}
// Add SQL user
if($add_sql==1) {
$request = "/frontend/$cpmod/sql/adduser.html?user=$email&pass=$password";
$result = cprq($host,$port,$ownername,$reseller_pass,$request);
$show = strip_tags($result);
if ($debugon==1) {
echo "$show<br><br>";
}
}
// Add SQL database
if($add_sql==1) {
$request = "/frontend/$cpmod/sql/adddb.html?db=$email";
$result = cprq($host,$port,$ownername,$reseller_pass,$request);
$show = strip_tags($result);
if ($debugon==1) {
echo "$show<br><br>";
}
}
// Add SQL user to database
if($add_sql==1) {
$db_user1=$ownername;
$db_user2="_" ;
$db_user3=$email;
$request = "/frontend/$cpmod/sql/addusertodb.html?user=$db_user1$db_user2$db_user3&db=$db_user1$db_user2$db_user3&ALL=ALL";
$result = cprq($host,$port,$ownername,$reseller_pass,$request);
$show = strip_tags($result);
if ($debugon==1) {
echo "$show<br><br>";
}
$recipient=$admin_email;
$subject="New SQL user created";
$msg="MySQL database username $email has been created with password of $password";
$mailheaders="From: Site Admin <admin@$domain>\n";
mail ($recipient, $subject, $msg, $mailheaders);
}
$sub_domain="$email.$base_domain";
$put_items="INSERT INTO email_users SET cp_email = '$cp_email', email ='$alt_email', sub_domain='$sub_domain',first_name = '$first_name', last_name = '$last_name', password=password('$password'), username='$email', quota='$quota', user_ip='$user_ip' ";
$put_items_res=mysql_query($put_items) or die(mysql_error( ));
if ($add_ftp==1) {
echo "Your FTP user name is $email@$domain and your FTP server is ftp.$domain<br><br>";
}
if ($add_sub==1) {
echo "You may access your Sub-Domain at <a href=http://$email.$base_domain target=blank>http://$email.$base_domain</a> .<br><br>";
}
if ($add_sql==1) {
echo "Your database name and username is $db_user1$db_user2$db_user3.<br> Note: Your username will not be active for up to 24 hours.<br><br>";
}
echo "Email Account Created. Your email and login name is $cp_email <a href=http://$domain target=blank>Go to our main site</a>";
}
}
end;
function cprq($host,$port,$ownername,$reseller_pass,$request) {
$sock = fsockopen($host,$port);
if(!$sock)
{
print('Socket error');
exit();
}
$authstr = "$ownername:$reseller_pass";
$pass = base64_encode($authstr);
$in = "GET $request\r\n";
$in .= "HTTP/1.0\r\n";
$in .= "Host:$domain\r\n";
$in .= "Authorization: Basic $pass\r\n";
$in .= "\r\n";
fputs($sock, $in);
while (!feof($sock)) {
// fgets ($sock,128);
$result .= fgets ($sock,128);
}
fclose( $sock );
return $result;
}
?>
Thanks for your help,