-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathemailTrackGenerate.php
More file actions
83 lines (77 loc) · 2.48 KB
/
emailTrackGenerate.php
File metadata and controls
83 lines (77 loc) · 2.48 KB
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
<?php
ob_clean();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
require_once("util.php");
echo '
<style>
table, th, td {
text-align: center;
}
</style>
';
function createTracker($to) {
$sql = SQLCon::getSQL();
$stmt = $sql->prepStmt("INSERT INTO EmailTracking (sent_to) VALUES (:to)");
$sql->bindParam($stmt, ":to", $to);
if ($sql->execute($stmt)) {
$res = $sql->sQuery("SELECT id FROM EmailTracking ORDER BY timestamp DESC limit 1")->fetch();
return $res[0];
} else {
return false;
}
}
function getViews($id) {
$sql = SQLCon::getSQL();
$stmt = $sql->prepStmt("SELECT * FROM EmailViews WHERE email_track_id = :id ORDER BY timestamp DESC");
$sql->bindParam($stmt, ":id", $id);
$result = $sql->execute($stmt)->fetchAll();
return $result;
}
function getTrackers() {
$sql = SQLCon::getSQL();
$stmt = $sql->prepStmt("SELECT * FROM EmailTracking ORDER BY timestamp DESC");
$result = $sql->execute($stmt)->fetchAll();
return $result;
}
if ($_SERVER['REQUEST_METHOD'] == "GET")
{
if (isset($_GET["to"])) {
$trackerID = createTracker($_GET["to"]);
if ($trackerID !== false) {
$imgStr = '<img src="https://vadweb.us/emailTrack.php?id=';
$imgStr .= $trackerID . '" width="1" height="1">';
echo htmlspecialchars($imgStr);
echo "<br>";
echo '<a href="https://vadweb.us/emailTrackGenerate.php?check=' . $trackerID . '"> Track here </a>';
exit();
}
} else if (isset($_GET["check"])) {
$views = getViews($_GET["check"]);
echo '<table style="width: 100%"';
echo '<tr>
<th> Timestamp </th>
<th> IP </th>
<th> Device </th>
</tr>';
foreach($views as $view) {
printf("<tr> <td>%s</td> <td>%s</td> <td>%s</td> </tr>", $view[2], $view[3], $view[4]);
}
echo '</table>';
} else if (isset($_GET["view"])) {
$trackers = getTrackers();
echo '<table style="width: 100%"';
echo '<tr>
<th> Timestamp </th>
<th> Sent To </th>
<th> Link </th>
</tr>';
foreach($trackers as $view) {
printf("<tr> <td>%s</td> <td>%s</td> <td><a href=emailTrackGenerate.php?check=%s>Check</a></td> </tr>", $view[2], $view[1], $view[0]);
}
echo '</table>';
} else {
echo "Error!";
}
}
?>