Completed
Push — master ( 76b4a1...141e43 )
by Michael
06:17 queued 02:44
created

contact.php (6 issues)

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
// $Id: contact.php,v 1.11 2004/12/02 C. Felix AKA the Cat
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 dirname(dirname(__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() . '/include/functions.php');
40
include_once('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;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
56
        $ts = MyTextSanitizer::getInstance();
57
        xoops_header();
58
59 View Code Duplication
        if ($option['opt_code'] == 1) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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_XFGB_FROMUSER . " $name_user " . _MD_XFGB_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_XFGB_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_XFGB_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_XFGB_MSGSEND . '</h4>';
86
        }
87
        $msgsend .= "<br><br><a href=\"javascript:window.close();\">" . _MD_XFGB_CLOSEWINDOW . '</a></div>';
88
        echo $msgsend;
89
        break;
90
91
    case 'preview':
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
92
93
        $ts = MyTextSanitizer::getInstance();
94
        xoops_header();
95
96 View Code Duplication
        if ($option['opt_code'] == 1) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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_XFGB_FROMUSER . " $name_user " . _MD_XFGB_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_XFGB_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:
0 ignored issues
show
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
124
125
        xoops_header();
126
        $msg_handler = &xoops_getModuleHandler('msg');
127
        $msg         = &$msg_handler->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