Passed
Pull Request — master (#9)
by Michael
03:24
created

brokenlink.php (2 issues)

Labels
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
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team
18
 */
19
20
use XoopsModules\Mylinks;
21
use XoopsModules\Mylinks\Utility;
22
23
require_once __DIR__ . '/header.php';
24
$myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object
25
26
//xoops_load('utility', $xoopsModule->getVar('dirname'));
27
$lid = Mylinks\Utility::cleanVars($_REQUEST, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
'lid' of type string is incompatible with the type XoopsModules\Mylinks\unknown_type expected by parameter $key of XoopsModules\Mylinks\Utility::cleanVars(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
$lid = Mylinks\Utility::cleanVars($_REQUEST, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
28
if (!empty($_POST['submit'])) {
29
    $sender = empty($xoopsUser) ? 0 : $xoopsUser->getVar('uid');
30
    $ip     = getenv('REMOTE_ADDR');
31
    if (0 != $sender) {
32
        // Check if REG user is trying to report twice.
33
        $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_broken') . " WHERE lid='{$lid}' AND sender='{$sender}'");
34
        list($count) = $xoopsDB->fetchRow($result);
35
        if ($count > 0) {
36
            redirect_header('index.php', 2, _MD_MYLINKS_ALREADYREPORTED);
37
        }
38
    } else {
39
        // Check if the sender is trying to report it more than once.
40
        $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_broken') . " WHERE lid='{$lid}' AND ip='{$ip}'");
41
        list($count) = $xoopsDB->fetchRow($result);
42
        if ($count > 0) {
43
            redirect_header('index.php', 2, _MD_MYLINKS_ALREADYREPORTED);
44
        }
45
    }
46
    $newid = $xoopsDB->genId($xoopsDB->prefix('mylinks_broken') . '_reportid_seq');
47
    $sql   = sprintf("INSERT INTO `%s` (reportid, lid, sender, ip) VALUES (%u, %u, %u, '%s')", $xoopsDB->prefix('mylinks_broken'), $newid, $lid, $sender, $ip);
48
    $xoopsDB->query($sql) || exit();
49
    $tags                      = [];
50
    $tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listBrokenLinks';
51
    $notificationHandler       = xoops_getHandler('notification');
52
    $notificationHandler->triggerEvent('global', 0, 'link_broken', $tags);
0 ignored issues
show
The method triggerEvent() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsNotificationHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
    $notificationHandler->/** @scrutinizer ignore-call */ 
53
                          triggerEvent('global', 0, 'link_broken', $tags);
Loading history...
53
    redirect_header('index.php', 2, _MD_MYLINKS_THANKSFORINFO);
54
} else {
55
    $GLOBALS['xoopsOption']['template_main'] = 'mylinks_brokenlink.tpl';
56
    require_once XOOPS_ROOT_PATH . '/header.php';
57
    //wanikoo
58
    $xoTheme->addStylesheet('browse.php?' . Utility::getStylePath('mylinks.css', 'include'));
59
    $xoTheme->addScript('browse.php?' . Utility::getStylePath('mylinks.js', 'include'));
60
61
    $xoopsTpl->assign('lang_reportbroken', _MD_MYLINKS_REPORTBROKEN);
62
    $xoopsTpl->assign('link_id', $lid);
63
    $xoopsTpl->assign('lang_thanksforhelp', _MD_MYLINKS_THANKSFORHELP);
64
    $xoopsTpl->assign('lang_forsecurity', _MD_MYLINKS_FORSECURITY);
65
    $xoopsTpl->assign('lang_cancel', _CANCEL);
66
67
    //wanikoo theme changer
68
    $xoopsTpl->assign('lang_themechanger', _MD_MYLINKS_THEMECHANGER);
69
70
    $mymylinkstheme_options = '';
71
    foreach ($GLOBALS['mylinks_allowed_theme'] as $mymylinkstheme) {
72
        $thisSelected           = ($mymylinkstheme == $GLOBALS['mylinks_theme']) ? ' selected' : '';
73
        $mymylinkstheme_options .= "<option value='{$mymylinkstheme}'{$thisSelected}>{$mymylinkstheme}</option>";
74
    }
75
76
    $mylinkstheme_select = "<select name='mylinks_theme_select' onchange='submit();' size='1'>{$mymylinkstheme_options}</select>";
77
    $xoopsTpl->assign('mylinksthemeoption', $mylinkstheme_select);
78
79
    //wanikoo search
80
    if (file_exists(XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php')) {
81
        require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php';
82
    } else {
83
        require_once XOOPS_ROOT_PATH . '/language/english/search.php';
84
    }
85
86
    $xoopsTpl->assign('lang_all', _SR_ALL);
87
    $xoopsTpl->assign('lang_any', _SR_ANY);
88
    $xoopsTpl->assign('lang_exact', _SR_EXACT);
89
    $xoopsTpl->assign('lang_search', _SR_SEARCH);
90
    $xoopsTpl->assign('module_id', $xoopsModule->getVar('mid'));
91
    //category head
92
    $catarray = [];
93
    if ($mylinks_show_letters) {
94
        $catarray['letters'] = Utility::letters();
95
    }
96
    if ($mylinks_show_toolbar) {
97
        $catarray['toolbar'] = Utility::toolbar();
98
    }
99
    $xoopsTpl->assign('catarray', $catarray);
100
101
    require_once XOOPSMYLINKPATH . '/footer.php';
102
}
103