adammc
02-23-2007, 11:26 PM
Hi Guys,
I am trying to add in a Cpanel Email account creator block of code into a user registration form.
I found the Cpanel email creator code after searching on Google, so far I have been unable to get it to function properly & securely.
This is the script that I including:
// Settings
$cpuser = ''; // cPanel username
$cppass = ''; // cPanel password
$cpdomain = ''; // cPanel domain or IP
$cpskin = 'rvlightolive'; // cPanel skin. Mostly x or x2.
$equota = 20; // amount of space in megabytes
// Create email account
$f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$username&domain=$edomain&password=$password1"a=$equota", "r");
if (!$f) {
die('Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode');
}
// Check result
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ("already exists!", $line, $out)) {
$cpanelerror = '1';
}
fclose($f);
The original script didnt use '$cpanelerror = '1';' it just echoed a success message after 'fclose($f);' I have added this to try and catch when there is an error.
This is the section in my registration form that I am including it:
// run the Cpanel email creator script
include ('cpemail.php');
// Check that an Cpanel email account doesnt already exist.
if ($cpanelerror ="1") {
$errors[] = 'An email account with that name already exists.';
}
// If everything went okay and there were no errors, continue.
if (empty($errors)) {
The problem is $cpanelerror seems to always be '1' even when an email accounts doesnt exist, it is creating the new email account ok but I just keep getting the error message ??
Can anyone possibly help?
I am trying to add in a Cpanel Email account creator block of code into a user registration form.
I found the Cpanel email creator code after searching on Google, so far I have been unable to get it to function properly & securely.
This is the script that I including:
// Settings
$cpuser = ''; // cPanel username
$cppass = ''; // cPanel password
$cpdomain = ''; // cPanel domain or IP
$cpskin = 'rvlightolive'; // cPanel skin. Mostly x or x2.
$equota = 20; // amount of space in megabytes
// Create email account
$f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$username&domain=$edomain&password=$password1"a=$equota", "r");
if (!$f) {
die('Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode');
}
// Check result
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ("already exists!", $line, $out)) {
$cpanelerror = '1';
}
fclose($f);
The original script didnt use '$cpanelerror = '1';' it just echoed a success message after 'fclose($f);' I have added this to try and catch when there is an error.
This is the section in my registration form that I am including it:
// run the Cpanel email creator script
include ('cpemail.php');
// Check that an Cpanel email account doesnt already exist.
if ($cpanelerror ="1") {
$errors[] = 'An email account with that name already exists.';
}
// If everything went okay and there were no errors, continue.
if (empty($errors)) {
The problem is $cpanelerror seems to always be '1' even when an email accounts doesnt exist, it is creating the new email account ok but I just keep getting the error message ??
Can anyone possibly help?