Zubrag.com
July 22, 2019, 12:41:15 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: CpEmail Script...Please Help  (Read 23358 times)
cartpauj
Newbie
*
Posts: 2


« on: November 03, 2007, 11:28:39 AM »

I have had the script up and running and it works fine but I have tried to implement it into my user registraion for my site using the following code but It's not working can you please tell me why?
$f = fopen ("http://MYUSER:MYPASS@MYDOMAIN:2082/frontend/rvblue/mail/doaddpop.html?email=$user_login&domain=MYDOMAIN&password=temp&quota=200", "r");
fclose($f);

It will not do anything and I don't know why.  Please help me fix it.  If I didn't supply enough information please let me know what you need.
Thanks

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: November 05, 2007, 07:11:06 AM »

Try following

Code:
$cpanel_statement = "http://MYUSER:MYPASS@MYDOMAIN:2082/frontend/rvblue/mail/doaddpop.html?email=$user_login&domain=MYDOMAIN&password=temp&quota=200";
echo $cpanel_statement;
$f = fopen ($cpanel_statement, "r");    fclose($f);

it should print the cpanel command before running it. Does it print what you expect? I mean domain / login / password inserted correctly?
Logged
cartpauj
Newbie
*
Posts: 2


« Reply #2 on: November 05, 2007, 12:47:35 PM »

I really liked your script and I didn't want to slim it down any so after nearly 3 days of trial and error I got it to work.  It is integrated with WordPress' User Registration system.  I know nothing about PHP so this is huge for me that I got it to work.  I will post the code in case someone would like to do somthing similar.  I realize that this is probably more complex then it needs to be but it works and that's what really counts right?  If anybody can figure out how to integrate these two both into the wp-login.php file and skip the need for the CPEmail.php script that would be even better.  Thanks for the help and the great scripts ZUBRAG.

WORDPRESS CODE in file wp-login.php:
case 'register' :
   if ( FALSE == get_option('users_can_register') ) {
      wp_redirect('wp-login.php?registration=disabled');
      exit();
   }

   if ( $_POST ) {
      require_once( ABSPATH . WPINC . '/registration.php');

      $user_login = sanitize_user( $_POST['user_login'] );
      $user_email = apply_filters( 'user_registration_email', $_POST['user_email'] );

      // Check the username
      if ( $user_login == '' )
         $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
      elseif ( !validate_username( $user_login ) ) {
         $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.');
         $user_login = '';
      } elseif ( username_exists( $user_login ) )
         $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');

      // Check the e-mail address
      if ($user_email == '') {
         $errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
      } elseif ( !is_email( $user_email ) ) {
         $errors['user_email'] = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
         $user_email = '';
      } elseif ( email_exists( $user_email ) )
         $errors['user_email'] = __('<strong>ERROR</strong>: This email is already registered, please choose another one.');

      do_action('register_post');

      $errors = apply_filters( 'registration_errors', $errors );

      if ( empty( $errors ) ) {
         $user_pass = substr( md5( uniqid( microtime() ) ), 0, 7);

            header( "Location: cpemail.php?user=$user_login&pass=$user_pass&quota=200&email=$user_email" );
                                exit();

      }
   }

   login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>');
?>

<form name="registerform" id="registerform" action="wp-login.php?action=register" method="post">
   <p>
      <label><?php _e('Desired Username:<br /><strong>DO NOT use spaces or CAPITALS or your free E-Mail account will not be created</strong>') ?><br />
      <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label>
   </p>
   <p>
      <label><?php _e('Your Current E-mail:') ?><br />
      <input type="text" name="user_email" id="user_email" class="input" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="25" tabindex="20" /></label>
   </p>
<?php do_action('register_form'); ?>
   <p id="reg_passmail"><?php _e('<strong>A password will be e-mailed to you.</strong>') ?></p>
   <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Register &raquo;'); ?>" tabindex="100" /></p>
</form>

CPANEL EMAIL SCRIPT:
<?php
require( dirname(__FILE__) . '/wp-config.php' );
###############################################################
# cPanel Email Account Creator 1.2
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################
# You can pass following parameters in calling URL. They will
# override those specified below.
# user - new email user
# pass - password
# domain - email domain
# quota - email quota, Mb
# Example: cpemail.php?user=newuser&pass=password&quota=50
###############################################################

// cPanel info
$cpuser = 'MYCPUserName'; // cPanel username
$cppass = 'MYCPPass'; // cPanel password
$cpdomain = 'MYDOMAIN'; // cPanel domain or IP
$cpskin = 'rvblue';  // cPanel skin. Mostly x or x2.
// See following URL to know how to determine your cPanel skin
// http://www.zubrag.com/articles/determine-cpanel-skin.php

// Default email info for new email accounts
// These will only be used if not passed via URL
$epass = ''; // email password
$edomain = 'MYDOMAIN'; // email domain (usually same as cPanel domain above)
$equota = 200; // amount of space in megabytes

###############################################################
# END OF SETTINGS
###############################################################

function getVar($name, $def = '') {
  if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
  else
    return $def;
}

// check if overrides passed
$euser = getVar('user', '');
$epass = getVar('pass', $epass);
$edomain = getVar('domain', $edomain);
$equota = getVar('quota', $equota);
$eemail = getVar('email', $eemail);
$user_id = '';
$errors = '';
$msg = '';
$doesexist = 0;

if (!empty($euser)) {

  // Create email account and wordpress account
  $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");
  if (!$f) {
    $msg = 'Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode';
  }
  else {
        $msg = "<h1>Your account has successfully been created</h1><br />Please check your E-Mail for your password.  You can change your password once you've logged in for the first time. <br /> <a href='http://MYDOMAIN.com/wp-login.php'>CLICK HERE to login</a>.";
}

    // Check result
    while (!feof ($f))
    {
      $line = fgets ($f, 1024);
      if (ereg ("already exists", $line, $out))
      {
        $doesexist = 1;
        $msg = "<h2><font color='red'>Sorry <font color='navy'>{$euser}</font> already exists.</font></h2><br /><a href='http://MYDOMAIN.com/wp-login.php?action=register'>Click Here</a> to try another username.";
        break;
      }
    }

if ( !$doesexist )
{
require_once( ABSPATH . WPINC . '/registration.php');
      $user_id = wp_create_user( $euser, $epass, $eemail );
   if ( !$user_id )
        {
   $msg = "Registration Failed.  Please <a href='http://MYDOMAIN.com/wp-login.php?action=register'>TRY AGAIN</a>.  If the problem persists please <a href='http://MYDOMAIN.com/?p=25'>CONTACT US</a>.";
        }
   else
        {
   wp_new_user_notification($user_id, $epass);
        wp_redirect('wp-login.php?checkemail=registered');
        }
}

    fclose($f);
   

}

?>
<?php echo $msg ?>
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #3 on: November 06, 2007, 10:57:14 AM »

Hi cartpauj.
Unfortunately I'm not familiar with Wordpress, so cannot help with implementing design.

Thank you for sharing the code! It would definitely be useful for others.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC