From 5f82eefa552d533e744160410860f80fd0b087d1 Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Sat, 06 Dec 2014 15:29:31 -0500
Subject: [PATCH] updated DKIM-Record-Editor
---
interface/web/dns/dns_dkim_edit.php | 31 ++++++----
/dev/null | 86 ----------------------------
interface/web/dns/templates/dns_dkim_edit.htm | 5 -
3 files changed, 21 insertions(+), 101 deletions(-)
diff --git a/interface/web/dns/dns_dkim_edit.php b/interface/web/dns/dns_dkim_edit.php
index 71741d0..41a2385 100644
--- a/interface/web/dns/dns_dkim_edit.php
+++ b/interface/web/dns/dns_dkim_edit.php
@@ -70,12 +70,20 @@
}
parent::onShowNew();
+
+ $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND ?'", $_GET['zone'], $app->tform->getAuthSQL('r'));
+ $sql=$app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ?", substr_replace($soa['origin'],'',-1), $app->tform->getAuthSQL('r'));
+ $public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$sql['dkim_public']);
+ $app->tpl->setVar('public_key', $public_key);
+ $app->tpl->setVar('selector', $sql['dkim_selector']);
+ $app->tpl->setVar('name', $soa['origin']);
+
}
function onSubmit() {
global $app, $conf;
// Get the parent soa record of the domain
- $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND ".$app->tform->getAuthSQL('r'), $app->functions->intval($_POST["zone"]));
+ $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND ?", $_POST["zone"], $app->tform->getAuthSQL('r'));
// Check if Domain belongs to user
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -101,16 +109,15 @@
$this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data'];
$this->dataRecord['name']=$this->dataRecord['selector'].'._domainkey.'.$this->dataRecord['name'];
}
- // Update the serial number and timestamp of the RR record
- $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ?", $this->id);
- $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
- $this->dataRecord["stamp"] = date('Y-m-d H:i:s');
+ // Update the serial number and timestamp of the RR record
+ $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ?", $this->id);
+ $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
+ $this->dataRecord["stamp"] = date('Y-m-d H:i:s');
- // check for duplicate entry
- $check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND type = ? AND data = ? AND name = ?", $this->dataRecord['zone'], $this->dataRecord['type'], $this->dataRecord['data'], $this->dataRecord['name']);
- if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"];
- if (empty($this->dataRecord['data'])) $app->tform->errorMessage .= $app->tform->wordbook["dkim_disabled_txt"];
-
+ // check for duplicate entry
+ $check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND type = ? AND data = ? AND name = ?", $this->dataRecord["zone"], $this->dataRecord["type"], $this->dataRecord["data"], $this->dataRecord['name']);
+ if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"];
+ if (empty($this->dataRecord['data'])) $app->tform->errorMessage .= $app->tform->wordbook["dkim_disabled_txt"];
parent::onSubmit();
}
@@ -118,7 +125,7 @@
global $app, $conf;
//* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
- $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = ? AND ".$app->tform->getAuthSQL('r'), $app->functions->intval($this->dataRecord['zone']));
+ $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = ? AND ?", $this->dataRecord["zone"], $app->tform->getAuthSQL('r'));
$app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
//* Update the serial number of the SOA record
@@ -131,7 +138,7 @@
global $app, $conf;
//* Update the serial number of the SOA record
- $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ? AND ".$app->tform->getAuthSQL('r'), $app->functions->intval($this->dataRecord["zone"]));
+ $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ? AND ?", $this->dataRecord["zone"], $app->tform->getAuthSQL('r'));
$soa_id = $app->functions->intval($_POST["zone"]);
$serial = $app->validate_dns->increase_serial($soa["serial"]);
$app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
diff --git a/interface/web/dns/dns_dkim_get.php b/interface/web/dns/dns_dkim_get.php
deleted file mode 100644
index 9c33ce2..0000000
--- a/interface/web/dns/dns_dkim_get.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-/**
-Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
-Copyright (c) 2013, Florian Schaal, info@schaal-24.de
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of ISPConfig nor the names of its contributors
- may be used to endorse or promote products derived from this software without
- specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
-* This script is invoked by interface/web/dns/templates/dns_dkim_edit.htm
-* when generating the DKIM Private-key.
-*
-* return DKIM Public-Key for the DNS-record
-*/
-
-require_once('../../lib/config.inc.php');
-require_once('../../lib/app.inc.php');
-
-//* Check permissions for module
-$app->auth->check_module_permissions('dns');
-
-global $app, $conf;
-
-// Loading classes
-$app->uses('tform,tform_actions');
-
-header('Content-Type: text/xml; charset=utf-8');
-header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0');
-
-/**
-* This function fix PHP's messing up POST input containing characters space, dot,
-* open square bracket and others to be compatible with with the deprecated register_globals
-* @return array POST
-*/
-
-function getRealPOST() {
- $pairs = explode("&", file_get_contents("php://input"));
- $vars = array();
- foreach ($pairs as $pair) {
- $nv = explode("=", $pair, 2);
- $name = urldecode($nv[0]);
- $value = $nv[1];
- $vars[$name] = $value;
- }
- return $vars;
-}
-
-$_POST=getRealPost();
-
-if (ctype_digit($_POST['zone'])) {
- // Get the parent soa record of the domain
- $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? and ?'", $app->db->quote($_POST['zone']), $app->tform->getAuthSQL('r'));
-
- $sql=$app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'Y' AND ?", substr_replace($soa['origin'],'',-1), $app->tform->getAuthSQL('r'));
- $public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$sql['dkim_public']);
-
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
- echo "<formatname>\n";
- echo "<data>".$public_key."</data>\n";
- echo "<name>".$soa['origin']."</name>\n";
- echo "<selector>".$sql['dkim_selector']."</selector>\n";
- echo "</formatname>\n";
-}
-?>
diff --git a/interface/web/dns/templates/dns_dkim_edit.htm b/interface/web/dns/templates/dns_dkim_edit.htm
index 052f6d5..85773a1 100644
--- a/interface/web/dns/templates/dns_dkim_edit.htm
+++ b/interface/web/dns/templates/dns_dkim_edit.htm
@@ -6,11 +6,11 @@
<fieldset class="inlineLabels">
<div class="ctrlHolder">
<label for="data">{tmpl_var name='public_key_txt'}</label>
- <textarea name="data" id="data" >{tmpl_var name='public_key'}</textarea>
+ <textarea readonly name="data" id="data" >{tmpl_var name='public_key'}</textarea>
</div>
<div class="ctrlHolder">
<label for="selector">{tmpl_var name='selector_txt'}</label>
- <input name="selector" id="selector" value="{tmpl_var name='selector'}" size="20" maxlength="63" type="text" class="textInput" />
+ <input name="selector" id="selector" value="{tmpl_var name='selector'}" size="20" maxlength="63" type="text" readonly class="textInput" />
</div>
<div class="ctrlHolder">
<label for="ttl">{tmpl_var name='ttl_txt'}</label>
@@ -38,5 +38,4 @@
</div>
</div>
-<script language="JavaScript" type="text/javascript" src="js/dns_dkim.js"></script>
--
Gitblit v1.9.1