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/recent_offers.php (9 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
// 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...
12
13
function b_recent_offers_show($options)
14
{
15
    include_once(XOOPS_ROOT_PATH . '/modules/smartpartner/include/common.php');
16
17
    // Creating the partner handler object
18
    $offerHandler   = smartpartner_gethandler('offer');
19
    $partnerHandler = smartpartner_gethandler('partner');
20
21
    include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
22
    $smartPermissionsHandler = new SmartobjectPermissionHandler($partnerHandler);
23
    $grantedItems            = $smartPermissionsHandler->getGrantedItems('full_view');
24
25
    if (!empty($grantedItems)) {
26
        $criteria = new CriteriaCompo();
27
        $criteria->add(new Criteria('partnerid', '(' . implode(', ', $grantedItems) . ')', 'IN'));
28
        $criteria->add(new Criteria('date_pub', time(), '<'));
29
        $criteria->add(new Criteria('date_end', time(), '>'));
30
        $criteria->add(new Criteria('status', _SPARTNER_STATUS_ONLINE));
31
        $criteria->setSort('date_sub');
32
        $criteria->setOrder('DESC');
33
        $criteria->setLimit($options[2]);
34
35
        $offersObj = $offerHandler->getObjects($criteria);
36
        $block     = array();
37 View Code Duplication
        if ($offersObj) {
0 ignored issues
show
This code seems to be duplicated across 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...
38
            foreach ($offersObj as $offerObj) {
39
                $block['offers'][] = $offerObj->toArray('e');
40
            }
41
            $smartConfig = smartpartner_getModuleConfig();
0 ignored issues
show
$smartConfig is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

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