-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmission.php
52 lines (41 loc) · 1.7 KB
/
submission.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
<?php
include('config.php');
// Function to get the user's IP address
function getUserIP() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
// IP from shared internet
return $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// IP passed from a proxy
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
// Default IP address
return $_SERVER['REMOTE_ADDR'];
}
}
// Captcha verification
session_start();
if ($_POST['captcha'] !== $_SESSION['captcha']) {
die("Invalid Captcha");
}
// Sanitize form data
$discord_id = filter_input(INPUT_POST, 'discord_id', FILTER_SANITIZE_STRING);
$steam_id = filter_input(INPUT_POST, 'steam_id', FILTER_SANITIZE_STRING);
$console_id = filter_input(INPUT_POST, 'console_id', FILTER_SANITIZE_STRING);
$reason = filter_input(INPUT_POST, 'reason', FILTER_SANITIZE_STRING);
$submitted_by_ip = getUserIP();
$steam_id = !empty(trim($steam_id)) ? $steam_id : null;
$console_id = !empty(trim($console_id)) ? $console_id : null;
try {
$stmt = $pdo->prepare("INSERT INTO submissions (discord_id, steam_id, console_id, reason, submitted_by_ip) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$discord_id, $steam_id, $console_id, $reason, $submitted_by_ip]);
// Notify admin
//include('email_notify.php');
//sendNotification($discord_id, $reason);
echo "<h3>Form submitted successfully!</h3>";
echo "<p><strong>Your blacklisting will be reviewed by an administrator soon and if found valid, it'll be approved.</strong></p>";
echo "<p><a href=index.php>Return to main page</a> or <a href=submit.php>submit another</a></p>";
} catch (PDOException $e) {
die("Error: " . $e->getMessage());
}
?>