...

View Full Version : Help catching error



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&quota=$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?

adammc
02-24-2007, 04:37 AM
I got it sorted using:


// 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 ??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum