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/modules/trash/trash.php (1 issue)

Labels
Severity

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
use CMSFactory\Events;
4
use CMSFactory\Exception;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Exception.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
5
use Propel\Runtime\Collection\ObjectCollection as PropelObjectCollection;
6
7
(defined('BASEPATH')) OR exit('No direct script access allowed');
8
9
/**
10
 * Image CMS
11
 *
12
 * Класс редиректа удаленных товаров
13
 * @property Cms_base $cms_base
14
 */
15
class Trash extends MY_Controller
16
{
17
18
    /**
19
     * @var string $is_create
20
     */
21
    private $trash_is_create_type;
22
23
    /**
24
     * Construct.
25
     */
26
    public function __construct() {
27
28
        parent::__construct();
29
        $lang = new MY_Lang();
30
        $lang->load('trash');
31
        $this->load->module('core');
32
    }
33
34
    /**
35
     * Index method.
36
     *
37
     * @return void
38
     */
39
    public function index() {
40
41
        $this->core->error_404();
42
    }
43
44
    /**
45
     * AdminAutoload method.
46
     *
47
     * @return void
48
     */
49
    public static function adminAutoload() {
50
51
        parent::adminAutoload();
52
        Events::create()->onShopProductDelete()->setListener('addProductWhenDelete');
53
        Events::create()->onShopProductCreate()->setListener('delProductWhenCreate');
54
        Events::create()->onShopProductAjaxChangeActive()->setListener('addProductWhenAjaxChangeActive');
55
        Events::create()->onShopCategoryDelete()->setListener('addProductsWhenCatDelete');
56
        Events::create()->onShopCategoryEdit()->setListener('updateCatUrl');
57
        Events::create()->onShopProductUpdate()->setListener('addProductWhenAjaxChangeActive');
58
        Events::create()->onShopProductCreate()->setListener('addProductWhenAjaxChangeActive');
59
        Events::create()->on('ShopAdminProducts:fastProdCreate')->setListener('addProductWhenAjaxChangeActive');
60
    }
61
62
    /**
63
     * Autoload method.
64
     *
65
     * @return void
66
     */
67
    public function autoload() {
68
69
        $url = ltrim(str_replace('/' . MY_Controller::getCurrentLocale() . '/', '', $this->input->server('REQUEST_URI')), '/'); //locale fix
70
        $row = $this->db
71
            ->where('trash_url', $url)
72
            ->or_where('trash_url', $this->uri->uri_string())
73
            ->get('trash')->row();
74
75
        if ($row != null) {
76
            /** Подключает модули, в авто лоаде они идут после*/
77
            $this->load->helper('menu/menu');
78
            $this->load->helper('xbanners/xbanners');
79
80
            ($row->trash_redirect_type != '404') OR $this->core->error_404();
81
82
            $this->setTrashIsCreateType($row->trash_redirect_type);
83
            redirect($this->formRedirectUrl($row->trash_redirect), 'location', $row->trash_type);
84
        } else {
85
            $url = $this->uri->getBaseUrl() . $this->input->server('REQUEST_URI');
86
            if ($url != $this->formRedirectUrl($url)) {
87
                redirect($this->formRedirectUrl($url), 'location', 301);
88
            }
89
        }
90
    }
91
92
    /**
93
     * Form URL redirect to
94
     * @param $url - url string
95
     * @return mixed
96
     */
97
    public function formRedirectUrl($url) {
98
99
        $siteSettings = $this->cms_base->get_settings();
100
101
        if ($this->getTrashIsCreateType() && $this->getTrashIsCreateType() != 'url') {
102
103
            $site_length = mb_strlen($this->input->server('REQUEST_SCHEME') . '://' .$this->input->server('SERVER_NAME'));
104
105
            $url = site_url(substr($url, $site_length));
106
107
        }
108
109
        switch ($siteSettings['www_redirect']) {
110
            case 'from_www':
111
                return str_replace('://www.', '://', $url);
112
            case 'to_www':
113
                $url = str_replace('://www.', '://', $url);
114
                return str_replace('://', '://www.', $url);
115
            default:
116
                return $url;
117
        }
118
119
    }
120
121
    /**
122
     *
123
     * @param string $trash_url
124
     * @param string $redirect_url
125
     * @param int $type
126
     * @throws Exception
127
     */
128
    public function create_redirect($trash_url, $redirect_url, $type = 301) {
129
130
        if (!isset($trash_url)) {
131
            throw new Exception(lang('Old URL is not specified', 'trash'));
132
        }
133
134
        if (!isset($redirect_url)) {
135
            throw new Exception(lang('New URL is not specified', 'trash'));
136
        }
137
138
        $array = [
139
                  'trash_url'           => ltrim($trash_url, '/'),
140
                  'trash_redirect_type' => 'url',
141
                  'trash_type'          => in_array($type, [301, 302]) ? $type : 301,
142
                  'trash_redirect'      => '/' . str_replace(['http://', 'https://'], '', $redirect_url),
143
                 ];
144
145
        $this->db->insert('trash', $array);
146
147
        if ($this->db->_error_message()) {
148
            throw new Exception($this->db->_error_message());
149
        }
150
    }
151
152
    /**
153
     * @param array $arg
154
     */
155
    public static function delProductWhenCreate($arg) {
156
157
        /** @var SProducts $model */
158
        $model = $arg['model'];
159
        $ci = &get_instance();
160
        $ci->db->where('trash_url', $model->getRouteUrl())->delete('trash');
161
    }
162
163
    /**
164
     * @param array $arg
165
     */
166
    public static function addProductWhenAjaxChangeActive($arg) {
167
168
        /* @var $model SProducts */
169
        $models = $arg['model'];
170
171
        /* @var $ci MY_Controller */
172
        $ci = &get_instance();
173
174
        if (!$models instanceof PropelObjectCollection) {
175
            $model = $models;
176
            $models = new PropelObjectCollection();
177
            $models->append($model);
178
        }
179
180
        foreach ($models as $model) {
181
            if (!$model) {
182
                continue;
183
            }
184
185
            $ci->db->where('trash_url', $model->getRouteUrl())->delete('trash');
186
            if (!$model->getActive()) {
187
                $array = [
188
                          'trash_id'            => $model->getCategoryId(),
189
                          'trash_url'           => $model->getRouteUrl(),
190
                          'trash_redirect_type' => 'category',
191
                          'trash_type'          => '302',
192
                          'trash_redirect'      => site_url($model->getMainCategory()->getRouteUrl()),
193
                         ];
194
                $ci->db->insert('trash', $array);
195
            }
196
        }
197
    }
198
199
    /**
200
     * @param array $arg
201
     */
202
    public static function addProductWhenDelete($arg) {
203
204
        $models = $arg['model'];
205
        $ci = &get_instance();
206
        /** @var SProducts $model */
207
        foreach ($models as $model) {
208
            $array = [
209
                      'trash_id'            => $model->getCategoryId(),
210
                      'trash_url'           => $model->getRouteUrl(),
211
                      'trash_redirect_type' => 'category',
212
                      'trash_type'          => '301',
213
                      'trash_redirect'      => site_url($model->getMainCategory()->getRouteUrl()),
214
                     ];
215
            $ci->db->insert('trash', $array);
216
        }
217
    }
218
219
    public function _install() {
220
221
        $this->load->dbforge();
222
        ($this->dx_auth->is_admin()) OR exit;
223
        $fields = [
224
                   'id'                  => [
225
                                             'type'           => 'INT',
226
                                             'auto_increment' => true,
227
                                            ],
228
                   'trash_id'            => [
229
                                             'type'       => 'VARCHAR',
230
                                             'constraint' => '255',
231
                                             'null'       => true,
232
                                            ],
233
                   'trash_url'           => [
234
                                             'type'       => 'VARCHAR',
235
                                             'constraint' => '255',
236
                                             'null'       => true,
237
                                            ],
238
                   'trash_redirect_type' => [
239
                                             'type'       => 'VARCHAR',
240
                                             'constraint' => '20',
241
                                             'null'       => true,
242
                                            ],
243
                   'trash_redirect'      => [
244
                                             'type'       => 'VARCHAR',
245
                                             'constraint' => '255',
246
                                             'null'       => true,
247
                                            ],
248
                   'trash_type'          => [
249
                                             'type'       => 'VARCHAR',
250
                                             'constraint' => '3',
251
                                             'null'       => true,
252
                                            ],
253
                  ];
254
255
        $this->dbforge->add_field($fields);
256
        $this->dbforge->add_key('id', true);
257
        $this->dbforge->create_table('trash');
258
259
        $this->db->where('name', 'trash');
260
        $this->db->update('components', ['enabled' => 0, 'autoload' => 1]);
261
    }
262
263
    public function _deinstall() {
264
265
        $this->load->dbforge();
266
        ($this->dx_auth->is_admin()) OR exit;
267
        $this->dbforge->drop_table('trash');
268
    }
269
270
    /**
271
     * @return string
272
     */
273
    public function getTrashIsCreateType() {
274
275
        return $this->trash_is_create_type;
276
    }
277
278
    /**
279
     * @param string $trash_is_create_type
280
     */
281
    public function setTrashIsCreateType($trash_is_create_type) {
282
283
        $this->trash_is_create_type = $trash_is_create_type;
284
    }
285
286
}
287
288
/* End of file trash.php */