summaryrefslogtreecommitdiff
path: root/templates/themes/staffapplication/staffapplicationpost.php
blob: 6e27f9325178d955d7a109843bafa47bb23cd15e (plain)
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
<?php 
$name = $contactmethod = $email = $application = $antispam = $displaymessage = "";
require '/var/www/html/inc/functions.php';
if (isset ($_POST["antispam"])){
	if ($_POST["antispam"] == "DUCK"){
	$namecheck = ! empty($_POST["name"]);
	$contactmethodcheck = $_POST["contactmethod"] == "email";
	$emailcheck = ! empty($_POST["email"]);
	$emailischecked = $contactmethodcheck ?  $emailcheck : true;

	if ($emailischecked && $namecheck){
		$name = $_POST["name"];	
		$contactmethod = $_POST["contactmethod"];	
		$email = $_POST["email"];	
		$application = $_POST["application"];	
		$antispam = $_POST["antispam"];	
		$to = "admin@lainchan.org";
		$subject = "Lainchan.org Staff Application for " . $name;
		
		$message = "Name: " . $name . "\r\n";
		$message .= "Contact method: " . $contactmethod . "\r\n";
		$message .= $application;
		$message = wordwrap($message, 70, "\r\n");
		
		$source = $emailcheck ? $email : $to;

		if(filter_var($source, FILTER_VALIDATE_EMAIL) && !preg_match('/[\r\n]/', $source)) {
			$headers = 'From: ' . $source . "\r\n" .
				'Reply-To: ' . $source . "\r\n" .
				'X-Mailer: PHP/' . phpversion();
			$sent = mail($to, $subject, $message, $headers);
			$sentmessage = $sent ? "was submitted successfully.</p>\r\n" : "was unable to be submitted.</p>\r\n";
			$displaymessage = "<p style=\"text-align:center;\"> Your staff application " . $sentmessage; 
		}
		else {
			$displaymessage = "<p style=\"text-align: center;\">INVALID EMAIL ADDRESS</p>";
		}
	}	

	}
	else
	{
        $displaymessage =  "<p style=\"text-align:center;\">ANTISPAM VALUE INCORRECT</p>\r\n"; 
	
	}
}
else {
$displaymessage = "<p style=\"text-align:center;\">ANTISPAM NOT SET</p>\r\n"; 
}
$displaymessage .= '<span style="text-align:center; display: block;" >[ <a href="https://lainchan.org/"> Return Home </a> ]</span>';

echo Element('page.html', ['index' => $config['root'], 'title' => _('Staff Application'), 'config' => $config, 'boardlist' => createBoardlist($mod ?? false), 'body' => $displaymessage]
	);
?>