-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.class.php
94 lines (79 loc) · 2.49 KB
/
request.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
<?php
class Request extends Preset implements iRequest {
public function recipient($recipient) {
$this->recipient = $recipient;
}
public function method($method) {
$this->setMethod($method);
}
public function confirm($suc, $fail) {
$this->success_msg = $suc;
$this->fail_msg = $fail;
}
protected function assign() {
$mess = null;
$n = (($this->debug == "on") ? "\n<br>" : "\n");
foreach ($this->inputFields() as $field) {
$mask = function($label = null) use ($mess, $n, $field) {
return $n.($label ? $label : ucfirst($field)).": ".$this->fields[$field];
};
if (!is_null(($this->fields[$field]))) {
switch ($field) {
case "name": $mess .= $mask("From"); break;
case "email": $mess .= $mask("eMail"); break;
case "zip": $mess .= $mask("ZIP Code"); break;
case "bic": $mess .= $mask("BIC"); break;
case "address": case "website": case "subject": case "title":
case "firstname": case "middlename": case "lastname": case "location":
case "country": case "phone": case "mobile": case "fax": case "company":
case "facebook": case "twitter": case "birth": $mess .= $mask(); break;
case "content": $mess .= $n.$n.$this->send->content; break;
default: $this->msg(0, __METHOD__.": Unknown input field: {$field}".$n); break;
}
}
}
return $mess;
}
protected function setMail() {
if ($this->debug == "on") {
$rep = str_repeat(" ",4);
$this->msg(3, "eMail Test Output:");
echo $rep."Recipient : ".$this->recipient."<br>"
.$rep."Mail Header : ".$this->m_header."<br>"
.$rep."Subject : <strong>".$this->fields["subject"]."</strong><br>"
.$rep."Content : ".$this->message."<br>";
} else {
$send = mail(
$this->recipient,
$this->fields["subject"],
$this->message,
$this->m_header
);
if ($send) {
$this->status["sent"] = 1;
echo $this->success_msg;
} else {
$this->status["fail"] = 1;
echo $this->fail_msg;
}
}
}
public function getName() {
$names = null;
foreach ($this->fields as $field => $val) {
$mask = function() use ($field) {
$f = $this->fields[$field];
$ifnull = is_null($f) ? null : $f;
return $ifnull." ";
};
switch ($field) {
case "title": case "name": case "firstname":
case "middlename": case "lastname":
$names .= $mask(); break;
default: break;
}
}
return $names;
}
}
?>