Issues (1177)

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.

application/helpers/admin_helper.php (2 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
if (!function_exists('check_admin_redirect')) {
4
5
    /**
6
     * @param array $languages
7
     * @param string $locale
8
     * @param string $url
9
     * @param bool|FALSE $pjax
10
     * @return string
11
     */
12
    function create_language_select($languages, $locale, $url, $pjax = FALSE) {
13
14
        if (count($languages) > 1 && \MY_Controller::isPremiumCMS()) {
15
            $html = "<div class='dropdown d-i_b'>";
16
            foreach ($languages as $language) {
17
                if ($language['identif'] == $locale) {
18
                    $html .= "<a class='btn dropdown-toggle btn-small' data-toggle='dropdown' data-lan='" . $language['identif'] . "' href='#'>";
19
                    $html .= $language['lang_name'];
20
                    $locale = $language['identif'];
21
                    $html .= "<input type='hidden' name='Locale' value='" . $language['identif'] . "'/>";
22
                    $html .= "<span class='caret'></span>";
23
                    $html .= '</a>';
24
                }
25
            }
26
            $html .= "<ul class='dropdown-menu pull-right'>";
27
            foreach ($languages as $language) {
28
                if ($language['identif'] != $locale) {
29
                    $html .= '<li>';
30
                    $html .= "<a href='" . $url . '/' . $language['identif'] . "' class='" . ($pjax ? 'pjax' : '') . "'>" . $language['lang_name'] . '</a>';
31
                    $html .= '</li>';
32
                }
33
            }
34
            if (count($languages) > 1) {
35
                $html .= '</ul></div>';
36
            }
37
        }
38
        return $html ?: '';
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    function create_admin_language_select() {
45
46
        $CI = &get_instance();
47
        $languages = $CI->db->select('lang_name, locale')->order_by('lang_name')->get('languages')->result_array();
48
        $current_locale = $CI->config->item('language');
49
        $current_language = lang('English', 'admin');
50
51
        if (count($languages)) {
52
            $html = '';
53
54
            $english_exists = FALSE;
55
            foreach ($languages as $language) {
56
                $html .= '<li><a href="/admin/settings/switch_admin_lang/' . $language['locale'] . '">' . $language['lang_name'] . '</a></li>';
57
                if ($current_locale == $language['locale']) {
58
                    $current_language = $language['lang_name'];
59
                }
60
61
                if (!$english_exists && strstr($language['locale'], 'en')) {
62
                    $english_exists = TRUE;
63
                }
64
            }
65
66
            if (!$english_exists) {
67
                $html = '<li><a href="/admin/settings/switch_admin_lang/en_US">' . lang('English', 'admin') . '</a></li>' . $html;
68
            }
69
70
            $html = '<div class="dropup d-i_b"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown">' .
71
                $current_language . '<span class="caret"></span></button>
72
            <ul class="dropdown-menu">' .
73
                $html .
74
                '</ul>
75
            </div>';
76
        }
77
        return $html ?: '';
78
    }
79
80
    /**
81
     * @param array $cats
82
     * @param array $selected_cats
83
     */
84
    function build_cats_tree($cats, $selected_cats = []) {
85
86
        if (is_array($cats)) {
87
            foreach ($cats as $cat) {
88
                echo '<option';
89
                if (is_array($selected_cats)) {
90
                    foreach ($selected_cats as $k) {
91
                        if ($k == $cat['id']) {
92
                            echo " selected = 'selected' ";
93
                        }
94
                    }
95
                }
96
                echo " value='" . $cat['id'] . "'>";
97
                for ($i = 0; $i < $cat['level']; $i++) {
98
                    echo '-';
99
                }
100
                echo $cat['name'] . '</option>';
101
                if ($cat['subtree']) {
102
                    build_cats_tree($cat['subtree'], $selected_cats);
103
                }
104
            }
105
        }
106
    }
107
108
    /**
109
     * @param array $cats
110
     * @param null|int $item_id
111
     * @param int $level
112
     */
113
    function build_cats_tree_ul_li($cats, $item_id = NULL, $level = 0) {
114
        if (is_array($cats)) {
115
116
            $subst = '';
117
            if ($level !== 0) {
118
                $indents = 3 * ($level - 1);
119
                $subst = str_repeat('&nbsp;', $indents) . '<span class="simple_tree">↳</span>';
120
            }
121
122
            foreach ($cats as $cat) {
123
                echo '<li>';
124
                if ($cat['id'] == $item_id) {
125
                    echo "<b><a class='category_item' data-title='" . $cat['name'] . "' data-id='" . $cat['id'] . "' href='#'>" . $subst . $cat['name'] . '</a></b>';
126
                } else {
127
128
                    echo "<a class='category_item' data-title='" . $cat['name'] . "' data-id='" . $cat['id'] . "' href='#'>" . $subst . $cat['name'] . '</a>';
129
                }
130
                if ($cat['subtree']) {
131
                    build_cats_tree_ul_li($cat['subtree'], $item_id, ++$level);
132
                }
133
            }
134
        }
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    function getCMSNumber() {
141
142
        return IMAGECMS_NUMBER;
143
    }
144
145
}
146
147
if (!function_exists('get_templates')) {
148
149
    /**
150
     * @return array|bool
0 ignored issues
show
Consider making the return type a bit more specific; maybe use array|false.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
151
     */
152
    function get_templates() {
153
154
        $new_arr_shop = [];
155
        if ($handle = opendir(TEMPLATES_PATH)) {
156
            while (false !== ($file = readdir($handle))) {
157
                if (false === strpos($file, '.') && $file != 'administrator' && $file != 'modules' && !stristr($file, '_mobile')) {
158
                    if (!is_file(TEMPLATES_PATH . $file)) {
159
                        if (is_dir(TEMPLATES_PATH . $file . '/shop/')) {
160
                            $new_arr_shop[$file] = $file;
161
                        } else {
162
                            $new_arr[$file] = $file;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$new_arr was never initialized. Although not strictly required by PHP, it is generally a good practice to add $new_arr = 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...
163
                        }
164
                    }
165
                }
166
            }
167
            closedir($handle);
168
169
            $templates = SHOP_INSTALLED ? $new_arr_shop : $new_arr;
170
            array_multisort($templates);
171
172
            return $templates;
173
        }
174
175
        return false;
176
    }
177
178
}