Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help catching error

    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:

    PHP Code:
    // 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 ($f1024);
      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:
    PHP Code:
    // 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?

  • #2
    New Coder
    Join Date
    Jul 2006
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got it sorted using:

    Code:
    // Check result 
    while (!feof ($f)) { 
      $line = fgets ($f, 1024); 
      if (ereg ("already exists!", $line, $out)) { 
          $cpanelerror = '1'; 
      } 
    }

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •