-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemm.class.php
106 lines (87 loc) · 2.51 KB
/
emm.class.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
<?php
/*
eMM v1.2
(c) 2016 Michel Thiel
thielicious.github.io
eMM ('eM' abbr. for eMail Manager) is a compact contact form builder including all
its adjustments for personal desires. This API simplifies the flexible use of several
input fields which will be used to send and transport data through a classical mailing
process. Useful for setting up customer email services and newsletters.
Visit thielicious.github.io for a detailed documentation
API scheme:
eMM.class.php
preset.class.php
request.class.php
news.class.php
utilities.inc.php
aLoad.class.php
_____________________________________________________________________________________________________
*/
require_once "utilities.inc.php";
class eMM implements iBase {
use Debugger, Fields;
protected
$recipient = null, $m_header = "From: Incoming Customer Enquiry",
$message = null, $send = null,
$success_msg = "Thank you!<br> Your enquiry has been sent.<br>",
$fail_msg = "All fields are required to be sent.<br>",
$status = array(
"sent" => null,
"fail" => null,
"mysql" => null
),
$method = array(
"post" => null,
"json" => null
);
public function __construct($method = null) {
if (!is_null($method)) {
$this->setMethod($method);
}
}
protected function inputFields() {
$get = array();
if (isset($_POST["send"])) {
if ($this->method["json"] == 1) {
foreach (json_decode($_POST["send"]) as $key => $val) {
if ($val != null) {
$get[] = $key;
}
}
return $get;
}
if ($this->method["post"] == 1) {
foreach ($_POST as $key => $val) {
if ($key != "send") {
if ($val != null) {
$get[] = $key;
}
}
}
return $get;
}
}
}
protected function setMethod($method) {
if (is_null($this->method["json"]) || is_null($this->method["post"])) {
if ($method == "post" || "json") {
$this->method[$method] = 1;
$this->decode();
} else {
$this->msg(0, __METHOD__.": Unknown method.");
}
} else {
$this->msg(0, __METHOD__.": Method already set.");
}
}
protected function decode() {
if ($this->method["json"] == 1) {
$this->send = json_decode($_POST["send"]);
$this->assignData("json", "Receiving Json Key Data...");
} elseif($this->method["post"] == 1) {
$this->send = json_decode(json_encode($_POST));
$this->assignData("post", "Receiving POST Key Data...");
}
}
}
?>