|
1
|
|
|
<?php |
|
2
|
|
|
// |
|
3
|
|
|
// ------------------------------------------------------------------------- // |
|
4
|
|
|
// XF Guestbook // |
|
5
|
|
|
// ------------------------------------------------------------------------- // |
|
6
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
7
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
8
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
9
|
|
|
// (at your option) any later version. // |
|
10
|
|
|
// // |
|
11
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
12
|
|
|
// of supporting developers from this source code or any supporting // |
|
13
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
14
|
|
|
// original comment or credit authors. // |
|
15
|
|
|
// // |
|
16
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
17
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
18
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
19
|
|
|
// GNU General Public License for more details. // |
|
20
|
|
|
// // |
|
21
|
|
|
// You should have received a copy of the GNU General Public License // |
|
22
|
|
|
// along with this program; if not, write to the Free Software // |
|
23
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
24
|
|
|
//---------------------------------------------------------------------------// |
|
25
|
|
|
|
|
26
|
|
|
use XoopsModules\Xfguestbook; |
|
27
|
|
|
|
|
28
|
|
|
require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
|
29
|
|
|
//** @var Xfguestbook\Helper $helper */ |
|
30
|
|
|
$helper = Xfguestbook\Helper::getInstance(); |
|
31
|
|
|
|
|
32
|
|
|
$op = 'form'; |
|
33
|
|
|
foreach ($_POST as $k => $v) { |
|
34
|
|
|
${$k} = $v; |
|
35
|
|
|
} |
|
36
|
|
|
foreach ($_GET as $k => $v) { |
|
37
|
|
|
${$k} = $v; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$email_user = \Xmf\Request::getString('email_user', ''); |
|
41
|
|
|
$title = \Xmf\Request::getString('title', ''); |
|
42
|
|
|
$message = \Xmf\Request::getString('message', ''); |
|
43
|
|
|
|
|
44
|
|
|
$phone = \Xmf\Request::getString('phone', ''); |
|
45
|
|
|
$name_user = \Xmf\Request::getString('name_user', ''); |
|
46
|
|
|
$email_author = \Xmf\Request::getString('email_author', ''); |
|
47
|
|
|
$preview = \Xmf\Request::getString('preview', ''); |
|
48
|
|
|
$post = \Xmf\Request::getString('post', ''); |
|
49
|
|
|
|
|
50
|
|
|
if (isset($preview)) { |
|
51
|
|
|
$op = 'preview'; |
|
52
|
|
|
} elseif (isset($post)) { |
|
53
|
|
|
$op = 'post'; |
|
54
|
|
|
} |
|
55
|
|
|
require_once __DIR__ . '/include/config.inc.php'; |
|
56
|
|
|
$option = getOptions(); |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param $title |
|
60
|
|
|
* @param $content |
|
61
|
|
|
*/ |
|
62
|
|
|
function displaypost($title, $content) |
|
63
|
|
|
{ |
|
64
|
|
|
echo '<table cellpadding="4" cellspacing="1" width="98%" class="outer"><tr><td class="head">' . $title . '</td></tr><tr><td><br>' . $content . '<br></td></tr></table>'; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
switch ($op) { |
|
68
|
|
|
case 'post': |
|
69
|
|
|
global $xoopsConfig; |
|
70
|
|
|
$ts = \MyTextSanitizer::getInstance(); |
|
71
|
|
|
xoops_header(); |
|
72
|
|
|
|
|
73
|
|
|
if (1 == $option['opt_code']) { |
|
74
|
|
|
xoops_load('XoopsCaptcha'); |
|
75
|
|
|
$xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
76
|
|
|
if (!$xoopsCaptcha->verify()) { |
|
77
|
|
|
redirect_header('index.php', 3, $xoopsCaptcha->getMessage()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
$fullmsg = MD_XFGUESTBOOK_FROMUSER . " $name_user " . MD_XFGUESTBOOK_YOURMSG . ' ' . $xoopsConfig['sitename'] . ' :<br><br>'; |
|
81
|
|
|
$fullmsg .= $title . '<br>'; |
|
82
|
|
|
$fullmsg .= '<hr><br>'; |
|
83
|
|
|
$fullmsg .= "$message<br><br>"; |
|
84
|
|
|
$fullmsg .= '<hr><br>'; |
|
85
|
|
|
$fullmsg .= MD_XFGUESTBOOK_CANJOINT . ' [email]' . $email_user . '[/email]'; |
|
86
|
|
|
|
|
87
|
|
|
$xoopsMailer = xoops_getMailer(); |
|
88
|
|
|
$xoopsMailer->useMail(); |
|
89
|
|
|
$xoopsMailer->setFromEmail($email_user); |
|
90
|
|
|
$xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
91
|
|
|
$xoopsMailer->setToEmails($email_author); |
|
92
|
|
|
$xoopsMailer->setSubject(MD_XFGUESTBOOK_CONTACTAFTERMSG); |
|
93
|
|
|
$xoopsMailer->multimailer->isHTML(true); |
|
94
|
|
|
$xoopsMailer->setBody($ts->xoopsCodeDecode($fullmsg)); |
|
95
|
|
|
$msgsend = "<div style='text-align:center;'><br><br>"; |
|
96
|
|
|
if (!$xoopsMailer->send()) { |
|
97
|
|
|
$msgsend .= $xoopsMailer->getErrors(); |
|
98
|
|
|
} else { |
|
99
|
|
|
$msgsend .= '<h4>' . MD_XFGUESTBOOK_MSGSEND . '</h4>'; |
|
100
|
|
|
} |
|
101
|
|
|
$msgsend .= '<br><br><a href="javascript:window.close();">' . MD_XFGUESTBOOK_CLOSEWINDOW . '</a></div>'; |
|
102
|
|
|
echo $msgsend; |
|
103
|
|
|
break; |
|
104
|
|
|
case 'preview': |
|
105
|
|
|
|
|
106
|
|
|
$ts = \MyTextSanitizer::getInstance(); |
|
107
|
|
|
xoops_header(); |
|
108
|
|
|
|
|
109
|
|
|
if (1 == $option['opt_code']) { |
|
110
|
|
|
xoops_load('XoopsCaptcha'); |
|
111
|
|
|
$xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
112
|
|
|
if (!$xoopsCaptcha->verify()) { |
|
113
|
|
|
redirect_header('index.php', 3, $xoopsCaptcha->getMessage()); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
$p_title = $title; |
|
118
|
|
|
$p_msg = MD_XFGUESTBOOK_FROMUSER . " $name_user " . MD_XFGUESTBOOK_YOURMSG . ' ' . $xoopsConfig['sitename'] . ' :<br>'; |
|
119
|
|
|
$p_msg .= $title . '<br>'; |
|
120
|
|
|
$p_msg .= '<hr><br>'; |
|
121
|
|
|
$p_msg .= $message . '<br><br>'; |
|
122
|
|
|
$p_msg .= '<hr><br>'; |
|
123
|
|
|
$p_msg .= MD_XFGUESTBOOK_CANJOINT . " $email_user"; |
|
124
|
|
|
|
|
125
|
|
|
$p_msg .= '<br>'; |
|
126
|
|
|
displaypost($p_title, $p_msg); |
|
127
|
|
|
|
|
128
|
|
|
require_once __DIR__ . '/include/form_contact.inc.php'; |
|
129
|
|
|
xoops_footer(); |
|
130
|
|
|
break; |
|
131
|
|
|
case 'form': |
|
132
|
|
|
default: |
|
133
|
|
|
|
|
134
|
|
|
xoops_header(); |
|
135
|
|
|
$msgHandler = $helper->getHandler('Message'); |
|
136
|
|
|
$msg = $msgHandler->get($msg_id); |
|
137
|
|
|
if (!$msg) { |
|
|
|
|
|
|
138
|
|
|
redirect_header('index.php', 3, _NOPERM); |
|
139
|
|
|
} |
|
140
|
|
|
$message = ''; |
|
141
|
|
|
$phone = ''; |
|
142
|
|
|
$name_user = ''; |
|
143
|
|
|
$email_user = ''; |
|
144
|
|
|
$email_author = $msg->getVar('email'); |
|
145
|
|
|
$title = $msg->getVar('title'); |
|
146
|
|
|
if ($xoopsUser) { |
|
147
|
|
|
$name_user = ('' !== $xoopsUser->getVar('name')) ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname'); |
|
148
|
|
|
$email_user = $xoopsUser->getVar('email', 'E'); |
|
149
|
|
|
} |
|
150
|
|
|
if (1 == $option['opt_code']) { |
|
151
|
|
|
xoops_load('XoopsCaptcha'); |
|
152
|
|
|
$xoopsCaptcha = XoopsCaptcha::getInstance(); |
|
153
|
|
|
} |
|
154
|
|
|
require_once __DIR__ . '/include/form_contact.inc.php'; |
|
155
|
|
|
xoops_footer(); |
|
156
|
|
|
break; |
|
157
|
|
|
} |
|
158
|
|
|
|