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

Discussion in 'General Discussion' started by chadi, Aug 4, 2004.

  1. chadi

    chadi BANNED

    Joined:
    Apr 20, 2004
    Messages:
    415
    Likes Received:
    0
    Trophy Points:
    0
    I need a capaiblity to add several server IP's within the same login form. How can I do this with the sample below?

    Thanks.

    THIS IS ONE EXAMPLE I FOUND ON ANOTHER FORUM. This is "cplogin.php" file.


    <html>
    <?php

    #your domain or ip
    $domain = "IP address";


    if(!$_POST['login']) {
    exit;
    }

    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $port = $_POST['port'];

    $port == "2083" || $port == "2096" ? $pre = "https://" : $pre = "http://";
    ?>
    <body onLoad="setTimeout('document.forms[0].submit();',10)">
    <form action="<?php echo "".$pre."".$domain.":".$port."/login/"; ?>" method="post">
    <input type="hidden" name="user" value="<?php echo $user; ?>">
    <input type="hidden" name="pass" value="<?php echo $pass; ?>">
    </form>
    </body>
    </html>

    THIS IS THE ACTUAL FORM CODE:

    <form action="cplogin.php" method="post">
    <table cellspacing="4" cellpadding="0">
    <tr><td>Username:</td><td><input type="text" name="user"></td></tr>
    <tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
    <tr><td>Login To:</td>
    <td align="right">
    <select name="port">
    <option value="2082">cPanel</option>
    <option value="2083">Secure cPanel</option>
    <option value="2095">Webmail</option>
    <option value="2096">Secure Webmail</option>
    </select>
    </td></tr>
    <tr><td align="right" colspan="2">
    <input type="submit" name="login" value="login" style="cursor:pointer">
    </td>
    </tr>
    </table>
    </form>
     
  2. chadi

    chadi BANNED

    Joined:
    Apr 20, 2004
    Messages:
    415
    Likes Received:
    0
    Trophy Points:
    0
    I also saw the other one in the generals forum (sticky).

    But the question is how can I use this single form to connect to all servers?
     
  3. SJJM

    SJJM Member

    Joined:
    Dec 17, 2002
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Here you go:

    Change the bits in navy blue to suit your needs.

    cplogin.php:
    Code:
    
    <html>
    <?php
    
    if(!$_POST['login']) {
    exit;
    }
    
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $port = $_POST['port'];
    $domain = $_POST['domain'];
    
    $port == "2083" || $port == "2096" ? $pre = "https://" : $pre = "http://";
    ?>
    <body onLoad="setTimeout('document.forms[0].submit();',10)">
    <form action="<?php echo "".$pre."".$domain.":".$port."/login/"; ?>" method="post">
    <input type="hidden" name="user" value="<?php echo $user; ?>">
    <input type="hidden" name="pass" value="<?php echo $pass; ?>">
    </form>
    </body>
    </html>
    
    Page with login form on:
    Code:
    <form action="cplogin.php" method="post">
    <table cellspacing="4" cellpadding="0">
    <tr><td>Username:</td><td><input type="text" name="user"></td></tr>
    <tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
    <tr><td>Login To:</td>
    <td align="right">
    <select name="port">
    <option value="2082">cPanel</option>
    <option value="2083">Secure cPanel</option>
    <option value="2095">Webmail</option>
    <option value="2096">Secure Webmail</option>
    </select>
    </td></tr>
    <tr><td>Server:</td>
    <td align="right">
    <select name="domain">
    <option value="[COLOR=Navy]Server 1's IP[/COLOR]">[COLOR=Navy]Server 1 Name[/COLOR]</option>
    <option value="[COLOR=Navy]Server 2's IP[/COLOR]">[COLOR=Navy]Server 2 Name[/COLOR]</option>
    <option value="[COLOR=Navy]Server 3's IP[/COLOR]">[COLOR=Navy]Server 3 Name[/COLOR]</option>
    </select>
    </td></tr>
    
    <tr><td align="right" colspan="2">
    <input type="submit" name="login" value="login" style="cursorointer">
    </td>
    </tr>
    </table>
    </form>
    
     
  4. chadi

    chadi BANNED

    Joined:
    Apr 20, 2004
    Messages:
    415
    Likes Received:
    0
    Trophy Points:
    0
    Thanks so much but here's the thing that I may have not clarified: these "other" servers are customer dedicated servers not particular our shared hosting servers.

    Can that still work? I don't think it would be professional for me to add a list of IP addresses in the drop down menu.
     
  5. SJJM

    SJJM Member

    Joined:
    Dec 17, 2002
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    OK, this should do the trick:

    cplogin.php
    Code:
    <html>
    <?php
    
    if(!$_POST['login']) {
    exit;
    }
    
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $port = $_POST['port'];
    $domain = $_POST['domain'];
    
    if($domain=="[COLOR=Navy]Server 1 Name[/COLOR]"){$domain="[COLOR=Navy]Server 1 IP[/COLOR]";}
    if($domain=="[COLOR=Navy]Server 2 Name[/COLOR]"){$domain="[COLOR=Navy]Server 2 IP[/COLOR]";}
    if($domain=="[COLOR=Navy]Server 3 Name[/COLOR]"){$domain="[COLOR=Navy]Server 3 IP[/COLOR]";}
    
    
    $port == "2083" || $port == "2096" ? $pre = "https://" : $pre = "http://";
    ?>
    <body onLoad="setTimeout('document.forms[0].submit();',10)">
    <form action="<?php echo "".$pre."".$domain.":".$port."/login/"; ?>" method="post">
    <input type="hidden" name="user" value="<?php echo $user; ?>">
    <input type="hidden" name="pass" value="<?php echo $pass; ?>">
    </form>
    </body>
    </html>
    
    Page with login form:
    Code:
    <form action="cplogin.php" method="post">
    <table cellspacing="4" cellpadding="0">
    <tr><td>Username:</td><td><input type="text" name="user"></td></tr>
    <tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
    <tr><td>Login To:</td>
    <td align="right">
    <select name="port">
    <option value="2082">cPanel</option>
    <option value="2083">Secure cPanel</option>
    <option value="2095">Webmail</option>
    <option value="2096">Secure Webmail</option>
    </select>
    </td></tr>
    <tr><td>Server:</td>
    <td align="right">
    <select name="domain">
    <option>[COLOR=Navy]Server 1 Name[/COLOR]</option>
    <option>[COLOR=Navy]Server 2 Name[/COLOR]</option>
    <option>[COLOR=Navy]Server 3 Name[/COLOR]</option>
    </select>
    </td></tr>
    
    <tr><td align="right" colspan="2">
    <input type="submit" name="login" value="login" style="cursorointer">
    </td>
    </tr>
    </table>
    </form>
    
     
  6. chadi

    chadi BANNED

    Joined:
    Apr 20, 2004
    Messages:
    415
    Likes Received:
    0
    Trophy Points:
    0
    Thanks so much for your help I appreciate. You see the second method is similiar to the first because they still have to select from the drop down menu. The thing is I don't want the drop down menu, just the capability to login regardless what server they're on. I'm sure there is a way.

    Do you know how?

    Thanks again!
     
  7. SJJM

    SJJM Member

    Joined:
    Dec 17, 2002
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    You cannot have a script log somebody onto a server it doesn't know the address of. :S
     
  8. fwwebs

    fwwebs Well-Known Member

    Joined:
    Feb 16, 2004
    Messages:
    329
    Likes Received:
    0
    Trophy Points:
    16
    Create a database of usernames and their IP's, then use the form to select the IP from the database based on the username.
     
  9. SJJM

    SJJM Member

    Joined:
    Dec 17, 2002
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    ...and what if server 1 has the username 'test' and so does server 2. It's a lot of unwanted trouble.
     
Loading...

Share This Page