Title: CMS Setup
Comment: Run the initial setup procedure for the new CMS.
Website Setup
If you are seeing this page, it means your website hasn't been configured yet.
To begin setting up your website, fill out the form below.
# Make sure setup hasn't been run already.
if (-f "$root->{base}/conf/site.conf") {
$root->{content} = "Access Denied
\n\n"
. "This website has already been configured. Please "
. "log in with the Administrator user and password "
. "to change the site configuration.";
}
else {
# Are we submitting?
my $act = $query->{action} || 'index';
if ($act eq 'index') {
my $tz = &listTimezones();
$root->{content} =~ s/%timezone%/$tz/ig;
}
elsif ($act eq 'dosetup') {
# Validate things.
my @errors = ();
my $title = $query->{title} || 'Untitled Website';
my $webmaster = $query->{webmaster} || '';
my $url = $query->{url} || '';
my $username = $query->{username} || '';
my $pw1 = $query->{pw1} || '';
my $pw2 = $query->{pw2} || '';
my $email = $query->{email} || $webmaster || '';
my $tz = $query->{timezone} || 'EDT';
if (length $webmaster == 0) {
push (@errors,"You must specify a webmaster "
. "e-mail address.");
}
if (length $url == 0) {
push (@errors,"You must specify a URL to your "
. "site.");
}
if (length $username == 0) {
push (@errors,"You must specify an admin user "
. "name.");
}
if ($username =~ /[^A-Za-z0-9]/) {
push (@errors,"Your username can only contain "
. "letters and numbers.");
}
if (length $username > 20) {
push (@errors,"Your username must be less than "
. "20 characters.");
}
if (length $pw1 < 6) {
push (@errors,"Your password must be at least "
. "6 characters long.");
}
if ($pw1 ne $pw2) {
push (@errors,"Your passwords don't match.");
}
# Errors?
if (@errors) {
$root->{content} = "Setup Failed
\n\n"
. "The setup process was aborted due "
. "to the following errors:\n\n"
. "\n"
. "- \n"
. join("
\n- ",@errors)
. "
\n"
. "
\n";
}
else {
# Update the configuration.
$root->{conf}->{site}->{title} = $title;
$root->{conf}->{site}->{webmaster} = $webmaster;
$root->{conf}->{site}->{url} = $url;
$root->{conf}->{site}->{timezone} = $tz;
&writeConfig("site.conf",$root->{conf});
# Create the admin user.
$username = &normalize($username);
my $pass = md5_hex($pw1);
&createUser ($username,
username => $username,
password => $pass,
power => 'admin',
email => $email,
timezone => $tz,
name => 'Administrator',
);
$root->{content} = "Setup Completed
\n"
. "Your website has been configured. "
. "You may now wish to log"
. " in as the administrator to "
. "begin building your site.";
}
}
}