aboutsummaryrefslogtreecommitdiff
path: root/model/Feedback.php
blob: 7ba697d24a36f6a04295f700785c5b39db24a37f (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
42
43
44
45
46
47
48
<?php

class Feedback extends ModelBase
{
	public function isEnabled() {
		return $this->has('FEEDBACK');
	}
	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'],
		));
	}
}