diff --git a/panel/classes/Panel/Vdns.php b/panel/classes/Panel/Vdns.php
new file mode 100644
index 0000000..a644392
--- /dev/null
+++ b/panel/classes/Panel/Vdns.php
@@ -0,0 +1,106 @@
+
+ * GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+ */
+
+namespace Panel;
+
+class Vdns extends \Panel {
+
+ function beforeRoute($f3) {
+
+ parent::beforeRoute($f3);
+
+ if ($f3->get('PDNSADMIN') != '1') {
+ $f3->reroute('/');
+ }
+
+ }
+
+ public static function verifyZoneExists($zone) {
+
+ global $f3;
+
+ exec("/usr/local/bin/vdns-zone-ext.sh -z $zone", $output, $result_code);
+ if ($result_code == 0 && $output[0] == 'true') {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+
+ }
+
+ public static function returnZoneDefaultsArray($zone) {
+
+ global $f3;
+
+ if ($defaults_array = $f3->call('\Panel::vGet', array("vdns-zone-def.sh -z $zone -c", FALSE))) {
+ return $defaults_array;
+ } else {
+ return FALSE;
+ }
+
+ }
+
+ public static function returnZoneDefaultsNameserverArray($zone) {
+
+ global $f3;
+
+ if ($defaults_array = $f3->call('\Panel\Vdns::returnZoneDefaultsArray', $zone)) {
+ $defaults_ns_array = array();
+ foreach($defaults_array as $record_array) {
+ if ($record_array['type'] == "NS") {
+ $defaults_ns_array[] = $record_array['content'];
+ }
+ }
+ sort($defaults_ns_array);
+ return $defaults_ns_array;
+ } else {
+ return FALSE;
+ }
+
+ }
+
+ public static function returnNameserverArray($zone) {
+
+ global $f3;
+
+ $ns_array = array();
+ if ($dns_ns_array = dns_get_record("$zone", DNS_NS)) {
+ foreach ($dns_ns_array as $record_array) {
+ $ns_array[] = $record_array['target'];
+ }
+ sort($ns_array);
+ return $ns_array;
+ } else {
+ return FALSE;
+ }
+
+
+ }
+
+ public static function returnNameserverStatus($zone) {
+
+ global $f3;
+
+ if ($defaults_ns_array = $f3->call('\Panel\Vdns::returnZoneDefaultsNameserverArray', $zone)) {
+ if ($ns_array = $f3->call('\Panel\Vdns::returnNameserverArray', $zone)) {
+ if ($defaults_ns_array === $ns_array) {
+ return "Verified";
+ } else {
+ return "Pending";
+ }
+ } else {
+ return "Unknown";
+ }
+ } else {
+ return "Error";
+ }
+
+ }
+
+}
diff --git a/panel/classes/Panel/Vdns/Zones.php b/panel/classes/Panel/Vdns/Zones.php
new file mode 100644
index 0000000..39509b0
--- /dev/null
+++ b/panel/classes/Panel/Vdns/Zones.php
@@ -0,0 +1,73 @@
+
+ * GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+ */
+
+namespace Panel\Vdns;
+
+class Zones extends \Panel\Vdns {
+
+ /* use this to make query */
+ function beforeRoute($f3) {
+
+ parent::beforeRoute($f3);
+
+ if ($f3->exists('PARAMS.zone')) {
+ $zone = $f3->get('PARAMS.zone');
+ if ($f3->call('\Panel\Vdns::verifyZoneExists', $zone)) {
+ if ($zone_array = $f3->call('\Panel::vGet', array("vdns-zone-exp.sh -z $zone -c", FALSE))) {
+ $f3->set('zone_array', $zone_array);
+ }
+ $ns_info_array = array();
+ $ns_info_array['zone'] = $zone;
+ $ns_info_array['status'] = $f3->call('\Panel\Vdns::returnNameserverStatus', $zone);
+ if ($ns_info_array['status'] != "Verified") {
+ $ns_info_array['defaults_ns_array'] = $f3->call('\Panel\Vdns::returnZoneDefaultsNameserverArray', $zone);
+ $ns_info_array['ns_array'] = $f3->call('\Panel\Vdns::returnNameserverArray', $zone);
+ }
+ $f3->set('ns_info_array', $ns_info_array);
+ }
+ } else {
+ if ($zones_array = $f3->call('\Panel::vGet', array("vdns-zone-lst.sh", FALSE))) {
+ foreach ($zones_array as $k=>$zone_array) {
+ $zones_array[$k]['ns_status'] = $f3->call('\Panel\Vdns::returnNameserverStatus', $zone_array['zone']);
+ }
+ $f3->set('zones_array', $zones_array);
+ }
+ }
+
+ }
+
+ static function get($f3) {
+
+ if ($f3->exists('PARAMS.zone')) {
+
+ $zone = $f3->get('PARAMS.zone');
+
+ if (is_array($f3->get('zone_array'))) {
+
+ $f3->set('page_header', "DNS Zone records for $zone");
+ echo \Template::instance()->render('vdns/zones-zone.html');
+
+ } else {
+
+ $messages[] = "Zone $zone not found.";
+ $f3->set('SESSION.messages', $messages);
+ $f3->reroute("/DNS");
+
+ }
+
+ } else {
+
+ $f3->set('page_header', "DNS Zones");
+ echo \Template::instance()->render('vdns/zones.html');
+
+ }
+
+ }
+
+}
diff --git a/panel/classes/Panel/Vdns/ZonesAdd.php b/panel/classes/Panel/Vdns/ZonesAdd.php
new file mode 100644
index 0000000..271db32
--- /dev/null
+++ b/panel/classes/Panel/Vdns/ZonesAdd.php
@@ -0,0 +1,69 @@
+
+ * GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+ */
+
+namespace Panel\Vdns;
+
+class ZonesAdd extends \Panel\Vdns {
+
+ function beforeRoute($f3) {
+
+ parent::beforeRoute($f3);
+
+ }
+
+ static function get($f3) {
+
+ echo \Template::instance()->render('vdns/zones-add.html');
+
+ }
+
+ function post($f3) {
+
+ // print_r($_POST);
+
+ /* force zone to be all lower case */
+ $zone = strtolower($_POST['zone']);
+ /* strip spaces */
+ $zone = trim($zone);
+ /* remove leading www. */
+ $zone = preg_replace('/^www\./', '', $zone);
+ /* remove trailing . (dot) */
+ $zone = rtrim($zone, '.');
+ if ($f3->call('\Panel::validateDomain', $zone)) {
+ /* check if zone exists */
+ if ($f3->call('\Panel\Vdns::verifyZoneExists', $zone)) {
+ $messages[] = "Zone $zone already exists in DNS.";
+ $messages[] = "Note if $zone should be associated with this server but it's now showing up in the list below please contact support.";
+ $f3->set('SESSION.messages', $messages);
+ $f3->call('\Panel\Vdns\ZonesAdd::get', $f3);
+ } else {
+ $hostname = $f3->get('NAV.hostname');
+ exec("/usr/local/bin/vdns-zone-add.sh -z $zone -w hostname=$hostname/$zone", $output, $result_code);
+ if ($result_code == 0) {
+ $messages[] = "Zone (Domain Name) $zone has been added to DNS.";
+ $f3->set('SESSION.messages', $messages);
+ $f3->reroute("/DNS");
+ } else {
+ if (count($output) > 0) {
+ foreach ($output as $k=>$output_message) {
+ $messages[] = "$output_message";
+ }
+ } else {
+ $messages[] = "Unknown error adding Zone $zone to DNS.";
+ }
+ $f3->set('SESSION.messages', $messages);
+ $f3->call('\Panel\Vdns\ZonesAdd::get', $f3);
+ }
+ }
+ } else {
+ $f3->call('\Panel\Vdns\ZonesAdd::get', $f3);
+ }
+ }
+
+}
diff --git a/panel/classes/Panel/Vdns/ZonesDelete.php b/panel/classes/Panel/Vdns/ZonesDelete.php
new file mode 100644
index 0000000..6aa74d7
--- /dev/null
+++ b/panel/classes/Panel/Vdns/ZonesDelete.php
@@ -0,0 +1,46 @@
+
+ * GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+ */
+
+namespace Panel\Vdns;
+
+class ZonesDelete extends \Panel\Vdns {
+
+ function beforeRoute($f3) {
+
+ parent::beforeRoute($f3);
+
+ /* verify zone exists */
+ $zone = $f3->get('PARAMS.zone');
+ if (!$f3->call('\Panel\Vdns::verifyZoneExists', $zone)) {
+ $messages[] = "Zone '$zone' does not exist.";
+ $f3->set('SESSION.messages', $messages);
+ $f3->reroute("/DNS");
+ }
+
+ }
+
+ static function get($f3) {
+
+ $f3->set('confirm', 'true');
+ echo \Template::instance()->render('vdns/zones-delete.html');
+
+ }
+
+ function post($f3) {
+
+ /* run delete command here */
+ $zone = $f3->get('PARAMS.zone');
+ exec("/usr/local/bin/vdns-zone-del.sh -z $zone -x", $output, $result_code);
+ $messages[] = "Zone '$zone' has been deleted from DNS.";
+ $f3->set('SESSION.messages', $messages);
+ $f3->reroute("/DNS");
+
+ }
+
+}
diff --git a/panel/config/config.ini b/panel/config/config.ini
index 7ccd7ad..989f3b8 100644
--- a/panel/config/config.ini
+++ b/panel/config/config.ini
@@ -1,30 +1,36 @@
-; vpanel-stack
-; https://git.stack-source.com/msb/vpanel-stack
-; Copyright (c) 2022 Matthew Saunders Brown
+Zone Enter the Domain Name that will be added to DNS.
+
+ Notes:
+
+
+ To make this DNS active update the Nameservers at your current Domain Name Registrar to:
+
+
+
+ If you are intentionally using another provider for DNS you can reference the records below for what should be added to your DNS (excluding the NS & SOA records).
+
+ Make sure the domain name is registered and has the folowing nameservers set:
+
+
+ If this persists please contact tech support.
+
+
+
+
+
+
+ Name
+ TTL
+ Class
+ Type
+ Value
+
+
+
+ {{ @record_array.name }}
+ {{ @record_array.ttl }}
+ {{ @record_array.class }}
+ {{ @record_array.type }}
+ "{{ @record_array.value }}" {{ @record_array.value }}
+
+
+
You should be able to cut-and-past above records directly into a BIND file, if desired.
e.g. "10 mail.example.com" indicates a Priority of "10" for "mail.example.com".
Only MX & SRV records use Priority, all other records have an unused priority of "0".
phpMyPDNS can be used to manage DNS entries here: {{ @PHPMYPDNSURL }}
+No Zone info.
+Zone | +Nameservers | +Action | +|
---|---|---|---|
{{ @zone.zone }} | +✓ {{ @zone.ns_status }} | {{ @zone.ns_status }} - click view for details → | View Delete | +
There are no DNS Zones on this server.
+
+Zone is what a Domain Name is called in DNS.
+View zone to see list of all DNS entries.
+Delete will remove the zone from DNS entirely.
+
phpMyPDNS can be used to manage DNS entries here: {{ @PHPMYPDNSURL }}
+