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.

Webmail, Cpanel, WHM Logon scripts

Discussion in 'E-mail Discussions' started by Planet_Master, Jan 14, 2004.

  1. Planet_Master

    Planet_Master Well-Known Member

    Joined:
    Apr 18, 2002
    Messages:
    233
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    New Yorker
    I noticed sites are actually charging for these scripts which is a sham. The script below allow your users to login to WHM, Cpanel, or Webmail on any server. These scripts can be easily modified for secure login and individual servers as well

    Webmail Login:

    In head section of page add:

    PHP:
    <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 
    webmail="http://" username "+" server ":" password "@" server "/webmail" "/" username "+" server
    window.location webmail

    else { 
    alert("Please enter your username and password."); 


    // End --> 
    </script> 


    Add anywhere where you want the login box to appear, this can be fitted to match your site as well.

    PHP:
    <form name=login
    <
    table border=1 cellpadding=3
    <
    tr
    <
    td colspan=2 align=center
    <
    h2><b>Logon to NeoMail </b></h2
    </
    td
    </
    tr
    <
    tr
    <
    td>Username:</td
    <
    td
    <
    input type=text name=username size=20 maxlength="36"
    </
    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 value=domain.com 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>
    *****************************

    Cpanel Login:

    First create file named cpanel.php and insert the code below

    PHP:
    <?   
          if (
    $_POST["submit"]) {   
              if ((!
    $_POST["user"]) || (!$_POST["pass"]) || (!$_POST["yourdomain"])) {   
                  echo(
    "Please complete all fields.");   
              }   
              else {   
     
    ?>   
     <HTML> 
     <HEAD> 
     <META HTTP-EQUIV="refresh" content="0;URL=http://<?=$_POST["user"]?>:<?=$_POST["pass"]?>@<?=$_POST["yourdomain"]?>:2082"  
     </HEAD> 
     </HTML> 
     <? 
              }   
          }   
     ?>

    Then add this to where you want the login box, of course can be modified as long as input fields are correct.

    PHP:
    <form method="post" action="cpanel.php"
    <
    table border=1 cellpadding=3
    <
    tr
    <
    td colspan=2 align=center
    <
    h2><b>Logon to Cpanel </b></h2
    </
    td
    </
    tr
    <
    tr
    <
    td>Username:</td
    <
    td
    <
    input type="text" name="user" size='10'><br>
    </
    td
    </
    tr
    <
    tr
    <
    td>Password:</td
    <
    td
    <
    input type="password" name="pass" size='10'><br>
    </
    td
    </
    tr
    <
    tr
    <
    td>Your Domain:</td
    <
    td
    [
    url]www.[/url]<input type="text" name="yourdomain" size='20'>
    </
    td
    </
    tr
    <
    tr
    <
    td colspan=2 align=center
    <
    input type="submit" name="submit" value="Login!">
    </
    td
    </
    tr
    </
    table
    </
    form>

    In cpanel.php change 2082 to 2083 for secure login.


    *****************************

    WHM Login:

    First create file named whm.php and insert the code below

    PHP:
    <?   
          if (
    $_POST["submit"]) {   
              if ((!
    $_POST["user"]) || (!$_POST["pass"]) || (!$_POST["yourdomain"])) {   
                  echo(
    "Please complete all fields.");   
              }   
              else {   
     
    ?>   
     <HTML> 
     <HEAD> 
     <META HTTP-EQUIV="refresh" content="0;URL=http://<?=$_POST["user"]?>:<?=$_POST["pass"]?>@<?=$_POST["yourdomain"]?>:2086"  
     </HEAD> 
     </HTML> 
     <? 
              }   
          }   
     ?>

    Then add the login box:

    PHP:
    <form method="post" action="whm.php"
    <
    table border=1 cellpadding=3
    <
    tr
    <
    td colspan=2 align=center
    <
    h2><b>Logon to Cpanel </b></h2
    </
    td
    </
    tr
    <
    tr
    <
    td>Username:</td
    <
    td
    <
    input type="text" name="user" size='10'><br>
    </
    td
    </
    tr
    <
    tr
    <
    td>Password:</td
    <
    td
    <
    input type="password" name="pass" size='10'><br>
    </
    td
    </
    tr
    <
    tr
    <
    td>Your Domain:</td
    <
    td
    [
    url]www.[/url]<input type="text" name="yourdomain" size='20'>
    </
    td
    </
    tr
    <
    tr
    <
    td colspan=2 align=center
    <
    input type="submit" name="submit" value="Login!">
    </
    td
    </
    tr
    </
    table
    </
    form>


    In whm.php change 2086 to 2087 for secure login.

    These are basic scripts, nothing fancy, but they do work well.

    You can name the php files whatever you like just make sure to change the form method URL. You can modify these as far as the HTML look of the login boxes and the PHP coding to allow only individual servers. I posted the basics for all. In the webmail script, if you just want neomail replace "/webmail" with ":2095"
     
    #1 Planet_Master, Jan 14, 2004
    Last edited: Jan 14, 2004
  2. AlexF

    AlexF Well-Known Member

    Joined:
    Nov 20, 2003
    Messages:
    148
    Likes Received:
    0
    Trophy Points:
    16
    This is fantastic! Thank you for the code... Just one question, does the webmail form work for Horde as well?

    Thanks,
    Alex
     
    #2 AlexF, Jan 15, 2004
    Last edited: Jan 15, 2004
  3. Planet_Master

    Planet_Master Well-Known Member

    Joined:
    Apr 18, 2002
    Messages:
    233
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    New Yorker
    The webmail code sends you to the page with all 3 mail programs, Horde, Neomail, and squirrelmail. I guess it could be modified for just horde and squirrelmail as well.
     
  4. AlexF

    AlexF Well-Known Member

    Joined:
    Nov 20, 2003
    Messages:
    148
    Likes Received:
    0
    Trophy Points:
    16
    Thanks for the quick reply, Planet_Master.
     
  5. pagedeveloping

    pagedeveloping Well-Known Member

    Joined:
    Jun 11, 2003
    Messages:
    219
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    New York
    You want to do some thing real cool with the web mail log on?

    add this little java script before the one planet_master has here:

    In order like this,
    +++++++++++++++++++++++++++++++++
    <script language="javascript">
    <!-- Begin
    var uri = '<!--#echo var="HTTP_HOST" -->'

    function urival() {
    document.login.server.value=uri;
    }
    window.onload=urival
    // End -->
    </script>

    <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 webmail="http://" + username + "+" + server + ":" + password + "@" + server + "/webmail" + "/" + username + "+" + server;
    window.location = webmail;
    }
    else {
    alert("Please enter your username and password.");
    }
    }
    // End -->
    </script>

    +++++++++++++++++++++++++++++++++++
    and change the domain name table inside the form to read :

    <tr>
    <td>
    Your Domain:</td>
    <td>
    <input type="text" value="" name="server" size=20>
    </td>
    </tr>
    <tr>
    ++++++++++++++++++++++++++++++++++++

    I had named the entire page webmail.shtml "remember .shtml" and uploaded it to my main account.

    Now here's the cool part if you don't mind adding entries to your httpd.conf

    open your httpd.conf in your fav editor you use on your server.

    scroll down to the bottom where cpanel adds their alias
    and right before them add:

    ScriptAlias /wmail /home/username/public_html/webmail.shtml

    of course username=name of main account you uploaded to

    I have chosen /wmail since this script does not work with default email accounts.

    you need to restart apache after you add the ScriptAlias

    Now you can go to any domian name on the server without the www. in front and the domain name will automatically be entered into the Domain Name area of the form.

    your webmail log on would be yourdomain.com/wmail

    Cool scripts Planet_Master! :D
     
    #5 pagedeveloping, Jan 19, 2004
    Last edited: Jan 20, 2004
  6. a66fm

    a66fm Well-Known Member

    Joined:
    Jul 12, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Greece
    could this be altered so that you get directly to horde or sqmail
     
  7. osfdeath

    osfdeath Well-Known Member

    Joined:
    Aug 29, 2003
    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    16
  8. qbert1987

    qbert1987 Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    130
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canberra, Australia
    lol, nice work mate, i read the forums and thote, great, finaly somthing i can help with. but seems you where telling not asking. Awsem work mate, i realy dont like people trying to carge for an houer of coading.
     
  9. chewy

    chewy Registered

    Joined:
    Feb 9, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    what would need to be changed to get it to go direct to squirrel ???

    the webmail code that is, nice one by the way I have it working here http://www.technosage.co.uk/test/techmail.htm
     
  10. a66fm

    a66fm Well-Known Member

    Joined:
    Jul 12, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Greece
    nice look but it's not working
     
  11. chewy

    chewy Registered

    Joined:
    Feb 9, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    how not working????
     
  12. a66fm

    a66fm Well-Known Member

    Joined:
    Jul 12, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Greece
    i get script error on internet explorer 6.1, myie 0.9.16, mozilla firefox 0.8 and opera 7.23 does nothing when i press the logon button
     
  13. chewy

    chewy Registered

    Joined:
    Feb 9, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    you have to allow cookies for the scripts to work :(
     
  14. a66fm

    a66fm Well-Known Member

    Joined:
    Jul 12, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Greece
  15. chewy

    chewy Registered

    Joined:
    Feb 9, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    you probs only allow session cookies ???
     
  16. a66fm

    a66fm Well-Known Member

    Joined:
    Jul 12, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Greece
  17. dinek

    dinek Member

    Joined:
    Sep 15, 2003
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    It doesn't work for me either.
     
  18. osfdeath

    osfdeath Well-Known Member

    Joined:
    Aug 29, 2003
    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    16
    That login wont work for IE users

    Code:
    var neomail = &[url]http://&[/url] + username + &:& + password + &@& + server + &:2095/& + username + &+& + server + &/neomail.pl&;
    that'd send the user to
    http://USERNAME:PASSWORD@domain.com

    That doesn't work any longer for IE users since the last IE patch
     
  19. dinek

    dinek Member

    Joined:
    Sep 15, 2003
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    Its not the question of the IE patch it doesn't work :) My IE is not patched yet...
    ANyways it doesn;t matter does it.... I will have IE updated sometime :)
    Take care
     
  20. pagedeveloping

    pagedeveloping Well-Known Member

    Joined:
    Jun 11, 2003
    Messages:
    219
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    New York
    Hi everyone,

    I'm using IE 6.0 with SP1 with no problem, perhaps if I upload the webmail script here you can download it and check it out.

    The document is in .shtml since I use the handy little java script that I had sitting around.

    If it works for you than you can add the following to your httpd.conf so that all your customers can access their email account with it
    Code:
    ScriptAlias /wmail /home/username/public_html/webmail.shtml
    
    replace the username with your website username "The account you uploaded the document to"

    This way, instead of using webmail to log in you can also use wmail as well.
     

    Attached Files:

Loading...

Share This Page