-
Notifications
You must be signed in to change notification settings - Fork 0
/
getstatdata.php
50 lines (40 loc) · 1.39 KB
/
getstatdata.php
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
49
50
<?php
require_once('../inc/sql.php');
require_once('../inc/init.php');
try {
$pdo = new PDO('mysql:host='.$db_server.';dbname='.$db_name, $db_user, $db_pw);
} catch (Exception $e) {
die("Internal server error while processing statistic data: Couldn't connect to database");
}
PMF_Init::cleanRequest();
$dat = unserialize(@$_POST['systemdata']);
if (!is_array($dat)) {
die("Internal server error while processing statistic data: Bad input!");
}
$dat['q'] = @$_POST['q'];
// special tratment for extension list:
$dat['PHP']['extensions'] = @implode($dat['PHP']['extensions'], '|');
$dat['q']['other'] = (string)@implode($dat['q']['other'], '|');
$fields = array();
$values = array();
foreach ($pdo->query("SHOW COLUMNS FROM stat") as $row)
{
if ($row['Field'] == 'id' || $row['Field'] == 'report_date') {
continue;
}
list($prefix, $field) = explode('_', $row['Field'], 2);
if (isset($dat[$prefix][$field]) && !is_null($dat[$prefix][$field])) {
$fields[] = '`'.$row['Field'].'`';
$values[] = @$dat[$prefix][$field];
}
}
$sql = sprintf("INSERT INTO %s (%s) VALUES (%s)",
'stat',
implode(', ', $fields),
implode(', ', array_fill(0, sizeof($fields), '?')));
$stmt = $pdo->prepare($sql);
foreach ($values as $key => $value) {
$stmt->bindValue($key + 1, $value);
}
$stmt->execute();
echo '<p>Thank you for yur support! Have fun with your FAQ!</p>';