Compare commits
No commits in common. "c1a98c5ff6d8a9844d7d4791532bf8ffd61743b1" and "afd8251f64fc2719e7882cdc68468805e076d5d8" have entirely different histories.
c1a98c5ff6
...
afd8251f64
|
@ -36,7 +36,26 @@ class Vhosts extends \Panel\Vhost {
|
||||||
$vhost_array = $f3->get('vhost_array');
|
$vhost_array = $f3->get('vhost_array');
|
||||||
|
|
||||||
/* convert data for frontend display */
|
/* convert data for frontend display */
|
||||||
// nothing to convert
|
if ($vhost_array['status'] == 1) {
|
||||||
|
$vhost_array['status'] = 'Enabled';
|
||||||
|
} else {
|
||||||
|
$vhost_array['status'] = 'Disabled';
|
||||||
|
}
|
||||||
|
if ($vhost_array['mbox_limit'] == "NULL") {
|
||||||
|
$vhost_array['mbox_limit'] = 'Unlimited';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($vhost_array['mbox_quota_default'] == "NULL") {
|
||||||
|
$vhost_array['mbox_quota_default'] = 'Unlimited';
|
||||||
|
} else {
|
||||||
|
$vhost_array['mbox_quota_default'] .= ' GB';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($vhost_array['mbox_ratelimit_default'] == "NULL") {
|
||||||
|
$vhost_array['mbox_ratelimit_default'] = 'Unlimited';
|
||||||
|
} else {
|
||||||
|
$vhost_array['mbox_ratelimit_default'] .= ' emails per hour';
|
||||||
|
}
|
||||||
|
|
||||||
$f3->set('vhost_array', $vhost_array);
|
$f3->set('vhost_array', $vhost_array);
|
||||||
|
|
||||||
|
|
|
@ -1,126 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* vpanel-stack
|
|
||||||
* https://git.stack-source.com/msb/vpanel-stack
|
|
||||||
* Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
|
||||||
* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Panel\Vhost;
|
|
||||||
|
|
||||||
class VhostsAdd extends \Panel\Vhost {
|
|
||||||
|
|
||||||
function beforeRoute($f3) {
|
|
||||||
|
|
||||||
parent::beforeRoute($f3);
|
|
||||||
|
|
||||||
// /* get vm_domains defaults for "add new" form */
|
|
||||||
// $vm_domains_defaults = $f3->call('\Panel::vGet', array("vmail-defaults-get.sh -c", FALSE));
|
|
||||||
// $f3->set('vm_domains_defaults', $vm_domains_defaults[0]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static function get($f3) {
|
|
||||||
|
|
||||||
echo \Template::instance()->render('vhost/vhosts-add.html');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function post($f3) {
|
|
||||||
|
|
||||||
extract($_POST);
|
|
||||||
|
|
||||||
$messages = array();
|
|
||||||
|
|
||||||
/* validate domain */
|
|
||||||
if (preg_match('/^[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,24}$/i', strtolower($_POST['domain']))) {
|
|
||||||
// strip www
|
|
||||||
$domain = strtolower($_POST['domain']);
|
|
||||||
} else {
|
|
||||||
$messages[] = "Invalid domain name.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* validate status */
|
|
||||||
if ($_POST['status'] != 0 && $_POST['status'] != 1) {
|
|
||||||
$messages[] = "Invalid 'Status'.";
|
|
||||||
} else {
|
|
||||||
$status = $_POST['status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* validate mbox_limit */
|
|
||||||
if (strtolower($_POST['mbox_limit']) == 'unlimited' || strtolower($_POST['mbox_limit'] == 'null')) {
|
|
||||||
$mbox_limit = "NULL";
|
|
||||||
} elseif (is_numeric($_POST['mbox_limit'])) {
|
|
||||||
/* make sure mbox_limit is a possitive integer */
|
|
||||||
$mbox_limit = abs(intval($_POST['mbox_limit']));
|
|
||||||
if ($mbox_limit < 1) {
|
|
||||||
echo "Mailbox Limit must be a positive number or \"Unlimited\".\n";
|
|
||||||
$messages[] = "Mailbox Limit must be a positive number or \"Unlimited\".";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$messages[] = "Mailbox Limit must be a positive number or \"Unlimited\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* validate mbox_quota_default */
|
|
||||||
if (strtolower($_POST['mbox_quota_default']) == 'unlimited' || strtolower($_POST['mbox_quota_default'] == 'null')) {
|
|
||||||
$mbox_quota_default = "NULL";
|
|
||||||
} elseif (is_numeric($_POST['mbox_quota_default'])) {
|
|
||||||
/* make sure mbox_quota_default is a possitive integer */
|
|
||||||
$mbox_quota_default = abs(intval($_POST['mbox_quota_default']));
|
|
||||||
if ($mbox_quota_default < 1) {
|
|
||||||
echo "Default Quota must be a positive number or \"Unlimited\".\n";
|
|
||||||
$messages[] = "Default Quota must be a positive number or \"Unlimited\".";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$messages[] = "Default Quota must be a positive number or \"Unlimited\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* validate mbox_ratelimit_default */
|
|
||||||
if (strtolower($_POST['mbox_ratelimit_default']) == 'unlimited' || strtolower($_POST['mbox_ratelimit_default'] == 'null')) {
|
|
||||||
$mbox_ratelimit_default = "NULL";
|
|
||||||
} elseif (is_numeric($_POST['mbox_ratelimit_default'])) {
|
|
||||||
/* make sure mbox_ratelimit_default is a possitive integer */
|
|
||||||
$mbox_ratelimit_default = abs(intval($_POST['mbox_ratelimit_default']));
|
|
||||||
if ($mbox_ratelimit_default < 1) {
|
|
||||||
$messages[] = "Default Rate Limit must be a positive number or \"Unlimited\".";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$messages[] = "Default Rate Limit must be a positive number or \"Unlimited\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check for validation errors */
|
|
||||||
if (count($messages) > 0) {
|
|
||||||
$messages[] = "Please re-submit the form to try again.";
|
|
||||||
$f3->set('SESSION.messages', $messages);
|
|
||||||
$f3->call('\Panel\Vmail\DomainsAdd::get', $f3);
|
|
||||||
} else {
|
|
||||||
/* check if vmail domain already exists */
|
|
||||||
$domain_array = $f3->call('\Panel::vGet', array("vmail-domains-get.sh -d $domain -c", FALSE));
|
|
||||||
if (count($domain_array) == 0) {
|
|
||||||
/* add email domain */
|
|
||||||
exec("/usr/local/bin/vmail-domains-add.sh -d $domain -l $mbox_limit -q $mbox_quota_default -r $mbox_ratelimit_default -s $status", $output, $result_code);
|
|
||||||
if ($result_code == 0) {
|
|
||||||
$messages[] = "Email Domain $domain has been added.";
|
|
||||||
$f3->set('SESSION.messages', $messages);
|
|
||||||
$f3->reroute("/Email/$domain");
|
|
||||||
} else {
|
|
||||||
if (count($output) > 0) {
|
|
||||||
foreach ($output as $k=>$output_message) {
|
|
||||||
$messages[] = "$output_message";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$messages[] = "Unknown error adding Email Domain $domain.";
|
|
||||||
}
|
|
||||||
$f3->set('SESSION.messages', $messages);
|
|
||||||
$f3->call('\Panel\Vmail\DomainsAdd::get', $f3);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$messages[] = "Email Domain '$domain' already exists.";
|
|
||||||
$f3->set('SESSION.messages', $messages);
|
|
||||||
$f3->reroute("/Email/$domain");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -48,12 +48,7 @@ class AliasesAdd extends \Panel\Vmail {
|
||||||
if ($result_code == 0) {
|
if ($result_code == 0) {
|
||||||
$messages[] = "Success: Email alias $alias@$domain added.";
|
$messages[] = "Success: Email alias $alias@$domain added.";
|
||||||
$f3->set('SESSION.messages', $messages);
|
$f3->set('SESSION.messages', $messages);
|
||||||
$mapping = $f3->get('NAV.mapping');
|
$f3->reroute("/Email/$domain/Accounts/$mbox/Aliases");
|
||||||
if ($mapping == 'vmail') {
|
|
||||||
$f3->reroute("/Accounts/$mbox/Aliases");
|
|
||||||
} else {
|
|
||||||
$f3->reroute("/Email/$domain/Accounts/$mbox/Aliases");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* failure, set error messages */
|
/* failure, set error messages */
|
||||||
if (count($output) > 0) {
|
if (count($output) > 0) {
|
||||||
|
|
|
@ -42,12 +42,7 @@ class AliasesDelete extends \Panel\Vmail {
|
||||||
$messages[] = "Error deleting alias '$alias@$domain'.";
|
$messages[] = "Error deleting alias '$alias@$domain'.";
|
||||||
}
|
}
|
||||||
$f3->set('SESSION.messages', $messages);
|
$f3->set('SESSION.messages', $messages);
|
||||||
$mapping = $f3->get('NAV.mapping');
|
$f3->reroute("/Email/$domain/Aliases");
|
||||||
if ($mapping == 'vmail') {
|
|
||||||
$f3->reroute("/Aliases");
|
|
||||||
} else {
|
|
||||||
$f3->reroute("/Email/$domain/Aliases");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
<include href="header.html" />
|
|
||||||
|
|
||||||
<form action="{{@REALM}}" method="POST">
|
|
||||||
<h4 id="Add_New_Website">Add New Website</h4>
|
|
||||||
<fieldset>
|
|
||||||
<legend>Only the domain name is required</legend>
|
|
||||||
<label for="domain">Domain Name <small>(Do not include 'www', that will be aliased to the main domain)</small></label>
|
|
||||||
<input id="domain" name="domain" type="text" placeholder="example.com" value="" required>
|
|
||||||
|
|
||||||
<label for="username">Username <small>(System username, leave empty for auto-creation)</small></label>
|
|
||||||
<input id="username" name="username" type="text" placeholder="examplec" value="" required>
|
|
||||||
|
|
||||||
Check to jail user: <input type="checkbox" id="jail" name="jail" value="yes" checked>
|
|
||||||
|
|
||||||
<label for="macro">Config <small>(A valid Let's Encrypt certificate is required for VHostHTTPS)</small></label>
|
|
||||||
<select id="macro" name="macro">
|
|
||||||
<option value="VHostHTTP" selected>VHostHTTP</option>
|
|
||||||
<option value="VHostHTTPS">VHostHTTPS</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<label for="status">Status</label>
|
|
||||||
<select id="status" name="status">
|
|
||||||
<option value="1" selected>Enabled</option>
|
|
||||||
<option value="0">Disabled</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<input type="submit" value="Submit">
|
|
||||||
<button id="reset" type="reset" disabled>Reset</button>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<!-- <small>Any other form instructions go here.</small> -->
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<b>Username</b><br>
|
|
||||||
<b>Jail</b><br>
|
|
||||||
<b>Config</b><br>
|
|
||||||
<b>Status</b> can be used to temporarily disable the website domain without deleting any settings or files.<br>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<include href="footer.html" />
|
|
|
@ -35,7 +35,42 @@
|
||||||
</check>
|
</check>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="{{@NAV.fullpath}}/Add">Add new Website form</a>
|
<a href="#Add_New_Website">Add new Website form</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<form action="{{@REALM}}" method="POST">
|
||||||
|
<h4 id="Add_New_Website">Add New Website</h4>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Only the domain name is required</legend>
|
||||||
|
<label for="domain">Domain Name <small>(Do not include 'www', that will be aliased to the main domain)</small></label>
|
||||||
|
<input id="domain" name="domain" type="text" placeholder="example.com" value="" required>
|
||||||
|
|
||||||
|
<label for="username">Username <small>(System username, leave empty for auto-creation)</small></label>
|
||||||
|
<input id="username" name="username" type="text" placeholder="examplec" value="" required>
|
||||||
|
|
||||||
|
Check to jail user: <input type="checkbox" id="jail" name="jail" value="yes" checked>
|
||||||
|
|
||||||
|
<label for="macro">Config <small>(A valid Let's Encrypt certificate is required for VHostHTTPS)</small></label>
|
||||||
|
<select id="macro" name="macro">
|
||||||
|
<option value="VHostHTTP" selected>VHostHTTP</option>
|
||||||
|
<option value="VHostHTTPS">VHostHTTPS</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="status">Status</label>
|
||||||
|
<select id="status" name="status">
|
||||||
|
<option value="1" selected>Enabled</option>
|
||||||
|
<option value="0">Disabled</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
<button id="reset" type="reset" disabled>Reset</button>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<small>Any other form instructions go here.</small>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
<include href="footer.html" />
|
<include href="footer.html" />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user