Customizing Webmail/cPanel/WHM Login Page

While resellers and dedicated server owners have much more branding options discussed here . Any user can create and customize their own login page easily without having to edit any files or settings within cPanel.

By default, when someone tries to login to the control panel, webmail or WHM, they will be greeted with a pop up window asking them for their username and password. If they press cancel or guess the wrong password too many times, they will be forwarded to a web form that asks for the username and password.

By customizing the login page, you are essentially recreating that form using the HTML <form> tag. cPanel services run on the following ports:

  • cPanel: 2083 (https) or 2082 (http)
  • webmail: 2096 (https) or 2095 (http)
  • whm: 2087 (https) or 2086 (http)

You need to know these port settings since you’ll be POSTing the username and password to each port. For example, if we were to login to cPanel, we’d need to POST the login variables to http://server.arvixe.com:2082/login/ . Since Arvixe uses signed certificates for cPanel, you can also use https://server.arvixe.com:2083/login/ for an ecrypted connection to keep the username and password safe.

The login variables required for login are:

  • user
  • pass
  • login_theme (may be optional)

Optionally, you can specify the variable ‘failurl’ to have CPanel send the user back to a certain page if the username and password don’t match what is on the record.

For those that are completely confused at this point, the following simple web form provided by cPanel at http://www.cpanel.net/cpanel-login.phps should provide some guidance on how to construct the HTML <form> tag.

The contents of the file are also included below:

<?
#Login Configuration

#cPanel
$protocol = 'http';
$port = 2082;

#Secure cPanel
#$protocol = 'https';
#$port = 2083;

#WHM
#$protocol = 'http';
#$port = 2086;

#Secure WHM
#$protocol = 'https';
#$port = 2087;

#Webmail
#$protocol = 'http';
#$port = 2095;

#Secure Webmail
#$protocol = 'https';
#$port = 2096;
?>

<html>
<h1>[Web Hosting Company Name Here]</h1>

<b>cPanel Login</b><br>

<?php
if ($_GET['failed'] == "1") {
?>
<font color=#FF0000>Your login attempt failed!</font>
<?php
}
print "<form action=\"" . $protocol . "://" . $_SERVER['HTTP_HOST'] . ":" . $port . "/login/\"
method=POST>";
?>
User: <input type="text" name="user"><br>
Pass: <input type="password" name="pass"><br>
<?php
print "<input type=hidden name=failurl value=\"http://" .  $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?failed=1\">";
?>
<input type="hidden" name="login_theme" value="default">
<input type="submit" value="Login">
</form><br>
<a href="cpanel-login.phps">Source</a><br>
Note: This examples requires cPanel 9.4.1 or later!
The login theme option requests cPanel 11.1.0 or later!

</html>

Note: If you are going to be using the same file mentioned above, simply “uncomment” the proper service you wish to use (ie cPanel, webmail or WHM) by removing the # beside the lines for that service. Remember to place a # beside all the lines for the other services. The form will only allow you to login to one service at a time. The corresponding port numbers are mentioned above in this post for your reference.

Update on December 29th, 2008: MartinH on our forums at http://forum.arvixe.com/smf/general/customizing-webmail-interface/ mentioned that while the above script works, there is a notification your visitors will receive using the Opera browser. The following form found at http://www.wlscripting.com/tutorial/33 provides an alternate form that does not give the initial warning in Opera:

<form action="cpanelLogin.php" method="POST">
<?php
// Show an error if the login failed
if(($_GET['failed'] == "1") or ($error == 1)){
echo '<font color="#FF0000">Your login attempt failed!</font><br />';
}
?>
Domain: <input type="text" name="domain" value="" size="20" /><br />
Username: <input type="text" name="username" value="" size="20" /><br />
Password: <input type="password" name="pass" value="" size="20" /><br />
<?php
// This failurl allows cPanel to redirect back to this site
echo '<input type="hidden" name="failurl" value="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?failed=1">';
?>
Options: <select name="port">
  <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 type="submit" value="Login" />

</form>

Main instruction included with the code is as follows:

If you only want to allow cPanel logins you can change the
<select name=”port”> to <input type=”hidden” name=”port”
value=”2082″>. This allows you to only show the domain, username and
password fields.

One thing you will have to make sure you change is the action on the
<form> so that it points to the file you will be saving on the
next page of this article.

Tags: , , , , | Posted under cPanel/Linux Hosting, Customization | RSS 2.0

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 1 = 3

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>