fixed several smaller issues added several improvements

This commit is contained in:
root 2010-10-07 21:03:13 +02:00
parent 5f61820c54
commit 3c94394a72
17 changed files with 65 additions and 59 deletions

17
add.php
View file

@ -5,7 +5,8 @@ $output = Output::start();
if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$zone = $config['sddns']['zones'][$_REQUEST['zone']];
$type = (empty($_REQUEST['type'])) ? $config['sddns']['std']['type'] : $_REQUEST['type'];
$rdata = (empty($_REQUEST['rdata']) && $type = 'A') ? $_SERVER['REMOTE_ADDR'] : $_REQUEST['rdata'];
$host = (empty($_REQUEST['host'])) ? Host::unique($zone, $db) : new Host($_REQUEST['host'], $zone);
$pw = (empty($_REQUEST['pw'])) ? randomString(8) : $_REQUEST['pw'];
@ -21,11 +22,18 @@ if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
}
if ($host->isRegistred($db)) {
if ($type == 'URL') {
$output->add('host is already registred', 'error', $host);
$output->send();
die();
}
$host = new DBHost($host->isRegistred($db), $db);
$output->add('found existing host' ,'notice', $host);
if (!$host->checkPassword($pw)) {
$output->add('not authentificated for host', 'error', $host);
$output->send();
die();
}
}
@ -37,9 +45,6 @@ if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$output->add('generated password' ,'notice', $pw);
}
$type = (empty($_REQUEST['type'])) ? $config['sddns']['std']['type'] : $_REQUEST['type'];
$rdata = (empty($_REQUEST['rdata']) && $type = 'A') ? $_SERVER['REMOTE_ADDR'] : $_REQUEST['rdata'];
if ($type != 'URL') { // pseudo type to create url redirection
$ttl = (empty($_REQUEST['ttl'])) ? $config['sddns']['std']['ttl'] : (int) $_REQUEST['ttl'];
$class = (empty($_REQUEST['class'])) ? $config['sddns']['std']['class'] : $_REQUEST['class'];
@ -55,11 +60,13 @@ if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
}
else {
$output->add('record already exists in db', 'error', $record);
$output->send();
die();
}
}
else {
$uri = new Uri($rdata, $host);
$uri->frame = (isset($_GET['frame']) && $_GET['frame']) ? 1 : 0;
$uri = $uri->add($db, $lifetime);
$output->add('uri redirection added to db', 'success', $uri);
}
@ -68,6 +75,6 @@ else {
$output->add('zone not found', 'error', $_REQUEST['zone']);
}
Output::send();
$output->send();
?>

View file

@ -1,8 +1,7 @@
<?php
$output = Output::start();
require_once dirname(__FILE__) . '/../include/init.php';
$output = Output::start();
if (empty($_REQUEST['zone']) || $_REQUEST['zone'] == 'all') {
$zones = $config['sddns']['zones'];
@ -19,6 +18,6 @@ foreach ($zones as $zone) {
$zone->cleanup($db);
}
Output::send();
$output->send();
?>

View file

@ -11,19 +11,33 @@ $dataTables = array(
'uris' => 'created'
);
$perModes = array(
'hour' => false, // mySQL funtion => is timestamp
'day' => false,
'date' => true,
'week' => false,
'month' => false,
'weekday' => false
);
$colors = array(
'records' => 'midnightblue',
'records' => 'blue',
'queries' => 'red',
'logs' => 'orange',
'uris' => 'black'
);
if (@!empty($_REQUEST['data'])) {
$tmps = explode(',', trim($_REQUEST['data'], ' ,'));
foreach ($tmps as $tmp) {
if (in_array(trim($tmp), array_keys($dataTables)) && !($output instanceof GraphOutput && !$dataTables[trim($tmp)]))
$get = array();
if (isset($_REQUEST['data'])) {
foreach (explode(',', $_REQUEST['data']) as $tmp) {
if (in_array($tmp, array_keys($dataTables)) && !($output instanceof GraphOutput && !$dataTables[$tmp])) {
$get[] = trim($tmp);
}
else {
$output->add('invalid data', 'error', $tmp);
$output->send();
die();
}
}
}
else {
@ -34,18 +48,15 @@ if ($output instanceof GraphOutput) {
require_once $site['path']['server'] . '/include/jpgraph/jpgraph_line.php';
require_once $site['path']['server'] . '/include/jpgraph/jpgraph_date.php';
$perModes = array(
'hour' => false, // mySQL funtion => is timestamp
'day' => false,
'date' => true,
'week' => false,
'month' => false,
'weekday' => false
);
if (@isset($_REQUEST['per'])) {
if (in_array($_REQUEST['per'], array_keys($perModes)))
if (isset($_REQUEST['per'])) {
if (in_array($_REQUEST['per'], array_keys($perModes))) {
$per = $_REQUEST['per'];
}
else {
$output->add('unknown grouping mode', 'error', $_REQUEST['per']);
$output->send();
die();
}
}
else {
$per = 'date';
@ -62,9 +73,7 @@ if ($output instanceof GraphOutput) {
}
else {
$graph->SetScale('intint');
$graph->xaxis->SetLabelFormatCallback(function($label) {
global $per;
$graph->xaxis->SetLabelFormatCallback(function($label) use ($per) {
switch ($per) {
case 'month':
return date('M', mktime(0, 0, 0, $label));
@ -203,6 +212,6 @@ else {
}
}
Output::send();
$output->send();
?>

View file

@ -60,6 +60,6 @@ else {
$output->add('no queries to parse', 'debug', 1);
}
Output::send();
$output->send();
?>

View file

@ -19,6 +19,6 @@ foreach ($results as $result) {
$output->add('', 'data', $result);
}
Output::send();
$output->send();
?>

View file

@ -9,6 +9,6 @@ foreach ($result as $row) {
$output->add($row['hostname'], 'data', $row['sum']);
}
Output::send();
$output->send();
?>

View file

@ -44,6 +44,6 @@ else {
}
}
Output::send();
$output->send();
?>

View file

@ -15,6 +15,6 @@ foreach ($zones as $zone) {
$zone->sync($db);
}
Output::send();
$output->send();
?>

View file

@ -9,17 +9,15 @@ if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$zone = $config['sddns']['zones'][$_REQUEST['zone']];
if (!empty($_REQUEST['host'])) {
$host = reset(DBHost::get($db, array('host' => $_REQUEST['host'], 'zone' => $zone)));
if (!empty($host)) {
if ($host = reset(DBHost::get($db, array('host' => $_REQUEST['host'], 'zone' => $zone)))) {
if ($host->checkPassword($pw) || isAuthentificated()) {
if (!empty($_REQUEST['class']) && in_array($_REQUEST['class'], $config['sddns']['classes']))
if (isset($_REQUEST['class']) && in_array($_REQUEST['class'], $config['sddns']['classes']))
$class = $_REQUEST['class'];
if (!empty($_REQUEST['type']) && in_array($_REQUEST['type'], $config['sddns']['types'])) {
if (isset($_REQUEST['type']) && in_array($_REQUEST['type'], $config['sddns']['types'])) {
$type = $_REQUEST['type'];
if (!empty($_REQUEST['rdata']) && Record::isRData($_REQUEST['rdata'], $type))
if (isset($_REQUEST['rdata']) && Record::isRData($_REQUEST['rdata'], $type))
$rdata = $_REQUEST['rdata'];
}
@ -58,6 +56,6 @@ else {
$output->add('zone not found', 'error', $_REQUEST['zone']);
}
Output::send();
$output->send();
?>

View file

@ -83,12 +83,8 @@ $checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']
<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></td></tr>
<?php
if (!isAuthentificated()) // admin needs no password
echo '<tr><td><label for="pw">password</label></td><td><input type="password" name="pw" /></td><td>optional; random generated</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>
<tr><td><label for="pw">password</label></td><td><input type="password" name="pw" /></td><td>optional; random generated</td></tr>
</table>
<input type="submit" />
@ -104,5 +100,5 @@ $checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']
</div>
<?php
Output::send();
$output->send();
?>

View file

@ -1 +1 @@
59012
59139

View file

@ -405,9 +405,8 @@ abstract class Output {
abstract protected function getOutput();
static function send() {
if ($output = Registry::get('output'))
echo $output->getOutput();
function send() {
echo $this->getOutput();
}
}

View file

@ -18,9 +18,7 @@ echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html>
<head><title>/dev/nulll - Frame</title></head>
<body style="margin: 0; padding: 0; overflow: hidden;">
<table style="height: 100%; width: 100%; position: absolute; top: 0; left: 0;"><tr><td>
<iframe height="100%" width="100%" frameborder="0" marginheight="0" marginwidth="0" src="' . $uri->uri . '"></iframe>
</td></tr></table>
<iframe style="height: 100%; width: 100%; position: absolute; top: 0; left: 0;" height="100%" width="100%" frameborder="0" marginheight="0" marginwidth="0" src="' . $uri->uri . '"></iframe>
</body>
</html>';

2
ip.php
View file

@ -7,6 +7,6 @@ $ip = new IpV4($_SERVER['REMOTE_ADDR']);
$output->add('your current internet ip address', 'notice', $ip);
Output::send();
$output->send();
?>

View file

@ -20,6 +20,6 @@ the credentials required.</p>
$output->add('authentificated as', 'notice', $_SERVER['PHP_AUTH_USER']);
}
Output::send()
$output->send()
?>

View file

@ -48,5 +48,5 @@ if (!isAuthentificated())
</div>
<?php
Output::send();
$output->send();
?>

View file

@ -93,5 +93,5 @@ else {
$output->add('zone not found', 'error', $_REQUEST['host'], $_REQUEST['zone']);
}
Output::send();
$output->send();
?>