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.

blocks/random_partner.php (8 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
 *
5
 * Module: SmartPartner
6
 * Author: The SmartFactory <www.smartfactory.ca>
7
 * Licence: GNU
8
 * @param $options
9
 * @return array
10
 */
11
12
function b_random_partner_show($options)
0 ignored issues
show
The function b_random_partner_show() has been defined more than once; this definition is ignored, only the first definition in blocks/moving_partner.php (L12-54) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
13
{
14
    include_once(XOOPS_ROOT_PATH . '/modules/smartpartner/include/common.php');
15
16
    // Creating the partner handler object
17
    $partnerHandler = smartpartner_gethandler('partner');
18
19
    // Randomize
20
    $partnersObj =& $partnerHandler->getPartners(0, 0, _SPARTNER_STATUS_ACTIVE);
21
    if (count($partnersObj) > 0) {
22
        $key_arr    = array_keys($partnersObj);
23
        $key_rand   = array_rand($key_arr, 1);
24
        $partnerObj = $partnersObj[$key_rand];
25
    }
26
27
    $block = array();
28
    if ($partnerObj) {
29
        $partner['id']      = $partnerObj->id();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$partner was never initialized. Although not strictly required by PHP, it is generally a good practice to add $partner = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
The variable $partnerObj does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
30
        $partner['urllink'] = $partnerObj->getUrlLink('block');
31
        if ($partnerObj->image() && (($options[1] == 1) || ($options[1] == 3))) {
32
            $partner['image'] = $partnerObj->getImageUrl();
33
        }
34
        if ($partnerObj->image() && (($options[1] == 2) || ($options[1] == 3))) {
35
            $partner['title'] = $partnerObj->title();
36
        } else {
37
            $partner['title'] = '';
38
        }
39
        $smartConfig             = smartpartner_getModuleConfig();
40
        $image_info              = smartpartner_imageResize($partnerObj->getImagePath(), $smartConfig['img_max_width'], $smartConfig['img_max_height']);
41
        $partner['img_attr']     = $image_info[3];
42
        $partner['extendedInfo'] = $partnerObj->extentedInfo();
43
44
        if ($options[0] == 1) {
45
            $block['fadeImage'] = 'style="filter:alpha(opacity=20);" onmouseover="nereidFade(this,100,30,5)" onmouseout="nereidFade(this,50,30,5)"';
46
        }
47
48
        $block['see_all']          = $options[2];
49
        $block['lang_see_all']     = _MB_SPARTNER_LANG_SEE_ALL;
50
        $block['smartpartner_url'] = SMARTPARTNER_URL;
51
    }
52
53
    return $block;
54
}
55
56
/**
57
 * @param $options
58
 * @return string
59
 */
60 View Code Duplication
function b_random_partner_edit($options)
0 ignored issues
show
The function b_random_partner_edit() has been defined more than once; this definition is ignored, only the first definition in blocks/moving_partner.php (L60-166) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
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...
61
{
62
    $form = "<table border='0'>";
63
    /*$form .= "<tr><td>"._MB_SPARTNER_PARTNERS_PSPACE."</td><td>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% 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...
64
     $chk   = "";
65
     if ($options[0] == 0) {
66
         $chk = " checked='checked'";
67
     }
68
     $form .= "<input type='radio' name='options[0]' value='0'".$chk." />"._NO."";
69
     $chk   = "";
70
     if ($options[0] == 1) {
71
         $chk = " checked='checked'";
72
     }
73
     $form .= "<input type='radio' name='options[0]' value='1'".$chk." />"._YES."</td></tr>";*/
74
    $form .= '<tr><td>' . _MB_SPARTNER_FADE . '</td><td>';
75
    $chk = '';
76
    if ($options[0] == 0) {
77
        $chk = " checked='checked'";
78
    }
79
    $form .= "<input type='radio' name='options[1]' value='0'" . $chk . ' />' . _NO . '';
80
    $chk = '';
81
    if ($options[0] == 1) {
82
        $chk = " checked='checked'";
83
    }
84
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' />' . _YES . '</td></tr>';
85
    /*$form .= "<tr><td>"._MB_SPARTNER_BRAND."</td><td>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% 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...
86
     $chk   = "";
87
     if ($options[2] == 0) {
88
         $chk = " checked='checked'";
89
     }
90
     $form .= "<input type='radio' name='options[2]' value='0'".$chk." />"._NO."";
91
     $chk   = "";
92
     if ($options[2] == 1) {
93
         $chk = " checked='checked'";
94
     }
95
     $form .= "<input type='radio' name='options[2]' value='1'".$chk." />"._YES."</td></tr>";
96
     $form .= "<tr><td>"._MB_SPARTNER_BLIMIT."</td><td>";
97
     $form .= "<input type='text' name='options[3]' size='16' value='".$options[3]."' /></td></tr>";*/
98
    $form .= '<tr><td>' . _MB_SPARTNER_BSHOW . '</td><td>';
99
    $form .= "<select size='1' name='options[1]'>";
100
    $sel = '';
101
    if ($options[1] == 1) {
102
        $sel = " selected='selected'";
103
    }
104
    $form .= "<option value='1' " . $sel . '>' . _MB_SPARTNER_IMAGES . '</option>';
105
    $sel = '';
106
    if ($options[1] == 2) {
107
        $sel = " selected='selected'";
108
    }
109
    $form .= "<option value='2' " . $sel . '>' . _MB_SPARTNER_TEXT . '</option>';
110
    $sel = '';
111
    if ($options[1] == 3) {
112
        $sel = " selected='selected'";
113
    }
114
    $form .= "<option value='3' " . $sel . '>' . _MB_SPARTNER_BOTH . '</option>';
115
    $form .= '</select></td></tr>';
116
    /*$form .= "<tr><td>"._MB_SPARTNER_BORDER."</td><td>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% 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...
117
     $form .= "<select size='1' name='options[5]'>";
118
     $sel = "";
119
     if ($options[5] == "id") {
120
         $sel = " selected='selected'";
121
     }
122
     $form .= "<option value='id' ".$sel.">"._MB_SPARTNER_ID."</option>";
123
     $sel = "";
124
     if ($options[5] == "hits") {
125
         $sel = " selected='selected'";
126
     }
127
     $form .= "<option value='hits' ".$sel.">"._MB_SPARTNER_HITS."</option>";
128
     $sel = "";
129
     if ($options[5] == "title") {
130
         $sel = " selected='selected'";
131
     }
132
     $form .= "<option value='title' ".$sel.">"._MB_SPARTNER_TITLE."</option>";
133
     if ($options[5] == "weight") {
134
         $sel = " selected='selected'";
135
     }
136
     $form .= "<option value='weight' ".$sel.">"._MB_SPARTNER_WEIGHT."</option>";
137
     $form .= "</select> ";
138
     $form .= "<select size='1' name='options[6]'>";
139
     $sel = "";
140
     if ($options[6] == "ASC") {
141
         $sel = " selected='selected'";
142
     }
143
     $form .= "<option value='ASC' ".$sel.">"._MB_SPARTNER_ASC."</option>";
144
     $sel = "";
145
     if ($options[6] == "DESC") {
146
         $sel = " selected='selected'";
147
     }
148
     $form .= "<option value='DESC' ".$sel.">"._MB_SPARTNER_DESC."</option>";
149
     $form .= "</select></td></tr>";
150
     */
151
    $form .= '<tr><td>' . _MB_SPARTNER_SEE_ALL . '</td><td>';
152
    $chk = '';
153
    if ($options[2] == 0) {
154
        $chk = " checked='checked'";
155
    }
156
    $form .= "<input type='radio' name='options[2]' value='0'" . $chk . ' />' . _NO . '';
157
    $chk = '';
158
    if ($options[7] == 1) {
159
        $chk = " checked='checked'";
160
    }
161
    $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' />' . _YES . '</td></tr>';
162
163
    $form .= '</table>';
164
165
    return $form;
166
}
167