-
Notifications
You must be signed in to change notification settings - Fork 71
/
save-reports.php
76 lines (68 loc) · 3.67 KB
/
save-reports.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
<?php
$tool = $_POST["tool_selected"];
$command_executed = $_POST["command_executed"];
$report_name = $_POST["report_name"];
$output_data = $_POST["output_data"];
include('assets/includes/config.php');
$con = getConnectionDB() or die ("Could not connect to database.");
$sql = $con->prepare("SELECT solution FROM tools WHERE name = '$tool' ");
if ($sql->execute()) {
$resultados = $sql->fetchAll(PDO::FETCH_ASSOC);
// FOREACH BEGINS
foreach ($resultados as $resultado) {
$solution = $resultado["solution"];
$sql2 = $con->prepare("INSERT INTO reports (name, command, tools, output, solution, dataHour) VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
if ($sql2->execute(array ($tool, $command_executed, $report_name, $output_data, $solution))) {
echo
"
<div class='card card-stats zoom-effect'>
<div class='card-body'>
<div class='row'>
<div class='col'>
<h5 class='card-title text-uppercase text-muted mb-0'>Save to reports</h5>
<span class='h3 font-weight-bold mb-0'>
<input id='report-name' type='text' class='form-control form-control-alternative' name='report-name' placeholder='Choose a name to this report'>
</span>
</div>
<div class='col-auto'>
<div class='icon icon-shape bg-yellow text-white rounded-circle shadow'>
<i class='ni ni-single-copy-04'></i>
</div>
</div>
</div>
<p class='mt-3 mb-0 text-muted text-sm'>
</p>
<textarea id='command-executed' hidden>".$run."</textarea>
<button class='btn btn-success' disabled onclick='save()'><i class='ni ni-single-copy-04'></i> Save to Reports</button><span class='alert-inner--text text-green'><strong>Success!</strong> Save to reports successfully!</span>
</div>
</div>
";
}
}
} else {
echo
"
<div class='card card-stats zoom-effect'>
<div class='card-body'>
<div class='row'>
<div class='col'>
<h5 class='card-title text-uppercase text-muted mb-0'>Save to reports</h5>
<span class='h3 font-weight-bold mb-0'>
<input id='report-name' type='text' class='form-control form-control-alternative' name='report-name' placeholder='Choose a name to this report'>
</span>
</div>
<div class='col-auto'>
<div class='icon icon-shape bg-yellow text-white rounded-circle shadow'>
<i class='ni ni-single-copy-04'></i>
</div>
</div>
</div>
<p class='mt-3 mb-0 text-muted text-sm'>
</p>
<textarea id='command-executed' hidden>".$run."</textarea>
<button class='btn btn-success' onclick='save()'><i class='ni ni-single-copy-04'></i> Save to Reports</button><span class='alert-inner--text text-red'><strong>Error!</strong> Please, try again!</span>
</div>
</div>
";
}
?>