aboutsummaryrefslogtreecommitdiff
path: root/view/feedback.php
blob: 7417f24b9e47e4a3515d0e9a302bf7399bddb790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

if(
	!isset($_POST['datetime']) ||
	!isset($_POST['net']) ||
	!isset($_POST['os']) ||
	!isset($_POST['player']) ||
	!isset($_POST['stream']) ||
	!isset($_POST['provider']) ||
	!isset($_POST['issuetext'])
) {
	echo $tpl->render(array(
		'page' => 'feedback',
		'title' => 'Give Feedback',
		'room' => null,
	));
}
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'],
	));
}