-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendform.php
More file actions
executable file
·97 lines (82 loc) · 2.48 KB
/
sendform.php
File metadata and controls
executable file
·97 lines (82 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// Universal Send Form via Email
// Date: 20080915
set_include_path(get_include_path().PATH_SEPARATOR.$_SERVER['DOCUMENT_ROOT']."/includes/");
include "global.php";
// Parse server variables
//foreach($_SERVER as $key => $value) { echo "$key: $value<br />"; }
//die;
// Future: reject foreign posts
/*
if($_SERVER['HTTP_REFERER'] != $site_domain){
echo "Bad Request";
die();
}
//$success_url
//$failure_url
*/
$email_subject = "";
$email_headers = "";
$email_message = "";
//This section handles known form variables
foreach($_POST as $key => $value) {
switch (strtolower($key)) {
case "subject":
$email_subject = htmlentities(trim($value), ENT_NOQUOTES);
break;
case "email":
$email_headers .= "From: ".htmlentities(trim($value), ENT_NOQUOTES)."\r\n";
break;
case "carboncopy":
$email_headers .= "Cc: ".htmlentities(trim($_POST['email']), ENT_NOQUOTES)."\r\n";
break;
case "file":
$fileatt = ""; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data));
$email_message .= "Content-Type: {$fileatt_type};\n" .
"name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
break;
default:
$email_message .= "$key: ".htmlentities(trim($value), ENT_NOQUOTES)."\r\n";
}
}
//echo $email_message;
if(isset($_POST['file'])){
// multipart message encoding (file attachment included)
} else {
// text message encoding
}
$result = mail($site_emailaddress, $email_subject, $email_message)
//$result = mail($site_emailaddress, $email_subject, $email_message, $email_headers)
if($result){
if($redirect_url){
//header redirect_url //redirect to page
} else {
echo "Message Sent Successfully."; //show success message
}
}
else {
echo "An error occurred while sending your message."; //show error message
}
//cleanup vars
unset($email_subject);
unset($email_headers);
unset($email_message);
unset($data);
unset($file);
unset($fileatt);
unset($fileatt_type);
unset($fileatt_name);
?>