xhttperror_checkModuleAdmin()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * ****************************************************************************
5
 *  - A Project by Developers TEAM For Xoops - ( https://xoops.org )
6
 * ****************************************************************************
7
 *  XHTTPERROR - MODULE FOR XOOPS
8
 *  Copyright (c) 2007 - 2012
9
 *  Rota Lucio ( http://luciorota.altervista.org/xoops/ )
10
 *
11
 *  You may not change or alter any portion of this comment or credits
12
 *  of supporting developers from this source code or any supporting
13
 *  source code which is considered copyrighted (c) material of the
14
 *  original comment or credit authors.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *  ---------------------------------------------------------------------------
21
 * @copyright  Rota Lucio ( http://luciorota.altervista.org/xoops/ )
22
 * @license    GNU General Public License v3.0
23
 * @package    xhttperror
24
 * @author     Rota Lucio ( [email protected] )
25
 *
26
 *  $Rev$:     Revision of last commit
27
 *  $Author$:  Author of last commit
28
 *  $Date$:    Date of last commit
29
 * ****************************************************************************
30
 */
31
function xhttperror_checkModuleAdmin()
32
{
33
    if (is_file($GLOBALS['xoops']->path('Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))) {
34
        require_once $GLOBALS['xoops']->path('Frameworks/moduleclasses/moduleadmin/moduleadmin.php');
35
36
        return true;
37
    }
38
    echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks");
0 ignored issues
show
Bug introduced by
Are you sure the usage of xoops_error('Error: You ...stall this Frameworks') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure xoops_error('Error: You ...stall this Frameworks') of type void can be used in echo? ( Ignorable by Annotation )

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

38
    echo /** @scrutinizer ignore-type */ xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks");
Loading history...
39
40
    return false;
41
}
42
43
/**
44
 * @param        $global
45
 * @param        $key
46
 * @param string $default
47
 * @param string $type
48
 * @return false|int|mixed|string
49
 */
50
function xhttperror_CleanVars($global, $key, $default = '', $type = 'int')
51
{
52
    switch ($type) {
53
        case 'array':
54
            $ret = (isset($global[$key]) && is_array($global[$key])) ? $global[$key] : $default;
55
            break;
56
        case 'date':
57
            $ret = isset($global[$key]) ? strtotime($global[$key]) : $default;
58
            break;
59
        case 'string':
60
            if (defined('FILTER_SANITIZE_ADD_SLASHES')) {
61
                $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_ADD_SLASHES) : $default;
62
            } else {
63
                $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default;
0 ignored issues
show
introduced by
The constant FILTER_SANITIZE_MAGIC_QUOTES has been deprecated: 7.4 ( Ignorable by Annotation )

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

63
                $ret = isset($global[$key]) ? filter_var($global[$key], /** @scrutinizer ignore-deprecated */ FILTER_SANITIZE_MAGIC_QUOTES) : $default;
Loading history...
64
            }
65
            break;
66
        case 'int':
67
        default:
68
            $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default;
69
            break;
70
    }
71
    if (false === $ret) {
72
        return $default;
73
    }
74
75
    return $ret;
76
}
77
78
/**
79
 * @param $content
80
 */
81
function xhttperror_meta_keywords($content)
82
{
83
    global $xoopsTpl, $xoTheme;
84
    $myts    = \MyTextSanitizer::getInstance();
85
    $content = $myts->undoHtmlSpecialChars($myts->displayTbox($content));
0 ignored issues
show
Bug introduced by
The method displayTbox() does not exist on MyTextSanitizer. Did you maybe mean displayTarea()? ( Ignorable by Annotation )

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

85
    $content = $myts->undoHtmlSpecialChars($myts->/** @scrutinizer ignore-call */ displayTbox($content));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
86
    if (isset($xoTheme) && is_object($xoTheme)) {
87
        $xoTheme->addMeta('meta', 'keywords', strip_tags($content));
88
    } else {    // Compatibility for old Xoops versions
89
        $xoopsTpl->assign('xoops_meta_keywords', strip_tags($content));
90
    }
91
}
92
93
/**
94
 * @param $content
95
 */
96
function xhttperror_meta_description($content)
97
{
98
    global $xoopsTpl, $xoTheme;
99
    $myts    = \MyTextSanitizer::getInstance();
100
    $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
101
    if (isset($xoTheme) && is_object($xoTheme)) {
102
        $xoTheme->addMeta('meta', 'description', strip_tags($content));
103
    } else {    // Compatibility for old Xoops versions
104
        $xoopsTpl->assign('xoops_meta_description', strip_tags($content));
105
    }
106
}
107