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 | include __DIR__ . '/header.php'; |
||
23 | $GLOBALS['xoopsOption']['template_main'] = 'contact_index.tpl'; |
||
24 | //unset($_SESSION); |
||
25 | include XOOPS_ROOT_PATH . '/header.php'; |
||
26 | |||
27 | /** reCaptcha by google **/ |
||
28 | global $xoopsConfig, $xoopsModuleConfig; |
||
0 ignored issues
–
show
|
|||
29 | $captcha = ''; |
||
30 | |||
31 | if ('' !== XoopsRequest::getString('g-recaptcha-response', '', 'POST')) { |
||
32 | $captcha = XoopsRequest::getString('g-recaptcha-response', '', 'POST'); |
||
33 | } |
||
34 | |||
35 | if (!$captcha && $xoopsModuleConfig['recaptchause']) { |
||
36 | redirect_header('index.php', 2, _MD_CONTACT_MES_NOCAPTCHA); |
||
37 | } else { |
||
38 | $response=file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $xoopsModuleConfig['recaptchakey'] . '&response=' . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR']); |
||
39 | if ($response.success === false && $xoopsModuleConfig['recaptchause']) { |
||
40 | redirect_header('index.php', 2, _MD_CONTACT_MES_CAPTCHAINCORRECT); |
||
41 | } else { |
||
42 | 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 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
43 | $op = XoopsRequest::getString('op', 'form', 'POST'); |
||
44 | $department = XoopsRequest::getString('department', '', 'GET'); |
||
45 | if ($op === 'save') { |
||
46 | if (''== XoopsRequest::getString('submit', '', 'POST')) { |
||
47 | redirect_header(XOOPS_URL, 3, _MD_CONTACT_MES_ERROR); |
||
48 | } else { |
||
49 | // check email |
||
50 | if (''== XoopsRequest::getString('contact_mail', '', 'POST')) { |
||
51 | redirect_header('index.php', 1, _MD_CONTACT_MES_NOVALIDEMAIL); |
||
52 | } |
||
53 | |||
54 | // Info Processing |
||
55 | $contact = $contactHandler->contactInfoProcessing(); |
||
56 | |||
57 | // insert in DB |
||
58 | if ($saveinfo = true) { |
||
59 | $obj = $contactHandler->create(); |
||
60 | $obj->setVars($contact); |
||
61 | if (!$contactHandler->insert($obj)) { |
||
62 | redirect_header('index.php', 3, _MD_CONTACT_MES_NOTSAVE); |
||
63 | } |
||
64 | } |
||
65 | |||
66 | // send mail can send message |
||
67 | if ($sendmail = true) { |
||
68 | $message = $contactHandler->contactSendMail($contact); |
||
69 | if ($xoopsModuleConfig['mailconfirm']) { |
||
70 | $res_mailconfirm = $contactHandler->contactSendMailConfirm($contact); |
||
71 | } |
||
72 | } elseif ($saveinfo = true) { |
||
73 | $message = _MD_CONTACT_MES_SAVEINDB; |
||
74 | } else { |
||
75 | $message = _MD_CONTACT_MES_SENDERROR; |
||
76 | } |
||
77 | |||
78 | redirect_header(XOOPS_URL, 3, $message); |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 | |||
84 | |||
85 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
86 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state