Issues (304)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

include/module.php (11 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 21.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
 *  userlog module
13
 *
14
 * @copyright       XOOPS Project (https://xoops.org)
15
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
16
 * @package         userlog include
17
 * @since           1
18
 * @author          irmtfan ([email protected])
19
 * @author          XOOPS Project <www.xoops.org> <www.xoops.ir>
20
 */
21
defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
22
require_once __DIR__ . '/common.php';
23
/**
24
 * @param XoopsModule $module
25
 *
26
 * @return int
27
 */
28
function xoops_module_uninstall_userlog(XoopsModule $module)
0 ignored issues
show
The parameter $module is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
{
30
    $logsetObj = UserlogSetting::getInstance();
31
32
    return $logsetObj->cleanCache(); // delete all settings caches
33
}
34
35
/**
36
 * @param XoopsModule $module
37
 * @param null        $prev_version
38
 *
39
 * @return bool|mixed
40
 */
41
42
function xoops_module_update_userlog(XoopsModule $module, $prev_version = null)
43
{
44
    if ($prev_version == round($module->getInfo('version') * 100, 2)) {
45
        $module->setErrors('You have the latest ' . $module->getInfo('name') . ' module (' . $module->getInfo('dirname') . ' version ' . $module->getInfo('version') . ') and update is not necessary');
46
//        print_r($module->getErrors());
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...
47
48
        return true;
49
    }
50
    $ret = true;
51
    // first db update
52
    if (100 == $prev_version) {
53
        $ret = update_userlog_v100($module);
54
    }
55
    if ($prev_version < 114) {
56
        $ret = update_userlog_v114($module);
57
    }
58
    if ($prev_version < 115) {
59
        $ret = update_userlog_v115($module);
60
    }
61
    if ($prev_version < 116) {
62
        $ret = update_userlog_v116($module);
63
    }
64
    $errors = $module->getErrors();
65
    if (!empty($errors)) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
66
//        print_r($errors);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
67
    }
68
69
    return $ret;
70
}
71
72
// update database from v1 to 1.01 (Beta1 to RC1)
73
// module_name VARCHAR(25) change to VARCHAR(50)
74
/**
75
 * @param XoopsModule $module
76
 *
77
 * @return bool
78
 */
79 View Code Duplication
function update_userlog_v100(XoopsModule $module)
0 ignored issues
show
This function seems to be duplicated in 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.

Loading history...
80
{
81
    $field   = 'module_name';
82
    $userlog  = Userlog::getInstance();
83
    $ret     = $userlog->getHandler('log')->showFields($field);
84
    preg_match_all('!\d+!', $ret[$field]['Type'], $nums);
85
    // only change if module_name Type was VARCHAR(25)
86
    if (25 == $nums[0][0]) {
87
        $ret2 = $userlog->getHandler('log')->changeField($field, "VARCHAR(50) NOT NULL default ''");
88
    } else {
89
        $ret2 = true;
90
        $module->setErrors("Your table field ({$field}) with size {$ret[$field]['Type']} don't need change.");
91
    }
92
93
    return $ret2;
94
}
95
96
// add ",active,inside,outside,unset_pass" to all settings
97
/**
98
 * @param XoopsModule $module
99
 *
100
 * @return bool
101
 */
102 View Code Duplication
function update_userlog_v114(XoopsModule $module)
0 ignored issues
show
This function seems to be duplicated in 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.

Loading history...
103
{
104
    $userlog    = Userlog::getInstance();
105
    $logsetsObj = $userlog->getHandler('setting')->getAll();
106
    $ret        = true;
107
    foreach ($logsetsObj as $setObj) {
108
        if (strpos($setObj->getVar('options'), 'active')) {
109
            continue;
110
        }
111
        $setObj->setVar('options', $setObj->getVar('options') . ',active,inside,outside,unset_pass');
112
        if (!$setObj->storeSet(true)) {
113
            $ret = false;
114
            $module->setErrors(_AM_USERLOG_SET_ERROR . ' id=' . $setObj->set_id() . ' options=' . $setObj->options());
115
        }
116
    }
117
118
    return $ret;
119
}
120
121
/**
122
 * @param XoopsModule $module
123
 *
124
 * @return mixed
125
 */
126 View Code Duplication
function update_userlog_v115(XoopsModule $module)
0 ignored issues
show
This function seems to be duplicated in 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.

Loading history...
127
{
128
    $userlog  = Userlog::getInstance();
129
    // Only change the field from INDEX to UNIQUE if it is not unique
130
    // if (isset($indexArr[0]["Non_unique"]) || $indexArr[0]["Non_unique"] == 1) { }
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% 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...
131
    // change the index in _stats table
132
    if (!$ret = $userlog->getHandler('stats')->changeIndex('stats_type_link_period', ['stats_type', 'stats_link', 'stats_period'], 'UNIQUE')) {
133
        $module->setErrors("'stats_type_link_period' index is not changed to unique. Warning: do not use module until you change this index to unique.");
134
    }
135
    // drop the index in _log table
136
    if (!$ret = $userlog->getHandler('log')->dropIndex('log_id_uid')) {
137
        $module->setErrors("'log_id_uid' index is not dropped.");
138
    }
139
    // add the index in _log table
140
    if (!$ret = $userlog->getHandler('log')->addIndex('log_time', ['log_time'])) {
141
        $module->setErrors("'log_time' index is not added.");
142
    }
143
144
    return $ret;
145
}
146
147
/**
148
 * @param XoopsModule $module
149
 *
150
 * @return bool
151
 */
152 View Code Duplication
function update_userlog_v116(XoopsModule $module)
0 ignored issues
show
This function seems to be duplicated in 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.

Loading history...
153
{
154
    // remove old html template files
155
    $template_directory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/';
156
    $template_list      = array_diff(scandir($template_directory, SCANDIR_SORT_NONE), ['..', '.']);
157
    foreach ($template_list as $k => $v) {
158
        $fileinfo = new SplFileInfo($template_directory . $v);
159
        if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) {
160
            @unlink($template_directory . $v);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
161
        }
162
    }
163
164
    return true;
165
}
166