Results 1 to 9 of 9

Thread: cplogin.php

  1. #1
    Join Date
    Jul 2005
    Location
    Tennessee
    Posts
    324

    cplogin.php

    Can anyone help me modify this so it will take a customer to their own cpanel? I REALLY appreciate it!

    <?php

    # domain or ip (no http://)
    $domain = $_POST['domain'];

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

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

    $port == '2083' || $port == '2096' ? $pre = 'https://' : $pre = 'http://';
    $port == '2095' || $port == '2096' && !eregi('@', $user) ? $user = $user.'@'.$domain : $user = $user;

    ?>

    I really suck at php.

  2. #2
    Join Date
    Feb 2002
    Location
    Vestal, NY
    Posts
    1,378
    Any customer can get to their own cPanel via any cPanel login when they enter their username and password. It doesn't matter if it is theirdomain.com/cpanel or someoneelse'sdomain/cpanel or yourserverhostname:2083, it will all go to the same place. Are you trying to make the script auto-login a user once they are logged in via something else (like your billing system for example)?
    H4Y Technologies LLC Check out our new website!
    "Smarter, Cheaper, Faster" - SMB, Reseller, VDS, Dedicated, Colo hosting done right.

    ZERO PACKETLOSS, ZERO DOWNTIME Dedicated and Colo - USA: IA, CA, NC, OR, NV
    **http://h4y.us**
    Voice: (866)435-5642. *** Email: askus at host4yourself d0t com

  3. #3
    Join Date
    Feb 2003
    Posts
    34

    here it is

    Refer http://forum.mamboserver.com

    it works perfectly

    Two PHP Script
    1)docpanellogin.php
    2)include_anywhere.php

    Code for docpanellogin.php

    <?php
    error_reporting(E_ALL ^ E_NOTICE);
    //Here we check if any field was missed / left empty and act accordingly
    if ($_POST['domain'] && $_POST['username'] && $_POST['pass'] && !($_GET['failed'] == "1"))
    {
    switch ($_POST['login_option'])
    {
    case "2082": $port = "2082";
    $protocol = "http://";
    break;
    case "2083": $port = "2083";
    $protocol = "https://";
    break;
    case "2086": $port = "2086";
    $protocol = "http://";
    break;
    case "2087": $port = "2087";
    $protocol = "https://";
    break;
    case "2095": $port = "2095";
    $protocol = "http://";
    break;
    case "2096": $port = "2096";
    $protocol = "https://";
    break;
    }

    $redirectlocation = $protocol.$_POST['domain'].":".$port."/login/?user=".$_POST['username']."&pass=".$_POST['pass']."&failurl=".$_POST['failurl'];
    header ("Location: ".$redirectlocation);
    }
    else
    {
    $error = 1;
    header ("Location: ".$_POST['failurl']);
    }
    ?>


    code for include_anywhere.php

    <?php
    $postlocation = "docpanellogin.php";
    print "<form action=\"" . $postlocation . "\" method=\"POST\">";

    if (($_GET['failed'] == "1") or ($error == 1))
    {
    ?>
    <font color=#FF0000 face=verdana size=1>Your login attempt failed!</font><br>
    <?php
    }
    ?>
    <font face="Verdana" size="1">Domain:</font>
    <input name="domain" class="input2" type="text" value="" style="width:110;height:18;font-family:Verdana; font-size:8pt" size="20" /><br>
    <font face="Verdana" size="1">Username:</font>
    <input name="username" class="input2" type="text" value="" style="width:110;height:18;font-family:Verdana; font-size:8pt" size="20" /><br>
    <font face="Verdana" size="1">Password:</font>
    <input name="pass" class="input2" type="password" value="" style="width:110;height:18;font-family:Verdana; font-size:8pt" size="20" />
    <?php
    print "<input type=hidden name=failurl value=\"http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?failed=1\">";
    ?>
    <br>
    <font face="Verdana" size="1">Options:</font>
    <select name="login_option" style="font-family: Verdana; font-size: 8pt;width:110;height:18">
    <option value="2082">cPanel </option>
    <option value="2083">Secure cPanel </option>
    <option value="2086">WHM</option>
    <option value="2087">Secure WHM</option>
    <option value="2095">Webmail</option>
    <option value="2096">Secure Webmail</option>
    </select>
    <br>
    <input class="input2" type="submit" value=" Click to Login " style="width:100;height:20;font-family:Verdana; font-size:8pt" onmouseout="blur(this);" />
    </form>

  4. #4
    Join Date
    Jul 2005
    Location
    Tennessee
    Posts
    324
    Yes, this is the one I FINALLY wound using and it works like a charm. My question is is how can I incorporate this in an html page? I had to save it as a separate php page in order for it to work.

  5. #5
    Join Date
    Feb 2003
    Posts
    34
    you have two files

    1)include_anywhere.php
    2)docpanellogin.php

    you shud be having a html or php page through which your clients are currently logging right

    so remove all the existing cpanel login code. Replace that page with this code in include_anywhere.php

    and the docpanellogin.php.. upload it in the same directory or different one. modify your form action if it is in a different directory

    thats it it is ready to go.

    you can take look at this site


    http://www.ec-webhosting.jp/login.php

    if you prefer java script i can give you the code for that too.

    only problem.. error messages !!!
    Last edited by ranjith; 08-05-2005 at 07:55 AM.

  6. #6
    Join Date
    Jul 2005
    Location
    Tennessee
    Posts
    324
    I want something I can put on my homepage, which is html. I haven't been able to get the include_anywhere code to work in a regular html page, but can get it to work like a charm on a page like login.php. I am wanting to incorporate it into my index.html page. I would really rather stay away from javascript. Any ideas?

  7. #7
    Join Date
    Feb 2003
    Posts
    34
    change it from index.html to index.php and add the code there
    you can get this done with out disturbing your html code

  8. #8
    Join Date
    Jul 2005
    Location
    Tennessee
    Posts
    324
    Ok, thanks tons. I haven't dealt with php much, so I am venturing into unchartered territory. Thanks

  9. #9
    Join Date
    Jan 2004
    Posts
    1,014
    Is it possible to log into a specific page of cpanel? Like if i wanted a user to login directly to his awstats. I know if you just type in the url for awstats, the login comes up, and you sign in, then thats what you will see. But i dont see a way to modify this script to do that.

Posting Permissions

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