From 7a163c226c99eb97fb9ce59ce5774da513bcdfd1 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Tue, 31 Mar 2015 21:38:03 +0200 Subject: Feedback Read-View --- assets/css/_bootstrap-selection.less | 2 +- assets/css/_structure.less | 9 +++++ model/Feedback.php | 36 +++++++++++++++++ template/feedback-read.phtml | 77 ++++++++++++++++++++++++++++++++++++ view/feedback-read.php | 29 ++++++++++++++ 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 template/feedback-read.phtml create mode 100644 view/feedback-read.php 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 @@ +
+

+
+ +
+
+
+ +
+ +
+
From:
+ +
+
+ +
+ +
+
To:
+ +
+
+ + +
+
+
+ +
+
+
+ + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+ +
+
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 @@ +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, +)); -- cgit v1.2.3