modules/dns/dyndns_edit.php
e45c3ec9
 <?php
c208bd90
 /*
 This file belongs to the Webinterface of schokokeks.org Hosting
 
cf54502a
 Written 2008-2018 by schokokeks.org Hosting, namely
c208bd90
   Bernd Wurst <bernd@schokokeks.org>
   Hanno Böck <hanno@schokokeks.org>
 
 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
 
2626dd47
 You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
c208bd90
 http://creativecommons.org/publicdomain/zero/1.0/
 
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
 */
e45c3ec9
 
 require_once('inc/base.php');
 require_once('inc/security.php');
 
0d0cc0d8
 require_role(ROLE_SYSTEMUSER);
e45c3ec9
 
 require_once('dnsinclude.php');
 
 $section = 'dns_dyndns';
 
 
 $new = true;
 $dyndns = array();
2626dd47
 if (isset($_REQUEST['id'])) {
     $dyndns = get_dyndns_account($_REQUEST['id']);
     $new = false;
e45c3ec9
 }
 
 
 $username_http = $_SESSION['userinfo']['username'];
2626dd47
 if (isset($dyndns['handle'])) {
     $username_http .= "_{$dyndns['handle']}";
 }
e45c3ec9
 
 $http_update_info = '';
2626dd47
 if (isset($dyndns['password'])) {
     $http_update_info = ' Lassen Sie das Passworteingabefeld unberührt um das bestehende Passwort zu erhalten. Entfernen Sie das bestehende Passwort um das HTTP-Update zu deaktivieren.';
 }
e45c3ec9
 
 
f2550e90
 $html_header .= '<script type="text/javascript">
e45c3ec9
 var username = "'.$_SESSION['userinfo']['username'].'";
 var handle;
 var http_username;
 
 function updateUsernameHTTP() {
 handle = document.getElementById("handle").value;
 http_username = username;
 if (handle != "")
 http_username = username + "_" + handle;
 
 document.getElementById("username_http").firstChild.data = http_username;
 }
 
 </script>
 ';
 
 
f2550e90
 title('DynDNS-Account');
e45c3ec9
 
 
2626dd47
 if (! $new) {
     $output .= '<div style="padding: 0.5em; border: 1px solid black;"><strong>aktuelle Daten:</strong><br />
e45c3ec9
   letztes Update: '.$dyndns['lastchange'].'<br />
   aktuelle Adresse: '.$dyndns['address'].'
   </div>';
2626dd47
 }
e45c3ec9
 
53f24981
 $form = '<p><label for="handle">Bezeichnung:</label>&#160;<input type="text" name="handle" id="handle" value="'.(isset($dyndns['handle']) ? $dyndns['handle'] : '').'" onkeyup="updateUsernameHTTP()" /></p>
e45c3ec9
 
75feee8b
 <h4>Update per HTTPs</h4>
e45c3ec9
 <p style="margin-left: 2em;">Geben Sie hier ein Passwort ein um das Update per HTTPs zu aktivieren.'.$http_update_info.'</p>
 <p style="margin-left: 2em;">Benutzername:&#160;<strong><span id="username_http">'.$username_http.'</span></strong></p>
53f24981
 <p style="margin-left: 2em;"><label for="password_http">Passwort:</label>&#160;<input type="password" id="password_http" name="password_http" value="'.(isset($dyndns['password']) ? '************' : '').'" /></p>
e45c3ec9
 
 <h4>Update per SSH</h4>
 <p style="margin-left: 2em;">Kopieren Sie Ihren SSH-public-Key im OpenSSH-Format in dieses Eingabefeld um das Update per SSH zu aktivieren.</p>
53f24981
 <p style="margin-left: 2em; vertical-align: middle;"><label for="sshkey">SSH Public-Key:</label><br /><textarea style="height: 10em; width: 80%;" id="sshkey" name="sshkey">'.(isset($dyndns['sshkey']) ? $dyndns['sshkey'] : '').'</textarea></p>
e45c3ec9
 
75feee8b
 <p style="margin-left: 2em;"><input type="submit" value="Speichern" /></p>
e45c3ec9
 ';
 
 
53f24981
 $output .= html_form('dyndns_edit', 'save', 'type=dyndns&action=edit&'.(isset($_REQUEST['id']) ? 'id='.$_REQUEST['id'] : ''), $form);
e45c3ec9
 
9086c9ad
 
2626dd47
 if (! $new) {
     $records = get_dyndns_records($_REQUEST['id']);
53f24981
 
2626dd47
     $output .= '<h4>Folgende DNS-records sind mit diesem DynDNS-Account verknüpft:</h4>
e45c3ec9
   
   <ul>';
9086c9ad
 
2626dd47
     foreach ($records as $record) {
         $output .= '<li>'.$record['fqdn'].' (Typ: '.strtoupper($record['type']).' / TTL: '.$record['ttl'].' Sek.)</li>';
     }
9086c9ad
 
2626dd47
     $output .= '</ul>';
     output("<p>".internal_link('dyndns_hostnames', "Liste ändern...", "id={$_REQUEST['id']}")."</p>");
e45c3ec9
 }