bernd commited on 2008-08-08 17:19:03
Zeige 6 geänderte Dateien mit 360 Einfügungen und 0 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1127 87cf0b9e-d624-0410-a070-f6ee81989793
| ... | ... |
@@ -0,0 +1,50 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('inc/base.php');
|
|
| 4 |
+require_once('inc/security.php');
|
|
| 5 |
+ |
|
| 6 |
+require_role(ROLE_CUSTOMER); |
|
| 7 |
+ |
|
| 8 |
+require_once('dnsinclude.php');
|
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+$domains = get_domain_list($_SESSION['customerinfo']['customerno']); |
|
| 12 |
+ |
|
| 13 |
+$output .= '<h3>DNS-Records</h3> |
|
| 14 |
+<p>Hier sehen Sie eine Übersicht über die angelegten DNS-records zu Ihren Domains.</p>'; |
|
| 15 |
+ |
|
| 16 |
+//$output .= '<table><tr><th>Hostname</th><th>Typ</th><th>IP-Adresse/Inhalt</th><th>TTL</th><th> </th></tr> |
|
| 17 |
+//'; |
|
| 18 |
+ |
|
| 19 |
+$output .= '<table><tr><th>Domainname</th><th>Manuelle records</th><th>Automatische records</th></tr>'; |
|
| 20 |
+ |
|
| 21 |
+DEBUG($domains); |
|
| 22 |
+ |
|
| 23 |
+foreach($domains AS $dom) |
|
| 24 |
+{
|
|
| 25 |
+ $records = get_domain_records($dom->id); |
|
| 26 |
+ |
|
| 27 |
+ $autorec = ($dom->autodns == 1 ? 'Ja' : 'Nein'); |
|
| 28 |
+ $output .= '<tr><td>'.internal_link("dns_domain.php", $dom->fqdn, "dom={$dom->id}").'</td><td>'.count($records).'</td><td>'.$autorec.'</td></tr>';
|
|
| 29 |
+ |
|
| 30 |
+/* if ($records) |
|
| 31 |
+ {
|
|
| 32 |
+ #$output .= '<h4>'.$dom->fqdn.'</h4>'; |
|
| 33 |
+ #$output .= '<table><tr><th>Hostname</th><th>Typ</th><th>IP-Adresse/Inhalt</th><th>TTL</th><th> </th></tr> |
|
| 34 |
+ #'; |
|
| 35 |
+ foreach ($records AS $rec) |
|
| 36 |
+ {
|
|
| 37 |
+ $data = ( $rec['ip'] ? $rec['ip'] : $rec['data'] ); |
|
| 38 |
+ if ($rec['dyndns']) |
|
| 39 |
+ $data = '<em>DynDNS #'.$rec['dyndns'].'</em>'; |
|
| 40 |
+ $output .= "<tr><td>".internal_link("dns_edit.php", $rec['fqdn'], "id={$rec['id']}")."</td><td>".strtoupper($rec['type'])."</td><td>$data</td><td>{$rec['ttl']} Sek.</td><td>".internal_link("save.php", '<img src="'.$prefix.'images/delete.png" width="16" height="16" alt="löschen" title="Account löschen" />', "id={$rec['id']}&type=dns&action=delete")."</td></tr>\n";
|
|
| 41 |
+ } |
|
| 42 |
+ #$output .= '</table><br />'; |
|
| 43 |
+ |
|
| 44 |
+ }*/ |
|
| 45 |
+} |
|
| 46 |
+ |
|
| 47 |
+$output .= '</table><br />'; |
|
| 48 |
+$output .= '<p>'.internal_link('dns_edit.php', 'Neuen DNS-Record anlegen').'</p>';
|
|
| 49 |
+ |
|
| 50 |
+?> |
| ... | ... |
@@ -0,0 +1,40 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('inc/base.php');
|
|
| 4 |
+require_once('inc/security.php');
|
|
| 5 |
+ |
|
| 6 |
+require_role(ROLE_CUSTOMER); |
|
| 7 |
+ |
|
| 8 |
+require_once('dnsinclude.php');
|
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+$dyndns = get_dyndns_accounts(); |
|
| 12 |
+ |
|
| 13 |
+$output .= '<h3>DynDNS-Accounts</h3> |
|
| 14 |
+<p>Hier sehen Sie eine Übersicht über die angelegten DynDNS-Accounts.</p>'; |
|
| 15 |
+ |
|
| 16 |
+$output .= '<table><tr><th>Kürzel</th><th>Methode</th><th>aktuelle IP</th><th>letztes Update</th><th> </th></tr> |
|
| 17 |
+'; |
|
| 18 |
+ |
|
| 19 |
+foreach ($dyndns AS $entry) {
|
|
| 20 |
+ $handle = $entry['handle']; |
|
| 21 |
+ if (!$handle) |
|
| 22 |
+ $handle = '<em>undefiniert</em>'; |
|
| 23 |
+ $method = ''; |
|
| 24 |
+ if ($entry['sshkey']) |
|
| 25 |
+ if ($entry['password']) |
|
| 26 |
+ $method = 'SSH, HTTP'; |
|
| 27 |
+ else |
|
| 28 |
+ $method = 'SSH'; |
|
| 29 |
+ else |
|
| 30 |
+ if ($entry['password']) |
|
| 31 |
+ $method = 'HTTP'; |
|
| 32 |
+ else |
|
| 33 |
+ $method = '<em>keine</em>'; |
|
| 34 |
+ $output .= "<tr><td>".internal_link("dyndns_edit.php", $handle, "id={$entry['id']}")."</td><td>{$method}</td><td>{$entry['address']}</td><td>{$entry['lastchange']}</td><td>".internal_link("save.php", '<img src="'.$prefix.'images/delete.png" width="16" height="16" alt="löschen" title="Account löschen" />', "id={$entry['id']}&type=dyndns&action=delete")."</td></tr>\n";
|
|
| 35 |
+} |
|
| 36 |
+$output .= '</table><br /> |
|
| 37 |
+ |
|
| 38 |
+<p>'.internal_link('dyndns_edit.php', 'Neuen DynDNS-Account anlegen').'</p>';
|
|
| 39 |
+ |
|
| 40 |
+?> |
| ... | ... |
@@ -0,0 +1,90 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('inc/base.php');
|
|
| 4 |
+require_once('inc/security.php');
|
|
| 5 |
+ |
|
| 6 |
+require_role(ROLE_CUSTOMER); |
|
| 7 |
+ |
|
| 8 |
+require_once('dnsinclude.php');
|
|
| 9 |
+ |
|
| 10 |
+$section = 'dns_dyndns'; |
|
| 11 |
+ |
|
| 12 |
+ |
|
| 13 |
+$new = true; |
|
| 14 |
+$dyndns = array(); |
|
| 15 |
+if ($_REQUEST['id']) |
|
| 16 |
+{
|
|
| 17 |
+ $dyndns = get_dyndns_account($_REQUEST['id']); |
|
| 18 |
+ $new = false; |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 21 |
+ |
|
| 22 |
+$username_http = $_SESSION['userinfo']['username']; |
|
| 23 |
+if ($dyndns['handle']) |
|
| 24 |
+$username_http .= "_{$dyndns['handle']}";
|
|
| 25 |
+ |
|
| 26 |
+$http_update_info = ''; |
|
| 27 |
+if ($dyndns['password']) |
|
| 28 |
+$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.'; |
|
| 29 |
+ |
|
| 30 |
+ |
|
| 31 |
+$output .= '<script type="text/javascript"> |
|
| 32 |
+var username = "'.$_SESSION['userinfo']['username'].'"; |
|
| 33 |
+var handle; |
|
| 34 |
+var http_username; |
|
| 35 |
+ |
|
| 36 |
+function updateUsernameHTTP() {
|
|
| 37 |
+handle = document.getElementById("handle").value;
|
|
| 38 |
+http_username = username; |
|
| 39 |
+if (handle != "") |
|
| 40 |
+http_username = username + "_" + handle; |
|
| 41 |
+ |
|
| 42 |
+document.getElementById("username_http").firstChild.data = http_username;
|
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+</script> |
|
| 46 |
+'; |
|
| 47 |
+ |
|
| 48 |
+ |
|
| 49 |
+$output .= '<h3>DynDNS-Account</h3>'; |
|
| 50 |
+ |
|
| 51 |
+ |
|
| 52 |
+if (! $new ) |
|
| 53 |
+ $output .= '<div style="padding: 0.5em; border: 1px solid black;"><strong>aktuelle Daten:</strong><br /> |
|
| 54 |
+ letztes Update: '.$dyndns['lastchange'].'<br /> |
|
| 55 |
+ aktuelle Adresse: '.$dyndns['address'].' |
|
| 56 |
+ </div>'; |
|
| 57 |
+ |
|
| 58 |
+$form = '<p><label for="handle">Bezeichnung:</label> <input type="text" name="handle" id="handle" value="'.$dyndns['handle'].'" onkeyup="updateUsernameHTTP()" /></p> |
|
| 59 |
+ |
|
| 60 |
+<h4>Update per HTTPs</strong></h4> |
|
| 61 |
+<p style="margin-left: 2em;">Geben Sie hier ein Passwort ein um das Update per HTTPs zu aktivieren.'.$http_update_info.'</p> |
|
| 62 |
+<p style="margin-left: 2em;">Benutzername: <strong><span id="username_http">'.$username_http.'</span></strong></p> |
|
| 63 |
+<p style="margin-left: 2em;"><label for="password_http">Passwort:</label> <input type="password" id="password_http" name="password_http" value="'.($dyndns['password'] ? '************' : '').'" /></p> |
|
| 64 |
+ |
|
| 65 |
+<h4>Update per SSH</h4> |
|
| 66 |
+<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> |
|
| 67 |
+<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">'.$dyndns['sshkey'].'</textarea></p> |
|
| 68 |
+ |
|
| 69 |
+<p style="margin-left: 2em;"><input type="submit" value="Speichern" /> |
|
| 70 |
+'; |
|
| 71 |
+ |
|
| 72 |
+ |
|
| 73 |
+$output .= html_form('dyndns_edit', 'save.php', 'type=dyndns&action=edit&id='.$_REQUEST['id'], $form);
|
|
| 74 |
+ |
|
| 75 |
+$records = get_dyndns_records($_REQUEST['id']); |
|
| 76 |
+ |
|
| 77 |
+if (! $new ) |
|
| 78 |
+{
|
|
| 79 |
+ $output .= '<h4>Folgende DNS-records sind mit diesem DynDNS-Account verknüpft:</h4> |
|
| 80 |
+ |
|
| 81 |
+ <ul>'; |
|
| 82 |
+ |
|
| 83 |
+ foreach ($records AS $record) {
|
|
| 84 |
+ $output .= '<li>'.$record['fqdn'].' (Typ: '.strtoupper($record['type']).' / TTL: '.$record['ttl'].' Sek.)</li>'; |
|
| 85 |
+ } |
|
| 86 |
+ |
|
| 87 |
+ $output .= '</ul>'; |
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+?> |
| ... | ... |
@@ -0,0 +1,114 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('inc/debug.php');
|
|
| 4 |
+require_once('inc/db_connect.php');
|
|
| 5 |
+require_once('inc/base.php');
|
|
| 6 |
+require_once('inc/security.php');
|
|
| 7 |
+ |
|
| 8 |
+require_once('class/domain.php');
|
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+function get_dyndns_accounts() |
|
| 12 |
+{
|
|
| 13 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
| 14 |
+ $result = db_query("SELECT * FROM dns.dyndns WHERE uid={$uid}");
|
|
| 15 |
+ $list = array(); |
|
| 16 |
+ while ($item = mysql_fetch_assoc($result)) {
|
|
| 17 |
+ array_push($list, $item); |
|
| 18 |
+ } |
|
| 19 |
+ DEBUG($list); |
|
| 20 |
+ return $list; |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+function get_dyndns_account($id) |
|
| 25 |
+{
|
|
| 26 |
+ $id = (int) $id; |
|
| 27 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
| 28 |
+ $result = db_query("SELECT * FROM dns.dyndns WHERE id={$id} AND uid={$uid}");
|
|
| 29 |
+ if (mysql_num_rows($result) != 1) {
|
|
| 30 |
+ logger("modules/dns/include/dnsinclude.php", "dyndns", "account »{$id}« invalid for uid »{$uid}«.");
|
|
| 31 |
+ system_failure("Account ungültig");
|
|
| 32 |
+ } |
|
| 33 |
+ $item = mysql_fetch_assoc($result); |
|
| 34 |
+ DEBUG($item); |
|
| 35 |
+ return $item; |
|
| 36 |
+} |
|
| 37 |
+ |
|
| 38 |
+ |
|
| 39 |
+function create_dyndns_account($handle, $password_http, $sshkey) |
|
| 40 |
+{
|
|
| 41 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
| 42 |
+ $handle = maybe_null(mysql_real_escape_string(filter_input_username($handle))); |
|
| 43 |
+ $sshkey = maybe_null(mysql_real_escape_string(filter_input_general($sshkey))); |
|
| 44 |
+ |
|
| 45 |
+ $pwhash = 'NULL'; |
|
| 46 |
+ if ($password_http) |
|
| 47 |
+ $pwhash = "'{SHA}".base64_encode(sha1($password_http, true))."'";
|
|
| 48 |
+ |
|
| 49 |
+ db_query("INSERT INTO dns.dyndns (uid, handle, password, sshkey) VALUES ({$uid}, {$handle}, {$pwhash}, {$sshkey})");
|
|
| 50 |
+ logger("modules/dns/include/dnsinclude.php", "dyndns", "inserted account");
|
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+ |
|
| 54 |
+function edit_dyndns_account($id, $handle, $password_http, $sshkey) |
|
| 55 |
+{
|
|
| 56 |
+ $id = (int) $id; |
|
| 57 |
+ $handle = maybe_null(mysql_real_escape_string(filter_input_username($handle))); |
|
| 58 |
+ $sshkey = maybe_null(mysql_real_escape_string(filter_input_general($sshkey))); |
|
| 59 |
+ |
|
| 60 |
+ $pwhash = 'NULL'; |
|
| 61 |
+ if ($password_http) |
|
| 62 |
+ $pwhash = "'{SHA}".base64_encode(sha1($password_http, true))."'";
|
|
| 63 |
+ |
|
| 64 |
+ db_query("UPDATE dns.dyndns SET handle={$handle}, password={$pwhash}, sshkey={$sshkey} WHERE id={$id} LIMIT 1");
|
|
| 65 |
+ logger("modules/dns/include/dnsinclude.php", "dyndns", "edited account »{$id}«");
|
|
| 66 |
+} |
|
| 67 |
+ |
|
| 68 |
+ |
|
| 69 |
+function delete_dyndns_account($id) |
|
| 70 |
+{
|
|
| 71 |
+ $id = (int) $id; |
|
| 72 |
+ |
|
| 73 |
+ db_query("DELETE FROM dns.dyndns WHERE id={$id} LIMIT 1");
|
|
| 74 |
+ logger("modules/dns/include/dnsinclude.php", "dyndns", "deleted account »{$id}«");
|
|
| 75 |
+} |
|
| 76 |
+ |
|
| 77 |
+ |
|
| 78 |
+function get_dyndns_records($id) |
|
| 79 |
+{
|
|
| 80 |
+ $id = (int) $id; |
|
| 81 |
+ $result = db_query("SELECT hostname, domain, type, ttl, lastchange, id FROM dns.custom_records WHERE dyndns={$id}");
|
|
| 82 |
+ $data = array(); |
|
| 83 |
+ while ($entry = mysql_fetch_assoc($result)) {
|
|
| 84 |
+ $dom = new Domain((int) $entry['domain']); |
|
| 85 |
+ $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn; |
|
| 86 |
+ if (! $entry['hostname']) |
|
| 87 |
+ $entry['fqdn'] = $dom->fqdn; |
|
| 88 |
+ array_push($data, $entry); |
|
| 89 |
+ } |
|
| 90 |
+ DEBUG($data); |
|
| 91 |
+ return $data; |
|
| 92 |
+} |
|
| 93 |
+ |
|
| 94 |
+ |
|
| 95 |
+ |
|
| 96 |
+function get_domain_records($dom) |
|
| 97 |
+{
|
|
| 98 |
+ $dom = (int) $dom; |
|
| 99 |
+ $result = db_query("SELECT hostname, domain, type, ip, dyndns, data, ttl, id FROM dns.custom_records WHERE domain={$dom}");
|
|
| 100 |
+ $data = array(); |
|
| 101 |
+ while ($entry = mysql_fetch_assoc($result)) {
|
|
| 102 |
+ $dom = new Domain((int) $entry['domain']); |
|
| 103 |
+ $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn; |
|
| 104 |
+ if (! $entry['hostname']) |
|
| 105 |
+ $entry['fqdn'] = $dom->fqdn; |
|
| 106 |
+ array_push($data, $entry); |
|
| 107 |
+ } |
|
| 108 |
+ DEBUG($data); |
|
| 109 |
+ return $data; |
|
| 110 |
+} |
|
| 111 |
+ |
|
| 112 |
+ |
|
| 113 |
+ |
|
| 114 |
+?> |
| ... | ... |
@@ -0,0 +1,12 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+$role = $_SESSION['role']; |
|
| 4 |
+ |
|
| 5 |
+ |
|
| 6 |
+if ($role & ROLE_CUSTOMER) |
|
| 7 |
+{
|
|
| 8 |
+ $menu["dns_dns"] = array("label" => "DNS-Einträge", "file" => "dns.php", "weight" => 1, "submenu" => "domains_domains");
|
|
| 9 |
+ $menu["dns_dyndns"] = array("label" => "DynDNS", "file" => "dyndns.php", "weight" => 2, "submenu" => "domains_domains");
|
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+?> |
| ... | ... |
@@ -0,0 +1,54 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('inc/base.php');
|
|
| 4 |
+require_once('inc/debug.php');
|
|
| 5 |
+global $debugmode; |
|
| 6 |
+require_once('inc/security.php');
|
|
| 7 |
+ |
|
| 8 |
+require_role(ROLE_CUSTOMER); |
|
| 9 |
+ |
|
| 10 |
+require_once('dnsinclude.php');
|
|
| 11 |
+ |
|
| 12 |
+$section = 'dns_dyndns'; |
|
| 13 |
+ |
|
| 14 |
+$id = NULL; |
|
| 15 |
+if ($_REQUEST['id']) |
|
| 16 |
+ $id = (int) $_REQUEST['id']; |
|
| 17 |
+ |
|
| 18 |
+ |
|
| 19 |
+if ($_GET['type'] == 'dyndns') {
|
|
| 20 |
+ if ($_GET['action'] == 'delete') {
|
|
| 21 |
+ $sure = user_is_sure(); |
|
| 22 |
+ if ($sure === NULL) |
|
| 23 |
+ {
|
|
| 24 |
+ are_you_sure("type=dyndns&action=delete&id={$id}", "Möchten Sie den DynDNS-Account wirklich löschen?");
|
|
| 25 |
+ } |
|
| 26 |
+ elseif ($sure === true) |
|
| 27 |
+ {
|
|
| 28 |
+ delete_dyndns_account($id); |
|
| 29 |
+ if (! $debugmode) |
|
| 30 |
+ header("Location: dyndns.php");
|
|
| 31 |
+ } |
|
| 32 |
+ elseif ($sure === false) |
|
| 33 |
+ {
|
|
| 34 |
+ if (! $debugmode) |
|
| 35 |
+ header("Location: dyndns.php");
|
|
| 36 |
+ } |
|
| 37 |
+ } |
|
| 38 |
+ if ($_GET['action'] == 'edit') {
|
|
| 39 |
+ check_form_token('dyndns_edit');
|
|
| 40 |
+ |
|
| 41 |
+ if ($id) {
|
|
| 42 |
+ edit_dyndns_account($id, $_POST['handle'], $_POST['password_http'], $_POST['sshkey']); |
|
| 43 |
+ } else {
|
|
| 44 |
+ create_dyndns_account($_POST['handle'], $_POST['password_http'], $_POST['sshkey']); |
|
| 45 |
+ } |
|
| 46 |
+ |
|
| 47 |
+ if (! ($debugmode || we_have_an_error())) |
|
| 48 |
+ header('Location: dyndns.php');
|
|
| 49 |
+ } |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 52 |
+ |
|
| 53 |
+ |
|
| 54 |
+ |
|
| 0 | 55 |