Line 322:
Line 322:
print $q->Tr (esmith::cgi::genSmallRedCell ($q, $pseudonym),
print $q->Tr (esmith::cgi::genSmallRedCell ($q, $pseudonym),
−
esmith::cgi::genSmallCell ($q, $account),
+
esmith::cgi::genSmallCell ($q, $account),
−
$q->td (' '), #also works
+
$q->td (' '), #also works
esmith::cgi::genSmallCell ($q, " " ),
esmith::cgi::genSmallCell ($q, " " ),
);
);
Line 471:
Line 471:
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
−
db_set
+
db_set
−
db_get
+
db_get
−
db_delete
+
db_delete
−
db_set_type
+
db_set_type
−
db_get_type
+
db_get_type
−
db_get_prop
+
db_get_prop
−
db_set_prop
+
db_set_prop
−
db_delete_prop
+
db_delete_prop
−
db_print
+
db_print
−
db_show
+
db_show
−
db_print_type
+
db_print_type
−
db_print_prop
+
db_print_prop
* examples
* examples
Line 533:
Line 533:
else
else
{
{
−
db_set(\%conf, 'DelegateMailServer', $delegate);
+
db_set(\%conf, 'DelegateMailServer', $delegate);
}
}
))
))
Line 561:
Line 561:
if ($delegate eq "")
if ($delegate eq "")
{
{
−
db_delete(\%conf, 'DelegateMailServer');
+
db_delete(\%conf, 'DelegateMailServer');
}
}
))
))
Line 585:
Line 585:
if (db_get(\%accounts, $groupName))
if (db_get(\%accounts, $groupName))
{
{
−
my $type = db_get_type(\%accounts, $groupName);
+
my $type = db_get_type(\%accounts, $groupName);
−
if ($type eq "pseudonym")
+
if ($type eq "pseudonym")
−
{
+
{
−
my $acct = db_get_prop(\%accounts, $groupName, "Account");
+
my $acct = db_get_prop(\%accounts, $groupName, "Account");
))
))
Line 602:
Line 602:
sub db_set_prop (%$$$;)
sub db_set_prop (%$$$;)
((
((
−
if ($specifyHeader eq 'on')
+
if ($specifyHeader eq 'on')
−
{
+
{
−
db_set_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope', $header);
+
db_set_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope', $header);
−
}
+
}
−
else
+
else
−
{
+
{
−
db_delete_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope');
+
db_delete_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope');
−
}
+
}
))
))
Line 625:
Line 625:
((
((
my $SecondaryMailServer =
my $SecondaryMailServer =
−
db_get_prop(\%conf, "fetchmail", "SecondaryMailServer")
+
db_get_prop(\%conf, "fetchmail", "SecondaryMailServer")
))
))
Line 638:
Line 638:
my ($hash, $key, $prop)
my ($hash, $key, $prop)
((
((
−
if ($specifyHeader eq 'on')
+
if ($specifyHeader eq 'on')
−
{
+
{
−
db_set_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope', $header);
+
db_set_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope', $header);
−
}
+
}
−
else
+
else
−
{
+
{
−
db_delete_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope');
+
db_delete_prop(\%conf, "fetchmail", 'SecondaryMailEnvelope');
−
}
+
}
))
))
Line 700:
Line 700:
my $FetchmailFreqOffice = db_get_prop(\%conf, "fetchmail", "FreqOffice")
my $FetchmailFreqOffice = db_get_prop(\%conf, "fetchmail", "FreqOffice")
−
|| 'every15min';
+
|| 'every15min';
my $account = db_get_prop(\%accounts, $pseudonym, 'Account'); $account = "Administrator" if ($account eq "admin"); "(value eq 'something') ?" if first is true determine the second
my $account = db_get_prop(\%accounts, $pseudonym, 'Account'); $account = "Administrator" if ($account eq "admin"); "(value eq 'something') ?" if first is true determine the second
my $FetchMethod =
my $FetchMethod =
−
(db_get_prop(\%conf, "fetchmail", "status") eq 'enabled') ?
+
(db_get_prop(\%conf, "fetchmail", "status") eq 'enabled') ?
−
(db_get_prop(\%conf, "fetchmail", "Method") || 'standard') :
+
(db_get_prop(\%conf, "fetchmail", "Method") || 'standard') :
−
'standard';
+
'standard';
"if (defined $something)" if defined then first else second
"if (defined $something)" if defined then first else second
Line 714:
Line 714:
if (defined $SecondaryMailEnvelope)
if (defined $SecondaryMailEnvelope)
{
{
−
$SecondaryMailUseEnvelope = "on";
+
$SecondaryMailUseEnvelope = "on";
}
}
else
else
{
{
−
$SecondaryMailUseEnvelope = "off";
+
$SecondaryMailUseEnvelope = "off";
−
$SecondaryMailEnvelope = "";
+
$SecondaryMailEnvelope = "";
}
}
Line 726:
Line 726:
if (defined $backup_status && $backup_status eq "enabled")
if (defined $backup_status && $backup_status eq "enabled")
{
{
−
print $q->p ("Tape backups are enabled.");
+
print $q->p ("Tape backups are enabled.");
}
}
else
else
{
{
−
print $q->p ("Tape backups are disabled.");
+
print $q->p ("Tape backups are disabled.");
}
}
db_set_prop(\%conf, "fetchmail", 'SecondaryMailServer', $server) unless ($server eq '');; db_set_prop(\%conf, "fetchmail", 'FreqOffice', $fetchmailFreqOffice); "foreach"
db_set_prop(\%conf, "fetchmail", 'SecondaryMailServer', $server) unless ($server eq '');; db_set_prop(\%conf, "fetchmail", 'FreqOffice', $fetchmailFreqOffice); "foreach"
−
foreach $pseudonym ("everyone", "mailer-daemon", "postmaster")
+
foreach $pseudonym ("everyone", "mailer-daemon", "postmaster")
−
{
+
{
do something over
do something over
}
}
Line 745:
Line 745:
if (length $HostName > 32)
if (length $HostName > 32)
{
{
−
showInitial ($q,
+
showInitial ($q,
−
"Error: account name \"$HostName\" is too long. The
+
"Error: account name \"$HostName\" is too long. The
−
maximum is 32 characters.");
+
maximum is 32 characters.");
−
return;
+
return;
}
}
Line 756:
Line 756:
if ($password =~ /^(.*)$/)
if ($password =~ /^(.*)$/)
{
{
−
$password = $1;
+
$password = $1;
}
}
else
else
{
{
−
$password = "";
+
$password = "";
}
}
Line 768:
Line 768:
if ($groupName =~ /^([a-z][\-\_\.a-z0-9]*)$/)
if ($groupName =~ /^([a-z][\-\_\.a-z0-9]*)$/)
{
{
−
$groupName = $1;
+
$groupName = $1;
}
}
else
else
{
{
−
showInitial ($q,
+
showInitial ($q,
−
"Error: unexpected characters in group name: " .
+
"Error: unexpected characters in group name: " .
−
"\"$groupName\". The group name should contain only " .
+
"\"$groupName\". The group name should contain only " .
−
"lower-case letters, numbers, hyphens, periods, and underscores, and should start " .
+
"lower-case letters, numbers, hyphens, periods, and underscores, and should start " .
−
"with a lower-case letter. For example \"sales\", \"beta5\", and \"reseller_partners\" are " .
+
"with a lower-case letter. For example \"sales\", \"beta5\", and \"reseller_partners\" are " .
−
"all valid group names, but \"3rd-event\", \"Marketing Team\" " .
+
"all valid group names, but \"3rd-event\", \"Marketing Team\" " .
−
"and \"order-status\" are not.");
+
"and \"order-status\" are not.");
−
return;
+
return;
If you have a lot of tests you can define a set of expressions, describe them, and test for them
If you have a lot of tests you can define a set of expressions, describe them, and test for them
Line 797:
Line 797:
#get input
#get input
−
esmith::cgi::genNameValueRow ($q,
+
esmith::cgi::genNameValueRow ($q,
−
"Hostname",
+
"Hostname",
−
"HostName",
+
"HostName",
−
""),
+
""),
#test input
#test input
my $MACAddress = lc($q->param ('MACAddress'));
my $MACAddress = lc($q->param ('MACAddress'));
Line 810:
Line 810:
elsif ($MACAddress =~ /^$REGEXPMACAddress$/ )
elsif ($MACAddress =~ /^$REGEXPMACAddress$/ )
{
{
−
$MACAddress = $1;
+
$MACAddress = $1;
}
}
else
else
{
{
−
showInitial ($q,
+
showInitial ($q,
−
"Error: Ethernet Address \"$MACAddress\"
+
"Error: Ethernet Address \"$MACAddress\"
is invalid. Ethernet addresses must be in the
is invalid. Ethernet addresses must be in the
form \"AA:BB:CC:DD:EE:FF\" and only contain the
form \"AA:BB:CC:DD:EE:FF\" and only contain the
numbers 0-9 and the letters A-F. Did not create
numbers 0-9 and the letters A-F. Did not create
host entry.");
host entry.");
−
return;
+
return;
====Run command (event)====
====Run command (event)====
Line 826:
Line 826:
system ("/sbin/e-smith/signal-event", "email-update") == 0
system ("/sbin/e-smith/signal-event", "email-update") == 0
−
or die ("Error occurred while updating system configuration.\n");
+
or die ("Error occurred while updating system configuration.\n");
esmith::cgi::genHeaderNonCacheable
esmith::cgi::genHeaderNonCacheable
Line 838:
Line 838:
esmith::cgi::genHeaderNonCacheable
esmith::cgi::genHeaderNonCacheable
−
($q, \%conf, "Dialup funtion performed - down");
+
($q, \%conf, "Dialup funtion performed - down");
esmith::cgi::genResult ($q, "The modem is going down");
esmith::cgi::genResult ($q, "The modem is going down");