aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind2015-03-31 21:38:03 +0200
committerMaZderMind2015-03-31 21:38:03 +0200
commit7a163c226c99eb97fb9ce59ce5774da513bcdfd1 (patch)
tree19e94eae8e42c0b7cb5efd02d03d3dab95601f04
parentf48084e1d68429235a5655a92b463cc5099be646 (diff)
Feedback Read-View
Diffstat (limited to '')
-rw-r--r--assets/css/_bootstrap-selection.less2
-rw-r--r--assets/css/_structure.less9
-rw-r--r--model/Feedback.php36
-rw-r--r--template/feedback-read.phtml77
-rw-r--r--view/feedback-read.php29
5 files changed, 152 insertions, 1 deletions
diff --git a/assets/css/_bootstrap-selection.less b/assets/css/_bootstrap-selection.less
index 2c50792..55e0cf2 100644
--- a/assets/css/_bootstrap-selection.less
+++ b/assets/css/_bootstrap-selection.less
@@ -12,7 +12,7 @@
@import "bootstrap-3.3.2/type.less";
//@import "bootstrap-3.3.2/code.less";
@import "bootstrap-3.3.2/grid.less";
-//@import "bootstrap-3.3.2/tables.less";
+@import "bootstrap-3.3.2/tables.less";
@import "bootstrap-3.3.2/forms.less";
@import "bootstrap-3.3.2/buttons.less";
diff --git a/assets/css/_structure.less b/assets/css/_structure.less
index a465bad..be74c43 100644
--- a/assets/css/_structure.less
+++ b/assets/css/_structure.less
@@ -127,3 +127,12 @@ body.feedback {
.well();
}
}
+
+body.feedback-read {
+ td {
+ white-space: nowrap;
+ &.issuetext {
+ white-space: normal;
+ }
+ }
+}
diff --git a/model/Feedback.php b/model/Feedback.php
index 7ba697d..578650a 100644
--- a/model/Feedback.php
+++ b/model/Feedback.php
@@ -45,4 +45,40 @@ class Feedback extends ModelBase
'issuetext' => $info['issuetext'],
));
}
+
+ public function isLoggedIn()
+ {
+ return
+ isset($_SERVER['PHP_AUTH_USER']) &&
+ $_SERVER['PHP_AUTH_USER'] == $this->get('FEEDBACK.USERNAME') &&
+ $_SERVER['PHP_AUTH_PW'] == $this->get('FEEDBACK.PASSWORD');
+ }
+
+ public function requestLogin()
+ {
+ header('WWW-Authenticate: Basic realm="Kadse?"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'You are no real Winkekatzenoperator!!!1!';
+ exit;
+ }
+
+ public function read($from, $to)
+ {
+ $db = new PDO($this->get('FEEDBACK.DSN'));
+ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ $stm = $db->prepare('
+ SELECT *
+ FROM feedback
+ WHERE reported BETWEEN :from AND :to
+ ');
+ $stm->setFetchMode(PDO::FETCH_ASSOC);
+
+ $stm->execute(array(
+ 'from' => $from,
+ 'to' => $to,
+ ));
+
+ return $stm;
+ }
}
diff --git a/template/feedback-read.phtml b/template/feedback-read.phtml
new file mode 100644
index 0000000..6886181
--- /dev/null
+++ b/template/feedback-read.phtml
@@ -0,0 +1,77 @@
+<div class="container">
+ <h1><?=h($title)?></h1>
+ <form action="feedback/read/" method="POST">
+
+ <div class="row">
+ <div class="col-xs-12">
+ <div class="form-inline">
+
+ <div class="form-group">
+ <label class="sr-only" for="from">From Date</label>
+ <div class="input-group">
+ <div class="input-group-addon">From:</div>
+ <input type="date" class="form-control" name="from" id="from" value="<?=h(date('Y-m-d', $from))?>">
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="sr-only" for="to">To Date</label>
+ <div class="input-group">
+ <div class="input-group-addon">To:</div>
+ <input type="date" class="form-control" name="to" id="to" value="<?=h(date('Y-m-d', $to))?>">
+ </div>
+ </div>
+
+ <button type="submit" class="btn btn-primary">Filter</button>
+ </div>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="col-xs-12">
+ <div class="form-inline">
+ <? foreach($allcolumns as $column): ?>
+ <label class="checkbox-inline">
+ <input
+ type="checkbox"
+ name="col[]"
+ value="<?=h($column)?>"
+ <? if(in_array($column, $columns)): ?>checked<? endif ?>
+ > <?=h($column)?>
+ </label>
+ <? endforeach ?>
+ </div>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="col-xs-12">
+ <table class="table table-striped table-hover">
+ <thead>
+ <tr>
+ <? foreach($columns as $column): ?>
+ <th class="<?=h($column)?>"><?=h($column)?></th>
+ <? endforeach ?>
+ </tr>
+ </thead>
+ <tbody>
+ <? foreach($responses as $response): ?>
+ <tr>
+ <? foreach($columns as $column): ?>
+ <td class="<?=h($column)?>">
+ <? if($column == 'reported' || $column == 'datetime'): ?>
+ <?=h(date('Y-m-d H:i:s', $response[$column]))?>
+ <? else: ?>
+ <?=h($response[$column])?>
+ <? endif ?>
+ </td>
+ <? endforeach ?>
+ </tr>
+ <? endforeach ?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ </form>
+</div>
diff --git a/view/feedback-read.php b/view/feedback-read.php
new file mode 100644
index 0000000..4f04a02
--- /dev/null
+++ b/view/feedback-read.php
@@ -0,0 +1,29 @@
+<?php
+
+$feedback = new Feedback();
+if(!$feedback->isEnabled())
+ throw new NotFoundException('Feedback is disabled');
+
+if(!$feedback->isLoggedIn())
+{
+ $feedback->requestLogin();
+ exit;
+}
+
+$from = isset($_POST['from']) ? strtotime($_POST['from']) : strtotime('2000-01-01');
+$to = isset($_POST['to']) ? strtotime($_POST['to']) : time() + 24*60*60;
+$cols = isset($_POST['col']) ? $_POST['col'] : array('reported', 'issuetext');
+
+$allcols = array('reported', 'datetime', 'net', 'os', 'player', 'stream', 'ipproto_v4', 'ipproto_v6', 'provider', 'issues', 'issuetext');
+
+echo $tpl->render(array(
+ 'page' => 'feedback-read',
+ 'title' => 'Read Feedback',
+
+ 'from' => $from,
+ 'to' => $to,
+ 'responses' => $feedback->read($from, $to),
+
+ 'columns' => array_intersect($allcols, $cols),
+ 'allcolumns' => $allcols,
+));