Completed
Branch master (89db23)
by Michael
04:09 queued 01:35
created

sign.php (3 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
2
/**
3
 * ****************************************************************************
4
 *  GBOOK - MODULE FOR XOOPS
5
 *  Copyright (c) 2007 - 2012
6
 *  Ingo H. de Boer (http://www.winshell.org)
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  (at your option) any later version.
12
 *
13
 *  You may not change or alter any portion of this comment or credits
14
 *  of supporting developers from this source code or any supporting
15
 *  source code which is considered copyrighted (c) material of the
16
 *  original comment or credit authors.
17
 *
18
 *  This program is distributed in the hope that it will be useful,
19
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 *  GNU General Public License for more details.
22
 *  ---------------------------------------------------------------------------
23
 *
24
 * @copyright       Ingo H. de Boer (http://www.winshell.org)
25
 * @license         GNU General Public License (GPL)
26
 * @package         GBook
27
 * @author          Ingo H. de Boer ([email protected])
28
 *
29
 * ****************************************************************************
30
 */
31
32
include_once __DIR__ . '/header.php';
33
include_once __DIR__ . '/class/utilities.php';
34
35
//Assign info
36
$myts = MyTextSanitizer::getInstance();
37
//$nameTmp0    = isset($_POST['Name']) ? $myts->stripSlashesGPC(trim($_POST['Name'])) : (null !== $xoopsUser ? $xoopsUser->getVar('uname', 'E') : '');
38
$nameTmp    = XoopsRequest::getString('Name', '', 'POST') ?: (null !== $xoopsUser ? $xoopsUser->getVar('uname', 'E') : '');
39
$emailTmp   = XoopsRequest::getString('Email', '', 'POST') ?: (null !== $xoopsUser ? $xoopsUser->getVar('email', 'E') : ''); //isset($_POST['Email']) ? $myts->stripSlashesGPC(trim($_POST['Email'])) : (null !== $xoopsUser ? $xoopsUser->getVar('email', 'E') : '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
$urlTmp     = XoopsRequest::getString('URL', '', 'POST') ?: (null !== $xoopsUser ? $xoopsUser->getVar('url', 'E') : ''); //isset($_POST['URL']) ? $myts->stripSlashesGPC(trim($_POST['URL'])) : (null !== $xoopsUser ? $xoopsUser->getVar('url', 'E') : '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
$messageTmp = XoopsRequest::getString('Message', '', 'POST') ?: ''; //isset($_POST['Message']) ? $myts->stripSlashesGPC(trim($_POST['Message'])) : '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
$timeTmp    = time();
43
$ipTmp      = GBookUtilities::gbookIP();
44
45
$xoopsOption['template_main']       = 'gbook_sign.tpl';
46
$xoopsOption['xoops_module_header'] = '<link rel="stylesheet" type="text/css" href="templates/gbook.css" />';
47
include XOOPS_ROOT_PATH . '/header.php';
48
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
49
50
//Assign data to smarty tpl
51
$xoopsTpl->assign('lang_back', _GBOOK_BACK);
52
$xoopsTpl->assign('lang_desc', _GBOOK_DESC);
53
54
if (empty($_POST['submit'])) {
55
    $gbookform = GBookUtilities::gbookSignForm($nameTmp, $emailTmp, $urlTmp, $messageTmp);
56
    $gbookform->assign($xoopsTpl);
57
} else {
58
    $stop = '';
59
    xoops_load('XoopsCaptcha');
60
    $xoopsCaptcha = xoopsCaptcha::getInstance();
61
    if (!$xoopsCaptcha->verify()) {
62
        $stop .= $xoopsCaptcha->getMessage();
63
    }
64
    if (!empty($emailTmp) && !checkEmail($emailTmp)) {
65
            $stop .= _GBOOK_EMAIL_INVALID;
66
    }
67
    if ('' !== $stop) {
68
        $stop .= '<br />';
69
        $GLOBALS['xoopsTpl']->assign('stop', $stop);
70
        $gbookform = GBookUtilities::gbookSignForm($nameTmp, $emailTmp, $urlTmp, $messageTmp);
71
        $gbookform->assign($xoopsTpl);
72
    } else {
73
        $handler = xoops_getModuleHandler('entries');
74
        $obj     =& $handler->create();
75
        $obj->setVar('name', $nameTmp);
76
        $obj->setVar('email', $emailTmp);
77
        $obj->setVar('url', formatURL($urlTmp));
78
        $obj->setVar('message', $messageTmp);
79
        $obj->setVar('time', $timeTmp);
80
        $obj->setVar('ip', $ipTmp);
81
        if ($handler->insert($obj)) {
82
            redirect_header('index.php', 3, _GBOOK_SIGNED);
83
        }
84
        include_once dirname(__DIR__) . '/include/forms.php';
85
        echo $obj->getHtmlErrors();
86
        $form =& $obj->getForm();
87
        $form->display();
88
    }
89
}
90
91
include_once __DIR__ . '/footer.php';
92