diff --git a/.gitignore b/.gitignore index 63468cc..fab4a5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -nbproject/private/ -config/config-user.php -releases/ +backend-legacy/config/config-user.php diff --git a/add-domain.php b/add-domain.php deleted file mode 100644 index 89a87b6..0000000 --- a/add-domain.php +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - PDNS Manager - Domains - - - - - - - - - - - - - - - -
- - -

Add Domain

-
- - -
-
-
- - -
-
- - -
-
- - -
- -
- -
-
- - -
-
- - -
-
- -
-
- - -
-
- - -
-
-
-
- -
- ' . $_SESSION['csrfToken'] . ''; ?> - - - diff --git a/api/add-domain.php b/backend-legacy/api/add-domain.php similarity index 95% rename from api/add-domain.php rename to backend-legacy/api/add-domain.php index 246af49..26e4c6a 100644 --- a/api/add-domain.php +++ b/backend-legacy/api/add-domain.php @@ -23,11 +23,6 @@ require_once '../lib/soa-mail.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") { echo "Permission denied!"; exit(); diff --git a/api/domains.php b/backend-legacy/api/domains.php similarity index 97% rename from api/domains.php rename to backend-legacy/api/domains.php index ab1fe53..a471323 100644 --- a/api/domains.php +++ b/backend-legacy/api/domains.php @@ -22,11 +22,6 @@ require_once '../lib/session.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - if(isset($input->action) && $input->action == "getDomains") { // Check if the requested page is a number if(!(isset($input->page) && is_int($input->page) && $input->page > 0)) { diff --git a/api/edit-master.php b/backend-legacy/api/edit-master.php similarity index 98% rename from api/edit-master.php rename to backend-legacy/api/edit-master.php index c1e0a3f..4366be3 100644 --- a/api/edit-master.php +++ b/backend-legacy/api/edit-master.php @@ -24,11 +24,6 @@ require_once '../lib/update-serial.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - //Permission check if(isset($input->domain)) { $permquery = $db->prepare("SELECT COUNT(*) FROM permissions WHERE userid=:user AND domain=:domain"); diff --git a/api/edit-remote.php b/backend-legacy/api/edit-remote.php similarity index 97% rename from api/edit-remote.php rename to backend-legacy/api/edit-remote.php index 93e2004..8081d69 100644 --- a/api/edit-remote.php +++ b/backend-legacy/api/edit-remote.php @@ -22,11 +22,6 @@ require_once '../lib/session.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - //Permission check if(isset($input->record)) { $permquery = $db->prepare("SELECT COUNT(*) FROM records JOIN permissions ON records.domain_id=permissions.domain WHERE userid=:user AND records.id=:id"); diff --git a/api/edit-user.php b/backend-legacy/api/edit-user.php similarity index 97% rename from api/edit-user.php rename to backend-legacy/api/edit-user.php index 9b33394..dc94bf7 100644 --- a/api/edit-user.php +++ b/backend-legacy/api/edit-user.php @@ -22,11 +22,6 @@ require_once '../lib/session.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") { echo "Permission denied!"; exit(); diff --git a/api/index.php b/backend-legacy/api/index.php similarity index 100% rename from api/index.php rename to backend-legacy/api/index.php diff --git a/api/install.php b/backend-legacy/api/install.php similarity index 100% rename from api/install.php rename to backend-legacy/api/install.php diff --git a/backend-legacy/api/logout.php b/backend-legacy/api/logout.php new file mode 100644 index 0000000..e7f252c --- /dev/null +++ b/backend-legacy/api/logout.php @@ -0,0 +1,8 @@ + + diff --git a/api/password.php b/backend-legacy/api/password.php similarity index 90% rename from api/password.php rename to backend-legacy/api/password.php index 5b51c48..77aa25e 100644 --- a/api/password.php +++ b/backend-legacy/api/password.php @@ -22,11 +22,6 @@ require_once '../lib/session.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - if(isset($input->action) && $input->action == "changePassword") { $passwordHash = password_hash($input->password, PASSWORD_DEFAULT); diff --git a/api/remote.php b/backend-legacy/api/remote.php similarity index 100% rename from api/remote.php rename to backend-legacy/api/remote.php diff --git a/api/upgrade.php b/backend-legacy/api/upgrade.php similarity index 100% rename from api/upgrade.php rename to backend-legacy/api/upgrade.php diff --git a/api/users.php b/backend-legacy/api/users.php similarity index 95% rename from api/users.php rename to backend-legacy/api/users.php index d554234..7465bcd 100644 --- a/api/users.php +++ b/backend-legacy/api/users.php @@ -22,11 +22,6 @@ require_once '../lib/session.php'; $input = json_decode(file_get_contents('php://input')); -if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { - echo "Permission denied!"; - exit(); -} - if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") { echo "Permission denied!"; exit(); diff --git a/config/config-default.php b/backend-legacy/config/config-default.php similarity index 100% rename from config/config-default.php rename to backend-legacy/config/config-default.php diff --git a/include/bootstrap/css/bootstrap-theme.min.css b/backend-legacy/include/bootstrap/css/bootstrap-theme.min.css similarity index 100% rename from include/bootstrap/css/bootstrap-theme.min.css rename to backend-legacy/include/bootstrap/css/bootstrap-theme.min.css diff --git a/include/bootstrap/css/bootstrap.min.css b/backend-legacy/include/bootstrap/css/bootstrap.min.css similarity index 100% rename from include/bootstrap/css/bootstrap.min.css rename to backend-legacy/include/bootstrap/css/bootstrap.min.css diff --git a/include/bootstrap/fonts/glyphicons-halflings-regular.eot b/backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from include/bootstrap/fonts/glyphicons-halflings-regular.eot rename to backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.eot diff --git a/include/bootstrap/fonts/glyphicons-halflings-regular.svg b/backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from include/bootstrap/fonts/glyphicons-halflings-regular.svg rename to backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.svg diff --git a/include/bootstrap/fonts/glyphicons-halflings-regular.ttf b/backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from include/bootstrap/fonts/glyphicons-halflings-regular.ttf rename to backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.ttf diff --git a/include/bootstrap/fonts/glyphicons-halflings-regular.woff b/backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from include/bootstrap/fonts/glyphicons-halflings-regular.woff rename to backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.woff diff --git a/include/bootstrap/fonts/glyphicons-halflings-regular.woff2 b/backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from include/bootstrap/fonts/glyphicons-halflings-regular.woff2 rename to backend-legacy/include/bootstrap/fonts/glyphicons-halflings-regular.woff2 diff --git a/include/bootstrap/js/bootstrap.min.js b/backend-legacy/include/bootstrap/js/bootstrap.min.js similarity index 100% rename from include/bootstrap/js/bootstrap.min.js rename to backend-legacy/include/bootstrap/js/bootstrap.min.js diff --git a/include/custom.css b/backend-legacy/include/custom.css similarity index 100% rename from include/custom.css rename to backend-legacy/include/custom.css diff --git a/include/jquery.js b/backend-legacy/include/jquery.js similarity index 100% rename from include/jquery.js rename to backend-legacy/include/jquery.js diff --git a/include/select2/select2-bootstrap.min.css b/backend-legacy/include/select2/select2-bootstrap.min.css similarity index 100% rename from include/select2/select2-bootstrap.min.css rename to backend-legacy/include/select2/select2-bootstrap.min.css diff --git a/include/select2/select2.min.css b/backend-legacy/include/select2/select2.min.css similarity index 100% rename from include/select2/select2.min.css rename to backend-legacy/include/select2/select2.min.css diff --git a/include/select2/select2.min.js b/backend-legacy/include/select2/select2.min.js similarity index 100% rename from include/select2/select2.min.js rename to backend-legacy/include/select2/select2.min.js diff --git a/lib/checkversion.php b/backend-legacy/lib/checkversion.php similarity index 100% rename from lib/checkversion.php rename to backend-legacy/lib/checkversion.php diff --git a/lib/database.php b/backend-legacy/lib/database.php similarity index 100% rename from lib/database.php rename to backend-legacy/lib/database.php diff --git a/lib/headers.php b/backend-legacy/lib/headers.php similarity index 100% rename from lib/headers.php rename to backend-legacy/lib/headers.php diff --git a/lib/session.php b/backend-legacy/lib/session.php similarity index 100% rename from lib/session.php rename to backend-legacy/lib/session.php diff --git a/lib/soa-mail.php b/backend-legacy/lib/soa-mail.php similarity index 100% rename from lib/soa-mail.php rename to backend-legacy/lib/soa-mail.php diff --git a/lib/update-serial.php b/backend-legacy/lib/update-serial.php similarity index 100% rename from lib/update-serial.php rename to backend-legacy/lib/update-serial.php diff --git a/domains.php b/domains.php deleted file mode 100644 index e897787..0000000 --- a/domains.php +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - PDNS Manager - Domains - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
ID -
-
- Name - - -
-
-
-
-
- Type - - -
-
-
Records
- - - '; - echo 'Add MASTER'; - echo 'Add NATIVE'; - echo '
'; - } - ?> - - - - - ' . $_SESSION['csrfToken'] . ''; ?> - - - diff --git a/edit-master.php b/edit-master.php deleted file mode 100644 index 4107ee6..0000000 --- a/edit-master.php +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - PDNS Manager - Domains - - - - - - - - - - - - - - - - - - -
- - -

-
- -
- -

SOA

-
- -
-
-
- - -
-
- - -
- -
- -
-
- - -
-
- - -
-
- -
-
- - -
-
- - -
-
- -
-
- - -
-
-
-
-
- -
- -

Records

-
- - - - - - - - - - - - - - - - - - - - - - -
ID -
-
- Name - - -
-
-
-
-
- Type - - -
-
-
-
-
- Content - - -
-
-
Priority TTL
New -
- - -
-
-
-
- ' . $_SESSION['csrfToken'] . ''; ?> - - - - diff --git a/edit-remote.php b/edit-remote.php deleted file mode 100644 index 69874de..0000000 --- a/edit-remote.php +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - PDNS Manager - Remotes - - - - - - - - - - - - - - - - - - -
- - -

Remote access

-
- - -
- - - - - - - - - - - - -
IDDescriptionType
- - - - - -
-
- -
-
- - -
-
- - -
-
- - -
- - -
-
- - -
-
- - -
-
- - -
- - -
-
-
-
-
- ' . $_SESSION['csrfToken'] . ''; ?> - - - - diff --git a/edit-user.php b/edit-user.php deleted file mode 100644 index b4b3d0b..0000000 --- a/edit-user.php +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - PDNS Manager - Users - - - - - - - - - - - - - - - - - - -
- - -

Change user

-
- - -
-
- -
- - -
-
- - -
-
- - -
-
- - -
- -
-
- -
-

Permissions

- - - - -
- - - -
- -
-
- -
- ' . $_SESSION['csrfToken'] . ''; ?> - - - - diff --git a/index.php b/index.php deleted file mode 100644 index c1e93d2..0000000 --- a/index.php +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - PDNS Manager - - - - - - - - - - - - - - - -
-
-
-
- -
-
- - -
-
- - -
- -
-
-
-
- - diff --git a/install.php b/install.php deleted file mode 100644 index 53efd40..0000000 --- a/install.php +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - PDNS Manager - Domains - - - - - - - - - - - - - - - -
- - -

Install PDNS Manager

-
- - - - - - - -
-
-

Database

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- -
-

Admin

- -
- - -
-
- - -
-
- - -
-
-
-
- -
- - - - diff --git a/js/add-domain.js b/js/add-domain.js deleted file mode 100644 index d6d767e..0000000 --- a/js/add-domain.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - - $('#zone-button-add').click(function(evt){ - evt.preventDefault(); - if(validateData()) { - saveData(function(id) { - location.assign("edit-master.php#" + id); - }); - } else { - shake($('#zone-button-add')); - } - }); - - $('form input').bind("paste keyup change", regexValidate); -}); - -function validateData() { - - var error = 0; - - $('form input').change(); - - $('form input').each(function() { - if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) { - error++; - $(this).parent().addClass('has-error'); - } - }); - - return error<=0; -} - -function regexValidate() { - var regex = new RegExp($(this).attr('data-regex')); - if(!regex.test($(this).val())) { - $(this).parent().addClass("has-error"); - } else { - $(this).parent().removeClass("has-error"); - } -} - -function saveData(callback) { - var data = { - name: $('#zone-name').val(), - primary: $('#zone-primary').val(), - mail: $('#zone-mail').val(), - refresh: $('#zone-refresh').val(), - retry: $('#zone-retry').val(), - expire: $('#zone-expire').val(), - ttl: $('#zone-ttl').val(), - type: window.location.hash.substring(1), - action: "addDomain", - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/add-domain.php", - JSON.stringify(data), - function(data) { - callback(data.newId); - }, - "json" - ); -} - -function shake(element){ - var interval = 50; - var distance = 5; - var times = 6; - - $(element).css('position','relative'); - - for(var iter=0;iter<(times+1);iter++){ - $(element).animate({ - left:((iter%2===0 ? distance : distance*-1)) - },interval); - } - - $(element).animate({ left: 0},interval); -} \ No newline at end of file diff --git a/js/domains.js b/js/domains.js deleted file mode 100644 index 5f375a2..0000000 --- a/js/domains.js +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var sort = { - field: "", - order: 1 -} - -$(document).ready(function() { - requestData(); - - $('#table-domains>thead>tr>td span').click(function() { - var field = $(this).siblings('strong').text().toLowerCase(); - if(sort.field == field) { - if(sort.order == 1) sort.order = 0; - else sort.field = ""; - } else { - sort.field = field; - sort.order = 1; - } - $('#table-domains>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt"); - - if(sort.field == field) { - if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes"); - else $(this).addClass("glyphicon-sort-by-attributes-alt"); - } - requestData(); - }); - - $('#searchName').bind("paste keyup", function() { - requestData(); - }); - - $('#searchType').change(function() { - requestData(); - }); - - $('#searchType').select2({ - minimumResultsForSearch: Infinity - }); -}); - -function requestData(page) { - if(typeof(page) !== 'number' || page <= 0) { - page = 1; - } - - var restrictions = { - csrfToken: $('#csrfToken').text(), - }; - - restrictions.sort = sort; - - var searchName = $('#searchName').val(); - if(searchName.length > 0) { - restrictions.name = searchName; - } - - var searchType = $('#searchType').val(); - if(searchType != "none") { - restrictions.type = searchType; - } - - restrictions.action = "getDomains"; - restrictions.page = page; - - $.post( - "api/domains.php", - JSON.stringify(restrictions), - function(data) { - recreateTable(data.data); - recreatePagination(data.pages) - }, - "json" - ); -} - -function recreatePagination(data) { - $('#pagination').empty(); - - if(data.total === 1) { - $('#pagination-wrapper').hide(); - return; - } - - if(data.current > 1) { - $('
  • ').appendTo('#pagination').data("page", data.current - 1).click(paginationClicked); - } - - $('
  • 1
  • ').appendTo('#pagination').data("page", 1).click(paginationClicked); - - if(data.current > 4) { - $('
  • ').appendTo('#pagination'); - } - - for(var i = data.current - 2; i <= data.current + 2; i++) { - if(i > 1 && i < data.total) { - if(data.current === i) { - $('
  • ' + i + '
  • ').appendTo('#pagination'); - } else { - $('
  • ' + i + '
  • ').appendTo('#pagination').data("page", i).click(paginationClicked); - } - } - } - - if(data.current < data.total - 3) { - $('
  • ').appendTo('#pagination'); - } - - $('
  • ' + data.total + '
  • ').appendTo('#pagination').data("page", data.total).click(paginationClicked); - - if(data.current < data.total) { - $('
  • ').appendTo('#pagination').data("page", data.current + 1).click(paginationClicked); - } - - $('#pagination-wrapper').show(); -} - -function recreateTable(data) { - $('#table-domains>tbody').empty(); - - $.each(data, function(index,item) { - $('').appendTo('#table-domains>tbody') - .append('' + item.id + '') - .append('' + item.name + '') - .append('' + item.type + '') - .append('' + item.records + '') - .append(''); - - }); - - $('#table-domains>tbody>tr>td:not(:last-child)').click(function() { - var id = $(this).parent().children('td').first().text(); - var type = $(this).parent().children('td').eq(2).text(); - - if(type == 'MASTER') { - location.assign('edit-master.php#' + id); - } else if(type == 'NATIVE') { - location.assign('edit-master.php#' + id); - } - }); - - $('#table-domains>tbody>tr>td>span.glyphicon-trash').click(function() { - $(this).parent().parent().unbind(); - deleteDomain.call(this); - }); -} - -function deleteDomain() { - var deleteId = $(this).parent().parent().children('td').eq(0).text(); - var deleteZone = $(this).parent().parent().children('td').eq(1).text(); - var rowToRemove = $(this).parent().parent(); - - $('#zoneToDelete').text(deleteZone); - - $('#deleteConfirm #buttonDelete').click(function() { - deleteDomainWithId(deleteId, function() { - $('#deleteConfirm').modal("hide"); - $(rowToRemove).remove(); - }); - }); - - $('#deleteConfirm').modal(); -} - -function deleteDomainWithId(id, callback) { - var data = { - action: "deleteDomain", - id: id, - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/domains.php", - JSON.stringify(data), - function() { - callback(); - }, - "json" - ); -} - -function paginationClicked() { - requestData($(this).data("page")); -} \ No newline at end of file diff --git a/js/edit-master.js b/js/edit-master.js deleted file mode 100644 index 144a397..0000000 --- a/js/edit-master.js +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var sort = { - field: "", - order: 1 -}; - -var domainName = ""; - -var recordTypes = [ - "A","AAAA","AFSDB","CERT","CNAME","DHCID", - "DLV","DNSKEY","DS","EUI48","EUI64","HINFO", - "IPSECKEY","KEY","KX","LOC","MINFO","MR", - "MX","NAPTR","NS","NSEC","NSEC3","NSEC3PARAM", - "OPT","PTR","RKEY","RP","RRSIG","SPF", - "SRV","SSHFP","TLSA","TSIG","TXT","WKS" -]; - -$(document).ready(function() { - - $('#soa button[type=submit]').click(function(){ - if(validateSoaData()) { - saveSoaData(); - $('#soa button[type=submit]').prop("disabled", true); - } else { - shake($('#soa button[type=submit]')); - } - }); - - $('#soa input').bind("paste keyup change", function() { - $('#soa button[type=submit]').prop("disabled", false); - }); - - $('#soa form input').bind("paste keyup change", regexValidate); - $('#table-records>tfoot input').bind("paste keyup change", regexValidate); - - $('#searchType').select2({ - placeholder: "Filter...", - data: recordTypes - }); - - $('#addType').select2({ - data: recordTypes - }); - - $('#table-records>thead>tr>td span.glyphicon').click(function() { - var field = $(this).siblings('strong').text().toLowerCase(); - if(sort.field == field) { - if(sort.order == 1) sort.order = 0; - else sort.field = ""; - } else { - sort.field = field; - sort.order = 1; - } - $('#table-records>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt"); - - if(sort.field == field) { - if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes"); - else $(this).addClass("glyphicon-sort-by-attributes-alt"); - } - requestRecordData(); - }); - - $('#searchName, #searchContent').bind("paste keyup", function() { - requestRecordData(); - }); - - $('#searchType').change(function() { - requestRecordData(); - }); - - requestRecordData(); - requestSoaData(); - requestSerial(); - requestDomainName(); -}); - -function validateSoaData() { - - var error = 0; - - $('#soa form input:not(#soa-serial)').each(function() { - if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) { - error++; - $(this).parent().addClass('has-error'); - } - }); - - return error<=0; -} - -function recreateTable(data) { - $('#table-records>tbody').empty(); - - $.each(data, function(index,item) { - $('').appendTo('#table-records>tbody') - .append('' + item.id + '') - .append('' + item.name + '') - .append('' + item.type + '') - .append('' + item.content + '') - .append('' + item.priority + '') - .append('' + item.ttl + '') - .append('') - .append('') - .append(''); - - }); - - $('#table-records>tbody>tr>td>span.glyphicon-trash').click(trashClicked); - $('#table-records>tbody>tr>td>span.glyphicon-pencil').click(editClicked); - $('#table-records>tbody>tr>td>span.glyphicon-share').click(remoteClicked); -} - -function requestRecordData() { - var restrictions = { - csrfToken: $('#csrfToken').text() - }; - - restrictions.sort = sort; - - var searchName = $('#searchName').val(); - if(searchName.length > 0) { - restrictions.name = searchName; - } - - var searchType = $('#searchType').val(); - if(searchType != null && searchType.length > 0) { - restrictions.type = searchType; - } - - var searchContent = $('#searchContent').val(); - if(searchContent.length > 0) { - restrictions.content = searchContent; - } - - restrictions.action = "getRecords"; - - restrictions.domain = location.hash.substring(1); - - $.post( - "api/edit-master.php", - JSON.stringify(restrictions), - function(data) { - recreateTable(data); - }, - "json" - ); -} - -function requestSoaData() { - var data = { - action: "getSoa", - csrfToken: $('#csrfToken').text() - }; - - data.domain = location.hash.substring(1); - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function(data) { - $('#soa-primary').val(data.primary); - $('#soa-mail').val(data.email); - $('#soa-refresh').val(data.refresh); - $('#soa-retry').val(data.retry); - $('#soa-expire').val(data.expire); - $('#soa-ttl').val(data.ttl); - }, - "json" - ); -} - -function requestSerial() { - var data = { - action: "getSerial", - csrfToken: $('#csrfToken').text() - }; - - data.domain = location.hash.substring(1); - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function(data) { - $('#soa-serial').val(data.serial); - }, - "json" - ); -} - -function saveSoaData() { - var data = { - action: "saveSoa", - csrfToken: $('#csrfToken').text() - }; - - data.domain = location.hash.substring(1); - - data.primary = $('#soa-primary').val(); - data.email = $('#soa-mail').val(); - data.refresh = $('#soa-refresh').val(); - data.retry = $('#soa-retry').val(); - data.expire = $('#soa-expire').val(); - data.ttl = $('#soa-ttl').val(); - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function() { - requestSerial(); - }, - "json" - ); -} - -function editClicked() { - var tableCells = $(this).parent().parent().children('td'); - var tableRow = $(this).parent().parent(); - - var valueExtractRegex = new RegExp('\.?' + domainName + "$"); - var valueName = tableCells.eq(1).text(); - valueName = valueName.replace(valueExtractRegex, ""); - tableCells.eq(1).empty(); - var inputGroupName = $('
    ').appendTo(tableCells.eq(1)); - $('').appendTo(inputGroupName).val(valueName); - $('').appendTo(inputGroupName).text("." + domainName); - - var valueType = tableCells.eq(2).text(); - tableCells.eq(2).empty(); - $('').appendTo(tableCells.eq(2)).select2({ - data: recordTypes - }).val(valueType).trigger("change"); - - var valueContent = tableCells.eq(3).text(); - tableCells.eq(3).empty(); - $('').appendTo(tableCells.eq(3)).val(valueContent); - - var valuePrio = tableCells.eq(4).text(); - tableCells.eq(4).empty(); - $('').appendTo(tableCells.eq(4)).val(valuePrio); - - var valueTtl = tableCells.eq(5).text(); - tableCells.eq(5).empty(); - $('').appendTo(tableCells.eq(5)).val(valueTtl); - - tableCells.eq(6).remove(); - tableCells.eq(7).remove(); - tableCells.eq(8).remove(); - - $(tableRow).append(''); - - $(tableRow).find('button').click(saveRecord); - - enableFilter(false); - - $(tableRow).find("input").bind("paste keyup change", regexValidate); -} - -function saveRecord() { - - var tableRow = $(this).parent().parent(); - - if(!validateLine.call(this)) { - shake($(this)); - return; - } - - var data = { - id: tableRow.children('td').eq(0).text(), - name: tableRow.children('td').eq(1).find('input').val(), - type: tableRow.children('td').eq(2).children('select').val(), - content: tableRow.children('td').eq(3).children('input').val(), - prio: tableRow.children('td').eq(4).children('input').val(), - ttl: tableRow.children('td').eq(5).children('input').val(), - action: "saveRecord", - domain: location.hash.substring(1), - csrfToken: $('#csrfToken').text() - }; - - if(data.name.length > 0) { - data.name = data.name + "." + domainName; - } else { - data.name = domainName; - } - - tableRow.children('td').eq(0).empty().text(data.id); - tableRow.children('td').eq(1).empty().text(data.name); - tableRow.children('td').eq(2).empty().text(data.type); - tableRow.children('td').eq(3).empty().text(data.content); - tableRow.children('td').eq(4).empty().text(data.prio); - tableRow.children('td').eq(5).empty().text(data.ttl); - - tableRow.children('td').eq(6).remove(); - - tableRow.append('') - .append('') - .append(''); - tableRow.find('span.glyphicon-trash').click(trashClicked); - tableRow.find('span.glyphicon-pencil').click(editClicked); - tableRow.find('span.glyphicon-share').click(remoteClicked); - - enableFilter(true); - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function() { - requestSerial(); - }, - "json" - ); -} - -function addRecord() { - if(!validateLine.call(this)) { - shake($('#addButton')); - return; - } - - var prio = $('#addPrio').val(); - if(prio.length === 0) prio = 0; - - var ttl = $('#addTtl').val(); - if(ttl.length === 0) ttl = 86400; - - var data = { - type: $('#addType').val(), - content: $('#addContent').val(), - prio: prio, - ttl: ttl, - action: "addRecord", - domain: location.hash.substring(1), - csrfToken: $('#csrfToken').text() - }; - - if($('#addName').val().length > 0) { - data.name = $('#addName').val() + "." + domainName; - } else { - data.name = domainName; - } - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function(dataRecv) { - $('').appendTo('#table-records>tbody') - .append('' + dataRecv.newId + '') - .append('' + data.name + '') - .append('' + data.type + '') - .append('' + data.content + '') - .append('' + data.prio + '') - .append('' + data.ttl + '') - .append('') - .append('') - .append(''); - - $('#table-records>tbody>tr').last().find('span.glyphicon-pencil').click(editClicked); - $('#table-records>tbody>tr').last().find('span.glyphicon-trash').click(trashClicked); - $('#table-records>tbody>tr').last().find('span.glyphicon-share').click(remoteClicked); - requestSerial(); - - $('#addName').val(""); - $('#addType').val("A").change(); - $('#addContent').val(""); - $('#addPrio').val(""); - $('#addTtl').val(""); - }, - "json" - ); -} - -function trashClicked() { - var data = { - id: $(this).parent().parent().children().eq(0).text(), - domain: location.hash.substring(1), - action: "removeRecord", - csrfToken: $('#csrfToken').text() - }; - - var lineAffected = $(this).parent().parent(); - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function() { - lineAffected.remove(); - requestSerial(); - }, - "json" - ); -} - -function requestDomainName() { - var data = { - action: "getDomainName", - domain: location.hash.substring(1), - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/edit-master.php", - JSON.stringify(data), - function(data) { - $('#domain-name').text(data.name); - $('#add-domain-name').text("." + data.name); - domainName = data.name; - $('#addButton').unbind().click(addRecord); - }, - "json" - ); -} - -function enableFilter(enable) { - if(enable) { - $('#searchName').prop("disabled", false); - $('#searchType').prop("disabled", false); - $('#searchContent').prop("disabled", false); - } else { - $('#searchName').prop("disabled", true); - $('#searchType').prop("disabled", true); - $('#searchContent').prop("disabled", true); - } -} - -function regexValidate() { - var regex = new RegExp($(this).attr('data-regex')); - if(!regex.test($(this).val())) { - $(this).parent().addClass("has-error"); - } else { - $(this).parent().removeClass("has-error"); - } -} - -function validateLine() { - $(this).parent().parent().find('input[data-regex]').change(); - var errors = 0; - $(this).parent().parent().find('input[data-regex]').each(function() { - if($(this).parent().hasClass('has-error')) { - errors++; - } - }); - - return errors <= 0; -} - -function remoteClicked() { - var recordId = $(this).parent().siblings().eq(0).text(); - location.assign("edit-remote.php#" + recordId); -} - -function shake(element){ - var interval = 50; - var distance = 5; - var times = 6; - - $(element).css('position','relative'); - - for(var iter=0;iter<(times+1);iter++){ - $(element).animate({ - left:((iter%2===0 ? distance : distance*-1)) - },interval); - } - - $(element).animate({ left: 0},interval); -} \ No newline at end of file diff --git a/js/edit-remote.js b/js/edit-remote.js deleted file mode 100644 index 6cb7e38..0000000 --- a/js/edit-remote.js +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - $('#data-password-password2').bind("paste keyup change", function() { - if($('#data-password-password').val() != $('#data-password-password2').val()) { - $(this).parent().addClass("has-error"); - } else { - $(this).parent().removeClass("has-error"); - } - }); - - $('#button-add-password').click(function() { - resetFields(); - $('#data-password').show(); - $('#data-key').hide(); - $('#data-password-confirm').unbind().click(addPassword); - }); - - $('#button-add-key').click(function() { - resetFields(); - $('#data-key').show(); - $('#data-password').hide(); - $('#data-key-confirm').unbind().click(addKey); - }); - - $('#data-password-cancel').click(function() { - $('#data-password').hide(); - }); - - $('#data-key-cancel').click(function() { - $('#data-key').hide(); - }); - - requestPermissions(); -}); - -function regexValidate() { - var regex = new RegExp($(this).attr('data-regex')); - if(!regex.test($(this).val())) { - $(this).parent().addClass("has-error"); - } else { - $(this).parent().removeClass("has-error"); - } -} - -function createTable(data) { - $('#permissions tbody').empty(); - - $.each(data, function(index,item) { - $('').appendTo('#permissions tbody') - .append('' + item.id + '') - .append('' + item.description + '') - .append('' + item.type + '') - .append('') - .append(''); - }); - - $('#permissions tbody span.glyphicon-trash').click(deletePermission); - $('#permissions tbody span.glyphicon-pencil').click(prepareEdit); -} - -function requestPermissions() { - var data = { - action: "getPermissions", - csrfToken: $('#csrfToken').text(), - record: location.hash.substring(1) - }; - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - createTable(data); - }, - "json" - ); -} - -function resetFields() { - $('#info-dialogs input').val(""); - $('#info-dialogs textarea').val(""); - $('#info-dialogs .form-group').removeClass("has-error"); - $('#data-password-password').attr("placeholder", "Password"); - $('#data-password-password2').attr("placeholder", "Password repeated"); - $('#data-password-confirm').text("Add"); - $('#data-key-confirm').text("Add"); -} - -function addPassword() { - if($('#data-password-password').val() != $('#data-password-password2').val() || $('#data-password-password').val().length <= 0) { - $('#data-password-password2').parent().addClass("has-error"); - shake($('#data-password-confirm')); - return; - } - - var data = { - csrfToken: $('#csrfToken').text(), - action: "addPassword", - description: $('#data-password-description').val(), - password: $('#data-password-password').val(), - record: location.hash.substring(1) - }; - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - $('#data-password').hide(); - requestPermissions(); - }, - "json" - ); -} - -function addKey() { - if($('#data-key-key').val().length <= 0) { - $('#data-key-key').parent().addClass("has-error"); - shake($('#data-key-confirm')); - return; - } - - var data = { - csrfToken: $('#csrfToken').text(), - action: "addKey", - description: $('#data-key-description').val(), - key: $('#data-key-key').val(), - record: location.hash.substring(1) - }; - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - $('#data-key').hide(); - requestPermissions(); - }, - "json" - ); -} - -function deletePermission() { - var data = { - csrfToken: $('#csrfToken').text(), - action: "deletePermission", - permission: $(this).parent().siblings().eq(0).text(), - record: location.hash.substring(1) - }; - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - requestPermissions(); - }, - "json" - ); -} - -function prepareEdit() { - var type = $(this).parent().siblings().eq(2).text(); - if(type === "password") { - resetFields(); - $('#data-password').show(); - $('#data-key').hide(); - $('#data-password-confirm').unbind().click(changePassword); - - $('#data-password-password').attr("placeholder", "(Unchanged)"); - $('#data-password-password2').attr("placeholder", "(Unchanged)"); - $('#data-password-confirm').text("Change"); - - $('#data-password-description').val($(this).parent().siblings().eq(1).text()); - - $('#data-password-confirm').data("permission-id", $(this).parent().siblings().eq(0).text()); - } else if(type === "key") { - resetFields(); - $('#data-key').show(); - $('#data-password').hide(); - $('#data-key-confirm').unbind().click(changeKey); - - $('#data-key-confirm').text("Change"); - $('#data-key-description').val($(this).parent().siblings().eq(1).text()); - - $('#data-key-confirm').data("permission-id", $(this).parent().siblings().eq(0).text()); - - var data = { - csrfToken: $('#csrfToken').text(), - action: "getKey", - permission: $(this).parent().siblings().eq(0).text(), - record: location.hash.substring(1) - }; - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - $('#data-key-key').val(data.key); - }, - "json" - ); - } -} - -function changePassword() { - if($('#data-password-password').val() != $('#data-password-password2').val()) { - $('#data-password-password2').parent().addClass("has-error"); - return; - } - - var data = { - csrfToken: $('#csrfToken').text(), - action: "changePassword", - description: $('#data-password-description').val(), - record: location.hash.substring(1), - permission: $('#data-password-confirm').data("permission-id") - }; - - if($('#data-password-password').val().length >= 0) { - data.password = $('#data-password-password').val(); - } - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - $('#data-password').hide(); - requestPermissions(); - }, - "json" - ); -} - -function changeKey() { - if($('#data-key-key').val().length <= 0) { - $('#data-key-key').parent().addClass("has-error"); - return; - } - - var data = { - csrfToken: $('#csrfToken').text(), - action: "changeKey", - description: $('#data-key-description').val(), - key: $('#data-key-key').val(), - record: location.hash.substring(1), - permission: $('#data-key-confirm').data("permission-id") - }; - - $.post( - "api/edit-remote.php", - JSON.stringify(data), - function(data) { - $('#data-key').hide(); - requestPermissions(); - }, - "json" - ); -} - -function shake(element){ - var interval = 50; - var distance = 5; - var times = 6; - - $(element).css('position','relative'); - - for(var iter=0;iter<(times+1);iter++){ - $(element).animate({ - left:((iter%2===0 ? distance : distance*-1)) - },interval); - } - - $(element).animate({ left: 0},interval); -} \ No newline at end of file diff --git a/js/edit-user.js b/js/edit-user.js deleted file mode 100644 index 18d2d9c..0000000 --- a/js/edit-user.js +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - - $('#user-button-add').click(function(evt){ - evt.preventDefault(); - - if(location.hash.substring(1) == "new") { - addUser(); - } else { - saveUserChanges(); - } - }); - - $('form input#user-name').bind("paste keyup change", regexValidate); - - $('#user-password').unbind().bind("paste keyup change", function() { - $('#user-password').parent().removeClass("has-error"); - }); - - $('#user-password2').unbind().bind("paste keyup change", function() { - if($('#user-password').val() != $('#user-password2').val()) { - $('#user-password2').parent().addClass("has-error"); - } else { - $('#user-password2').parent().removeClass("has-error"); - } - }); - - $('#user-type').select2({ - minimumResultsForSearch: Infinity - }); - - //Prepare for new user - if(location.hash.substring(1) == "new") { - $('#heading').text("Add user"); - $('#user-button-add').text("Add"); - $('#user-password').attr("placeholder", "Password"); - $('#user-password2').attr("placeholder", "Password repeated"); - } else { - getUserData(); - requestPermissions(); - $('#permissions').removeClass("defaulthidden"); - } - - $('#permissions select#selectAdd').select2({ - ajax: { - url: "api/edit-user.php", - dataType: "json", - delay: 200, - method: "post", - data: function(params) { - return JSON.stringify({ - action: "searchDomains", - term: params.term, - userId: location.hash.substring(1), - csrfToken: $('#csrfToken').text() - }); - }, - processResults: function (data) { - return { - results: data - }; - }, - minimumInputLength: 1 - }, - placeholder: "Search...", - minimumInputLength: 1 - }); - - $('#btnAddPermissions').click(addPermissions); -}); - -function regexValidate() { - var regex = new RegExp($(this).attr('data-regex')); - if(!regex.test($(this).val())) { - $(this).parent().addClass("has-error"); - } else { - $(this).parent().removeClass("has-error"); - } -} - -function addUser() { - $('form input').change(); - - if($('#user-password').val().length <= 0) { - $('#user-password').parent().addClass("has-error"); - $('#user-password2').parent().addClass("has-error"); - shake($('#user-button-add')); - } - - if($('#user-name').parent().hasClass("has-error")) { - shake($('#user-button-add')); - return; - } - if($('#user-password2').parent().hasClass("has-error")) { - shake($('#user-button-add')); - return; - } - - var data = { - name: $('#user-name').val(), - password: $('#user-password').val(), - type: $('#user-type').val(), - action: "addUser", - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/edit-user.php", - JSON.stringify(data), - function(data) { - location.assign("edit-user.php#" + data.newId); - location.reload(); - }, - "json" - ); -} - -function getUserData() { - var data = { - id: location.hash.substring(1), - action: "getUserData", - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/edit-user.php", - JSON.stringify(data), - function(data) { - $('#user-name').val(data.name); - $('#user-type').val(data.type).change(); - }, - "json" - ); -} - -function saveUserChanges() { - - if($('#user-name').parent().hasClass("has-error")) { - shake($('#user-button-add')); - return; - } - if($('#user-password2').parent().hasClass("has-error")) { - shake($('#user-button-add')); - return; - } - - var data = { - id: location.hash.substring(1), - name: $('#user-name').val(), - type: $('#user-type').val(), - action: "saveUserChanges", - csrfToken: $('#csrfToken').text() - }; - - if($('#user-password').val().length > 0) { - data.password = $('#user-password').val(); - } - - $.post( - "api/edit-user.php", - JSON.stringify(data), - null, - "json" - ); -} - -function requestPermissions() { - var data = { - id: location.hash.substring(1), - action: "getPermissions", - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/edit-user.php", - JSON.stringify(data), - function(data) { - createTable(data); - }, - "json" - ); -} - -function createTable(data) { - $('#permissions table>tbody').empty(); - - $.each(data, function(index,item) { - $('').appendTo('#permissions table>tbody') - .append('' + item.name + '') - .append('') - .data("id", item.id); - }); - - $('#permissions table>tbody>tr>td>span.glyphicon-remove').click(removePermission); -} - -function removePermission() { - var data = { - domainId: $(this).parent().parent().data("id"), - userId: location.hash.substring(1), - action: "removePermission", - csrfToken: $('#csrfToken').text() - }; - - var lineToRemove = $(this).parent().parent(); - - $.post( - "api/edit-user.php", - JSON.stringify(data), - function(data) { - $(lineToRemove).remove(); - }, - "json" - ); -} - -function addPermissions() { - var data = { - action: "addPermissions", - userId: location.hash.substring(1), - domains: $('#permissions select#selectAdd').val(), - csrfToken: $('#csrfToken').text() - } - - $.post( - "api/edit-user.php", - JSON.stringify(data), - function(data) { - $('#permissions select#selectAdd').val(null).change(); - requestPermissions(); - }, - "json" - ); -} - -function shake(element){ - var interval = 50; - var distance = 5; - var times = 6; - - $(element).css('position','relative'); - - for(var iter=0;iter<(times+1);iter++){ - $(element).animate({ - left:((iter%2===0 ? distance : distance*-1)) - },interval); - } - - $(element).animate({ left: 0},interval); -} \ No newline at end of file diff --git a/js/index.js b/js/index.js deleted file mode 100644 index 9751b99..0000000 --- a/js/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - - $('#buttonSubmit').click(function(event) { - event.preventDefault(); - - $('#alertLoginFailed').slideUp(300); - - var data = {}; - data.user=$('#inputUser').val(); - data.password=$('#inputPassword').val(); - - $.post( - "api/index.php", - JSON.stringify(data), - function(data){ - if(data.status == "fail") { - $('#alertLoginFailed').slideDown(600); - } else { - location.assign("domains.php"); - } - }, - "json" - ); - - }); -}); diff --git a/js/install.js b/js/install.js deleted file mode 100644 index 3351d95..0000000 --- a/js/install.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - - $('#buttonInstall').click(function(evt){ - evt.preventDefault(); - checkSettings(); - }); - - $('#adminPassword2').bind("change keyup paste", function() { - if($('#adminPassword').val() == $('#adminPassword2').val()) { - $(this).parent().removeClass("has-error"); - } else { - $(this).parent().addClass("has-error"); - } - }) -}); - -function checkSettings() { - - if($('#adminPassword').val() != $('#adminPassword2').val()) { - $('#adminPassword2').parent().addClass("has-error"); - } - - if($('#adminPassword').val().length <= 0) { - $('#adminPassword').parent().addClass("has-error"); - } - - if($('#adminName').val().length <= 0) { - $('#adminName').parent().addClass("has-error"); - } - - var data = { - host: $('#dbHost').val(), - user: $('#dbUser').val(), - password: $('#dbPassword').val(), - database: $('#dbDatabase').val(), - port: $('#dbPort').val(), - userName: $('#adminName').val(), - userPassword: $('#adminPassword').val(), - type: $('#dbType').val() - }; - - $.post( - "api/install.php", - JSON.stringify(data), - function(data) { - if(data.status == "error") { - $('#alertFailed').text(data.message); - $('#alertFailed').slideDown(600); - } else if(data.status == "success") { - location.assign("index.php"); - } - }, - "json" - ); -} - diff --git a/js/password.js b/js/password.js deleted file mode 100644 index 0e363a2..0000000 --- a/js/password.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - - $('#saveChanges').click(function(evt){ - evt.preventDefault(); - savePassword(); - }); - - $('#user-password').unbind().bind("paste keyup change", function() { - $('#user-password').parent().removeClass("has-error"); - }); - - $('#user-password2').unbind().bind("paste keyup change", function() { - if($('#user-password').val() != $('#user-password2').val()) { - $('#user-password2').parent().addClass("has-error"); - } else { - $('#user-password2').parent().removeClass("has-error"); - } - }); -}); - -function savePassword() { - - if($('#user-password').val().length <= 0) { - $('#user-password').parent().addClass("has-error"); - $('#user-password2').parent().addClass("has-error"); - } - if($('#user-password2').parent().hasClass("has-error")) { - shake($('#saveChanges')); - return; - } - - var data = { - password: $('#user-password').val(), - action: "changePassword", - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/password.php", - JSON.stringify(data), - function(data) { - $('#user-password').val(""); - $('#user-password2').val(""); - }, - "json" - ); -} - -function shake(element){ - var interval = 50; - var distance = 5; - var times = 6; - - $(element).css('position','relative'); - - for(var iter=0;iter<(times+1);iter++){ - $(element).animate({ - left:((iter%2===0 ? distance : distance*-1)) - },interval); - } - - $(element).animate({ left: 0},interval); -} \ No newline at end of file diff --git a/js/upgrade.js b/js/upgrade.js deleted file mode 100644 index d6d2443..0000000 --- a/js/upgrade.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -$(document).ready(function() { - - $('#button-start').click(function() { - $('#row-button-start').hide(); - requestVersions(); - }); -}); - -function requestVersions() { - var data = { - action: "getVersions" - }; - - $.post( - "api/upgrade.php", - JSON.stringify(data), - function(data) { - $('#status').append('

    Upgrading from version ' + data.from + ' to ' + data.to + '

    '); - requestUpdate(); - }, - "json" - ); -} - -function requestUpdate() { - var data = { - action: "requestUpgrade" - }; - - $.post( - "api/upgrade.php", - JSON.stringify(data), - function(data) { - $('#status').append('

    Upgrade successfull!

    '); - $('#row-button-home').show(); - }, - "json" - ); -} \ No newline at end of file diff --git a/js/users.js b/js/users.js deleted file mode 100644 index 3b5ff19..0000000 --- a/js/users.js +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2016 Lukas Metzger . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var sort = { - field: "", - order: 1 -} - -$(document).ready(function() { - requestData(); - - $('#table-users>thead>tr>td span').click(function() { - var field = $(this).siblings('strong').text().toLowerCase(); - if(sort.field == field) { - if(sort.order == 1) sort.order = 0; - else sort.field = ""; - } else { - sort.field = field; - sort.order = 1; - } - $('#table-users>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt"); - - if(sort.field == field) { - if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes"); - else $(this).addClass("glyphicon-sort-by-attributes-alt"); - } - requestData(); - }); - - $('#searchName').bind("paste keyup", function() { - requestData(); - }); - - $('#searchType').change(function() { - requestData(); - }); - - $('#searchType').select2({ - minimumResultsForSearch: Infinity - }); -}); - -function requestData() { - var restrictions = { - csrfToken: $('#csrfToken').text() - }; - - restrictions.sort = sort; - - var searchName = $('#searchName').val(); - if(searchName.length > 0) { - restrictions.name = searchName; - } - - var searchType = $('#searchType').val(); - if(searchType != "none") { - restrictions.type = searchType; - } - - restrictions.action = "getUsers"; - - $.post( - "api/users.php", - JSON.stringify(restrictions), - function(data) { - recreateTable(data); - }, - "json" - ); -} - -function recreateTable(data) { - $('#table-users>tbody').empty(); - - $.each(data, function(index,item) { - $('').appendTo('#table-users>tbody') - .append('' + item.id + '') - .append('' + item.name + '') - .append('' + item.type + '') - .append(''); - - }); - - $('#table-users>tbody>tr>td:not(:last-child)').click(function() { - var id = $(this).parent().children('td').first().text(); - location.assign('edit-user.php#' + id); - }); - - $('#table-users>tbody>tr>td>span.glyphicon-trash').click(function() { - $(this).parent().parent().unbind(); - deleteDomain.call(this); - }); -} - -function deleteDomain() { - var deleteId = $(this).parent().parent().children('td').eq(0).text(); - var deleteName = $(this).parent().parent().children('td').eq(1).text(); - var rowToRemove = $(this).parent().parent(); - - $('#userToDelete').text(deleteName); - - $('#deleteConfirm #buttonDelete').click(function() { - deleteUserWithId(deleteId, function() { - $('#deleteConfirm').modal("hide"); - $(rowToRemove).remove(); - }); - }); - - $('#deleteConfirm').modal(); -} - -function deleteUserWithId(id, callback) { - var data = { - action: "deleteUser", - id: id, - csrfToken: $('#csrfToken').text() - }; - - $.post( - "api/users.php", - JSON.stringify(data), - function() { - callback(); - }, - "json" - ); -} \ No newline at end of file diff --git a/logout.php b/logout.php deleted file mode 100644 index f10d3af..0000000 --- a/logout.php +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - PDNS Manager - - - - - - - - - - - - - -
    -
    -
    -
    -

    You have been logged out successfully!

    - Login again -
    -
    -
    - - - diff --git a/make-release.sh b/make-release.sh deleted file mode 100755 index f61c46c..0000000 --- a/make-release.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -mkdir -p releases/ - -tar -czf releases/pdns-manager-$( git describe | cut -c 2- ).tar.gz *.php LICENSE lib/ js/ include/ api/ config/config-default.php diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index c437d89..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,10 +0,0 @@ -auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs -browser.reload.on.save=true -include.path=${php.global.include.path} -php.version=PHP_56 -project.license=apache20 -source.encoding=UTF-8 -src.dir=. -tags.asp=false -tags.short=false -web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 6d6eae3..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - org.netbeans.modules.php.project - - - pdnsmanager - - - - diff --git a/password.php b/password.php deleted file mode 100644 index 667c42f..0000000 --- a/password.php +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - PDNS Manager - Password - - - - - - - - - - - - - - - - - - -
    - - -

    Change password

    -
    - - -
    -
    -
    - - -
    -
    - - -
    - -
    -
    -
    - -
    - ' . $_SESSION['csrfToken'] . ''; ?> - - - - diff --git a/upgrade.php b/upgrade.php deleted file mode 100644 index 57875e6..0000000 --- a/upgrade.php +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - PDNS Manager - Upgrade - - - - - - - - - - - - - - - -
    - - -

    Upgrade PDNS Manager

    -
    - - - An upgrade for your PDNS Manager database is available and must be installed! - - -
    - -
    - - - - - - - - - - Login - -
    -
    - - - - diff --git a/users.php b/users.php deleted file mode 100644 index 11e2fd6..0000000 --- a/users.php +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - PDNS Manager - Users - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    ID -
    -
    - Name - - -
    -
    -
    -
    -
    - Type - - -
    -
    -
    - - Add -
    - - - ' . $_SESSION['csrfToken'] . ''; ?> - -