Completed
Push — master ( 07b04b...37a2f2 )
by Michael
04:34 queued 02:23
created

contact.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 47 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
include __DIR__ . '/../../mainfile.php';
26
$op = 'form';
27
foreach ($_POST as $k => $v) {
28
    ${$k} = $v;
29
}
30
foreach ($_GET as $k => $v) {
31
    ${$k} = $v;
32
}
33
34
if (isset($preview)) {
35
    $op = 'preview';
36
} elseif (isset($post)) {
37
    $op = 'post';
38
}
39
include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/class/util.php';
40
include_once __DIR__ . '/include/config.inc.php';
41
$option = getOptions();
42
43
/**
44
 * @param $title
45
 * @param $content
46
 */
47
function displaypost($title, $content)
48
{
49
    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>';
50
}
51
52
switch ($op) {
53
54
    case 'post':
55
        global $xoopsConfig;
56
        $ts = MyTextSanitizer::getInstance();
57
        xoops_header();
58
59 View Code Duplication
        if ($option['opt_code'] == 1) {
60
            xoops_load('XoopsCaptcha');
61
            $xoopsCaptcha = XoopsCaptcha::getInstance();
62
            if (!$xoopsCaptcha->verify()) {
63
                redirect_header('index.php', 3, $xoopsCaptcha->getMessage());
64
            }
65
        }
66
        $fullmsg = MD_XFGUESTBOOK_FROMUSER . " $name_user " . MD_XFGUESTBOOK_YOURMSG . ' ' . $xoopsConfig['sitename'] . ' :<br><br>';
67
        $fullmsg .= $title . '<br>';
68
        $fullmsg .= '<hr><br>';
69
        $fullmsg .= "$message<br><br>";
70
        $fullmsg .= '<hr><br>';
71
        $fullmsg .= MD_XFGUESTBOOK_CANJOINT . ' [email]' . $email_user . '[/email]';
72
73
        $xoopsMailer =& xoops_getMailer();
74
        $xoopsMailer->useMail();
75
        $xoopsMailer->setFromEmail($email_user);
76
        $xoopsMailer->setFromName($xoopsConfig['sitename']);
77
        $xoopsMailer->setToEmails($email_author);
78
        $xoopsMailer->setSubject(MD_XFGUESTBOOK_CONTACTAFTERMSG);
79
        $xoopsMailer->multimailer->isHTML(true);
80
        $xoopsMailer->setBody($ts->xoopsCodeDecode($fullmsg));
81
        $msgsend = "<div style='text-align:center;'><br><br>";
82
        if (!$xoopsMailer->send()) {
83
            $msgsend .= $xoopsMailer->getErrors();
84
        } else {
85
            $msgsend .= '<h4>' . MD_XFGUESTBOOK_MSGSEND . '</h4>';
86
        }
87
        $msgsend .= '<br><br><a href="javascript:window.close();">' . MD_XFGUESTBOOK_CLOSEWINDOW . '</a></div>';
88
        echo $msgsend;
89
        break;
90
91
    case 'preview':
92
93
        $ts = MyTextSanitizer::getInstance();
94
        xoops_header();
95
96 View Code Duplication
        if ($option['opt_code'] == 1) {
97
            xoops_load('XoopsCaptcha');
98
            $xoopsCaptcha = XoopsCaptcha::getInstance();
99
            if (!$xoopsCaptcha->verify()) {
100
                redirect_header('index.php', 3, $xoopsCaptcha->getMessage());
101
            }
102
        }
103
        $p_title = $title;
104
        $p_title = $ts->htmlSpecialChars($ts->stripSlashesGPC($p_title));
105
        $p_msg   = MD_XFGUESTBOOK_FROMUSER . " $name_user " . MD_XFGUESTBOOK_YOURMSG . ' ' . $xoopsConfig['sitename'] . ' :<br>';
106
        $p_msg   .= $title . '<br>';
107
        $p_msg   .= '<hr><br>';
108
        $p_msg   .= $message . '<br><br>';
109
        $p_msg   .= '<hr><br>';
110
        $p_msg   .= MD_XFGUESTBOOK_CANJOINT . " $email_user";
111
112
        $p_msg .= '<br>';
113
        displaypost($p_title, $p_msg);
114
115
        $title   = $ts->htmlSpecialChars($ts->stripSlashesGPC($title));
116
        $message = $ts->htmlSpecialChars($ts->stripSlashesGPC($message));
117
118
        include __DIR__ . '/include/form_contact.inc.php';
119
        xoops_footer();
120
        break;
121
122
    case 'form':
123
    default:
124
125
        xoops_header();
126
        $msgHandler = xoops_getModuleHandler('msg');
127
        $msg        = $msgHandler->get($msg_id);
128
        if (!$msg) {
129
            redirect_header('index.php', 3, _NOPERM);
130
        }
131
        $message      = '';
132
        $phone        = '';
133
        $name_user    = '';
134
        $email_user   = '';
135
        $email_author = $msg->getVar('email');
136
        $title        = $msg->getVar('title');
137
        if ($xoopsUser) {
138
            $name_user  = ($xoopsUser->getVar('name') !== '') ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname');
139
            $email_user = $xoopsUser->getVar('email', 'E');
140
        }
141
        if ($option['opt_code'] == 1) {
142
            xoops_load('XoopsCaptcha');
143
            $xoopsCaptcha = XoopsCaptcha::getInstance();
144
        }
145
        include __DIR__ . '/include/form_contact.inc.php';
146
        xoops_footer();
147
        break;
148
}
149