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/metagen.php (7 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 $document
9
 * @return mixed
10
 */
11
12
function smartpartner_metagen_html2text($document)
13
{
14
    // PHP Manual:: function preg_replace
15
    // $document should contain an HTML document.
16
    // This will remove HTML tags, javascript sections
17
    // and white space. It will also convert some
18
    // common HTML entities to their text equivalent.
19
    // Credits: newbb2
20
21
    $search = array(
22
        "'<script[^>]*?>.*?</script>'si", // Strip out javascript
23
        "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
24
        "'([\r\n])[\s]+'", // Strip out white space
25
        "'&(quot|#34);'i", // Replace HTML entities
26
        "'&(amp|#38);'i",
27
        "'&(lt|#60);'i",
28
        "'&(gt|#62);'i",
29
        "'&(nbsp|#160);'i",
30
        "'&(iexcl|#161);'i",
31
        "'&(cent|#162);'i",
32
        "'&(pound|#163);'i",
33
        "'&(copy|#169);'i",
34
        "'&#(\d+);'e"
35
    ); // evaluate as php
36
37
    $replace = array(
38
        '',
39
        '',
40
        "\\1",
41
        "\"",
42
        '&',
43
        '<',
44
        '>',
45
        ' ',
46
        chr(161),
47
        chr(162),
48
        chr(163),
49
        chr(169),
50
        "chr(\\1)"
51
    );
52
53
    $text = preg_replace($search, $replace, $document);
54
55
    return $text;
56
}
57
58
/**
59
 * @param         $description
60
 * @param  int    $maxWords
61
 * @return string
62
 */
63
function smartpartner_createMetaDescription($description, $maxWords = 100)
0 ignored issues
show
The parameter $maxWords 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...
64
{
65
    $myts = MyTextSanitizer::getInstance();
0 ignored issues
show
$myts 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...
66
67
    $words = array();
0 ignored issues
show
$words 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...
68
    $words = explode(' ', smartpartner_metagen_html2text($description));
69
70
    $ret       = '';
71
    $i         = 1;
72
    $wordCount = count($words);
73
    foreach ($words as $word) {
74
        $ret .= $word;
75
        if ($i < $wordCount) {
76
            $ret .= ' ';
77
        }
78
        ++$i;
79
    }
80
81
    return $ret;
82
}
83
84
/**
85
 * @param $text
86
 * @param $minChar
87
 * @return array
88
 */
89
function smartpartner_findMetaKeywords($text, $minChar)
90
{
91
    $myts = MyTextSanitizer::getInstance();
0 ignored issues
show
$myts 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...
92
93
    $keywords         = array();
94
    $originalKeywords = explode(' ', $text);
95
    foreach ($originalKeywords as $originalKeyword) {
96
        $secondRoundKeywords = explode("'", $originalKeyword);
97
        foreach ($secondRoundKeywords as $secondRoundKeyword) {
98
            if (strlen($secondRoundKeyword) >= $minChar) {
99
                if (!in_array($secondRoundKeyword, $keywords)) {
100
                    $keywords[] = trim($secondRoundKeyword);
101
                }
102
            }
103
        }
104
    }
105
106
    return $keywords;
107
}
108
109
/**
110
 * @param        $title
111
 * @param string $categoryPath
112
 * @param string $description
113
 * @param int    $minChar
114
 */
115
function smartpartner_createMetaTags($title, $categoryPath = '', $description = '', $minChar = 4)
116
{
117
    global $xoopsTpl, $xoopsModule, $xoopsModuleConfig;
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...
118
    $myts = MyTextSanitizer::getInstance();
119
120
    $ret = '';
121
122
    $title = $myts->displayTarea($title);
123
    $title = $myts->undoHtmlSpecialChars($title);
124
125
    if (isset($categoryPath)) {
126
        $categoryPath = $myts->displayTarea($categoryPath);
127
        $categoryPath = $myts->undoHtmlSpecialChars($categoryPath);
128
    }
129
130
    // Creating Meta Keywords
131
    if (isset($title) && ($title != '')) {
132
        $keywords = smartpartner_findMetaKeywords($title, $minChar);
133
134
        if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) && $xoopsModuleConfig['moduleMetaKeywords'] != '') {
135
            $moduleKeywords = explode(',', $xoopsModuleConfig['moduleMetaKeywords']);
136
            foreach ($moduleKeywords as $moduleKeyword) {
137
                if (!in_array($moduleKeyword, $keywords)) {
138
                    $keywords[] = trim($moduleKeyword);
139
                }
140
            }
141
        }
142
143
        $keywordsCount = count($keywords);
144
        for ($i = 0; $i < $keywordsCount; ++$i) {
145
            $ret .= $keywords[$i];
146
            if ($i < $keywordsCount - 1) {
147
                $ret .= ', ';
148
            }
149
        }
150
151
        $xoopsTpl->assign('xoops_meta_keywords', $ret);
152
    }
153
    // Creating Meta Description
154
    if ($description != '') {
155
        $xoopsTpl->assign('xoops_meta_description', smartpartner_createMetaDescription($description));
156
    }
157
158
    // Creating Page Title
159
    $moduleName = '';
160
    $titleTag   = array();
161
162
    if (isset($xoopsModule)) {
163
        $moduleName         = $myts->displayTarea($xoopsModule->name());
164
        $titleTag['module'] = $moduleName;
165
    }
166
167
    if (isset($title) && ($title != '') && (strtoupper($title) != strtoupper($moduleName))) {
168
        $titleTag['title'] = $title;
169
    }
170
171
    if (isset($categoryPath) && ($categoryPath != '')) {
172
        $titleTag['category'] = $categoryPath;
173
    }
174
175
    $ret = '';
176
177
    if (isset($titleTag['title']) && $titleTag['title'] != '') {
178
        $ret .= $titleTag['title'];
179
    }
180
181 View Code Duplication
    if (isset($titleTag['category']) && $titleTag['category'] != '') {
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...
182
        if ($ret != '') {
183
            $ret .= ' - ';
184
        }
185
        $ret .= $titleTag['category'];
186
    }
187 View Code Duplication
    if (isset($titleTag['module']) && $titleTag['module'] != '') {
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...
188
        if ($ret != '') {
189
            $ret .= ' - ';
190
        }
191
        $ret .= $titleTag['module'];
192
    }
193
    $xoopsTpl->assign('xoops_pagetitle', $ret);
194
}
195