PHP
Some PHP snippets and applications supporting hosting functions in the CPANEL/WHM environment
MyCpanel
In the beginning....... I created some neat little javascript powered buttons to allow me to access Cpanel for my httpme sites and one client.
As time progressed, however, and I gained more clients, many of whom were to be managed by me, it became too time-consuming to create these little button beasties. This meant that when I had to jump around my clients and my domains to do cpanel work I had to laboriously navigate through many cpanel screens.
Well, finally, I had had enough, so I wrote this simple mixture of php and html to allow me to quickly select my target domain from a listbox, submit the form, and happily jump straight to the cpanel functions I required. As an after thought I also included the common WHM functions I need to execute as well.
When you access the URLS, you will be prompted for your logon name and password as usual. The links in myCpanel are just a method of speeding up the process of accessing cpanel functions.
Typically when I release a utility, the released version is not the one I use: mine is always a bit more elaborate (and problematic). So this is a cut-down version. Hopefully I made few mistakes in this release version.
Tony (DOMAJ) 03May03
Introduction
This
is what myCpanel.php looks like.
(click on the picture to see it - but remember the domains are fictitious
so the links are invalid)
DOWNLOAD the
tar archive
Configuring myCpanel (CPANEL FileManager edit examples)
Step 1. Set Your WHM IP
Simply put your WMH IP here.

Step2. Set your time zone offset
The date is displayed in local time and server time. As we all know the server floats somewhere between New Jersey and California depending on the time of year (that is my little joke).
In the code, therefore, I have specified a variable called hourdiff which gives the the number of hours to add or subtract from the server time to display my local time. For east coast Australia the difference at the moment is +14 hours.
Why do I want to display local time? Well for me, the main reason is that it makes it easier to establish the times to use in CRON jobs but there are other reasons.
So.. to set your own local time offset edit the code and enter your own value for hourdiff.
![]()
Step3. Enter your domains
The list box lists all the domains I may wish to use Cpanel functions.
Because I access my own cpanel most often, I place it as the first entry. The first entry is the default domain for the intial execution of the script.
You enter the names into the domainsList array.
Edit the list to use your domains.
If you do not require all 6 domain name entries then delete from the end of the list the entries, those that are not required.

To add an entry, copy an existing, increment the index number and replace the domain name.
eg. $domainsList[6]='www.client4.com';
Step 4.Assign the theme for each domain
Now this is a real 'kludge' I know but I have all my clients (mostly) using the BLUELAGOON theme. To make the code a bit more flexible I added this awful extra array called themeList.

Edit this array to assign the theme to the corresponding index numbers as the domain name entry in the previous step.
Once again, if there are too many entries delete from the end of the list and to add another domains theme, insert a new entry after the last.
eg. $themeList[5]='graysim';
Installation
Place the script into a directory of your choice in one of your domains
Running your script
Simply type the url of your script into your browser address window.
Eg. the demo version in this directory is http://www.domaj.com/localcpanel/mycpanel.php
Want to see the code. Uggh! it is not a pretty site (php is not my strong 'suit')please see below OR..... click this link http://www.domaj.com/localcpanel/mycpanel.phps
One final note:
As I use a tabbed browser (crazy browser) I start all CPANEL and WHM url's in a new window.
Source code
<?php
/*********** Configuration ************/
// 1. set your whm IP address
$whmIP='209.123.4.112';
// 2. adjust for local time 14 for Australia EST (vs USA PST)
$hourdiff=14;
// 3. list your domains for the listbox
// just add your own domains to the list
// remember to increment the index -> $domainList[index]
// ^^^
$domainList[0]='www.mydomain.com';
$domainList[1]='www.testdomain.com';
$domainList[2]='www.client1.com';
$domainList[3]='www.client2.com';
$domainList[4]='www.client3.com';
$domainList[5]='sub.client3.com';
// 4. domain Theme List
// I added this at the last minute as
// my domains all use blueLagoon.
// This is an awful way to do this I know!
// Add your themes for each of the above domains
$themeList[0]='bluelagoon';
$themeList[1]='default';
$themeList[2]='iconic';
$themeList[3]='bluesim';
$themeList[4]='bluelagoon';
/*********** end of configuration ************/
// calculate local time
// Change the date format to suit your datetime style
$timeadjust = ($hourdiff * 60 * 60);
$localTime = date("D, d F Y h:i a",time() + $timeadjust);
$serverTime= date("D, d F Y h:i a");
// check for a valid starting domain if one is not passed
if ($domainname=='') {
$domainname=$domainList[0];
}
// uggh! kludge
$domain=$domainname;
foreach ($domainList as $key => $value) {
if ($value==$domain) {
$theme=$themeList[$key];
}
}
// write the web page (simply)
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
echo "<!-- Original code by DOMAJ tony@domaj.com -->\n";
echo "<html>\n";
echo "<head>\n";
echo "<title>myCpanel Functions</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
echo "<style type=\"text/css\">\n";
echo " <!--\n";
echo " body, div, th, td {\n";
echo " font-family: Arial, sans-serif;\n";
echo " font-size: small;\n";
echo " text-align: center;\n";
echo "}\n";
echo " div.title {\n";
echo " font-family: Verdana, Arial, sans-serif;\n";
echo " font-weight: bold;\n";
echo " font-size: medium;\n";
echo " color: navy;\n";
echo "}\n";
echo " div.filename {font-weight: bold; color: blue; font-size: small; margin-top: 10px;}\n";
echo " div.date {font-weight: bold; margin-top: 10px;}\n";
echo " div.styledef {font-weight: bold; margin-bottom: 10px; font-size: small;}\n";
echo " table {border: none;}\n";
echo " table.key {text-align: center;}\n";
echo " table.key td {font-size: x-small;}\n";
echo " th {text-align: left; font-weight: bold; text-decoration: underline}\n";
echo " th.colerrlevel {text-decoration: none; width: 20px;}\n";
echo " th.colselector {width: 20%;}\n";
echo " th.coldescription {text-align: left;}\n";
echo " td.error, td.invalidurl {background: red;}\n";
echo " td.warning {background: yellow;}\n";
echo " td.tip {background: lime;}\n";
echo " td.hint, td.validurl {background: aqua;}\n";
echo " tr.evenrow { background: #F0F0F0;}\n";
echo " tr.oddrow { background: white;}\n";
echo " hr { height: 1px; color: black;}\n";
echo " ul.filelist { }\n";
echo " -->\n";
echo " </style>\n";
echo "</head>\n";
echo "<body>\n";
echo "<table width=\"633\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td width=\"100%\" height=\"71\" valign=\"top\">\n";
echo "<h3><font color=\"#990000\">$domain<br>\n";
echo " MyCpanel Domain Management Functions<br>\n";
echo " $localTime (local) $serverTime (server)</font></h3>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td height=\"20\" valign=\"top\"><hr></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table width=\"633\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td width=\"193\" height=\"334\" valign=\"top\"><form name=\"form1\" method=\"post\" action=\"mycpanel.php\">\n";
echo " <p align=\"center\">\n";
echo " <select name=\"domainname\" size=\"".count($domainList)."\" id=\"domainname\">\n";
foreach ($domainList as $key => $value) {
echo (" <option value=\"$value\">$value</option>\n");
}
echo " </select>\n";
echo " </p>\n";
echo " <p align=\"center\">\n";
echo " <input type=\"submit\" name=\"Submit\" value=\"Submit\">\n";
echo " </p>\n";
echo "</form></td>\n";
echo " <td width=\"440\" valign=\"top\"><table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>Mail</strong></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/mail/pops.html\" target=\"_blank\">POPs</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/mail/autores.html\" target=\"_blank\">Responders</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/mail/blocks.html\" target=\"_blank\">Blockers</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/mail/fwds.html\" target=\"_blank\">Forwarders</a></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>Stats</strong></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/stats/awstats.html\" target=\"_blank\">AWstats</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/stats/webalizer.html\" target=\"_blank\">Webalizer</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/stats/lastvistors.html\" target=\"_blank\">Visitors</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/stats/errlog.html\" target=\"_blank\">Error\n";
echo " Log</a></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>FTP</strong></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/ftp/accounts.html\" target=\"_blank\">Manage</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/ftp/anonmyous.html\" target=\"_blank\">AnonSetup</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/ftp/message.html\" target=\"_blank\">LoginMsg</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/ftp/session.html\" target=\"_blank\">Sessions</a></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>Site Management</strong></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/backup/index.html\" target=\"_blank\">Backup</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/htaccess/index.html\" target=\"_blank\">WebProtect</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/indexmanager/index.html\" target=\"_blank\">IndexMgr</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/denyip/index.html\" target=\"_blank\">IPDeny</a></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>Domains</strong></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/subdomain/index.html\" target=\"_blank\">SubDomains</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/park/index.html\" target=\"_blank\">ParkedDomains</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/addon/index.html\" target=\"_blank\">AddOnDomains</a></td>\n";
echo " <td bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/subdomain/logs.html\" target=\"_blank\">SubDmnStats</a></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>Advanced</strong></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"#FFFFCC\">\n";
echo " <td><a href=\"http://$domain:2082/frontend/$theme/cron/index.html\" target=\"_blank\">Cron</a></td>\n";
echo " <td><a href=\"http://$domain:2082/frontend/$theme/gpg/index.html\" target=\"_blank\">Keys</a></td>\n";
echo " <td><a href=\"http://$domain:2082/frontend/$theme/files/index.html\" target=\"_blank\">FileMgr</a></td>\n";
echo " <td><a href=\"http://$domain/cpanel/\" target=\"_blank\">CPANEL</a</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>Database</strong></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"2\" bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/frontend/$theme/sql/index.html\" target=\"_blank\">MySQLManager</a></td>\n";
echo " <td colspan=\"2\" bgcolor=\"#FFFFCC\"><a href=\"http://$domain:2082/3rdparty/phpMyAdmin/index.php\" target=\"_blank\">phpMyAdmin</a></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\"><strong>WHM</strong></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"#FFFFCC\">\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts2/wwwacctform\" target=\"_blank\">Create\n";
echo " Account</a></td>\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts/edituserlist\" target=\"_blank\">Modify\n";
echo " Account</a></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"#FFFFCC\">\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts2/listaccts\" target=\"_blank\">List\n";
echo " Accounts</a></td>\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts/showbw\" target=\"_blank\">View\n";
echo " Bandwidth</a></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"#FFFFCC\">\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts/limitbwlist\" target=\"_blank\">Modify\n";
echo " Bandwidth</a></td>\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts/quotalist\" target=\"_blank\">Modify\n";
echo " Quota</a></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"#FFFFCC\">\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts/prepark\" target=\"_blank\">Park\n";
echo " or Point</a></td>\n";
echo " <td colspan=\"2\"><a href=\"https://$whmIP:2087/scripts2/listparked\" target=\"_blank\">List\n";
echo " Parked</a></td>";
echo " </table></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td height=\"35\" colspan=\"2\" valign=\"top\"><hr>\n";
echo " <p>Original code by <strong>DOMAJ</strong><a href=\"mailto:tony@domaj.com\">\n";
echo " tony@domaj.com</a></p></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "</body>\n";
echo "</html>\n";
echo "";
?>
