-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidatedeldel.php
116 lines (98 loc) · 5.75 KB
/
validatedeldel.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
<?php
if (!isset($_GET['valcode']))
{
http_response_code(404);
die();
}
?>
<?php
define('index_origin', true);
include 'db.inc.php';
?>
<?php
$valcode = $_GET['valcode'];
$querycodeexisting = "SELECT id FROM validate_del_strikes_del WHERE code = ?;";
$prepcodeexisting = mysqli_prepare($db, $querycodeexisting);
mysqli_stmt_bind_param ($prepcodeexisting, 's', $valcode);
mysqli_stmt_execute($prepcodeexisting);
$resultcodeexisting = mysqli_stmt_get_result($prepcodeexisting);
if(mysqli_num_rows($resultcodeexisting) == "0") {
#Message when someone already used his validation link
echo "Obacht... Du hast schon auf den Link geklickt...";
}
else
{
$querypsdid = "SELECT pending_strikes_del.id FROM pending_strikes_del INNER JOIN pending_del_strikes_del ON pending_strikes_del.id = pending_del_strikes_del.psdid INNER JOIN validate_del_strikes_del ON pending_del_strikes_del.id = validate_del_strikes_del.pdsdid WHERE validate_del_strikes_del.code = ?;";
$preppsdid = mysqli_prepare($db, $querypsdid);
mysqli_stmt_bind_param ($preppsdid, 's', $valcode);
mysqli_stmt_execute($preppsdid);
$resultpsdid = mysqli_stmt_get_result($preppsdid);
while ($row = $resultpsdid->fetch_assoc()) {
$psdid = $row['id'];
}
$querydata = "SELECT validations_needed, validations_acc, validated FROM pending_del_strikes_del INNER JOIN validate_del_strikes_del ON pending_del_strikes_del.id = validate_del_strikes_del.pdsdid WHERE validate_del_strikes_del.code = ?;";
$prepdata = mysqli_prepare($db, $querydata);
mysqli_stmt_bind_param ($prepdata, 's', $valcode);
mysqli_stmt_execute($prepdata);
$resultdata = mysqli_stmt_get_result($prepdata);
while ($row = $resultdata->fetch_assoc()) {
$validated = $row['validated'];
$validations_needed = $row['validations_needed'];
$validations_acc = $row['validations_acc'];
}
$validations_left = abs($validations_needed - $validations_acc);
if ($validated) {
#Message when pending strike is already validated
echo "Zu langsam... Strike wurde bereits validiert!";
$querydelcode = "DELETE FROM validate_del_strikes_del WHERE code = ?;";
$prepdelcode = mysqli_prepare($db, $querydelcode);
mysqli_stmt_bind_param ($prepdelcode, 's', $valcode);
mysqli_stmt_execute($prepdelcode);
$resultdelcode = mysqli_stmt_get_result($prepdelcode);
}
else
{
if ($validations_left > "1") {
$querysetvalidations_acc = "UPDATE pending_del_strikes_del INNER JOIN validate_del_strikes_del ON pending_del_strikes_del.id = validate_del_strikes_del.pdsdid SET validations_acc = validations_acc + 1 WHERE validate_del_strikes_del.code = ?;";
$prepsetvalidations_acc = mysqli_prepare($db, $querysetvalidations_acc);
mysqli_stmt_bind_param ($prepsetvalidations_acc, 's', $valcode);
mysqli_stmt_execute($prepsetvalidations_acc);
$resultsetvalidations_acc = mysqli_stmt_get_result($prepsetvalidations_acc);
$validations_left = $validations_left - 1;
echo "Validation wurde mit dem Code " . htmlspecialchars($valcode) . " erfolgreich durchgeführt! Es fehlen noch " . htmlspecialchars($validations_left) . " Validierungen!";
$querydelcode = "DELETE FROM validate_del_strikes_del WHERE code = ?;";
$prepdelcode = mysqli_prepare($db, $querydelcode);
mysqli_stmt_bind_param ($prepdelcode, 's', $valcode);
mysqli_stmt_execute($prepdelcode);
$resultdelcode = mysqli_stmt_get_result($prepdelcode);
} elseif ($validations_left == "1") {
$querysetvalidations_acc = "UPDATE pending_del_strikes_del INNER JOIN validate_del_strikes_del ON pending_del_strikes_del.id = validate_del_strikes_del.pdsdid SET validations_acc = validations_acc + 1 WHERE validate_del_strikes_del.code = ?;";
$prepsetvalidations_acc = mysqli_prepare($db, $querysetvalidations_acc);
mysqli_stmt_bind_param ($prepsetvalidations_acc, 's', $valcode);
mysqli_stmt_execute($prepsetvalidations_acc);
$resultsetvalidations_acc = mysqli_stmt_get_result($prepsetvalidations_acc);
$querydelvalstrikedel = "DELETE FROM validate_strikes_del WHERE psdid = ?;";
$prepdelvalstrikedel = mysqli_prepare($db, $querydelvalstrikedel);
mysqli_stmt_bind_param ($prepdelvalstrikedel, 'i', $psdid);
mysqli_stmt_execute($prepdelvalstrikedel);
$resultdelvalstrikedel = mysqli_stmt_get_result($prepdelvalstrikedel);
$querydelcode = "DELETE FROM validate_del_strikes_del WHERE code = ?;";
$prepdelcode = mysqli_prepare($db, $querydelcode);
mysqli_stmt_bind_param ($prepdelcode, 's', $valcode);
mysqli_stmt_execute($prepdelcode);
$resultdelcode = mysqli_stmt_get_result($prepdelcode);
$querydelpendingdelstrikedel = "UPDATE pending_del_strikes_del SET validated = '1' WHERE psdid = ?;";
$prepdelpendingdelstrikedel = mysqli_prepare($db, $querydelpendingdelstrikedel);
mysqli_stmt_bind_param ($prepdelpendingdelstrikedel, 'i', $psdid);
mysqli_stmt_execute($prepdelpendingdelstrikedel);
$resultdelpendingdelstrikedel = mysqli_stmt_get_result($prepdelpendingdelstrikedel);
$querydelpendingstrike = "UPDATE pending_strikes_del psd INNER JOIN pending_del_strikes_del pdsd ON psd.id = pdsd.psdid SET deleted = '1' WHERE psd.id = ?;";
$prepdelpendingstrike = mysqli_prepare($db, $querydelpendingstrike);
mysqli_stmt_bind_param ($prepdelpendingstrike, 'i', $psdid);
mysqli_stmt_execute($prepdelpendingstrike);
$resultdelpendingstrike = mysqli_stmt_get_result($prepdelpendingstrike);
echo "Validation wurde mit dem Code " . htmlspecialchars($valcode) . " erfolgreich durchgeführt! Alle " . htmlspecialchars($validations_needed) . " Validationen sind erfolgt. Der Strike-Del wurde erfolgreich abgebrochen!";
}
}
}
?>