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 | * @version $Id: index.php 12285 2014-01-30 11:31:16Z beckmi $ |
||
22 | */ |
||
23 | include 'header.php'; |
||
24 | $xoopsOption['template_main'] = 'contact_index.html'; |
||
25 | //unset($_SESSION); |
||
26 | include XOOPS_ROOT_PATH . "/header.php"; |
||
27 | |||
28 | /** reCaptcha by google **/ |
||
29 | global $xoopsConfig; |
||
0 ignored issues
–
show
|
|||
30 | |||
31 | if(isset($_POST['g-recaptcha-response'])){ |
||
32 | $captcha=$_POST['g-recaptcha-response']; |
||
33 | } |
||
34 | |||
35 | if(!$captcha && $xoopsModuleConfig['useCaptcha']){ |
||
36 | redirect_header("index.php", 2, _MD_CONTACT_MES_NOCAPTCHA); |
||
37 | } |
||
38 | else { |
||
39 | $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$xoopsModuleConfig['captchaSecretKey']."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']); |
||
40 | if($response.success==false && $xoopsModuleConfig['useCaptcha']) |
||
0 ignored issues
–
show
|
|||
41 | { |
||
42 | redirect_header("index.php", 2, _MD_CONTACT_MES_CAPTCHAINCORRECT); |
||
43 | }else{ |
||
44 | |||
45 | global $xoopsConfig, $xoopsOption, $xoopsTpl, $xoopsUser, $xoopsUserIsAdmin, $xoopsLogger; |
||
46 | $op = $contact_handler->Contact_CleanVars($_POST, 'op', 'form', 'string'); |
||
47 | $department = $contact_handler->Contact_CleanVars($_GET, 'department', '', 'string'); |
||
48 | if($op == "save") { |
||
49 | if (empty($_POST['submit']) ) { |
||
50 | redirect_header(XOOPS_URL, 3, _MD_CONTACT_MES_ERROR); |
||
51 | exit(); |
||
52 | } else { |
||
53 | |||
54 | // check email |
||
55 | if (!$contact_handler->Contact_CleanVars($_POST, 'contact_mail', '', 'mail')) { |
||
56 | redirect_header("index.php", 1, _MD_CONTACT_MES_NOVALIDEMAIL); |
||
57 | exit(); |
||
58 | } |
||
59 | |||
60 | // Info Processing |
||
61 | $contact = $contact_handler->Contact_InfoProcessing($_POST); |
||
62 | |||
63 | // insert in DB |
||
64 | if ($saveinfo = true) { |
||
65 | $obj = $contact_handler->create(); |
||
66 | $obj->setVars($contact); |
||
67 | if (!$contact_handler->insert($obj)) { |
||
68 | redirect_header("index.php", 3, _MD_CONTACT_MES_NOTSAVE); |
||
69 | exit(); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | // send mail can send message |
||
74 | View Code Duplication | if ($sendmail = true) { |
|
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. ![]() |
|||
75 | $message = $contact_handler->Contact_SendMail($contact); |
||
76 | } elseif ($saveinfo = true) { |
||
77 | $message = _MD_CONTACT_MES_SAVEINDB; |
||
78 | } else { |
||
79 | $message = _MD_CONTACT_MES_SENDERROR; |
||
80 | } |
||
81 | |||
82 | redirect_header(XOOPS_URL, 3, $message); |
||
83 | exit(); |
||
84 | } |
||
85 | } |
||
86 | |||
87 | } |
||
88 | } |
||
89 | |||
90 | include XOOPS_ROOT_PATH . "/footer.php"; |
||
91 |
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