<?php
namespace dns\page;
-use dns\util\ParseZone;
use dns\system\DNS;
use dns\system\User;
+use dns\util\ParseZone;
/**
* @author Jan Altensen (Stricted)
exit;
}
-
echo "failure";
exit;
}
-<?php
-namespace dns\page;
-use dns\system\DNS;
-use dns\system\User;
-use dns\api\idna\idna_convert;
-
-/**
- * @author Jan Altensen (Stricted)
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @copyright 2014-2015 Jan Altensen (Stricted)
- */
-class IndexPage extends AbstractPage {
- public $activeMenuItem = 'index';
-
- public function prepare() {
- $domains = array();
- $soaIDs = User::getAccessibleDomains();
- $idna = new idna_convert();
-
- $sortField = "id";
- $sortOrder = "ASC";
- $sqlOrderBy = "";
- $validSortFields = array('id', 'origin', 'serial');
-
- if (isset($_GET['sortField'])) {
- if (in_array($_GET['sortField'], $validSortFields)) {
- $sortField = $_GET['sortField'];
- }
- }
-
- if (isset($_GET['sortOrder'])) {
- if ($_GET['sortOrder'] == "ASC" || $_GET['sortOrder'] == "DESC") {
- $sortOrder = $_GET['sortOrder'];
- }
- }
-
- if (!empty($sortField) && !empty($sortField)) {
- $sqlOrderBy = $sortField." ".$sortOrder;
- }
-
- $pageNo = 1;
- if (isset($_GET['pageNo']) && !empty($_GET['pageNo'])) {
- $pageNo = intval($_GET['pageNo']);
- }
-
- $itemsPerPage = 20;
- $pages = 0;
-
- $sqlLimit = $itemsPerPage;
- $sqlOffset = ($pageNo - 1) * $itemsPerPage;
- $pages = intval(ceil(count($soaIDs) / $itemsPerPage));
-
-
- if (count($soaIDs) > 0) {
- $sql = "SELECT * FROM dns_soa WHERE id IN (".str_repeat('?, ', count($soaIDs) - 1). "?)".(!empty($sqlOrderBy) ? " ORDER BY ".$sqlOrderBy : '')." LIMIT " . $sqlLimit . " OFFSET " . $sqlOffset;
- $res = DNS::getDB()->query($sql, $soaIDs);
- while ($row = DNS::getDB()->fetch_array($res)) {
- $sql2 = "SELECT count(*) as count FROM dns_rr WHERE zone = ?";
- $res2 = DNS::getDB()->query($sql2, array($row['id']));
- $row2 = DNS::getDB()->fetch_array($res2);
- $row['origin'] = $idna->decode($row['origin']);
- $row['rrc'] = $row2['count'];
- $domains[] = $row;
- }
- }
-
- DNS::getTPL()->assign(array(
- 'domains' => $domains,
- 'pageNo' => $pageNo,
- 'pages' => $pages,
- 'count' => count($soaIDs),
- 'sortField' => $sortField,
- 'sortOrder' => $sortOrder
- ));
- }
-}
+<?php\r
+namespace dns\page;\r
+use dns\api\idna\idna_convert;\r
+use dns\system\DNS;\r
+use dns\system\User;\r
+\r
+/**\r
+ * @author Jan Altensen (Stricted)\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @copyright 2014-2015 Jan Altensen (Stricted)\r
+ */\r
+class IndexPage extends AbstractPage {\r
+ public $activeMenuItem = 'index';\r
+ \r
+ public function prepare() {\r
+ $domains = array();\r
+ $soaIDs = User::getAccessibleDomains();\r
+ $idna = new idna_convert();\r
+ \r
+ $sortField = "id";\r
+ $sortOrder = "ASC";\r
+ $sqlOrderBy = "";\r
+ $validSortFields = array('id', 'origin', 'serial');\r
+ \r
+ if (isset($_GET['sortField'])) {\r
+ if (in_array($_GET['sortField'], $validSortFields)) {\r
+ $sortField = $_GET['sortField'];\r
+ }\r
+ }\r
+ \r
+ if (isset($_GET['sortOrder'])) {\r
+ if ($_GET['sortOrder'] == "ASC" || $_GET['sortOrder'] == "DESC") {\r
+ $sortOrder = $_GET['sortOrder'];\r
+ }\r
+ }\r
+ \r
+ if (!empty($sortField) && !empty($sortField)) {\r
+ $sqlOrderBy = $sortField." ".$sortOrder;\r
+ }\r
+ \r
+ $pageNo = 1;\r
+ if (isset($_GET['pageNo']) && !empty($_GET['pageNo'])) {\r
+ $pageNo = intval($_GET['pageNo']);\r
+ }\r
+ \r
+ $itemsPerPage = 20;\r
+ $pages = 0;\r
+ \r
+ $sqlLimit = $itemsPerPage;\r
+ $sqlOffset = ($pageNo - 1) * $itemsPerPage;\r
+ $pages = intval(ceil(count($soaIDs) / $itemsPerPage));\r
+ \r
+ if (count($soaIDs) > 0) {\r
+ $sql = "SELECT * FROM dns_soa WHERE id IN (".str_repeat('?, ', count($soaIDs) - 1). "?)".(!empty($sqlOrderBy) ? " ORDER BY ".$sqlOrderBy : '')." LIMIT " . $sqlLimit . " OFFSET " . $sqlOffset;\r
+ $res = DNS::getDB()->query($sql, $soaIDs);\r
+ while ($row = DNS::getDB()->fetch_array($res)) {\r
+ $sql2 = "SELECT count(*) as count FROM dns_rr WHERE zone = ?";\r
+ $res2 = DNS::getDB()->query($sql2, array($row['id']));\r
+ $row2 = DNS::getDB()->fetch_array($res2);\r
+ $row['origin'] = $idna->decode($row['origin']);\r
+ $row['rrc'] = $row2['count'];\r
+ $domains[] = $row;\r
+ }\r
+ }\r
+ \r
+ DNS::getTPL()->assign(array(\r
+ 'domains' => $domains,\r
+ 'pageNo' => $pageNo,\r
+ 'pages' => $pages,\r
+ 'count' => count($soaIDs),\r
+ 'sortField' => $sortField,\r
+ 'sortOrder' => $sortOrder\r
+ ));\r
+ }\r
+}\r
-<?php
-namespace dns\page;
-use dns\system\DNS;
-use dns\system\User;
-use dns\api\idna\idna_convert;
-
-/**
- * @author Jan Altensen (Stricted)
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @copyright 2014-2015 Jan Altensen (Stricted)
- */
-class RecordAddPage extends AbstractPage {
- public $activeMenuItem = 'index';
-
- public function prepare() {
- if (!isset($_GET['id']) || empty($_GET['id'])) {
- throw new \Exception('The link you are trying to reach is no longer available or invalid.', 404);
- }
-
- $soaIDs = User::getAccessibleDomains();
- if (!in_array($_GET['id'], $soaIDs)) {
- throw new \Exception('Access denied. You\92re not authorized to view this page.', 403);
- }
- $idna = new idna_convert();
-
- $sql = "SELECT * FROM dns_soa WHERE id = ?";
- $res = DNS::getDB()->query($sql, array($_GET['id']));
- $soa = DNS::getDB()->fetch_array($res);
-
- $soa['origin'] = $idna->decode($soa['origin']);
-
- DNS::getTPL()->assign(array("soa" => $soa));
-
- $types = array('A', 'AAAA', 'CNAME', 'MX', 'PTR', 'SRV', 'TXT', 'TLSA', 'NS', 'DS');
- $error = array();
- if (isset($_POST['submit']) && !empty($_POST['submit'])) {
- if (isset($_POST['name']) && isset($_POST['ttl']) && !empty($_POST['ttl']) && isset($_POST['type']) && !empty($_POST['type']) && isset($_POST['data']) && !empty($_POST['data'])) {
- $type = trim($_POST['type']);
-
- if (!empty($_POST['name'])) {
- $name = $idna->encode(trim($_POST['name']));
- }
- else {
- $name = $idna->encode(trim($soa['origin']));
- }
-
- if (in_array($type, $types)) {
- $aux = 0;
- if (($type == "MX" || $type == "TLSA" || $type == "SRV" || $type == "DS") && isset($_POST['aux']) && !empty($_POST['aux'])) {
- $aux = trim($_POST['aux']);
- }
-
- $data = trim($_POST['data']);
- if ($type == "SRV" || $type == "DS") {
- if (isset($_POST['weight']) && !empty($_POST['weight']) && isset($_POST['port']) && !empty($_POST['port'])) {
- if ($type == "SRV") {
- $data = $idna->encode($data);
- }
- $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;
- }
- else {
- $error = array_merge($error, array('weight', 'port', 'data'));
- }
- }
-
- $ttl = $_POST['ttl'];
- if ($ttl < DNS_SOA_MINIMUM_TTL) {
- $ttl = DNS_SOA_MINIMUM_TTL;
- }
-
- if ($type == "TLSA") {
- if ($aux != 3) {
- // fallback
- $aux = 3;
- }
-
- if (isset($_POST['weight']) && isset($_POST['port'])) {
- if (!is_numeric($_POST['weight'])) {
- $error = array_merge($error, array('weight'));
- }
- else if (!is_numeric($_POST['port'])) {
- $error = array_merge($error, array('weight'));
- }
- else if (strlen($_POST['data']) != 64) {
- $error = array_merge($error, array('data'));
- }
- else {
- $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;
- }
- }
- else {
- $error = array_merge($error, array('weight', 'port', 'data'));
- }
- }
-
- if ($type == "A") {
- if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
- $error = array_merge($error, array('data'));
- }
- }
- else if ($type == "AAAA") {
- if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
- $error = array_merge($error, array('data'));
- }
- }
- }
- else {
- $error = array_merge($error, array('type'));
- }
- }
- else {
- $error = array_merge($error, array('name', 'ttl', 'data'));
- }
-
- $sql = 'SELECT * FROM dns_rr WHERE zone = ? AND name = ? AND type = ? AND data = ?';
- $res = DNS::getDB()->query($sql, array($_GET['id'], $name, $type, $data));
- $rr = DNS::getDB()->fetch_array($res);
- if (!empty($rr)) {
- $error = array_merge($error, array('type', 'data'));
- }
-
- if (empty($error)) {
- $sql = 'INSERT INTO dns_rr (id, zone, name, type, data, aux, ttl) VALUES (NULL, ?, ?, ?, ?, ?, ?)';
- if ($type == "SRV" || $type == "DS" || $type == "TLSA") {
- DNS::getDB()->query($sql, array($_GET['id'], $name, $type, $data, $aux, $ttl));
- }
- else {
- DNS::getDB()->query($sql, array($_GET['id'], $name, $type, $idna->encode($data), $aux, $ttl));
- }
-
- $sql = "UPDATE dns_soa SET serial = ? WHERE id = ?";
- DNS::getDB()->query($sql, array($this->fixSerial($soa['serial']), $soa['id']));
- DNS::getTPL()->assign(array('success' => true));
- }
- else {
- if ($type == "SRV" || $type == "DS" || $type == "TLSA") {
- DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'weight' => $_POST['weight'], 'port' => $_POST['port'], 'data' => $_POST['data'], 'aux' => $aux, 'ttl' => $ttl));
- }
- else {
- DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'data' => $data, 'aux' => $aux, 'ttl' => $ttl));
- }
- }
- }
-
- DNS::getTPL()->assign(array("error" => $error));
- }
-
- public function fixSerial ($old) {
- if (substr($old, 0, -2) == date("Ymd")) {
- $new = $old + 1;
- }
- else {
- $new = date("Ymd")."01";
- }
-
- return $new;
- }
-}
+<?php\r
+namespace dns\page;\r
+use dns\api\idna\idna_convert;\r
+use dns\system\DNS;\r
+use dns\system\User;\r
+\r
+/**\r
+ * @author Jan Altensen (Stricted)\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @copyright 2014-2015 Jan Altensen (Stricted)\r
+ */\r
+class RecordAddPage extends AbstractPage {\r
+ public $activeMenuItem = 'index';\r
+ \r
+ public function prepare() {\r
+ if (!isset($_GET['id']) || empty($_GET['id'])) {\r
+ throw new \Exception('The link you are trying to reach is no longer available or invalid.', 404);\r
+ }\r
+ \r
+ $soaIDs = User::getAccessibleDomains();\r
+ if (!in_array($_GET['id'], $soaIDs)) {\r
+ throw new \Exception('Access denied. You\92re not authorized to view this page.', 403);\r
+ }\r
+ $idna = new idna_convert();\r
+ \r
+ $sql = "SELECT * FROM dns_soa WHERE id = ?";\r
+ $res = DNS::getDB()->query($sql, array($_GET['id']));\r
+ $soa = DNS::getDB()->fetch_array($res);\r
+ \r
+ $soa['origin'] = $idna->decode($soa['origin']);\r
+ \r
+ DNS::getTPL()->assign(array("soa" => $soa));\r
+ \r
+ $types = array('A', 'AAAA', 'CNAME', 'MX', 'PTR', 'SRV', 'TXT', 'TLSA', 'NS', 'DS');\r
+ $error = array();\r
+ if (isset($_POST['submit']) && !empty($_POST['submit'])) {\r
+ if (isset($_POST['name']) && isset($_POST['ttl']) && !empty($_POST['ttl']) && isset($_POST['type']) && !empty($_POST['type']) && isset($_POST['data']) && !empty($_POST['data'])) {\r
+ $type = trim($_POST['type']);\r
+ \r
+ if (!empty($_POST['name'])) {\r
+ $name = $idna->encode(trim($_POST['name']));\r
+ }\r
+ else {\r
+ $name = $idna->encode(trim($soa['origin']));\r
+ }\r
+ \r
+ if (in_array($type, $types)) {\r
+ $aux = 0;\r
+ if (($type == "MX" || $type == "TLSA" || $type == "SRV" || $type == "DS") && isset($_POST['aux']) && !empty($_POST['aux'])) {\r
+ $aux = trim($_POST['aux']);\r
+ }\r
+ \r
+ $data = trim($_POST['data']);\r
+ if ($type == "SRV" || $type == "DS") {\r
+ if (isset($_POST['weight']) && !empty($_POST['weight']) && isset($_POST['port']) && !empty($_POST['port'])) {\r
+ if ($type == "SRV") {\r
+ $data = $idna->encode($data);\r
+ }\r
+ $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;\r
+ }\r
+ else {\r
+ $error = array_merge($error, array('weight', 'port', 'data'));\r
+ }\r
+ }\r
+ \r
+ $ttl = $_POST['ttl'];\r
+ if ($ttl < DNS_SOA_MINIMUM_TTL) {\r
+ $ttl = DNS_SOA_MINIMUM_TTL;\r
+ }\r
+ \r
+ if ($type == "TLSA") {\r
+ if ($aux != 3) {\r
+ // fallback\r
+ $aux = 3;\r
+ }\r
+ \r
+ if (isset($_POST['weight']) && isset($_POST['port'])) {\r
+ if (!is_numeric($_POST['weight'])) {\r
+ $error = array_merge($error, array('weight'));\r
+ }\r
+ else if (!is_numeric($_POST['port'])) {\r
+ $error = array_merge($error, array('weight'));\r
+ }\r
+ else if (strlen($_POST['data']) != 64) {\r
+ $error = array_merge($error, array('data'));\r
+ }\r
+ else {\r
+ $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;\r
+ }\r
+ }\r
+ else {\r
+ $error = array_merge($error, array('weight', 'port', 'data'));\r
+ }\r
+ }\r
+ \r
+ if ($type == "A") {\r
+ if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {\r
+ $error = array_merge($error, array('data'));\r
+ }\r
+ }\r
+ else if ($type == "AAAA") {\r
+ if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {\r
+ $error = array_merge($error, array('data'));\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ $error = array_merge($error, array('type'));\r
+ } \r
+ }\r
+ else {\r
+ $error = array_merge($error, array('name', 'ttl', 'data'));\r
+ }\r
+ \r
+ $sql = 'SELECT * FROM dns_rr WHERE zone = ? AND name = ? AND type = ? AND data = ?';\r
+ $res = DNS::getDB()->query($sql, array($_GET['id'], $name, $type, $data));\r
+ $rr = DNS::getDB()->fetch_array($res);\r
+ if (!empty($rr)) {\r
+ $error = array_merge($error, array('type', 'data'));\r
+ }\r
+ \r
+ if (empty($error)) {\r
+ $sql = 'INSERT INTO dns_rr (id, zone, name, type, data, aux, ttl) VALUES (NULL, ?, ?, ?, ?, ?, ?)';\r
+ if ($type == "SRV" || $type == "DS" || $type == "TLSA") {\r
+ DNS::getDB()->query($sql, array($_GET['id'], $name, $type, $data, $aux, $ttl));\r
+ }\r
+ else {\r
+ DNS::getDB()->query($sql, array($_GET['id'], $name, $type, $idna->encode($data), $aux, $ttl));\r
+ }\r
+ \r
+ $sql = "UPDATE dns_soa SET serial = ? WHERE id = ?";\r
+ DNS::getDB()->query($sql, array($this->fixSerial($soa['serial']), $soa['id']));\r
+ DNS::getTPL()->assign(array('success' => true));\r
+ }\r
+ else {\r
+ if ($type == "SRV" || $type == "DS" || $type == "TLSA") {\r
+ DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'weight' => $_POST['weight'], 'port' => $_POST['port'], 'data' => $_POST['data'], 'aux' => $aux, 'ttl' => $ttl));\r
+ }\r
+ else {\r
+ DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'data' => $data, 'aux' => $aux, 'ttl' => $ttl));\r
+ }\r
+ }\r
+ }\r
+ \r
+ DNS::getTPL()->assign(array("error" => $error));\r
+ }\r
+ \r
+ public function fixSerial ($old) {\r
+ if (substr($old, 0, -2) == date("Ymd")) {\r
+ $new = $old + 1;\r
+ }\r
+ else {\r
+ $new = date("Ymd")."01";\r
+ }\r
+ \r
+ return $new;\r
+ }\r
+}\r
-<?php
-namespace dns\page;
-use dns\system\DNS;
-use dns\system\User;
-use dns\api\idna\idna_convert;
-
-/**
- * @author Jan Altensen (Stricted)
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @copyright 2014-2015 Jan Altensen (Stricted)
- */
-class RecordEditPage extends AbstractPage {
- public $activeMenuItem = 'index';
-
- public function prepare() {
- if (!isset($_GET['id']) || empty($_GET['id'])) {
- throw new \Exception('The link you are trying to reach is no longer available or invalid.', 404);
- }
- $idna = new idna_convert();
-
- $sql = "SELECT * FROM dns_rr WHERE id = ?";
- $res = DNS::getDB()->query($sql, array($_GET['id']));
- $rr = DNS::getDB()->fetch_array($res);
-
- $soaIDs = User::getAccessibleDomains();
- if (!in_array($rr['zone'], $soaIDs)) {
- throw new \Exception('Access denied. You\92re not authorized to view this page.', 403);
- }
-
- $sql = "SELECT * FROM dns_soa WHERE id = ?";
- $res = DNS::getDB()->query($sql, array($rr['zone']));
- $soa = DNS::getDB()->fetch_array($res);
-
- $soa['origin'] = $idna->decode($soa['origin']);
-
- DNS::getTPL()->assign(array("soa" => $soa, "rr" => $rr));
-
- $types = array('A', 'AAAA', 'CNAME', 'MX', 'PTR', 'SRV', 'TXT', 'TLSA', 'NS', 'DS');
- $error = array();
- if (isset($_POST['submit']) && !empty($_POST['submit'])) {
- if (isset($_POST['name']) && isset($_POST['ttl']) && !empty($_POST['ttl']) && isset($_POST['type']) && !empty($_POST['type']) && isset($_POST['data']) && !empty($_POST['data'])) {
- $type = trim($_POST['type']);
-
- if (!empty($_POST['name'])) {
- $name = $idna->encode(trim($_POST['name']));
- }
- else {
- $name = $idna->encode(trim($soa['origin']));
- }
-
- if (in_array($type, $types)) {
- $aux = 0;
- if (($type == "MX" || $type == "TLSA" || $type == "SRV" || $type == "DS") && isset($_POST['aux']) && !empty($_POST['aux'])) {
- $aux = trim($_POST['aux']);
- }
-
- $data = trim($_POST['data']);
- if ($type == "SRV" || $type == "DS") {
- if (isset($_POST['weight']) && !empty($_POST['weight']) && isset($_POST['port']) && !empty($_POST['port'])) {
- if ($type == "SRV") {
- $data = $idna->encode($data);
- }
- $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;
- }
- else {
- $error = array_merge($error, array('weight', 'port', 'data'));
- }
- }
-
- $ttl = $_POST['ttl'];
- if ($ttl < DNS_SOA_MINIMUM_TTL) {
- $ttl = DNS_SOA_MINIMUM_TTL;
- }
-
- if ($type == "TLSA") {
- if ($aux != 3) {
- // fallback
- $aux = 3;
- }
-
- if (isset($_POST['weight']) && isset($_POST['port'])) {
- if (!is_numeric($_POST['weight'])) {
- $error = array_merge($error, array('weight'));
- }
- else if (!is_numeric($_POST['port'])) {
- $error = array_merge($error, array('weight'));
- }
- else if (strlen($_POST['data']) != 64) {
- $error = array_merge($error, array('data'));
- }
- else {
- $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;
- }
- }
- else {
- $error = array_merge($error, array('weight', 'port', 'data'));
- }
- }
-
- if ($type == "A") {
- if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
- $error = array_merge($error, array('data'));
- }
- }
- else if ($type == "AAAA") {
- if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
- $error = array_merge($error, array('data'));
- }
- }
- }
- else {
- $error = array_merge($error, array('type'));
- }
- }
- else {
- $error = array_merge($error, array('name', 'ttl', 'data'));
- }
-
- $sql = 'SELECT * FROM dns_rr WHERE zone = ? AND name = ? AND type = ? AND data = ? AND id != ?';
- $res = DNS::getDB()->query($sql, array($rr['zone'], $name, $type, $data, $_GET['id']));
- $rr = DNS::getDB()->fetch_array($res);
- if (!empty($rr)) {
- $error = array_merge($error, array('type', 'data'));
- }
-
- if (empty($error)) {
-
- $sql = 'UPDATE dns_rr SET name = ?, type = ?, aux = ?, data = ?, ttl = ? WHERE id = ?';
- if ($type == "SRV" || $type == "DS" || $type == "TLSA") {
- DNS::getDB()->query($sql, array($name, $type, $aux, $data, $ttl, $_GET['id']));
- }
- else {
- DNS::getDB()->query($sql, array($name, $type, $aux, $idna->encode($data), $ttl, $_GET['id']));
- }
-
- $sql = "UPDATE dns_soa SET serial = ? WHERE id = ?";
- DNS::getDB()->query($sql, array($this->fixSerial($soa['serial']), $soa['id']));
-
- $sql = "SELECT * FROM dns_rr WHERE id = ?";
- $res = DNS::getDB()->query($sql, array($_GET['id']));
- $rr = DNS::getDB()->fetch_array($res);
-
- $weight = 0;
- $port = 0;
- $data = $rr['data'];
- $type = $rr['type'];
- $name = $idna->decode($rr['name']);
- $aux = $rr['aux'];
- $ttl = $rr['ttl'];
- if ($type == "SRV" || $type == "DS" || $type == "TLSA") {
- $datae = explode(" ", $data);
- $weight = $datae[0];
- $port = $datae[1];
- if ($type == "SRV") {
- $data = $idna->decode($datae[2]);
- }
- else {
- $data = $datae[2];
- }
- }
- else {
- $data = $idna->decode($data);
- }
-
- DNS::getTPL()->assign(array('name' => $name, 'type' => $type, 'weight' => $weight, 'port' => $port, 'data' => $data, 'aux' => $aux, 'ttl' => $ttl));
- DNS::getTPL()->assign(array('success' => true));
- }
- else {
- if ($type == "SRV" || $type == "DS" || $type == "TLSA") {
- DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'weight' => $_POST['weight'], 'port' => $_POST['port'], 'data' => $_POST['data'], 'aux' => $aux, 'ttl' => $ttl));
- }
- else {
- DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'data' => $idna->decode($data), 'aux' => $aux, 'ttl' => $ttl));
- }
- }
- }
- else {
- $weight = 0;
- $port = 0;
- $data = $rr['data'];
- $type = $rr['type'];
- $name = $idna->decode($rr['name']);
- $aux = $rr['aux'];
- $ttl = $rr['ttl'];
- if ($type == "SRV" || $type == "DS" || $type == "TLSA") {
- $datae = explode(" ", $data);
- $weight = $datae[0];
- $port = $datae[1];
- if ($type == "SRV") {
- $data = $idna->decode($datae[2]);
- }
- else {
- $data = $datae[2];
- }
- }
- else {
- $data = $idna->decode($data);
- }
-
- DNS::getTPL()->assign(array('name' => $name, 'type' => $type, 'weight' => $weight, 'port' => $port, 'data' => $data, 'aux' => $aux, 'ttl' => $ttl));
- }
-
- DNS::getTPL()->assign(array("error" => $error));
- }
-
- public function fixSerial ($old) {
- if (substr($old, 0, -2) == date("Ymd")) {
- $new = $old + 1;
- }
- else {
- $new = date("Ymd")."01";
- }
-
- return $new;
- }
-}
+<?php\r
+namespace dns\page;\r
+use dns\api\idna\idna_convert;\r
+use dns\system\DNS;\r
+use dns\system\User;\r
+\r
+/**\r
+ * @author Jan Altensen (Stricted)\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @copyright 2014-2015 Jan Altensen (Stricted)\r
+ */\r
+class RecordEditPage extends AbstractPage {\r
+ public $activeMenuItem = 'index';\r
+ \r
+ public function prepare() {\r
+ if (!isset($_GET['id']) || empty($_GET['id'])) {\r
+ throw new \Exception('The link you are trying to reach is no longer available or invalid.', 404);\r
+ }\r
+ $idna = new idna_convert();\r
+ \r
+ $sql = "SELECT * FROM dns_rr WHERE id = ?";\r
+ $res = DNS::getDB()->query($sql, array($_GET['id']));\r
+ $rr = DNS::getDB()->fetch_array($res);\r
+ \r
+ $soaIDs = User::getAccessibleDomains();\r
+ if (!in_array($rr['zone'], $soaIDs)) {\r
+ throw new \Exception('Access denied. You\92re not authorized to view this page.', 403);\r
+ }\r
+ \r
+ $sql = "SELECT * FROM dns_soa WHERE id = ?";\r
+ $res = DNS::getDB()->query($sql, array($rr['zone']));\r
+ $soa = DNS::getDB()->fetch_array($res);\r
+ \r
+ $soa['origin'] = $idna->decode($soa['origin']);\r
+ \r
+ DNS::getTPL()->assign(array("soa" => $soa, "rr" => $rr));\r
+ \r
+ $types = array('A', 'AAAA', 'CNAME', 'MX', 'PTR', 'SRV', 'TXT', 'TLSA', 'NS', 'DS');\r
+ $error = array();\r
+ if (isset($_POST['submit']) && !empty($_POST['submit'])) {\r
+ if (isset($_POST['name']) && isset($_POST['ttl']) && !empty($_POST['ttl']) && isset($_POST['type']) && !empty($_POST['type']) && isset($_POST['data']) && !empty($_POST['data'])) {\r
+ $type = trim($_POST['type']);\r
+ \r
+ if (!empty($_POST['name'])) {\r
+ $name = $idna->encode(trim($_POST['name']));\r
+ }\r
+ else {\r
+ $name = $idna->encode(trim($soa['origin']));\r
+ }\r
+ \r
+ if (in_array($type, $types)) {\r
+ $aux = 0;\r
+ if (($type == "MX" || $type == "TLSA" || $type == "SRV" || $type == "DS") && isset($_POST['aux']) && !empty($_POST['aux'])) {\r
+ $aux = trim($_POST['aux']);\r
+ }\r
+ \r
+ $data = trim($_POST['data']);\r
+ if ($type == "SRV" || $type == "DS") {\r
+ if (isset($_POST['weight']) && !empty($_POST['weight']) && isset($_POST['port']) && !empty($_POST['port'])) {\r
+ if ($type == "SRV") {\r
+ $data = $idna->encode($data);\r
+ }\r
+ $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;\r
+ }\r
+ else {\r
+ $error = array_merge($error, array('weight', 'port', 'data'));\r
+ }\r
+ }\r
+ \r
+ $ttl = $_POST['ttl'];\r
+ if ($ttl < DNS_SOA_MINIMUM_TTL) {\r
+ $ttl = DNS_SOA_MINIMUM_TTL;\r
+ }\r
+ \r
+ if ($type == "TLSA") {\r
+ if ($aux != 3) {\r
+ // fallback\r
+ $aux = 3;\r
+ }\r
+ \r
+ if (isset($_POST['weight']) && isset($_POST['port'])) {\r
+ if (!is_numeric($_POST['weight'])) {\r
+ $error = array_merge($error, array('weight'));\r
+ }\r
+ else if (!is_numeric($_POST['port'])) {\r
+ $error = array_merge($error, array('weight'));\r
+ }\r
+ else if (strlen($_POST['data']) != 64) {\r
+ $error = array_merge($error, array('data'));\r
+ }\r
+ else {\r
+ $data = trim($_POST['weight']).' '.trim($_POST['port']).' '.$data;\r
+ }\r
+ }\r
+ else {\r
+ $error = array_merge($error, array('weight', 'port', 'data'));\r
+ }\r
+ }\r
+ \r
+ if ($type == "A") {\r
+ if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {\r
+ $error = array_merge($error, array('data'));\r
+ }\r
+ }\r
+ else if ($type == "AAAA") {\r
+ if (filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {\r
+ $error = array_merge($error, array('data'));\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ $error = array_merge($error, array('type'));\r
+ } \r
+ }\r
+ else {\r
+ $error = array_merge($error, array('name', 'ttl', 'data'));\r
+ }\r
+ \r
+ $sql = 'SELECT * FROM dns_rr WHERE zone = ? AND name = ? AND type = ? AND data = ? AND id != ?';\r
+ $res = DNS::getDB()->query($sql, array($rr['zone'], $name, $type, $data, $_GET['id']));\r
+ $rr = DNS::getDB()->fetch_array($res);\r
+ if (!empty($rr)) {\r
+ $error = array_merge($error, array('type', 'data'));\r
+ }\r
+ \r
+ if (empty($error)) {\r
+ \r
+ $sql = 'UPDATE dns_rr SET name = ?, type = ?, aux = ?, data = ?, ttl = ? WHERE id = ?';\r
+ if ($type == "SRV" || $type == "DS" || $type == "TLSA") {\r
+ DNS::getDB()->query($sql, array($name, $type, $aux, $data, $ttl, $_GET['id']));\r
+ }\r
+ else {\r
+ DNS::getDB()->query($sql, array($name, $type, $aux, $idna->encode($data), $ttl, $_GET['id']));\r
+ }\r
+ \r
+ $sql = "UPDATE dns_soa SET serial = ? WHERE id = ?";\r
+ DNS::getDB()->query($sql, array($this->fixSerial($soa['serial']), $soa['id']));\r
+ \r
+ $sql = "SELECT * FROM dns_rr WHERE id = ?";\r
+ $res = DNS::getDB()->query($sql, array($_GET['id']));\r
+ $rr = DNS::getDB()->fetch_array($res);\r
+ \r
+ $weight = 0;\r
+ $port = 0;\r
+ $data = $rr['data'];\r
+ $type = $rr['type'];\r
+ $name = $idna->decode($rr['name']);\r
+ $aux = $rr['aux'];\r
+ $ttl = $rr['ttl'];\r
+ if ($type == "SRV" || $type == "DS" || $type == "TLSA") {\r
+ $datae = explode(" ", $data);\r
+ $weight = $datae[0];\r
+ $port = $datae[1];\r
+ if ($type == "SRV") {\r
+ $data = $idna->decode($datae[2]);\r
+ }\r
+ else {\r
+ $data = $datae[2];\r
+ }\r
+ }\r
+ else {\r
+ $data = $idna->decode($data);\r
+ }\r
+ \r
+ DNS::getTPL()->assign(array('name' => $name, 'type' => $type, 'weight' => $weight, 'port' => $port, 'data' => $data, 'aux' => $aux, 'ttl' => $ttl));\r
+ DNS::getTPL()->assign(array('success' => true));\r
+ }\r
+ else {\r
+ if ($type == "SRV" || $type == "DS" || $type == "TLSA") {\r
+ DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'weight' => $_POST['weight'], 'port' => $_POST['port'], 'data' => $_POST['data'], 'aux' => $aux, 'ttl' => $ttl));\r
+ }\r
+ else {\r
+ DNS::getTPL()->assign(array('name' => $idna->decode($name), 'type' => $type, 'data' => $idna->decode($data), 'aux' => $aux, 'ttl' => $ttl));\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ $weight = 0;\r
+ $port = 0;\r
+ $data = $rr['data'];\r
+ $type = $rr['type'];\r
+ $name = $idna->decode($rr['name']);\r
+ $aux = $rr['aux'];\r
+ $ttl = $rr['ttl'];\r
+ if ($type == "SRV" || $type == "DS" || $type == "TLSA") {\r
+ $datae = explode(" ", $data);\r
+ $weight = $datae[0];\r
+ $port = $datae[1];\r
+ if ($type == "SRV") {\r
+ $data = $idna->decode($datae[2]);\r
+ }\r
+ else {\r
+ $data = $datae[2];\r
+ }\r
+ }\r
+ else {\r
+ $data = $idna->decode($data);\r
+ }\r
+ \r
+ DNS::getTPL()->assign(array('name' => $name, 'type' => $type, 'weight' => $weight, 'port' => $port, 'data' => $data, 'aux' => $aux, 'ttl' => $ttl));\r
+ }\r
+ \r
+ DNS::getTPL()->assign(array("error" => $error));\r
+ }\r
+ \r
+ public function fixSerial ($old) {\r
+ if (substr($old, 0, -2) == date("Ymd")) {\r
+ $new = $old + 1;\r
+ }\r
+ else {\r
+ $new = date("Ymd")."01";\r
+ }\r
+ \r
+ return $new;\r
+ }\r
+}\r
<?php
namespace dns\page;
+use dns\api\idna\idna_convert;
use dns\system\DNS;
use dns\system\User;
-use dns\api\idna\idna_convert;
/**
* @author Jan Altensen (Stricted)
+++ /dev/null
-<?php
-namespace dns\page;
-use dns\system\DNS;
-use dns\system\User;
-
-/**
- * @author Jan Altensen (Stricted)
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @copyright 2014-2015 Jan Altensen (Stricted)
- */
-class UserListPage extends AbstractPage {
- /*public $activeMenuItem = 'index';*/
-
- public function prepare() {
- if (User::isLoggedIn() && User::isReseller()) {
- if (User::isAdmin()) {
- $sql = "SELECT * from dns_user";
- $res = DNS::getDB()->query($sql);
- }
- else {
- $sql = "SELECT * from dns_user WHERE reseller = ?";
- $res = DNS::getDB()->query($sql, array(DNS::getSession()->userID));
- }
-
- $user = array();
- while ($row = DNS::getDB()->fetch_array($res)) {
- $user[] = $row;
- }
-
- DNS::getTPL()->assign(array("user" => $user));
- }
- else {
- throw new \Exeption('Forbidden', 403);
- }
- }
-}
$languageCode = $availableLanguages[$code];
}
}
- else if (DNS::getSession()->language !== null) {
- $code = strtolower(DNS::getSession()->language);
+ else if (self::getSession()->language !== null) {
+ $code = strtolower(self::getSession()->language);
if (in_array($code, $availableLanguages)) {
$languageCode = $code;
}
}
$file = $basedir.$languageCode.'.lang.php';
- DNS::getSession()->register('language', $languageCode);
+ self::getSession()->register('language', $languageCode);
if (file_exists($file)) {
require_once($file);
protected function initTPL () {
require(DNS_DIR.'/config.inc.php');
- if (DNS::getSession()->tpl !== null && !empty(DNS::getSession()->tpl)) {
- $tpl = DNS::getSession()->tpl;
+ if (self::getSession()->tpl !== null && !empty(self::getSession()->tpl)) {
+ $tpl = self::getSession()->tpl;
}
require_once(DNS_DIR.'/lib/api/smarty/Smarty.class.php');
-<?php
-namespace dns\util;
-
-/**
- * @author Jan Altensen (Stricted)
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @copyright 2015 Jan Altensen (Stricted)
- */
-class DNSSECUtil {
- // see: http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
- public static $availableAlgorithm = array(3, 5, 6, 7, 8, 10, 12, 13, 14);
-
- /**
- * calculate the DS record for parent zone
- *
- * @param string $owner
- * @param string $algorithm
- * @param string $publicKey
- * @return array
- */
- public static function calculateDS ($owner, $algorithm, $publicKey) {
- $owner = self::convertOwner($owner);
- $flags = '0101';
- $protocol = '03';
- $algorithm = '0'.dechex($algorithm);
- $publicKey = bin2hex(base64_decode($publicKey));
-
- $string = hex2bin($owner.$flags.$protocol.$algorithm.$publicKey);
-
- $sha1 = strtoupper(sha1($string));
- $sha256 = strtoupper(hash('sha256', $string));
-
- return array('sha1' => $sha1, 'sha256' => $sha256);
- }
-
- /**
- * convert the domain name to HEX
- *
- * @param string $owner
- * @return string
- */
- public static function convertOwner ($owner) {
- if (substr($owner, -1) == '.') {
- $owner = substr($owner, 0, -1);
- }
-
- $return = '';
-
- $parts = explode(".", $owner);
- foreach ($parts as $part) {
- $len = dechex(strlen($part));
- $return .= str_repeat('0', 2 - strlen($len)).$len;
- $part = str_split($part);
- for ($i = 0; $i < count($part); $i++) {
- $byte = strtoupper(dechex(ord($part[$i])));
- $byte = str_repeat('0', 2 - strlen($byte)).$byte;
- $return .= $byte;
- }
- }
-
- $return .= '00';
-
- return $return;
- }
-
- /**
- * validate DNSSEC public key
- *
- * @param string $content
- * @return boolean
- */
- public static function validatePublicKey ($content) {
- // unify newlines
- $content = preg_replace("/(\r\n)|(\r)/", "\n", $content);
-
- $pattern = "; This is a (key|zone)-signing key, keyid (?P<keyid>[0-9]+), for (?P<domain>[\s\S]+)\.\n";
- $pattern .= "; Created: (?P<created>[0-9]+) \(([a-z0-9: ]+)\)\n";
- $pattern .= "; Publish: (?P<publish>[0-9]+) \(([a-z0-9: ]+)\)\n";
- $pattern .= "; Activate: (?P<activate>[0-9]+) \(([a-z0-9: ]+)\)\n";
- $pattern .= "([\s\S]+). IN DNSKEY 25(6|7) 3 (?P<algorithm>[0-9]+) (?P<key>[\s\S]+)(\n)?";
- preg_match('/'.$pattern.'/i', $content, $matches);
- if (!empty($matches)) {
- if (!in_array($matches['algorithm'], self::$availableAlgorithm)) {
- return false;
- }
-
- $data = explode(' ', $matches['key']);
- foreach ($data as $d) {
- if (base64_encode(base64_decode($d, true)) !== $d) {
- return false;
- }
- }
- }
- else {
- return false;
- }
-
- return true;
- }
-
- /**
- * validate DNSSEC private key
- *
- * @param string $content
- * @return boolean
- */
- public static function validatePrivateKey ($content) {
- // unify newlines
- $content = preg_replace("/(\r\n)|(\r)/", "\n", $content);
-
- $pattern = "Private-key-format: v([0-9a-z.]+)\n";
- $pattern .= "Algorithm: (?P<algorithm>[0-9]+) \(([0-9a-z\-]+)\)\n";
- $pattern .= "Modulus: (?P<modulus>[\s\S]+)\n";
- $pattern .= "PublicExponent: (?P<publicexponent>[\s\S]+)\n";
- $pattern .= "PrivateExponent: (?P<privatexponent>[\s\S]+)\n";
- $pattern .= "Prime1: (?P<prime1>[\s\S]+)\n";
- $pattern .= "Prime2: (?P<prime2>[\s\S]+)\n";
- $pattern .= "Exponent1: (?P<exponent1>[\s\S]+)\n";
- $pattern .= "Exponent2: (?P<exponent2>[\s\S]+)\n";
- $pattern .= "Coefficient: (?P<coefficient>[\s\S]+)\n";
- $pattern .= "Created: (?P<created>[0-9]+)\n";
- $pattern .= "Publish: (?P<publish>[0-9]+)\n";
- $pattern .= "Activate: (?P<activate>[0-9]+)(\n)?";
-
- preg_match('/'.$pattern.'/i', $content, $matches);
- if (!empty($matches)) {
- if (!in_array($matches['algorithm'], self::$availableAlgorithm)) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['modulus'], true)) !== $matches['modulus']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['publicexponent'], true)) !== $matches['publicexponent']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['privatexponent'], true)) !== $matches['privatexponent']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['prime1'], true)) !== $matches['prime1']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['prime2'], true)) !== $matches['prime2']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['exponent1'], true)) !== $matches['exponent1']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['exponent2'], true)) !== $matches['exponent2']) {
- return false;
- }
- else if (base64_encode(base64_decode($matches['coefficient'], true)) !== $matches['coefficient']) {
- return false;
- }
- }
- else {
- return false;
- }
-
- return true;
- }
-}
+<?php\r
+namespace dns\util;\r
+\r
+/**\r
+ * @author Jan Altensen (Stricted)\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @copyright 2015 Jan Altensen (Stricted)\r
+ */\r
+class DNSSECUtil {\r
+ // see: http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml\r
+ public static $availableAlgorithm = array(3, 5, 6, 7, 8, 10, 12, 13, 14);\r
+ \r
+ /**\r
+ * calculate the DS record for parent zone\r
+ *\r
+ * @param string $owner\r
+ * @param string $algorithm\r
+ * @param string $publicKey\r
+ * @return array\r
+ */\r
+ public static function calculateDS ($owner, $algorithm, $publicKey) {\r
+ $owner = self::convertOwner($owner);\r
+ $flags = '0101';\r
+ $protocol = '03';\r
+ $algorithm = '0'.dechex($algorithm);\r
+ $publicKey = bin2hex(base64_decode($publicKey));\r
+ \r
+ $string = hex2bin($owner.$flags.$protocol.$algorithm.$publicKey);\r
+ \r
+ $sha1 = strtoupper(sha1($string));\r
+ $sha256 = strtoupper(hash('sha256', $string));\r
+ \r
+ return array('sha1' => $sha1, 'sha256' => $sha256);\r
+ }\r
+ \r
+ /**\r
+ * convert the domain name to HEX\r
+ *\r
+ * @param string $owner\r
+ * @return string\r
+ */\r
+ public static function convertOwner ($owner) {\r
+ if (substr($owner, -1) == '.') {\r
+ $owner = substr($owner, 0, -1);\r
+ }\r
+ \r
+ $return = '';\r
+ \r
+ $parts = explode(".", $owner);\r
+ foreach ($parts as $part) {\r
+ $len = dechex(strlen($part));\r
+ $return .= str_repeat('0', 2 - strlen($len)).$len;\r
+ $part = str_split($part);\r
+ $count = count($part);\r
+ for ($i = 0; $i < $count; $i++) {\r
+ $byte = strtoupper(dechex(ord($part[$i])));\r
+ $byte = str_repeat('0', 2 - strlen($byte)).$byte;\r
+ $return .= $byte;\r
+ }\r
+ }\r
+ \r
+ $return .= '00';\r
+ \r
+ return $return;\r
+ }\r
+ \r
+ /**\r
+ * validate DNSSEC public key\r
+ *\r
+ * @param string $content\r
+ * @return boolean\r
+ */\r
+ public static function validatePublicKey ($content) {\r
+ // unify newlines\r
+ $content = preg_replace("/(\r\n)|(\r)/", "\n", $content);\r
+ \r
+ $pattern = "; This is a (key|zone)-signing key, keyid (?P<keyid>[0-9]+), for (?P<domain>[\s\S]+)\.\n";\r
+ $pattern .= "; Created: (?P<created>[0-9]+) \(([a-z0-9: ]+)\)\n";\r
+ $pattern .= "; Publish: (?P<publish>[0-9]+) \(([a-z0-9: ]+)\)\n";\r
+ $pattern .= "; Activate: (?P<activate>[0-9]+) \(([a-z0-9: ]+)\)\n";\r
+ $pattern .= "([\s\S]+). IN DNSKEY 25(6|7) 3 (?P<algorithm>[0-9]+) (?P<key>[\s\S]+)(\n)?";\r
+ preg_match('/'.$pattern.'/i', $content, $matches);\r
+ if (!empty($matches)) {\r
+ if (!in_array($matches['algorithm'], self::$availableAlgorithm)) {\r
+ return false;\r
+ }\r
+ \r
+ $data = explode(' ', $matches['key']);\r
+ foreach ($data as $d) {\r
+ if (base64_encode(base64_decode($d, true)) !== $d) {\r
+ return false;\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ \r
+ return true;\r
+ }\r
+ \r
+ /**\r
+ * validate DNSSEC private key\r
+ *\r
+ * @param string $content\r
+ * @return boolean\r
+ */\r
+ public static function validatePrivateKey ($content) {\r
+ // unify newlines\r
+ $content = preg_replace("/(\r\n)|(\r)/", "\n", $content);\r
+ \r
+ $pattern = "Private-key-format: v([0-9a-z.]+)\n";\r
+ $pattern .= "Algorithm: (?P<algorithm>[0-9]+) \(([0-9a-z\-]+)\)\n";\r
+ $pattern .= "Modulus: (?P<modulus>[\s\S]+)\n";\r
+ $pattern .= "PublicExponent: (?P<publicexponent>[\s\S]+)\n";\r
+ $pattern .= "PrivateExponent: (?P<privatexponent>[\s\S]+)\n";\r
+ $pattern .= "Prime1: (?P<prime1>[\s\S]+)\n";\r
+ $pattern .= "Prime2: (?P<prime2>[\s\S]+)\n";\r
+ $pattern .= "Exponent1: (?P<exponent1>[\s\S]+)\n";\r
+ $pattern .= "Exponent2: (?P<exponent2>[\s\S]+)\n";\r
+ $pattern .= "Coefficient: (?P<coefficient>[\s\S]+)\n";\r
+ $pattern .= "Created: (?P<created>[0-9]+)\n";\r
+ $pattern .= "Publish: (?P<publish>[0-9]+)\n";\r
+ $pattern .= "Activate: (?P<activate>[0-9]+)(\n)?";\r
+ \r
+ preg_match('/'.$pattern.'/i', $content, $matches);\r
+ if (!empty($matches)) {\r
+ if (!in_array($matches['algorithm'], self::$availableAlgorithm)) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['modulus'], true)) !== $matches['modulus']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['publicexponent'], true)) !== $matches['publicexponent']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['privatexponent'], true)) !== $matches['privatexponent']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['prime1'], true)) !== $matches['prime1']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['prime2'], true)) !== $matches['prime2']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['exponent1'], true)) !== $matches['exponent1']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['exponent2'], true)) !== $matches['exponent2']) {\r
+ return false;\r
+ }\r
+ else if (base64_encode(base64_decode($matches['coefficient'], true)) !== $matches['coefficient']) {\r
+ return false;\r
+ }\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ \r
+ return true;\r
+ }\r
+}\r
* param string $line
*/
public function parseRR ($line) {
- if(preg_match("/([*-a-z0-9.]+)? ([0-9]+)?(?: )?(IN)?(?: )?([a-z]+) ([\s\S]+)/i", $line, $matches)) {
+ if (preg_match("/([*-a-z0-9.]+)? ([0-9]+)?(?: )?(IN)?(?: )?([a-z]+) ([\s\S]+)/i", $line, $matches)) {
$record=array();
// parse domain name
if (!empty($this->origin) && $matches[1] == "@") {