Forum Moderators: coopster
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:
[php]
// 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);
[/php]
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:
[php]
// 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)) {
[/php]
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?
[edited by: dreamcatcher at 11:32 pm (utc) on Feb. 23, 2007]
[edit reason] Fixed side scroll. [/edit]
// Check result
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ("already exists!", $line, $out)) {
$cpanelerror = '1';
}
} // 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.';
}
While on this topic...
What kind of security measures should I have in place to protect my *** from bots and hackers with this Cpanel email account creator?