diff options
Diffstat (limited to '')
-rw-r--r-- | model/Feedback.php | 37 | ||||
-rw-r--r-- | view/feedback.php | 36 |
2 files changed, 43 insertions, 30 deletions
diff --git a/model/Feedback.php b/model/Feedback.php index 86ef886..7ba697d 100644 --- a/model/Feedback.php +++ b/model/Feedback.php @@ -8,4 +8,41 @@ class Feedback extends ModelBase public function getUrl() { return 'feedback/'; } + + public function validate($info) + { + return + isset($_POST['datetime']) || + isset($_POST['net']) || + isset($_POST['os']) || + isset($_POST['player']) || + isset($_POST['stream']) || + isset($_POST['provider']) || + isset($_POST['issuetext']); + } + + public function store($info) + { + $db = new PDO($this->get('FEEDBACK.DSN')); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $stm = $db->prepare(' + INSERT INTO feedback (reported, datetime, net, os, player, stream, ipproto_v4, ipproto_v6, provider, issues, issuetext) + VALUES (:reported, :datetime, :net, :os, :player, :stream, :ipproto_v4, :ipproto_v6, :provider, :issues, :issuetext) + '); + + $stm->execute(array( + 'reported' => time(), + 'datetime' => strtotime($info['datetime']), + 'net' => $info['net'], + 'os' => $info['os'], + 'player' => $info['player'], + 'stream' => $info['stream'], + 'ipproto_v4' => isset($info['ipproto']) && is_array($info['ipproto']) && in_array('v4', $info['ipproto']), + 'ipproto_v6' => isset($info['ipproto']) && is_array($info['ipproto']) && in_array('v6', $info['ipproto']), + 'provider' => $info['provider'], + 'issues' => isset($info['issues']) && is_array($info['issues']) ? implode(',', $info['issues']) : '', + 'issuetext' => $info['issuetext'], + )); + } } diff --git a/view/feedback.php b/view/feedback.php index 7417f24..73b0241 100644 --- a/view/feedback.php +++ b/view/feedback.php @@ -1,14 +1,9 @@ <?php -if( - !isset($_POST['datetime']) || - !isset($_POST['net']) || - !isset($_POST['os']) || - !isset($_POST['player']) || - !isset($_POST['stream']) || - !isset($_POST['provider']) || - !isset($_POST['issuetext']) -) { +$feedback = new Feedback(); +$info = $_POST; + +if(!$feedback->validate($info)) { echo $tpl->render(array( 'page' => 'feedback', 'title' => 'Give Feedback', @@ -17,25 +12,6 @@ if( } else { - $db = new PDO(get('FEEDBACK.DSN')); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - - $stm = $db->prepare(' - INSERT INTO feedback (reported, datetime, net, os, player, stream, ipproto_v4, ipproto_v6, provider, issues, issuetext) - VALUES (:reported, :datetime, :net, :os, :player, :stream, :ipproto_v4, :ipproto_v6, :provider, :issues, :issuetext) - '); - - $stm->execute(array( - 'reported' => time(), - 'datetime' => strtotime($_POST['datetime']), - 'net' => $_POST['net'], - 'os' => $_POST['os'], - 'player' => $_POST['player'], - 'stream' => $_POST['stream'], - 'ipproto_v4' => isset($_POST['ipproto']) && is_array($_POST['ipproto']) && in_array('v4', $_POST['ipproto']), - 'ipproto_v6' => isset($_POST['ipproto']) && is_array($_POST['ipproto']) && in_array('v6', $_POST['ipproto']), - 'provider' => $_POST['provider'], - 'issues' => isset($_POST['issues']) && is_array($_POST['issues']) ? implode(',', $_POST['issues']) : '', - 'issuetext' => $_POST['issuetext'], - )); + $feedback->store($info); + echo 1; } |