-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,391 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# PHP File template | ||
|
||
Use this template at the start of any PHP file | ||
|
||
```PHP | ||
<?php | ||
/** | ||
* DNSAdmin | ||
* | ||
* @link https://github.com/archey347/userfrosting-dns-admin | ||
* @license https://github.com/archey347/userfrosting-dns-admin/blob/master/LICENSE (MIT Licence) | ||
*/ | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# userfrosting-dns-admin | ||
This sprinkle gives a front end for managing zone files on a BIND DNS Server | ||
|
||
## Installation | ||
|
||
Add `"archey347/userfrosting-dns-admin" : "~v0.0"` in the requires section of your sprinkles.json file. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"bundle": { | ||
"js/pages/zones-admin": { | ||
"scripts": [ | ||
"userfrosting/js/widgets/zones-admin.js" | ||
], | ||
"options": { | ||
"result": { | ||
"type": { | ||
"scripts": "plain" | ||
} | ||
} | ||
} | ||
}, | ||
"js/pages/zone-entries-admin": { | ||
"scripts": [ | ||
"userfrosting/js/widgets/zone-entries-admin.js" | ||
], | ||
"options": { | ||
"result": { | ||
"type": { | ||
"scripts": "plain" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
function onEntryTypeChange() { | ||
if (this.value == 'NS') { | ||
$('#zone_caption').hide(); | ||
} else { | ||
$('#zone_caption').show(); | ||
} | ||
} | ||
|
||
function bindZoneEntryTableButtons(el) { | ||
el.find('.js-zone-entry-edit').click(function () { | ||
$('body').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/edit-zone-entry', | ||
ajaxParams : { | ||
id : $(this).data('zoneEntry') | ||
}, | ||
msgTarget : $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
$("#form-zone-entry-edit").ufForm({ | ||
msgTarget : $('#form-zone-entry-alerts'), | ||
validators : page.validators.editEntry | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
}); | ||
}); | ||
|
||
el.find('.js-zone-entry-delete').click(function () { | ||
$('body').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/delete-zone-entry', | ||
ajaxParams : { | ||
id : $(this).data('zoneEntry') | ||
}, | ||
msgTarget : $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
$("#form-zone-entry-delete").ufForm({ | ||
msgTarget : $('#form-zone-entry-delete-alerts'), | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
}); | ||
}); | ||
|
||
} | ||
|
||
$(document).ready(function() { | ||
$('#zone-entries-table').ufTable({ | ||
dataUrl: site.uri.public + '/api/dns/zones/z/'+page.zone.id+'/entries' | ||
}); | ||
|
||
$("#zone-entries-table").on("pagerComplete.ufTable", function () { | ||
bindZoneEntryTableButtons($(this)); | ||
}); | ||
|
||
$('#btn-create-zone-entry').click(function () { | ||
$('#zone-entries-table').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/create-zone-entry', | ||
ajaxParams : { | ||
id : page.zone.id | ||
}, | ||
msgTarget : $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
|
||
$('#form-zone-entry-create').ufForm({ | ||
msgTarget: $('#form-zone-entry-alerts'), | ||
validators: page.validators.createEntry | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
|
||
onEntryTypeChange(); | ||
}); | ||
}); | ||
|
||
$('#btn-export-zone').click(function () { | ||
$('body').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/export-zone', | ||
ajaxParams : { | ||
id : page.zone.id | ||
}, | ||
msgTarget : $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
|
||
$('#form-export-zone').ufForm({ | ||
msgTarget: $('#form-export-zone-alerts'), | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
|
||
|
||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
var ip_examples = [ | ||
{ | ||
"start" : "192.168.0.1", | ||
"end" : "192.168.0.254", | ||
"subnet" : "255.255.255.0 /24", | ||
"input" : "192.168.0" | ||
}, | ||
{ | ||
"start" : "74.0.0.0", | ||
"end" : "74.15.254.254", | ||
"subnet" : "255.240.0.0 /12", | ||
"input" : "74" | ||
}, | ||
{ | ||
"start": "2001:0db8::1", | ||
"end" : " 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff", | ||
"subnet" : "/32", | ||
"input" : " 2001:db8" | ||
} | ||
]; | ||
|
||
|
||
function fInt(num, length) { | ||
var r = "" + num; | ||
while (r.length < length) { | ||
r = "0" + r; | ||
} | ||
return r; | ||
} | ||
|
||
function bindZoneTableButtons(el) { | ||
el.find('.js-zone-settings').click(function() { | ||
$('body').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/edit-zone', | ||
ajaxParams : { | ||
id : $(this).data('zone') | ||
}, | ||
msgTarget: $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
var modal = $(this).ufModal('getModal'); | ||
|
||
form = new Vue({ | ||
el: '#form-zone-edit', | ||
data: { | ||
"zone_type" : zone.type, | ||
"show_examples" : false, | ||
"domain" : zone.name, | ||
"serial_number_mode" : zone.serial_number_mode, | ||
"serial_number" : getTimestamp(), | ||
"old_serial_number" : zone.serial_number, | ||
ip_examples | ||
}, | ||
methods: { | ||
updateSerialNumber: function () { | ||
if (this.serial_number_mode == "timestamp") { | ||
this.old_serial_number = this.serial_number | ||
this.serial_number = getTimestamp(); | ||
} else { | ||
this.serial_number = this.old_serial_number; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
$('#form-zone-edit').ufForm({ | ||
msgTarget: $('#form-zone-alerts'), | ||
validators: page.validators.editZone | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
}); | ||
}); | ||
|
||
el.find('.js-zone-delete').click(function() { | ||
$('body').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/delete-zone', | ||
ajaxParams : { | ||
id : $(this).data('zone') | ||
}, | ||
msgTarget: $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
$('#form-zone-delete').ufForm({ | ||
msgTarget : $('#form-delete-zone-alerts') | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
}); | ||
}); | ||
el.find('.js-status').each(function () { | ||
$(this).ufForm({ | ||
msgTarget: $('#alerts-page') | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
button = $(this).find('.js-status-button'); | ||
caption = $(this).find('.js-status-caption'); | ||
|
||
if (button.find('button').val() == "enable") { | ||
button.html('<button class="btn btn-danger" name="status" value="disable" type="submit">Disable</button>'); | ||
caption.html('Enabled'); | ||
caption.css('color', 'green'); | ||
} else { | ||
button.html('<button class="btn btn-primary" name="status" value="enable" type="submit">Enable</button>'); | ||
caption.html('Disabled'); | ||
caption.css('color', 'red') | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function getTimestamp() { | ||
now = new Date(); | ||
|
||
return fInt(now.getFullYear(), 4) + fInt(now.getMonth(), 2) + fInt(now.getDate().toString(), 2) + fInt(now.getHours(), 2) + fInt(now.getMinutes(), 2) + fInt(now.getSeconds(), 2) | ||
} | ||
|
||
$(document).ready(function() { | ||
$('#zones-table').ufTable({ | ||
dataUrl: site.uri.public + '/api/dns/zones' | ||
}); | ||
|
||
$("#zones-table").on("pagerComplete.ufTable", function () { | ||
bindZoneTableButtons($(this)); | ||
}); | ||
|
||
$("#btn-create-zone").click(function() { | ||
$('body').ufModal({ | ||
sourceUrl : site.uri.public + '/modals/dnsadmin/create-zone', | ||
msgTarget: $('#alerts-page') | ||
}); | ||
|
||
$('body').on("renderSuccess.ufModal", function (data) { | ||
var modal = $(this).ufModal('getModal'); | ||
|
||
var form = new Vue({ | ||
el: '#form-zone-create', | ||
data: { | ||
"zone_type" : "normal", | ||
"show_examples" : false, | ||
"domain" : "", | ||
"serial_number_mode" : "timestamp", | ||
"serial_number" : getTimestamp(), | ||
ip_examples | ||
}, | ||
methods: { | ||
updateSerialNumber: function () { | ||
if (this.serial_number_mode == "timestamp") { | ||
this.serial_number = getTimestamp(); | ||
} else { | ||
this.serial_number = 1; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
$('#form-zone-create').ufForm({ | ||
msgTarget: $('#form-zone-alerts'), | ||
validators: page.validators.createZone | ||
}).on("submitSuccess.ufForm", function(event, data, textStatus, jqXHR) { | ||
window.location.reload(); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Config file for DNS Admin Sprinkle | ||
* | ||
*/ | ||
return [ | ||
'dnsadmin' => [ | ||
'directory' => '/etc/bind/dnsadmin' | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
$app->group('/dnsadmin', function () use ($app) { | ||
$app->get('', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:pageZonesAdmin'); | ||
$app->get('/zones/z/{id}', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:pageZoneEntriesAdmin'); | ||
|
||
}); | ||
|
||
$app->group('/modals/dnsadmin', function () use ($app) { | ||
$app->get('/create-zone', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalCreateZone'); | ||
$app->get('/edit-zone', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalEditZone'); | ||
$app->get('/delete-zone', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalDeleteZone'); | ||
$app->get('/export-zone', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalExportZoneEntry'); | ||
|
||
|
||
$app->get('/create-zone-entry', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalCreateZoneEntry'); | ||
$app->get('/edit-zone-entry', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalEditZoneEntry'); | ||
$app->get('/delete-zone-entry', 'UserFrosting\Sprinkle\Dnsadmin\Controller\AdminController:modalDeleteZoneEntry'); | ||
|
||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
$app->group('/api/dns', function () use ($app) { | ||
$app->get('/zones', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:getZones'); | ||
$app->post('/zones', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:createZone'); | ||
$app->put('/zones/z/{id}', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:editZone'); | ||
$app->delete('/zones/z/{id}', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:deleteZone'); | ||
|
||
$app->put('/zones/z/{id}/configuration', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:saveConfiguration'); | ||
$app->put('/zones/z/{id}/status', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:setStatus'); | ||
|
||
|
||
$app->get('/zones/z/{id}/entries', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:getZoneEntries'); | ||
$app->post('/zones/z/{id}/entries', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:createZoneEntry'); | ||
$app->put('/zones/z/{zone_id}/entries/e/{entry_id}', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:editZoneEntry'); | ||
$app->delete('/zones/z/{zone_id}/entries/e/{entry_id}', 'UserFrosting\Sprinkle\Dnsadmin\Controller\ApiController:deleteZoneEntry'); | ||
|
||
|
||
|
||
}); |
Oops, something went wrong.