mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
Merge remote-tracking branch 'origin/master' into issue-68
Conflicts: index.php
This commit is contained in:
commit
41d6d16a86
8 changed files with 60 additions and 30 deletions
17
Dockerfile
17
Dockerfile
|
@ -3,9 +3,7 @@ MAINTAINER Yury Evtikhov <yury@evtikhov.info>
|
|||
#
|
||||
# This Dockerfile is intended only for test/development use.
|
||||
# It will be a really BAD idea to use it for production or public services.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
|
@ -19,14 +17,15 @@ ENV PDNSAPIPORT 8081
|
|||
# Update and Upgrade system
|
||||
RUN apt-get -y update && \
|
||||
apt-get -y install curl git-core php5-cli php5-curl php5-json php5-sqlite && \
|
||||
mkdir /app && \
|
||||
git clone --recursive https://github.com/tuxis-ie/nsedit.git /app/nsedit && \
|
||||
cp /app/nsedit/includes/config.inc.php-dist /app/nsedit/includes/config.inc.php && \
|
||||
sed "s/\$apipass = ''/\$apipass = '$PDNSAPIPWD'/" -i /app/nsedit/includes/config.inc.php && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN mkdir /app
|
||||
RUN git clone --recursive https://github.com/tuxis-ie/nsedit.git /app/nsedit
|
||||
RUN cp /app/nsedit/includes/config.inc.php-dist /app/nsedit/includes/config.inc.php
|
||||
RUN sed "s/\$apipass = ''/\$apipass = '$PDNSAPIPWD'/" -i /app/nsedit/includes/config.inc.php && \
|
||||
sed "s/\$apiip = ''/\$apiip = '$PDNSAPIIP'/" -i /app/nsedit/includes/config.inc.php && \
|
||||
sed "s/\$apiport = ''/\$apiport = '$PDNSAPIPORT'/" -i /app/nsedit/includes/config.inc.php && \
|
||||
sed "s/\$apiport = '8081'/\$apiport = '$PDNSAPIPORT'/" -i /app/nsedit/includes/config.inc.php && \
|
||||
sed "s/\$authdb = \"\.\.\/etc\/pdns\.users\.sqlite3\"/\$authdb = \"\/app\/pdns\.users\.sqlite3\"/" -i /app/nsedit/includes/config.inc.php
|
||||
|
||||
|
||||
# Define working directory.
|
||||
VOLUME /app/nsedit
|
||||
WORKDIR /app/nsedit
|
||||
|
|
|
@ -56,6 +56,12 @@ Installing
|
|||
|
||||
Have fun ;)
|
||||
|
||||
Other methods of installation (Unsupported)
|
||||
===========================================
|
||||
|
||||
* Baji Zsolt created a Suse image: https://susestudio.com/a/vvnMqa/powerdns-with-nsedit
|
||||
* Yury Evtikhov created the Docker file: https://github.com/tuxis-ie/nsedit/blob/master/Dockerfile
|
||||
|
||||
Configuring PowerDNS
|
||||
====================
|
||||
Minimal cofiguration of PowerDNS for supporting nsedit has to include 3 directives:
|
||||
|
|
|
@ -93,12 +93,6 @@ class ApiHandler {
|
|||
|
||||
curl_setopt($this->curlh, CURLOPT_URL, $this->baseurl().$this->url);
|
||||
|
||||
//print "Here we go:\n";
|
||||
//print "Request: ".$this->method.' '.$this->baseurl().$this->url."\n";
|
||||
//if ($this->content != '') {
|
||||
// print "Content: ".$this->content."\n";
|
||||
//}
|
||||
|
||||
$return = curl_exec($this->curlh);
|
||||
$code = curl_getinfo($this->curlh, CURLINFO_HTTP_CODE);
|
||||
$json = json_decode($return, 1);
|
||||
|
@ -116,12 +110,11 @@ class ApiHandler {
|
|||
}
|
||||
|
||||
public function call() {
|
||||
if (substr($this->url, 0, 1) == '/') {
|
||||
$this->apiurl();
|
||||
} else {
|
||||
$this->apiurl = '/';
|
||||
if (substr($this->url, 0, 1) != '/') {
|
||||
$this->url = '/'.$this->url;
|
||||
}
|
||||
|
||||
$this->apiurl();
|
||||
$this->url = str_replace($this->apiurl, '', $this->url);
|
||||
$this->go();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,18 @@ $templates[] = array(
|
|||
'name' => 'Tuxis',
|
||||
'owner' => 'username', # Set to 'public' to make it available to all users
|
||||
'records' => array(
|
||||
array(
|
||||
'name' => '',
|
||||
'type' => 'MX',
|
||||
'content' => '200 mx2.tuxis.nl')
|
||||
array(
|
||||
'name' => '',
|
||||
'type' => 'MX',
|
||||
'content' => '200 mx2.tuxis.nl'),
|
||||
array(
|
||||
'name' => '',
|
||||
'type' => 'A',
|
||||
'content' => '1.2.3.4'),
|
||||
array(
|
||||
'name' => 'www',
|
||||
'type' => 'CNAME',
|
||||
'content' => '[zonename]')
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
|
|
@ -36,7 +36,7 @@ if (isset($defaults['primaryns'])) {
|
|||
}
|
||||
|
||||
if (!isset($logo) or empty($logo)) {
|
||||
$logo = 'http://www.tuxis.nl/uploads/images/nsedit.png';
|
||||
$logo = 'https://www.tuxis.nl/uploads/images/nsedit.png';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,11 +9,13 @@ global $current_user;
|
|||
$current_user = false;
|
||||
|
||||
// session startup
|
||||
function _set_current_user($username, $is_admin = false, $has_csrf_token = false, $is_api = false) {
|
||||
function _set_current_user($username, $userid, $localauth = true, $is_admin = false, $has_csrf_token = false, $is_api = false) {
|
||||
global $current_user;
|
||||
|
||||
$current_user = array(
|
||||
'username' => $username,
|
||||
'id' => $userid,
|
||||
'localauth' => $localauth,
|
||||
'is_admin' => $is_admin,
|
||||
'has_csrf_token' => $has_csrf_token,
|
||||
'is_api' => $is_api,
|
||||
|
@ -177,7 +179,7 @@ function _try_login($username, $password) {
|
|||
writelog("Failed to find user!", $username);
|
||||
return false;
|
||||
} else {
|
||||
_set_current_user($username, (bool) $user['isadmin']);
|
||||
_set_current_user($username, $user['id'], (bool) $do_local_auth, (bool) $user['isadmin']);
|
||||
|
||||
if (session_id()) {
|
||||
session_unset();
|
||||
|
@ -187,6 +189,8 @@ function _try_login($username, $password) {
|
|||
session_regenerate_id(true) or die('session failure: regenerated id failed');
|
||||
session_unset();
|
||||
$_SESSION['username'] = $username;
|
||||
$_SESSION['localauth'] = $do_local_auth;
|
||||
$_SESSION['userid'] = $user['id'];
|
||||
|
||||
# requires session:
|
||||
_check_csrf_token($user);
|
||||
|
@ -206,7 +210,7 @@ function _check_session() {
|
|||
and $_POST['adminapikey'] === $adminapikey)
|
||||
{
|
||||
# Allow this request, fake that we're logged in as user.
|
||||
return _set_current_user('admin', true, true, true);
|
||||
return _set_current_user('admin', 1, false, true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -222,7 +226,7 @@ function _check_session() {
|
|||
session_destroy();
|
||||
session_unset();
|
||||
} else {
|
||||
_set_current_user($_SESSION['username'], (bool) $user['isadmin']);
|
||||
_set_current_user($_SESSION['username'], $_SESSION['userid'], (bool) $_SESSION['localauth'], (bool) $user['isadmin']);
|
||||
_check_csrf_token($user);
|
||||
return;
|
||||
}
|
||||
|
@ -281,6 +285,16 @@ function get_sess_user() {
|
|||
return $current_user ? $current_user['username'] : null;
|
||||
}
|
||||
|
||||
function get_sess_userid() {
|
||||
global $current_user;
|
||||
return $current_user ? $current_user['id'] : null;
|
||||
}
|
||||
|
||||
function has_local_auth() {
|
||||
global $current_user;
|
||||
return $current_user ? $current_user['localauth'] : null;
|
||||
}
|
||||
|
||||
function logout() {
|
||||
@session_destroy();
|
||||
@session_unset();
|
||||
|
|
11
index.php
11
index.php
|
@ -20,7 +20,7 @@ if (!is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "lo
|
|||
|
||||
if (is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "changepwform") {
|
||||
if (get_sess_user() == $_POST['username']) {
|
||||
if (!update_user(get_sess_user(), is_adminuser(), $_POST['password'])) {
|
||||
if (!update_user(get_sess_userid(), is_adminuser(), $_POST['password'])) {
|
||||
$errormsg = "Unable to update password!\n";
|
||||
}
|
||||
} else {
|
||||
|
@ -138,6 +138,7 @@ if ($blocklogin === TRUE) {
|
|||
<option value="AAAA">AAAA</option>
|
||||
<option value="CERT">CERT</option>
|
||||
<option value="CNAME">CNAME</option>
|
||||
<option value="ALIAS">ALIAS</option>
|
||||
<option value="LOC">LOC</option>
|
||||
<option value="MX">MX</option>
|
||||
<option value="NAPTR">NAPTR</option>
|
||||
|
@ -148,6 +149,7 @@ if ($blocklogin === TRUE) {
|
|||
<option value="SRV">SRV</option>
|
||||
<option value="SSHFP">SSHFP</option>
|
||||
<option value="TLSA">TLSA</option>
|
||||
<option value="CAA">CAA</option>
|
||||
<option value="TXT">TXT</option>
|
||||
</select><br></td></tr>
|
||||
<tr><td>Content:</td><td><input type="text" id ="searchzone-content"></td></tr>
|
||||
|
@ -210,6 +212,7 @@ if ($blocklogin === TRUE) {
|
|||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (has_local_auth()) { ?>
|
||||
<div id="AboutMe">
|
||||
<div class="tables">
|
||||
<p>Hi <?php echo get_sess_user(); ?>. You can change your password here.</p>
|
||||
|
@ -234,9 +237,11 @@ if ($blocklogin === TRUE) {
|
|||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="formname" value="changepwform">
|
||||
<input type="hidden" name="id" value="<?php echo get_sess_userid(); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
window.csrf_token = '<?php echo CSRF_TOKEN ?>';
|
||||
|
@ -781,12 +786,14 @@ $(document).ready(function () {
|
|||
'AAAA': 'AAAA',
|
||||
'CERT': 'CERT',
|
||||
'CNAME': 'CNAME',
|
||||
'ALIAS': 'ALIAS',
|
||||
'LOC': 'LOC',
|
||||
'NAPTR': 'NAPTR',
|
||||
'SPF': 'SPF',
|
||||
'SRV': 'SRV',
|
||||
'SSHFP': 'SSHFP',
|
||||
'TLSA': 'TLSA',
|
||||
'CAA': 'CAA',
|
||||
'DNAME': 'DNAME',
|
||||
'DS': 'DS'
|
||||
};
|
||||
|
@ -797,6 +804,7 @@ $(document).ready(function () {
|
|||
'CERT': 'CERT',
|
||||
'CNAME': 'CNAME',
|
||||
'DNAME': 'DNAME',
|
||||
'ALIAS': 'ALIAS',
|
||||
'DS': 'DS',
|
||||
'LOC': 'LOC',
|
||||
'MX': 'MX',
|
||||
|
@ -808,6 +816,7 @@ $(document).ready(function () {
|
|||
'SRV': 'SRV',
|
||||
'SSHFP': 'SSHFP',
|
||||
'TLSA': 'TLSA',
|
||||
'CAA': 'CAA',
|
||||
'TXT': 'TXT',
|
||||
};
|
||||
},
|
||||
|
|
|
@ -340,6 +340,7 @@ case "create":
|
|||
|
||||
foreach ($template['records'] as $record) {
|
||||
$name = $record['name'] != '' ? join(Array($record['name'],'.',$zonename)) : $zonename;
|
||||
$record['content'] = str_replace("[zonename]", $zonename, $record['content']);
|
||||
$zone->addRecord($name, $record['type'], $record['content']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue