-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertions.php
182 lines (157 loc) · 6.43 KB
/
convertions.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Respostas do Questionário</title>
<!-- Incluindo Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<style>
::-webkit-scrollbar {
width: 10px;
background-color: #333;
transition: background-color 0.3s ease;
}
::-webkit-scrollbar-thumb {
background-color: #888;
transition: background-color 0.3s ease;
}
::-webkit-scrollbar-track {
background-color: #222;
transition: background-color 0.3s ease;
}
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('/assets/land-bg.jpeg') center/cover no-repeat;
}
.wrapper {
width: 100%;
max-width: 1200px;
}
.user-container {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 12px;
margin-bottom: 20px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.3s ease;
}
.user-container:hover {
transform: translateY(-5px);
}
.user-info {
font-weight: bold;
margin-bottom: 15px;
}
.user-info h3 {
color: #3498db;
font-size: 1.8rem;
margin-top: 0;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #ddd;
}
.user-info p {
margin: 5px 0;
}
.answers-list {
list-style-type: none;
padding: 0;
margin-top: 15px;
}
.answer-item {
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.answer-item:last-child {
border-bottom: none;
}
.answer-label {
font-weight: bold;
color: #3498db;
width: 150px;
display: inline-block;
}
.answer-value {
color: #666;
}
.fa-icon {
margin-right: 5px;
}
@media screen and (max-width: 600px) {
.user-container {
border-radius: 0;
border-left: none;
border-right: none;
}
}
</style>
</head>
<body>
<div class="wrapper">
<?php
// Conexão com o banco de dados usando PDO
$dsn = 'sqlite:questionnaire.db';
try {
$pdo = new PDO($dsn);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Consulta para obter todas as respostas organizadas por usuário
$query = 'SELECT user_info.id, user_info.user_hash, user_info.ip_address, user_info.browser_info, user_info.language,
user_info.country, user_info.region, user_info.currency, user_info.mobile, user_info.proxy, user_info.hosting,
questions_answers.input_name, questions_answers.input_value, questions_answers.received_at
FROM questions_answers
INNER JOIN user_info ON questions_answers.user_id = user_info.id
ORDER BY user_info.user_hash, questions_answers.received_at';
$stmt = $pdo->query($query);
$current_user_hash = null;
// Loop para exibir as respostas
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
// Se mudou de usuário, inicia um novo container de usuário
if ($row['user_hash'] !== $current_user_hash) {
// Fechar o container anterior, se necessário
if ($current_user_hash !== null) {
echo '</ul></div>';
}
// Iniciar novo container para o usuário
echo '<div class="user-container">';
echo '<div class="user-info">';
echo '<h3><i class="fas fa-user fa-icon"></i>IP: ' . $row['ip_address'];
if ($row['mobile'] == true) {
echo '<i class="fas fa-mobile-alt fa-icon" title="Acessando via dispositivo móvel"></i>';
}
echo '</h3>';
echo '<p><i class="fas fa-globe-americas fa-icon"></i><span class="answer-label">País:</span> <span class="answer-value">' . $row['country'] . '</span></p>';
echo '<p><i class="fas fa-map-marker-alt fa-icon"></i><span class="answer-label">Região/Estado:</span> <span class="answer-value">' . $row['region'] . '</span></p>';
echo '<p><i class="fas fa-money-bill-wave fa-icon"></i><span class="answer-label">Moeda:</span> <span class="answer-value">' . $row['currency'] . '</span></p>';
echo '<p><i class="fas fa-info-circle fa-icon"></i><span class="answer-label">Informações do Navegador:</span> <span class="answer-value">' . $row['browser_info'] . '</span></p>';
echo '<p><i class="fas fa-language fa-icon"></i><span class="answer-label">Idioma:</span> <span class="answer-value">' . $row['language'] . '</span></p>';
echo '</div>'; // fecha user-info
echo '<ul class="answers-list">';
$current_user_hash = $row['user_hash'];
}
// Exibir cada resposta dentro do container do usuário atual
echo '<li class="answer-item">';
echo '<p><span class="answer-label">' . str_replace('_', ' ', ucfirst($row['input_name'])) . ':</span> <span class="answer-value">' . $row['input_value'] . '</span></p>';
echo '<p><span class="answer-label">Recebido em:</span> <span class="answer-value">' . $row['received_at'] . '</span></p>';
echo '</li>';
}
// Fechar o último container de usuário
if ($current_user_hash !== null) {
echo '</ul></div>';
}
// Fechar a conexão com o banco de dados
$pdo = null;
} catch (PDOException $e) {
echo '<p>Erro ao conectar ao banco de dados: ' . $e->getMessage() . '</p>';
}
?>
</div>
</body>
</html>