Completed
Push — master ( 720064...d5ad83 )
by Michael
02:05
created

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
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Contact module
14
 *
15
 * @copyright   The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @author      Kazumi Ono (aka Onokazu)
18
 * @author      Trabis <[email protected]>
19
 * @author      Hossein Azizabadi (AKA Voltan)
20
 * @author      Mirza (AKA Bleekk)
21
 */
22
23
use Xmf\Request;
24
25
include __DIR__ . '/header.php';
26
$GLOBALS['xoopsOption']['template_main'] = 'contact_index.tpl';
27
//unset($_SESSION);
28
include XOOPS_ROOT_PATH . '/header.php';
29
30
/** reCaptcha by google **/
31
global $xoopsConfig, $xoopsModuleConfig;
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...
32
$captcha = '';
33
34
$saveinfo = $xoopsModuleConfig['saveinfo'];
35
$sendmail = $xoopsModuleConfig['sendmail'];
36
37
if ('' !== Request::getString('g-recaptcha-response', '', 'POST')) {
38
    $captcha = Request::getString('g-recaptcha-response', '', 'POST');
39
}
40
41
if (!$captcha && $xoopsModuleConfig['recaptchause']) {
42
    redirect_header('index.php', 2, _MD_CONTACT_MES_NOCAPTCHA);
43
} else {
44
    $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $xoopsModuleConfig['recaptchakey'] . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR']);
45
    if ($response['success'] === false && $xoopsModuleConfig['recaptchause']) {
46
        redirect_header('index.php', 2, _MD_CONTACT_MES_CAPTCHAINCORRECT);
47
    } else {
48
        global $xoopsConfig, $xoopsOption, $xoopsTpl, $xoopsUser, $xoopsUserIsAdmin, $xoopsLogger;
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...
49
        $op         = Request::getString('op', 'form', 'POST');
50
        $department = Request::getString('department', '', 'GET');
51
        if ($op === 'save') {
52
            if ('' === Request::getString('submit', '', 'POST')) {
53
                redirect_header(XOOPS_URL, 3, _MD_CONTACT_MES_ERROR);
54
            } else {
55
                // check email
56
                if ('' === Request::getString('contact_mail', '', 'POST')) {
57
                    redirect_header('index.php', 1, _MD_CONTACT_MES_NOVALIDEMAIL);
58
                }
59
60
                // Info Processing
61
                $contact = $contactHandler->contactInfoProcessing();
62
63
                // insert in DB
64
                if (1 === $saveinfo) {
65
                    $obj = $contactHandler->create();
66
                    $obj->setVars($contact);
67
                    if (!$contactHandler->insert($obj)) {
68
                        redirect_header('index.php', 3, _MD_CONTACT_MES_NOTSAVE);
69
                    }
70
                }
71
72
                // send mail can send message
73
                if (1 === $sendmail) {
74
                    $message = $contactHandler->contactSendMail($contact);
75
                    if ($xoopsModuleConfig['mailconfirm']) {
76
                        $res_mailconfirm = $contactHandler->contactSendMailConfirm($contact);
77
                    }
78
                } elseif (1 === $saveinfo) {
79
                    $message = _MD_CONTACT_MES_SAVEINDB;
80
                } else {
81
                    $message = _MD_CONTACT_MES_SENDERROR;
82
                }
83
84
                redirect_header(XOOPS_URL, 3, $message);
85
            }
86
        }
87
    }
88
}
89
90
include XOOPS_ROOT_PATH . '/footer.php';
91