Code:
#!/usr/bin/perl
# You may need to change this path to /usr/local/bin/perl
#**************************************************************
#
# Script to modify skeleton files upon account creation: PWSpostwwwacct3 V2.0
#
# Written by:
# Premier Website Solutions - http://www.premierwebsitesolutions.com
# Created - in 2003 (V1.0)
# Last Modified - October 6, 2004 (V2.0)
# - altered to be more usable by others
# - added instructions for other users
#
# To use this script, just list the pages you want modified below, provide markers on
# those pages as explained shortly, and upload this file to the /scripts directory on
# your server, renamed to postwwwacct and made executable.
#
# Every time an account is created in WHM, this script is automatically called to
# do it's job. Variables are passed to it from WHM's wwwacct script and some of
# those variable are used in place of the markers on the skeleton file pages.
#
# Here are the variables that are passed to this script:
# $ARGV[0] = domain
# $ARGV[1] = username
# $ARGV[2] = password
# $ARGV[3] = space (MB)
# $ARGV[4] = theme
# $ARGV[5] = ded IP (y/n)
# $ARGV[6] = cgi (y/n)
# $ARGV[7] = FP (y/n)
# $ARGV[8] = max ftp (n or #)
# $ARGV[9] = max sql (n or #)
# $ARGV[10] = max POP (n or #)
# $ARGV[11] = max lists (n or #)
# $ARGV[12] = max subs (n or #)
# $ARGV[13] = bandwidth (# or 0) in MB's
# $ARGV[14] = shell (y/n)
# $ARGV[15] = owner
# $ARGV[16] = plan
# $ARGV[17] = max park (# or unlimited)
# $ARGV[18] = max addon (# or unlimited)
# $ARGV[19] = feature list (default)
# $ARGV[20] = contact email
#
#
# PROVIDING MARKERS ON PAGES TO BE MODIFIED
# -----------------------------------------
#
# What this script does is substitute markers on your cpanel3_skel pages with the
# variables just listed. The markers are in the format
# **ARGV0**
# **ARGV1**
# **ARGV2**
# and so on.
#
# Anywhere you place **ARGV0** in your skeleton pages, that will be replaced with the domain.
# Anywhere you place **ARGV1** in your skeleton pages, that will be replaced with the username.
# Anywhere you place **ARGV2** in your skeleton pages, that will be replaced with the password.
#
# Obviously, you DO NOT want to put the password on the default pages. That's just
# explaining how it works. The ones you may want to use are:
# **ARGV0** is replaced with the domain (i.e. domain.com)
# **ARGV1** is replaced with the username (we use it for our custom formmail script)
# **ARGV3** is replaced with the space in MB's
# **ARGV13** is replaced with the bandwidth in MB's
#
# Here is an example of a skeleton index.html page:
#
# <html>
# <head>
# <title>**ARGV0** temporary front page</title>
# </head>
#
# <body bgcolor="#ffffff" link="#0000ff" alink="#ff00ff" vlink="#ff0000">
#
# <p align="center">
# <b>Welcome to **ARGV0**</b>
#
# <p align="left">
# This is a newly created account. Please bookmark this site and check back later.
#
# <p align="left">
# You can contact the site owner at <a href="mailto:**ARGV20**">**ARGV20**</a>.
#
# <p align="left">
# <u>Website Owner:</u>
#
# <p align="left">
# Your new account is ready. You have **ARGV3**MB's of space and **ARGV13**MB's of bandwidth.<br>
# If you have any questions, please contact us at <a href="mailto:email@host.com">email@host.com</a>.
#
# </body>
# </html>
#
#
# Registered users of this script will be notified of any future updates.
# If you registered this copy with us, put your email here for future reference.
# This copy is registered to:
#
#**************************************************************
@pages = ("public_html/index.html",
"public_html/404.shtml",
"public_html/500.shtml"
);
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# UNLESS YOU KNOW CGI, DO NOT EDIT ANYTHING BELOW HERE
# Feel free to study the code, but alterations are at your own risk
#-------------------------------------------------------------------
#-------------------------------------------------------------------
print "\nRunning postwwwacct to alter skeleton files ...\n";
&editsite;
print "\nAlterations completed\n";
if (-e "/scripts/postwwwacct2") {
print "\nSending variables to postwwwacct2.\n";
system("/scripts/postwwwacct2",@ARGV);
}
exit;
sub editsite {
foreach $page (@pages) {
if (-e "/home/$ARGV[1]/$page") {
print "editing $page\n";
open (FILE,"/home/$ARGV[1]/$page");
@LINES=<FILE>;
close(FILE);
$size=@LINES;
open(FILE2,">/home/$ARGV[1]/$page");
for ($i=0;$i<=$size;$i++) {
for ($a=0;$a<="21";$a++) {
$LINES[$i] =~ s/\*\*ARGV$a\*\*/$ARGV[$a]/g;
}
chomp($LINES[$i]);
print FILE2 "$LINES[$i]\n";
}
close(FILE2);
}
else {
print "$page doesn't exist\n";
}
}
}