replaced images and some code cleanup
This commit is contained in:
parent
fd9f34aeea
commit
04af93d644
10 changed files with 42 additions and 46 deletions
16
expert.php
16
expert.php
|
@ -16,7 +16,7 @@ $checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']
|
|||
|
||||
?>
|
||||
<div id="expert">
|
||||
<div style="float: right;"><a href="images/0l.png"><img src="images/0l_small.png" alt="0l" /></a></div>
|
||||
<div style="float: right;"><a href="http://0l.de"><img src="images/nulll_small.png" alt="/dev/nulll" /></a></div>
|
||||
<h1>Tiny DNS & URL</h1>
|
||||
<h3>aka SDDNS - <b>S</b>imple <b>D</b>ynamic <b>D</b>omain <b>N</b>ame <b>S</b>ervice</h3>
|
||||
<p>by <a href="http://www.steffenvogel.de">Steffen Vogel</a></p>
|
||||
|
@ -38,24 +38,24 @@ $checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']
|
|||
<tr>
|
||||
<td><label for="format">format</label></td>
|
||||
<td><select name="format" size="1">
|
||||
|
||||
|
||||
<?php
|
||||
foreach ($config['sddns']['formats'] as $format) {
|
||||
echo '<option value="' . $format . '">' . $format . '</option>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<option><i>none</i></option></select></td>
|
||||
<td><input type="checkbox" name="debug" value="1" /> include debugging information</td>
|
||||
</tr>
|
||||
<tr><td><label for="host">hostname</label></td><td><input type="text" name="host" value="<?= @$_REQUEST['host'] ?>" />.<select name="zone" size="1">';
|
||||
|
||||
<?php
|
||||
|
||||
<?php
|
||||
foreach ($config['sddns']['zones'] as $zone) {
|
||||
echo '<option' . (($_REQUEST['zone'] == $zone->name) ? ' selected="selected"' : '') . ' value="' . $zone->name . '">' . $zone->name . '</option>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
</select></td><td>optional; random or servername</td></tr>
|
||||
<tr><td><label for="ttl">ttl</label></td><td><input type="text" name="ttl" value="<?= $ttl ?>" /> seconds</td><td>time to live in cache; max <?= $config['sddns']['max_ttl'] ?> seconds</td></tr>
|
||||
<tr><td><label for="lifetime">lifetime</label></td><td><input type="text" name="lifetime" value="<?= $lifetime ?>" /> seconds</td><td>lifetime of a record/url without an update; max <?= $config['sddns']['max_lifetime'] ?></td></tr>
|
||||
|
@ -63,7 +63,7 @@ $checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']
|
|||
<td><label for="class">class</label></td>
|
||||
<td><select name="class" size="1">
|
||||
|
||||
<?php
|
||||
<?php
|
||||
foreach ($config['sddns']['classes'] as $class) {
|
||||
echo '<option' . (($class == $checkedClass) ? ' selected="selected"' : '') . ' value="' . $class . '">' . $class . '</option>';
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ $checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']
|
|||
echo '<option' . (($type == $checkedType) ? ' selected="selected"' : '') . ' value="' . $type . '">' . $type . '</option>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<option><i>all</i></option></select></td>
|
||||
</tr>
|
||||
<tr><td><label for="rdata">rdata</label></td><td><input value="<?= (empty($_REQUEST['rdata']) && $checkedType == 'A') ? $_SERVER['REMOTE_ADDR'] : @$_REQUEST['rdata'] ?>" type="text" name="rdata" /></td><td><input type="checkbox" value="1" name="frame" /> hide uri in a frameset</td></tr>
|
||||
|
|
BIN
images/0l.png
BIN
images/0l.png
Binary file not shown.
Before Width: | Height: | Size: 56 KiB |
0
images/0l_small.png → images/nulll_small.png
Executable file → Normal file
0
images/0l_small.png → images/nulll_small.png
Executable file → Normal file
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
interface DBObject extends Object {
|
||||
|
||||
|
||||
public static function get(Database $db, $filter);
|
||||
public function delete();
|
||||
public function __destruct();
|
||||
public function update();
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -4,7 +4,7 @@ class DBRecord extends Record implements DBObject {
|
|||
public $id;
|
||||
public $lifetime;
|
||||
public $lastAccessed;
|
||||
|
||||
|
||||
private $db;
|
||||
|
||||
public function __construct($id, Database $db) {
|
||||
|
@ -26,14 +26,14 @@ class DBRecord extends Record implements DBObject {
|
|||
|
||||
parent::__construct($this->host, (int) $record['ttl'], $record['class'], $record['type'], $record['rdata']);
|
||||
}
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
//$this->update();
|
||||
}
|
||||
|
||||
|
||||
public function update() {
|
||||
$config = Registry::get('config');
|
||||
|
||||
|
||||
$sql = 'UPDATE ' . $config['db']['tbl']['records'] . '
|
||||
SET
|
||||
lifetime = ' . (int) $this->lifetime . ',
|
||||
|
@ -44,18 +44,18 @@ class DBRecord extends Record implements DBObject {
|
|||
type = \'' . $this->db->escape($this->type) . '\',
|
||||
rdata = \'' . $this->db->escape( $this->rdata) . '\'
|
||||
WHERE id = ' . (int) $this->id;
|
||||
|
||||
|
||||
$this->db->execute($sql);
|
||||
}
|
||||
|
||||
|
||||
public function toXml(DOMDocument $doc) {
|
||||
$xmlRecord = parent::toXml($doc);
|
||||
|
||||
$xmlRecord->setAttribute('id', $this->id);
|
||||
|
||||
|
||||
$xmlRecord->appendChild($doc->createElement('lifetime', $this->lifetime));
|
||||
$xmlRecord->appendChild($doc->createElement('lastaccessed', $this->lastAccessed));
|
||||
|
||||
|
||||
return $xmlRecord;
|
||||
}
|
||||
|
||||
|
@ -64,10 +64,10 @@ class DBRecord extends Record implements DBObject {
|
|||
|
||||
$sql = 'DELETE FROM ' . $config['db']['tbl']['records'] . '
|
||||
WHERE id = ' . (int) $this->id;
|
||||
|
||||
|
||||
$this->db->execute($sql);
|
||||
}
|
||||
|
||||
|
||||
public static function get(Database $db, $filter = false) {
|
||||
$config = Registry::get('config');
|
||||
|
||||
|
@ -76,7 +76,7 @@ class DBRecord extends Record implements DBObject {
|
|||
LEFT JOIN ' . $config['db']['tbl']['hosts'] . ' AS h
|
||||
ON h.id = r.host_id
|
||||
WHERE true';
|
||||
|
||||
|
||||
if (!empty($filter['id']))
|
||||
$sql .= ' && id = ' . (int) $filter['id'];
|
||||
if (!empty($filter['host']) && $filter['host'] instanceof Host)
|
||||
|
@ -99,9 +99,9 @@ class DBRecord extends Record implements DBObject {
|
|||
$sql .= ' && ttl = ' . (int) $filter['ttl'];
|
||||
|
||||
$sql .= ' ORDER BY r.id ASC';
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
|
||||
$records = array();
|
||||
foreach ($result as $record) {
|
||||
$records[] = new self($record['id'], $db);
|
||||
|
@ -110,4 +110,4 @@ class DBRecord extends Record implements DBObject {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
100064
|
||||
114412
|
|
@ -9,7 +9,7 @@ class Record implements Object {
|
|||
$config = Registry::get('config');
|
||||
|
||||
$this->host = $host;
|
||||
|
||||
|
||||
if (is_int($ttl) && $ttl > 0 && $ttl <= $config['sddns']['max_ttl']) {
|
||||
$this->ttl = $ttl;
|
||||
} else {
|
||||
|
@ -30,8 +30,7 @@ class Record implements Object {
|
|||
|
||||
$this->setRData($rdata);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Setter & Getter
|
||||
*/
|
||||
|
@ -58,7 +57,7 @@ class Record implements Object {
|
|||
public function add(Database $db, $lifetime) {
|
||||
$config = Registry::get('config');
|
||||
$db = Registry::get('db');
|
||||
|
||||
|
||||
if ($this->host->isRegistred($db)) {
|
||||
$host = new DBHost($this->host->isRegistred($db), $db);
|
||||
}
|
||||
|
@ -76,10 +75,10 @@ class Record implements Object {
|
|||
NOW(),
|
||||
' . (int) $lifetime . ',
|
||||
\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\')';
|
||||
|
||||
|
||||
|
||||
$db->execute($sql);
|
||||
|
||||
|
||||
return new DBRecord($db->lastId(), $db);
|
||||
}
|
||||
|
||||
|
@ -102,10 +101,10 @@ class Record implements Object {
|
|||
case 'NS':
|
||||
$valid = Host::isValid($rdata);
|
||||
break;
|
||||
|
||||
|
||||
case 'URL':
|
||||
$valid = Uri::isValid($rdata);
|
||||
|
||||
|
||||
default:
|
||||
$valid = true;
|
||||
break;
|
||||
|
@ -113,7 +112,7 @@ class Record implements Object {
|
|||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
|
||||
public function isRegistred(Database $db) {
|
||||
$config = Registry::get('config');
|
||||
|
||||
|
@ -130,8 +129,7 @@ class Record implements Object {
|
|||
|
||||
return ($result->count() > 0) ? $record['id'] : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Output
|
||||
*/
|
||||
|
@ -158,7 +156,7 @@ class Record implements Object {
|
|||
$xmlRecord->appendChild($doc->createElement('ttl', $this->ttl));
|
||||
$xmlRecord->appendChild($doc->createElement('class', $this->class));
|
||||
$xmlRecord->appendChild($doc->createElement('type', $this->type));
|
||||
|
||||
|
||||
switch ($this->type) {
|
||||
case 'A':
|
||||
case 'AAAA':
|
||||
|
@ -170,27 +168,27 @@ class Record implements Object {
|
|||
|
||||
return $xmlRecord;
|
||||
}
|
||||
|
||||
|
||||
public function toHtml() {
|
||||
$html = '' . $this->host->toHtml() . ' <a target="_blank" href="/?host=' . $this->host->toPunycode() . '&ttl=' . $this->ttl . '&type=' . $this->type . '&class=' . $this->class . '&rdata=' . $this->rdata . '">' . $this->ttl . ' ' . $this->class . ' ' . $this->type . '</a>';
|
||||
|
||||
|
||||
$html .= ' ';
|
||||
switch ($this->type) {
|
||||
case 'A':
|
||||
case 'AAAA':
|
||||
$html .= $this->rdata->toHtml();
|
||||
break;
|
||||
|
||||
|
||||
case 'NS':
|
||||
case 'CNAME':
|
||||
$html .= '<a target="_blank" href="http://' . $this->rdata . '">' . $this->rdata . '</a>';
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$html .= $this->rdata;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 475 B |
BIN
misc/favicon.xcf
Normal file
BIN
misc/favicon.xcf
Normal file
Binary file not shown.
|
@ -5,7 +5,7 @@ $output = Output::start('html');
|
|||
<div id="simple">
|
||||
|
||||
<header>
|
||||
<a href="http://0l.de"><img src="http://0l.de/_media/nulll_small.png" alt="0l" /></a>
|
||||
<a href="http://0l.de"><img src="images/nulll_small.png" alt="/dev/nulll" /></a>
|
||||
<h1>Tiny DNS & URL</h1>
|
||||
</header>
|
||||
|
||||
|
@ -21,7 +21,7 @@ $output = Output::start('html');
|
|||
<?php } ?>
|
||||
</select>
|
||||
</dd>
|
||||
|
||||
|
||||
<dt><label for="rdata"><a href="http://de.wikipedia.org/wiki/IP-Adresse">IP</a> / <a href="http://de.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a></label></dt>
|
||||
<dd><input style="width:217px" tabindex="2" value="<?= isset($_REQUEST['rdata']) ? $_REQUEST['rdata'] : $_SERVER['REMOTE_ADDR'] ?>" type="text" name="rdata" /></dd>
|
||||
|
||||
|
@ -32,10 +32,9 @@ if (!isAuthentificated())
|
|||
?>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
<input type="submit" tabindex="4" value="register" />
|
||||
<input type="hidden" name="type" value="A" />
|
||||
|
||||
</form>
|
||||
|
||||
<iframe name="ifr" id="ifr"></iframe>
|
||||
|
|
Loading…
Add table
Reference in a new issue