fix last commit
authorStricted <info@stricted.de>
Thu, 11 Jun 2015 15:03:46 +0000 (17:03 +0200)
committerStricted <info@stricted.de>
Thu, 11 Jun 2015 15:03:46 +0000 (17:03 +0200)
lib/api/page/ServerPage.class.php [new file with mode: 0644]
lib/page/SecAddPage.class.php [new file with mode: 0644]
templates/default/secAdd.tpl

diff --git a/lib/api/page/ServerPage.class.php b/lib/api/page/ServerPage.class.php
new file mode 100644 (file)
index 0000000..e0386ba
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+namespace dns\page;
+use dns\page\AbstractPage;
+use dns\system\DNS;
+
+/**
+ * @author      Jan Altensen (Stricted)
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @copyright   2014-2015 Jan Altensen (Stricted)
+ */
+class ServerPage extends AbstractPage {
+       const AVAILABLE_DURING_OFFLINE_MODE = true;
+       
+       public function prepare() {
+               // todo: user/server seletion
+               $key = "";
+               if (isset($_REQUEST['key'])) {
+                       $key = strtoupper(trim($_REQUEST['key']));
+               }
+               
+               if (!defined('DNS_API_KEY') || $key != DNS_API_KEY || empty($key) || !preg_match('/[a-f0-9]{8}\-[a-f0-9]{4}\-4[a-f0-9]{3}\-[89ab][a-f0-9]{3}\-[a-f0-9]{12}/i', $key)) {
+                       header('Content-Type: application/json');
+                       echo json_encode(array("error" => "wrong access key"), JSON_PRETTY_PRINT);
+                       exit;
+               }
+               else {
+                       $data = array();
+                       
+                       $sql = "SELECT * FROM dns_soa where active = ?";
+                       $statement = DNS::getDB()->query($sql, array(1));
+                       
+                       while ($zone = DNS::getDB()->fetch_array($statement)) {
+                               $data[$zone['origin']] = array();
+                               $data[$zone['origin']]['soa'] = $zone;
+                               $data[$zone['origin']]['rr'] = array();
+                               $data[$zone['origin']]['sec'] = array();
+                               
+                               /* resource records */
+                               $sql2 = "SELECT * FROM dns_rr where zone = ? and active = ?";
+                               $statement2 = DNS::getDB()->query($sql2, array($zone['id'], 1));
+                               while ($rr = DNS::getDB()->fetch_array($statement2)) {
+                                       $data[$zone['origin']]['rr'][] = $rr;
+                               }
+                               
+                               if (ENABLE_DNSSEC) {
+                                       /* dnssec keys */
+                                       $sql3 = "SELECT * FROM dns_sec where zone = ? and active = ?";
+                                       $statement3 = DNS::getDB()->query($sql3, array($zone['id'], 1));
+                                       while ($sec = DNS::getDB()->fetch_array($statement3)) {
+                                               $data[$zone['origin']]['sec'][] = $sec;
+                                       }
+                               }
+                       }
+
+                       header('Content-Type: application/json');
+                       echo json_encode($data, JSON_PRETTY_PRINT);
+                       exit;
+               }
+       }
+}
diff --git a/lib/page/SecAddPage.class.php b/lib/page/SecAddPage.class.php
new file mode 100644 (file)
index 0000000..a5d18a6
--- /dev/null
@@ -0,0 +1,29 @@
+<?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 SecAddPage extends AbstractPage {
+       
+       public function prepare() {
+               if (!isset($_GET['id']) || empty($_GET['id']) || !ENABLE_DNSSEC) {
+                       throw new \Exception('The link you are trying to reach is no longer available or invalid.', 404);
+               }
+               print_r($_REQUEST);
+               $soaIDs = User::getAccessibleDomains();
+               if (!in_array($_GET['id'], $soaIDs)) {
+                       throw new \Exception('Access denied. You\'re not authorized to view this page.', 403);
+               }
+               
+               $sql = "SELECT * FROM dns_soa WHERE id = ?";
+               $res = DNS::getDB()->query($sql, array($_GET['id']));
+               $soa = DNS::getDB()->fetch_array($res);
+               
+               DNS::getTPL()->assign(array("soa" => $soa));
+       }
+}
index 72bdf86fb09b62e785b6470d9c2ff6afe4b81f79..ec434bdacbebdc413baa410e2a30137b668983ec 100644 (file)
                                <div class="panel-heading">Add Record</div>
                                <div class="panel-body">
                                        <div>
-                        <fieldset>
-                            <dl>
-                                <dt>Algorithmus</dt>
-                                <dd>
-                                    <select id="type" name="algo" class="medium">
-                                        <option label="RSA/SHA-256 (8)" value="8">RSA/SHA-256 (8)</option>
-                                        <option label="RSA/SHA-512 (10)" value="10">RSA/SHA-512 (10)</option>
-                                    </select>
-                                </dd>
-                            </dl>
-                            <dl>
-                                <dt>ZSK Public Key</dt>
-                                <dd>
-                                    <textarea cols="70" rows="10" id="zskpub" name="zskpub"></textarea>
-                                </dd>
-                            </dl>
-                            <dl>
-                                <dt>ZSK Private Key</dt>
-                                <dd>
-                                    <textarea cols="70" rows="10" id="zskpriv" name="zskpriv"></textarea>
-                                </dd>
-                            </dl>
-                            <dl>
-                                <dt>KSK Public Key</dt>
-                                <dd>
-                                    <textarea cols="70" rows="10" id="kskpub" name="kskpub"></textarea>
-                                </dd>
-                            </dl>
-                            <dl>
-                                <dt>KSK Private Key</dt>
-                                <dd>
-                                    <textarea cols="70" rows="10" id="kskpriv" name="kskpriv"></textarea>
-                                </dd>
-                            </dl>
-                        </fieldset>
+                                               <fieldset>
+                                                       <dl>
+                                                               <dt>Algorithmus</dt>
+                                                               <dd>
+                                                                       <select id="type" name="algo" class="medium">
+                                                                               <option label="RSA/SHA-256 (8)" value="8">RSA/SHA-256 (8)</option>
+                                                                               <option label="RSA/SHA-512 (10)" value="10">RSA/SHA-512 (10)</option>
+                                                                       </select>
+                                                               </dd>
+                                                       </dl>
+                                                       <dl>
+                                                               <dt>Type</dt>
+                                                               <dd>
+                                                                       <select id="type" name="type" class="medium">
+                                                                               <option label="ZSK" value="ZSK">ZSK</option>
+                                                                               <option label="KSK" value="KSK">KSK</option>
+                                                                       </select>
+                                                               </dd>
+                                                       </dl>
+                                                       <dl>
+                                                               <dt>DNSSEC Public Key</dt>
+                                                               <dd>
+                                                                       <textarea cols="70" rows="10" id="pub" name="pub"></textarea>
+                                                               </dd>
+                                                       </dl>
+                                                       <dl>
+                                                               <dt>DNSSEC Private Key</dt>
+                                                               <dd>
+                                                                       <textarea cols="70" rows="10" id="priv" name="priv"></textarea>
+                                                               </dd>
+                                                       </dl>
+                                               </fieldset>
+
                                        </div>
                                </div>
                        </div>