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.

CPanel Login Information

Discussion in 'General Discussion' started by redlorry919, Mar 24, 2004.

  1. redlorry919

    redlorry919 Well-Known Member

    Joined:
    Feb 14, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    I currently have a site www.dream-hosting.co.uk which has a members area in which the customer can log into their account and manage billing etc.

    What I want to do is have a link to their cpanel within this area. It currently exists in a link to the secure server with the port 2083 and then the user inputs their cpanel username/password.

    Is there a way of automaically logging the user in from this screen without the popup login screen appearing? I store their cpanel user in my database but obviously not the cpanel password due to privacy but also the fact that the user can chage their password through cpanel and therefore not updating my database.

    Can the password be accessed by any scripts or is there another way of doing this?

    Any advice welcomed.

    Thanks,
    Adam.
     
  2. ryno267

    ryno267 Well-Known Member

    Joined:
    Mar 3, 2004
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chandler, AZ
    cPanel Access Level:
    Root Administrator
    excuse the code.. but this is what i'm working on currently

    Code:
    <html>
      <head>
        <title>
          Cpanel Login
        </title>
        <style type="text/css">
          .login_text {
            font-family: Verdana;
            font-size: 12px;
            color: #1A2B8A;
            text-decoration: none;
            border: none;
            vertical-align: middle;}
          .input {
            font-family: Verdana;
            font-size: 12px;
            color: #1A2B8A;
            text-decoration: none;
            border: black solid 1px;
            vertical-align: bottom;
            background-color: #eee;}
        </style>
        <script type="text/javascript">
          function set_target() {
            var username, password, servername, login_option, protocol;
            username     = document.forms.login_form.user.value;
            password     = document.forms.login_form.pass.value;
            servername   = document.forms.login_form.server.value;
            login_option = document.forms.login_form.login_option.value;
     
            login_option == '2083' ? protocol = 'https://' : protocol = 'http://' ;
        
            document.forms.login_form.action = protocol + servername + ':' + login_option + '/login';
          }
        </script>
      </head>
      <body>
        <form name="login_form" method="post" onsubmit="set_target();">
          <table align="center">
            <tr>
              <td>
                <span class="login_text">Username:</span>
              </td>
              <td>
                <input name="user" class="input" type="text" value="" style="width:125;height:18" />
              </td>
            </tr>
            <tr>
              <td>
                <span class="login_text">Password:</span>
              </td>
              <td>
                <input name="pass" class="input" type="password" value="" style="width:125;height:18" />
    			<input type="hidden" name="server" value="69.44.153.9" />
              </td>
            </tr>
            <tr>
              <td>
                <span class="login_text">Options:</span>
              </td>
              <td>
                <select name="login_option" class="input" style="width:125;height:18">
                  <option value="2082">Cpanel</option>
                  <option value="2083">Cpanel Secure</option>
                  <option value="2095">Webmail</option>
                </select>
              </td>
            </tr>
            <tr>
              <td colspan="2" align="center">
                <input class="input" type="submit" value="Login" style="width:200;height:18" onmouseout="blur(this);" />
              </td>
            </tr>
          </table>        
        </form>
      </body>
    </html>
    
     
  3. redlorry919

    redlorry919 Well-Known Member

    Joined:
    Feb 14, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    Looks like a good script but not quite what I'm after.

    When one of my customers logs in to the dream-hosting.co.uk members area, their details are retrieved from my database securly. I want a way that the user can then log into cpanel bypassing the prompt i.e. user and password passed to cpanel automatically.

    When a user currently has multiple accounts, they have to remember the user/password for everyone and it would be easier if the only user/password they had to remember was the dream-hosting.co.uk one.

    Any ideas? Do you know where the cpanel password is stored, and as I have access to the root can I dip into it via script?

    Thanks,
    Adam.
     
  4. ryno267

    ryno267 Well-Known Member

    Joined:
    Mar 3, 2004
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chandler, AZ
    cPanel Access Level:
    Root Administrator
    okay.. i get it now...

    i don't know where that password is.. i'm still green when it comes to this server stuff...
    :D
     
  5. tsg247

    tsg247 Active Member

    Joined:
    Feb 8, 2004
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Georgia
    Why not just store the user/pass in php values when they log in, then pass it on to the control panel via a script when the click the "cpanel" link?
     
  6. redlorry919

    redlorry919 Well-Known Member

    Joined:
    Feb 14, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    They use a different password for the members area as it allows them to manage more than one cpanel account so the password entered for the members area if different than the one entered for their cpanel accounts and hence they have at least two sets of user/passwords.
     
  7. tsg247

    tsg247 Active Member

    Joined:
    Feb 8, 2004
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Georgia
    Well... I guess my idea wouldn't work then!

    You would need to figure out a way to have cpanel look to your user/password database for authentication for login... and I can't help you with that... maybe someone else here knows if this can be done, and how.

    Chris
     
  8. BrightAdmin

    BrightAdmin Well-Known Member

    Joined:
    Feb 29, 2004
    Messages:
    204
    Likes Received:
    0
    Trophy Points:
    16
    Hi,

    If you want your customer have to login to there cpanel from your site then the following script may help you in solving the problem:

    <html>
    <script language="javascript">
    <!-- Begin
    function Login(form) {
    var username = form.username.value;
    var password = form.password.value;
    var server = form.server.value;
    if (username && password && server) {
    var cpanel="https://" + username + ":" + password + "@" + server + ":2083";
    window.location = cpanel;
    }
    else {
    alert("Please enter your username and password.");
    }
    }
    // End -->
    </script>
    <body>
    <form name=login>
    <table border=1 cellpadding=3>
    <tr>
    <td colspan=2 align=center>
    <h2>Logon to CPanel! </h2>
    </td>
    </tr>
    <tr>
    <td>Username:</td>
    <td>
    <input type=text name=username size=20 maxlength="26">
    </td>
    </tr>
    <tr>
    <td>Password:</td>
    <td>
    <input type=password name=password size=20>
    </td>
    </tr>
    <tr>
    <td>Your Domain:</td>
    <td>
    <input type=server name=server size=20>
    </td>
    </tr>
    <tr>
    <td colspan=2 align=center>
    <input type=button value="Login!" onClick="Login(this.form)" name="button">
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    Regards,

    Bright :)
     
  9. DN-Paul

    DN-Paul Well-Known Member

    Joined:
    Oct 30, 2003
    Messages:
    91
    Likes Received:
    0
    Trophy Points:
    6
    That won't work for people using an up-to-date version of IE.
     
  10. tsg247

    tsg247 Active Member

    Joined:
    Feb 8, 2004
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Georgia
    From a conceptual standpoint, I really don't think what he wants to do is even possible without making some major changes to the cpanel scripting... after doing all that, you'd probably be better off with your own custom control panel.
     
  11. redlorry919

    redlorry919 Well-Known Member

    Joined:
    Feb 14, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    I was having a think and I think the only way I can do it is to disable cpanel password modifications. Then store the user/password for each cpanel in mysql when I set the accounts up. I could then provide an automatic link through to their cpanel from their members area.

    The obvious restriction being that the user can not alter their cpanel password, and that the latest version of IE wont support it.

    What do you think? Any other ideas - great advice so far?
     
  12. tsg247

    tsg247 Active Member

    Joined:
    Feb 8, 2004
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Georgia
    Disabling the change password function for cpanel and then storing that info in your sql database would work. As for it not working with the new IE update, I believe I saw a script floating around here a couple days ago that bypassed this problem... if I find it, I'll post a link... I'm pretty sure you could modify the script to work for what you're wanting it to do.

    By the way... the members area that you're talking about... is this something custom that you've done or is it a script that you've purchased? I'm looking into setting something like this up for my clients, but haven't really found anything yet that I like.

    Chris
     
  13. ryno267

    ryno267 Well-Known Member

    Joined:
    Mar 3, 2004
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chandler, AZ
    cPanel Access Level:
    Root Administrator
    im with chris... like his ideas...

    waiting to hear his solution.... ;)
     
  14. tsg247

    tsg247 Active Member

    Joined:
    Feb 8, 2004
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Georgia
    Acutally,
    I think I know a way you can do this without having to turn the password change option off... it involves setting up a second user for each cpanel account. You'd store this info in the sql database and us it to log in to cpanel... but let me look more into it and get back to you.
    Chris
     
  15. uphost

    uphost Registered

    Joined:
    Jan 10, 2004
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    i have my own user administration software. The users password is md5 encripted in a database. With some scripts I created the users is able to change the cpanel password fom my page. I disabled the change password from the cpanel, so I keep my md5 sincronized with the cpanel.

    I'm workin in a code to automatic login my users using PHP.

    When you loging in the cpanel (and that's also valid for WHM, horde etc....) your browser recives a cookie with the session ID of your connection.

    the script will login with a user and password information, get the cookie and send to the browser.

    The user will login to my page. I'll check the md5 of the password he typed against the ms5 in my database. If it's the same, i store the plain password in a session var he just entered and give access to the system.

    When he clicks in the "Cpanel" button I run the script with the plain password he entered.

    ------------------ File cpanel_login.php -----------------
    <?PHP
    # Please Keep this comment
    # Ricardo Riet Correa
    # ricardo@riet.com.br


    #get user information from session
    $login_user = array ( "user" => $_SESSION[usuario],
    "pass" => $_SESSION[pasinfo]);

    #connect to host and send login info
    $host = 'your_host_address.com';
    $fp = fsockopen($host, 2082, $errno, $errstr, 3);
    $out = "POST /login/ HTTP/1.1\r\n";
    $out .= "Host: $host\r\n";
    $out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\n";

    #brake login info and send to host
    while (list ($k, $v) = each ($login_user)) {
    if(strlen($content) != 0) $content .= "&";
    $content .= rawurlencode($k). "=" .rawurlencode($v);
    }

    #I this is not necessary
    $out .= "Content-Length: ".strlen($content)."\r\n\r\n";
    $out .= $content." \r\n";

    #send everyting out and get the return
    fputs($fp, $out);
    $data = '';
    while (!feof($fp)) {
    $data .= fgets($fp, 128);
    }
    fclose($fp);

    #look the result for the string Set-Cookie
    #and get the value
    $string_nedle = 'Set-Cookie: ';
    $inicio = strpos($data,$string_nedle);
    $inicio = $inicio + strlen($string_nedle);
    $end_position = strpos($data,';',$inicio);
    $end_pos = $end_position - $inicio;
    $cookie_string = substr($data, $inicio , $end_pos);

    #split the cookie in the =
    list($name, $value) = split ("=", $cookie_string);

    #set cookie with the session value
    setcookie ($name, $value,time()+3600, "/", ".uphost.com.br");

    #send the user browser to the correct page
    Header("Location: http://your_host_address.com:2082/");
    ?>
    ----------------------- END --------------------------------

    I hope this code helps some one to get things working.

    Thank you
    Ricardo Riet
    http://www.uphost.com.br
     
  16. redlorry919

    redlorry919 Well-Known Member

    Joined:
    Feb 14, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    In response to previous posts -

    I think I have the solution for it now. I'm including it within a piece of billing software specifically created called dreampanel.

    Give me a couple of days and I'll setup a test area and post the information.

    Thanks for all your help people, excellent advice!

    Adam.
     
  17. redlorry919

    redlorry919 Well-Known Member

    Joined:
    Feb 14, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    I know this is an old thread but I now have a rough system that allows users to manage more than one cpanel account but will automatically log them in without the need to remember their cpanel passwords.

    Drop me a PM if you want to see more and I'll give you a temp login to a demo account.

    I'm looking to produce this software as a product so if any skilled php/mysql people out there are interested, again PM me.

    Regards,
    Adam.
     
  18. firexit

    firexit Active Member

    Joined:
    Nov 4, 2004
    Messages:
    29
    Likes Received:
    1
    Trophy Points:
    8
    301 error on script

    Hello
    I ran your script and i get HTTP 301 error all the time
    why?
    did you run into that also?
     
  19. rborg

    rborg Registered

    Joined:
    Jul 19, 2005
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Tried ricardo's script but still being asked to log in...

    Hi Ricardo,

    Hope you can help me

    I read your post
    http://forums.cpanel.net/showthread.php?t=22172&highlight=log+automatically

    because I am trying to do the following (my post):
    http://forums.cpanel.net/showthread.php?t=41507&highlight=log+automatically

    I modified your script as follows and I checked cookie for data and seems that something is being returned. (although I cannot find cookie with other cookies in IE temp internet files ... is this normal?)

    However when header goes to location I am still getting a log in dialog box :(


    <?php
    session_start();
    # Please Keep this comment
    # Ricardo Riet Correa
    # ricardo@riet.com.br


    #get user information from session
    //$login_user = array ( "user" => $_SESSION[usuario],
    //"pass" => $_SESSION[pasinfo]);

    $_SESSION[usuario] = "username";
    $_SESSION[pasinfo] = "password";
    $login_user = array ( "user" => $_SESSION[usuario], "pass" => $_SESSION[pasinfo]);


    #connect to host and send login info
    $host = 'manicmalta.com';
    $fp = fsockopen($host, 2082, $errno, $errstr, 3);
    $out = "POST /login/ HTTP/1.1\r\n";
    $out .= "Host: $host\r\n";
    $out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\n";

    #brake login info and send to host
    while (list ($k, $v) = each ($login_user)) {
    if(strlen($content) != 0) $content .= "&";
    $content .= rawurlencode($k). "=" .rawurlencode($v);
    }

    #I this is not necessary
    $out .= "Content-Length: ".strlen($content)."\r\n\r\n";
    $out .= $content." \r\n";

    #send everyting out and get the return
    fputs($fp, $out);
    $data = '';
    while (!feof($fp)) {
    $data .= fgets($fp, 128);
    }
    fclose($fp);

    #look the result for the string Set-Cookie
    #and get the value
    $string_nedle = 'Set-Cookie: ';
    $inicio = strpos($data,$string_nedle);
    $inicio = $inicio + strlen($string_nedle);
    $end_position = strpos($data,';',$inicio);
    $end_pos = $end_position - $inicio;
    $cookie_string = substr($data, $inicio , $end_pos);

    #split the cookie in the =
    list($name, $value) = split ("=", $cookie_string);

    #set cookie with the session value
    setcookie ($name, $value,time()+3600, "/", ".manicmalta.com");
    //echo($cookie_string);

    #send the user browser to the correct page
    Header("Location: http://www.manicmalta.com:2082/");
     
Loading...

Share This Page