The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

clear cookies all the time with form related to email creation

Discussion in 'cPanel Developers' started by regidoor, Jul 26, 2011.

  1. regidoor

    regidoor Member

    Joined:
    Jul 25, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hello There

    We have created a form to create email accounts and forwarders from outside cPanel... so that some moderators can create these accounts without accessing to cPanel...

    This is the form...

    /http://regidordigital.com/email_create/index.php

    It's in Spanish
    User = Usuario
    Contraseña = Password
    Repite Contraseña: = Repeat Password
    Redireccionado a: Forwarder

    Now at first we create the emails alright. But once we exit the browser and come back again, the form appears with the message "Las contraseñas no coinciden" (passwords don't match) and if we try to create an email account, it won't allow us to do it...

    If I go to options in the browser and clear cookies... then refresh... the passwords don't match message don't appear and I can create accounts properly again...

    This issue is taking place at least a IE, FF and chrome... And I was wondering if you could help me with it... My server provider hasn't been able to help me further with the issue and has recommended me to post in the forum....

    If you have any idea as to why this takes place, it'd be great...

    Thanks very much in advance
    Alberto
     
  2. kalid

    kalid Active Member

    Joined:
    Jul 26, 2011
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    > America/Mexico_City
    cPanel Access Level:
    Root Administrator
    Hello.

    What's source code?
     
  3. regidoor

    regidoor Member

    Joined:
    Jul 25, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    This is the code at index.php

    <?php

    include("./xmlapi.php"); //XMLAPI cpanel client class

    // Default whm/cpanel account info

    $ip = "127.0.0.1"; // should be server IP address or 127.0.0.1 if local server
    $account = "username"; // cpanel user account name
    $passwd ="password"; // cpanel user password
    $port =2083; // cpanel secure authentication port unsecure port# 2082

    $email_domain = 'regidordigital.com'; // email domain (usually same as cPanel domain)
    $email_quota = 50; // default amount of space in megabytes


    /*************End of Setting***********************/

    function getVar($name, $def = '') {
    if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
    else
    return $def;
    }
    // check if overrides passed
    $email_user = getVar('user', '');
    $email_pass = getVar('pass', $passwd);
    $email_vpass = getVar('vpass', $vpasswd);
    $email_domain = getVar('domain', $email_domain);
    $email_quota = getVar('quota', $email_quota);
    $dest_email = getVar('forward', '');

    $msg = '';
    if (!empty($email_user))
    while(true) {


    if ($email_pass !== $email_vpass){ //check password
    $msg = "Las contrase&ntilde;as no coinciden";
    break;
    }

    $xmlapi = new xmlapi($ip);

    $xmlapi->set_port($port); //set port number. cpanel client class allow you to access WHM as well using WHM port.

    $xmlapi->password_auth($account, $passwd); // authorization with password. not as secure as hash.

    // cpanel email addpop function Parameters
    $call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
    // cpanel email fwdopt function Parameters
    $call_f = array(domain=>$email_domain, email=>$email_user, fwdopt=>"fwd", fwdemail=>$dest_email);
    $xmlapi->set_debug(0); //output to error file set to 1 to see error_log.

    // making call to cpanel api
    $result = $xmlapi->api2_query($account, "Email", "addpop", $call );
    $result_forward = $xmlapi->api2_query($account, "Email", "addforward", $call_f); //create a forward
    //for debugging purposes. uncomment to see output
    //echo 'Result\n<pre>';
    //print_r($result);
    //echo '</pre>';

    if ($result->data->result == 1){
    $msg = $email_user.'@'.$email_domain.' ha sido creada';
    if ($result_forward->data->result == 1){
    $msg = $email_user.'@'.$email_domain.' redireccionada a '.$dest_email;
    }
    } else {
    $msg = $result->data->reason;
    break;
    }

    break;
    }

    ?>
    <html>
    <head><title>CREA CUENTAS DE EMAIL</title></head>
    <body>
    <?php echo '<div style="color:red">'.$msg.'</div>'; ?>
    <h1>CREA CUENTAS DE EMAIL</h1>
    <form name="frmEmail" method="post">
    <table width="400" border="0">
    <tr><td>Usuario:</td><td><input name="user" size="20" type="text" /></td></tr>
    <tr><td>Contrase&ntilde;a:</td><td><input name="pass" size="20" type="password" /></td></tr>
    <tr><td>Repite Contrase&ntilde;a:</td><td><input name="vpass" size="20" type="password" /></td></tr>
    <tr><td>Redireccionado a:</td><td><input name="forward" size="20" type="text" /></td></tr>
    <tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Crea Email" /></td></tr>
    </table>
    </form>
    </body>
    </html>
    <html><body></body></html>


    ............................................

    Thx very much
    Alberto
     
  4. regidoor

    regidoor Member

    Joined:
    Jul 25, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Is it being moderated or I cannot publish code?
    thx very much
    alberto
     
  5. regidoor

    regidoor Member

    Joined:
    Jul 25, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    <?php

    include("./xmlapi.php"); //XMLAPI cpanel client class

    // Default whm/cpanel account info

    $ip = "127.0.0.1"; // should be server IP address or 127.0.0.1 if local server
    $account = "username"; // cpanel user account name
    $passwd ="password"; // cpanel user password
    $port =2083; // cpanel secure authentication port unsecure port# 2082

    $email_domain = 'regidordigital.com'; // email domain (usually same as cPanel domain)
    $email_quota = 50; // default amount of space in megabytes


    /*************End of Setting***********************/

    function getVar($name, $def = '') {
    if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
    else
    return $def;
    }
    // check if overrides passed
    $email_user = getVar('user', '');
    $email_pass = getVar('pass', $passwd);
    $email_vpass = getVar('vpass', $vpasswd);
    $email_domain = getVar('domain', $email_domain);
    $email_quota = getVar('quota', $email_quota);
    $dest_email = getVar('forward', '');

    $msg = '';
    if (!empty($email_user))
    while(true) {


    if ($email_pass !== $email_vpass){ //check password
    $msg = "Las contrase&ntilde;as no coinciden";
    break;
    }

    $xmlapi = new xmlapi($ip);

    $xmlapi->set_port($port); //set port number. cpanel client class allow you to access WHM as well using WHM port.

    $xmlapi->password_auth($account, $passwd); // authorization with password. not as secure as hash.

    // cpanel email addpop function Parameters
    $call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
    // cpanel email fwdopt function Parameters
    $call_f = array(domain=>$email_domain, email=>$email_user, fwdopt=>"fwd", fwdemail=>$dest_email);
    $xmlapi->set_debug(0); //output to error file set to 1 to see error_log.

    // making call to cpanel api
    $result = $xmlapi->api2_query($account, "Email", "addpop", $call );
    $result_forward = $xmlapi->api2_query($account, "Email", "addforward", $call_f); //create a forward
    //for debugging purposes. uncomment to see output
    //echo 'Result\n<pre>';
    //print_r($result);
    //echo '</pre>';

    if ($result->data->result == 1){
    $msg = $email_user.'@'.$email_domain.' ha sido creada';
    if ($result_forward->data->result == 1){
    $msg = $email_user.'@'.$email_domain.' redireccionada a '.$dest_email;
    }
    } else {
    $msg = $result->data->reason;
    break;
    }

    break;
    }

    ?>
    <html>
    <head><title>CREA CUENTAS DE EMAIL</title></head>
    <body>
    <?php echo '<div style="color:red">'.$msg.'</div>'; ?>
    <h1>CREA CUENTAS DE EMAIL</h1>
    <form name="frmEmail" method="post">
    <table width="400" border="0">
    <tr><td>Usuario:</td><td><input name="user" size="20" type="text" /></td></tr>
    <tr><td>Contrase&ntilde;a:</td><td><input name="pass" size="20" type="password" /></td></tr>
    <tr><td>Repite Contrase&ntilde;a:</td><td><input name="vpass" size="20" type="password" /></td></tr>
    <tr><td>Redireccionado a:</td><td><input name="forward" size="20" type="text" /></td></tr>
    <tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Crea Email" /></td></tr>
    </table>
    </form>
    </body>
    </html>
    <html><body></body></html>
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If a post has a sufficiently high enough spam score, it will end up moderated prior to being approved. This did indeed happen with the code you've posted, so I've gone ahead and approved your posts.
     
  7. regidoor

    regidoor Member

    Joined:
    Jul 25, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Ok... Thx very much... I see that it has been published...
    Was that the code you meant?'

    Thanks a lot
    Alberto
     
  8. regidoor

    regidoor Member

    Joined:
    Jul 25, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hello... Any hint as to why this cookie issue takes place with the form at

    CREA CUENTAS DE EMAIL

    Thank you
    Alberto
     

Share This Page