Scripts and other stuff for cPanel boxes

[cPanel Modules] [Admin scripts] [Apache Modules] [Themes] [Links]

Unless indicated otherwise, the following scripts are copyright by Juan R. Pozo (jrpozo at conclase dot net) and are licensed under the GPL (General Public License).

You can use them for free, but the GPL license applies.

I offer these scripts and tips in the hope that they'll be useful, but without any warranty. Use at your own risk. See the GNU General Public License for more details.

You can also

Thanks!

Please consider making a donation. I have an Amazon wishlist where I have selected several products that I would gladly accept. Thank you :)

Note: cPanel is a trademark of cPanel, Inc. I have no commercial relationship with cPanel, Inc. at all, other than being a user of their product.

API Modules

These are custom modules I wrote for myself or by request from other cPanel users. As you can see cPanel is very easily expandable. By the way, I am open to suggestions, so if you think you have a good idea for improving any of these modules just email me, thanks.

HCCBandwidth

Bandwidth related API calls: show maximum, used and available monthly data transfer, in the units you specify.

HCCDate

Formatted Date/Time related API calls: Today, StartDate.

HCCDns

DNS related API calls: domain name servers, whois, dig.

HCCEmail

The default POP account list in cPanel works well but has customization and i18n problems which make it desirable to have a better alternative. cPanel's new API can be used to solve most problems but does not address them all. The HCCEmail module allows you to completely customize the POP account list. It allows for multipage listings, diverse ordering schemes, and has full i18n support. HCCEmail also contains an API call to add several accounts at once, which is useful for customers migrating from other providers. The list of addresses is a list of lines like: address@domain, password[, quota].

Thanks to Wilton Bennet for the Portuguese translation.

HCCFtp

This is a replacement for cPanel's FTP account list API call. It permits you to select the accounts you want to show and has full i18n support.

HCCInclude

API calls to include web documents: Include, IncludeBodyContents.

HCCServerinfo

This is a replacement for cPanel's Serverinfo API call. It permits you to choose the type of information you want your users to see, and has full i18n support.

HCCLogIP

This is a very basic module to log the IP and time that users login in their cPanel. It uses a MySQL database to store all the information. A helper application is included to see the latest entries of all or one of your users.

HCCChangeLang

Note: this module is obsolete now, use the SetLang API instead.

HCCChangeTheme

Note: This module currently does not work. cPanel must have some sort of cache mechanism that prevents theme changes from taking effect immediately.

HCCExtensions

This is my catch-all module. Currently it just contains the remnants of the old HCCApi module. Take a look at the documentation for details.

HCCStats

I was having lots of problems with stats generation, especially with Analog cache files and Webalizer DNS reverse resolution, among several other issues. Therefore I decided to write my own logrunner for Analog and Webalizer. I still haven't used AWStats so it's not included yet. More info about HCCStats...

MySubDomain

This is a very simple module I wrote as an example for another cPanel user. It just displays a list of subdomain redirections. Use it as an example module if you wish.

Admin tools

2somebody

Since Apache runs as user nobody, all email sent from scripts executed by Apache is sent by user nobody by default. There are several exceptions to this:

In any other case, the message's Return Path address will be nobody@hostname. This has the nasty effect that the postmaster will receive all the bounces of mail sent by these scripts. "2somebody" is an Exim filter file that tries to determine who the real sender of the bounced message is (by looking for Reply- To and From headers that the user may have set when sending the message), and forwards the bounced message to them instead. Installation instructions are enclosed in the filter file.

The file includes installation notes.

bwreport

This Perl script emails a plain text and/or HTML bandwidth report to your specified address. It highlights users who have used more than 80% of their alloted bandwidth (data transfer to be precise) and more than 100%. This can be run by root or by any reseller.

quotareport

This Perl script emails a plain text and/or HTML quota report to your specified address. It highlights users who have used more than 80% of their alloted disk space and more than 100%. This can be run by root or by any reseller.

cleanhttpdconf

This Perl script removes the "Added by cpanel" lines from httpd.conf (except the most recently added ones).

cpanelphp

This is a replacement for cPanel's PHP wrapper. The current wrapper doesn't properly pass the POST variables to cPanel. Released under the MIT license.

This was my first incursion in Unix IPC and it was really interesting. I still wonder if it's possible to do the task whithout using an intermediate temp file... Maybe using the CLI SAPI of PHP instead of the CGI one...

Copy this file as /usr/local/cpanel/cpanelphp and make it immutable so it won't be updated by cPanel (or use postupcp):

# /bin/su -
# cd /usr/local/cpanel
# wget http://html.conclase.net/cp/scripts/cpanelphp.perl.txt
# chown root.root cpanelphp.txt
# chmod 0755 cpanelphp.txt
# cp -a cpanelphp cpanelphp.orig
# mv cpanelphp.perl.txt cpanelphp
# chattr +i cpanelphp

fakemail

This simple script can be used to determine how an attacker is trying to find a vulnerability in a formmail script. You can then use this information to strengthen your formmail script security.

defindex

Allows you to automatically setup and customize an index page for all new created accounts. Instructions enclosed in source file.

deflang

Allows you to automatically setup the language of all new created accounts (therefore bypassing WHM's limitation by which default language is always English). Instructions enclosed in source file.

removewormedmail + blockmailfromip

Removes from Exim's queue messages containing scr and pif attachments (99,9% of which are infected emails which spread via a well-known pseudo mail user agent).

postupcp samples

A lot of people don't like the way cPanel handles software upgrades (rewriting config files and such). Actually, it can be quite tricky to customize your system while cPanel is installed and running. But you have to think of cPanel as if it was a very stubborn sysadmin who was in charge of thousands of servers, and he was responsible of the security of all of them. If you were in charge of thousands of servers of different owners, and you had to keep them up to date each and every day, and your reputation depended on 100% of the servers being kept secure, how could you possibly adapt to hundreds of different, changing configurations? So, if you don't want to get rid of this stubborn sysadmin, you'll have to adapt yourself to cPanel.

Quota scripts

checkquota

This Perl script displays a list of cPanel users who have used more than 80% of their alloted quota. This is intended to be run by root from the console. (In particular when one of those kernel error messages pops up saying someone is over quota without saying what user it refers to!)

quotafree and quotaused

These are two small scripts which return the available space a user has, in MB; and the space a user has used, as a percentage. They are used by the HCCStats module above, but you could find them useful for your own scripts. They must be called by root.

checklocaldomains

This script checks that local domains are really local and warns owners (and optionally users) if they aren't. Released under the MIT license.

Apache 1.3 Modules

mod_block_worms

This is my first Apache module. It allows to catch certain HTTP requests (using regular expressions) in the early stages of processing by Apache, and to send back an arbitrary HTTP error code (or no response at all). This is intended to minimize the effect of MS worms on Apache logs, but can be used to block any unwanted requests. Caught requests can be logged in a separate log file.

mod_server_tokens

This Apache module allows to specify a fake Server String for connections coming from all hosts, and one or more IP addresses or domains from where the real Server String will be seen. That way, when specifying cPanel's as the only allowed domains, WHM will still be able to detect the current version of each loaded module (Note: as of November 11 2005 you need to specify web1.cpanel.net and web2.cpanel.net as allowed domains).

mod_scoreboard

Whis this Apache module and the accompanying helper application you can view the Apache running processes in a top-like display (including domain, %CPU and HTTP request). This module requires Ralph Engelschall's MM library to be installed. You may download it from http://www.ossp.org/pkg/lib/mm/. The latest version supports output to a log file and has a greater time resolution than the initial release.

Themes

WHM Themes

There are no WHM themes at the moment. The old Canarias and Trueblue themes which were available here are no longer maintained. I apologize for any problems this may cause or have caused.

cPanel themes

There are no cPanel themes at the moment. Developing cPanel themes requires a lot of work and time. I don't think I could offer a free cPanel theme without charging for support and upgrades.

One interesting place to visit: the (unofficial) #cpanel IRC channel on EFnet.

Community forums

Third party themes

Add-ons sites

Articles, tutorials...

Third party support

cPanel.com.es offers cPanel server management and outsourced support services in Spanish.