Issues (733)

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/updateblock.inc.php (4 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
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
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...
5
6
// Keep Block option values when update (by nobunobu)
7
global $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
8
$query  = 'SELECT mid FROM ' . $xoopsDB->prefix('modules') . " WHERE dirname='" . $modversion['dirname'] . "' ";
9
$result = $xoopsDB->query($query);
10
$record = $xoopsDB->fetcharray($result);
11
if ($record) {
12
    $mid   = $record['mid'];
13
    $count = count($modversion['blocks']);
14
    /* $sql = "SELECT * FROM ".$xoopsDB->prefix('newblocks')." WHERE mid=".$mid." AND block_type ='D'";
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
15
         $fresult = $xoopsDB->query($sql);
16
         $n_funcnum = $count;
17
         while ($fblock = $xoopsDB->fetchArray($fresult)) {
18
             $bnum = 0;
19
             for ($i = 1 ; $i <= $count ; ++$i) {
20
                 if (($modversion['blocks'][$i]['file'] == $fblock['func_file']) and ($modversion['blocks'][$i]['show_func'] == $fblock['show_func'])) {
21
                     $bnum = $i;
22
                     break;
23
                 }
24
             }
25
             if ($bnum) {
26
                 ++$n_funcnum;
27
                 $modversion['blocks'][$n_funcnum]['file'] = $fblock['func_file'];
28
                 $modversion['blocks'][$n_funcnum]['name'] = $fblock['name'];
29
                 $modversion['blocks'][$n_funcnum]['description'] = $fblock['name'];
30
                 $modversion['blocks'][$n_funcnum]['show_func'] = $fblock['show_func'];
31
                 $modversion['blocks'][$n_funcnum]['edit_func'] = $fblock['edit_func'];
32
                 $modversion['blocks'][$n_funcnum]['template'] = $fblock['template'];
33
                 if ($fblock['options']) {
34
                     $old_vals=explode("|",$fblock['options']);
35
                     $def_vals=explode("|",$modversion['blocks'][$bnum]['options']);
36
                     if (count($old_vals) == count($def_vals)) {
37
                         // the number of parameters is not changed
38
                         $modversion['blocks'][$n_funcnum]['options'] = $fblock['options'];
39
                         $local_msgs[] = "Option's values of the cloned block <b>".$fblock['name']."</b> will be kept. (value = <b>".$fblock['options']."</b>)";
40
                     } elseif (count($old_vals) < count($def_vals)) {
41
                         // the number of parameters is increased
42
                         for ($j=0; $j < count($old_vals); ++$j) {
43
                             $def_vals[$j] = $old_vals[$j];
44
                         }
45
                         $modversion['blocks'][$n_funcnum]['options'] = implode("|",$def_vals);
46
                         $local_msgs[] = "Option's values of the cloned block <b>".$fblock['name']."</b> will be kept and new options are added. (value = <b>".$modversion['blocks'][$fblock['func_num']]['options']."</b>)";
47
                     } else {
48
                         $modversion['blocks'][$n_funcnum]['options'] = implode("|",$def_vals);
49
                         $local_msgs[] = "Option's values of the cloned block <b>".$fblock['name']."</b> will be reset to the default, because of some decrease of options. (value = <b>".$modversion['blocks'][$n_funcnum]['options']."</b>)";
50
                     }
51
                 }
52
                 $sql = "UPDATE ".$xoopsDB->prefix('newblocks')." SET func_num='$n_funcnum' WHERE mid=".$mid." AND bid='".$fblock['bid']."'";
53
                 $iret = $xoopsDB->query($sql);
54
55
             }
56
         } */
57
58
    $sql     = 'SELECT * FROM ' . $xoopsDB->prefix('newblocks') . ' WHERE mid=' . $mid . " AND block_type <>'D' AND func_num > $count";
59
    $fresult = $xoopsDB->query($sql);
60
    while ($fblock = $xoopsDB->fetchArray($fresult)) {
61
        $local_msgs[] = 'Non Defined Block <b>' . $fblock['name'] . '</b> will be deleted';
62
        $sql          = 'DELETE FROM ' . $xoopsDB->prefix('newblocks') . " WHERE bid='" . $fblock['bid'] . "'";
63
        $iret         = $xoopsDB->query($sql);
64
    }
65
66
    for ($i = 1; $i <= $count; ++$i) {
67
        $sql     = 'SELECT name,options FROM '
68
                   . $xoopsDB->prefix('newblocks')
69
                   . ' WHERE mid='
70
                   . $mid
71
                   . ' AND func_num='
72
                   . $i
73
                   . " AND show_func='"
74
                   . addslashes($modversion['blocks'][$i]['show_func'])
75
                   . "' AND func_file='"
76
                   . addslashes($modversion['blocks'][$i]['file'])
77
                   . "'";
78
        $fresult = $xoopsDB->query($sql);
79
        $fblock  = $xoopsDB->fetchArray($fresult);
80
        if (isset($fblock['options'])) {
81
            $old_vals = explode('|', $fblock['options']);
82
            $def_vals = explode('|', $modversion['blocks'][$i]['options']);
83
            if (count($old_vals) == count($def_vals)) {
84
                $modversion['blocks'][$i]['options'] = $fblock['options'];
85
                $local_msgs[]                        = "Option's values of the block <b>" . $fblock['name'] . '</b> will be kept. (value = <b>' . $fblock['options'] . '</b>)';
86
            } elseif (count($old_vals) < count($def_vals)) {
87
                for ($j = 0, $jMax = count($old_vals); $j < $jMax; ++$j) {
88
                    $def_vals[$j] = $old_vals[$j];
89
                }
90
                $modversion['blocks'][$i]['options'] = implode('|', $def_vals);
91
                $local_msgs[]                        =
92
                    "Option's values of the block <b>" . $fblock['name'] . '</b> will be kept and new option(s) are added. (value = <b>' . $modversion['blocks'][$i]['options'] . '</b>)';
93
            } else {
94
                $local_msgs[] = "Option's values of the block <b>"
95
                                . $fblock['name']
96
                                . '</b> will be reset to the default, because of some decrease of options. (value = <b>'
97
                                . $modversion['blocks'][$i]['options']
98
                                . '</b>)';
99
            }
100
        }
101
    }
102
}
103
104
global $msgs, $myblocksadmin_parsed_updateblock;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
105
if (!empty($msgs) && empty($myblocksadmin_parsed_updateblock)) {
106
    $msgs                             = array_merge($msgs, $local_msgs);
107
    $myblocksadmin_parsed_updateblock = true;
108
}
109