Issues (2021)

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.

catalog/index.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
  * osCommerce Online Merchant
4
  *
5
  * @copyright (c) 2016 osCommerce; https://www.oscommerce.com
6
  * @license MIT; https://www.oscommerce.com/license/mit.txt
7
  */
8
9
  use OSC\OM\HTML;
10
  use OSC\OM\OSCOM;
11
12
  require('includes/application_top.php');
13
14 View Code Duplication
  if (OSCOM::hasSitePage()) {
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...
15
    if (OSCOM::isRPC() === false) {
16
        $page_file = OSCOM::getSitePageFile();
17
18
        if (empty($page_file) || !is_file($page_file)) {
19
          $page_file = OSCOM::getConfig('dir_root') . 'includes/error_documents/404.php';
20
        }
21
22
        if (OSCOM::useSiteTemplateWithPageFile()) {
23
          include($oscTemplate->getFile('template_top.php'));
24
        }
25
26
        include($page_file);
27
28
        if (OSCOM::useSiteTemplateWithPageFile()) {
29
          include($oscTemplate->getFile('template_bottom.php'));
30
        }
31
    }
32
33
    goto main_sub3;
34
  }
35
36
// the following cPath references come from application_top.php
37
  $category_depth = 'top';
38
  if (isset($cPath) && tep_not_null($cPath)) {
39
    $Qcheck = $OSCOM_Db->prepare('select products_id from :table_products_to_categories where categories_id = :categories_id limit 1');
40
    $Qcheck->bindInt(':categories_id', $current_category_id);
41
    $Qcheck->execute();
42
43
    if ($Qcheck->fetch() !== false) {
44
      $category_depth = 'products'; // display products
45
    } else {
46
      $Qcheck = $OSCOM_Db->prepare('select categories_id from :table_categories where parent_id = :parent_id');
47
      $Qcheck->bindInt(':parent_id', $current_category_id);
48
      $Qcheck->execute();
49
50
      if ($Qcheck->fetch() !== false) {
51
        $category_depth = 'nested'; // navigate through the categories
52
      } else {
53
        $category_depth = 'products'; // category has no products, but display the 'no products' message
54
      }
55
    }
56
  }
57
58
  $OSCOM_Language->loadDefinitions('index');
59
60
  require($oscTemplate->getFile('template_top.php'));
61
62
  if ($category_depth == 'nested') {
63
    $Qcategory = $OSCOM_Db->prepare('select cd.categories_name, c.categories_image, cd.categories_description from :table_categories c, :table_categories_description cd where c.categories_id = :categories_id and c.categories_id = cd.categories_id and cd.language_id = :language_id');
64
    $Qcategory->bindInt(':categories_id', $current_category_id);
65
    $Qcategory->bindInt(':language_id', $OSCOM_Language->getId());
66
    $Qcategory->execute();
67
?>
68
69
<div class="page-header">
70
  <h1><?php echo $Qcategory->value('categories_name'); ?></h1>
71
</div>
72
73
<?php
74
  if ($messageStack->size('product_action') > 0) {
75
    echo $messageStack->output('product_action');
76
  }
77
?>
78
79
<div class="contentContainer">
80
  <div class="row">
81
    <?php echo $oscTemplate->getContent('index_nested'); ?>
82
  </div>
83
</div>
84
85
<?php
86
  } elseif ($category_depth == 'products' || (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id']))) {
87
// create column list
88
    $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
89
                         'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
90
                         'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
91
                         'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
92
                         'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
93
                         'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
94
                         'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
95
                         'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
96
97
    asort($define_list);
98
99
    $column_list = array();
100
    foreach($define_list as $key => $value) {
101
      if ($value > 0) $column_list[] = $key;
102
    }
103
104
    $search_query = 'select SQL_CALC_FOUND_ROWS';
105
106 View Code Duplication
    for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
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...
107
      switch ($column_list[$i]) {
108
        case 'PRODUCT_LIST_MODEL':
109
          $search_query .= ' p.products_model,';
110
          break;
111
        case 'PRODUCT_LIST_NAME':
112
          $search_query .= ' pd.products_name,';
113
          break;
114
        case 'PRODUCT_LIST_MANUFACTURER':
115
          $search_query .= ' m.manufacturers_name,';
116
          break;
117
        case 'PRODUCT_LIST_QUANTITY':
118
          $search_query .= ' p.products_quantity,';
119
          break;
120
        case 'PRODUCT_LIST_IMAGE':
121
          $search_query .= ' p.products_image,';
122
          break;
123
        case 'PRODUCT_LIST_WEIGHT':
124
          $search_query .= ' p.products_weight,';
125
          break;
126
      }
127
    }
128
129
// show the products of a specified manufacturer
130
    if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
131 View Code Duplication
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
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...
132
// We are asked to show only a specific category
133
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m, :table_products_to_categories p2c where p.products_status = "1" and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
134
      } else {
135
// We show them all
136
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m where p.products_status = "1" and pd.products_id = p.products_id and pd.language_id = :language_id and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id';
137
      }
138 View Code Duplication
    } else {
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...
139
// show the products in a given categorie
140
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
141
// We are asked to show only specific catgeory
142
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products p left join :table_specials s on p.products_id = s.products_id, :table_products_description pd, :table_manufacturers m, :table_products_to_categories p2c where p.products_status = "1" and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = :manufacturers_id and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
143
      } else {
144
// We show them all
145
        $search_query .= ' p.products_id, SUBSTRING_INDEX(pd.products_description, " ", 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from :table_products_description pd, :table_products p left join :table_manufacturers m on p.manufacturers_id = m.manufacturers_id left join :table_specials s on p.products_id = s.products_id, :table_products_to_categories p2c where p.products_status = "1" and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
146
      }
147
    }
148
149 View Code Duplication
    if ( (!isset($_GET['sort'])) || (!preg_match('/^[1-8][ad]$/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
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...
150
      for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
151
        if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
152
          $_GET['sort'] = $i+1 . 'a';
153
          $search_query .= ' order by pd.products_name';
154
          break;
155
        }
156
      }
157
    } else {
158
      $sort_col = substr($_GET['sort'], 0 , 1);
159
      $sort_order = substr($_GET['sort'], 1);
160
161
      switch ($column_list[$sort_col-1]) {
162
        case 'PRODUCT_LIST_MODEL':
163
          $search_query .= ' order by p.products_model ' . ($sort_order == 'd' ? 'desc' : '') . ', pd.products_name';
164
          break;
165
        case 'PRODUCT_LIST_NAME':
166
          $search_query .= ' order by pd.products_name ' . ($sort_order == 'd' ? 'desc' : '');
167
          break;
168
        case 'PRODUCT_LIST_MANUFACTURER':
169
          $search_query .= ' order by m.manufacturers_name ' . ($sort_order == 'd' ? 'desc' : '') . ', pd.products_name';
170
          break;
171
        case 'PRODUCT_LIST_QUANTITY':
172
          $search_query .= ' order by p.products_quantity ' . ($sort_order == 'd' ? 'desc' : '') . ', pd.products_name';
173
          break;
174
        case 'PRODUCT_LIST_IMAGE':
175
          $search_query .= ' order by pd.products_name';
176
          break;
177
        case 'PRODUCT_LIST_WEIGHT':
178
          $search_query .= ' order by p.products_weight ' . ($sort_order == 'd' ? 'desc' : '') . ', pd.products_name';
179
          break;
180
        case 'PRODUCT_LIST_PRICE':
181
          $search_query .= ' order by final_price ' . ($sort_order == 'd' ? 'desc' : '') . ', pd.products_name';
182
          break;
183
      }
184
    }
185
186
    $search_query .= ' limit :page_set_offset, :page_set_max_results';
187
188
    $Qlisting = $OSCOM_Db->prepare($search_query);
189
190
    if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
191 View Code Duplication
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
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...
192
        $Qlisting->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
193
        $Qlisting->bindInt(':language_id', $OSCOM_Language->getId());
194
        $Qlisting->bindInt(':categories_id', $_GET['filter_id']);
195
      } else {
196
        $Qlisting->bindInt(':language_id', $OSCOM_Language->getId());
197
        $Qlisting->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
198
      }
199 View Code Duplication
    } else {
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...
200
      if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
201
        $Qlisting->bindInt(':manufacturers_id', $_GET['filter_id']);
202
        $Qlisting->bindInt(':language_id', $OSCOM_Language->getId());
203
        $Qlisting->bindInt(':categories_id', $current_category_id);
204
      } else {
205
        $Qlisting->bindInt(':language_id', $OSCOM_Language->getId());
206
        $Qlisting->bindInt(':categories_id', $current_category_id);
207
      }
208
    }
209
210
    $Qlisting->setPageSet(isset($_GET['view']) && ($_GET['view'] == 'all') ? 999999 : MAX_DISPLAY_SEARCH_RESULTS);
211
    $Qlisting->execute();
212
213
    $catname = OSCOM::getDef('heading_title', ['store_name' => STORE_NAME]);
214
    if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
215
      $Qtitle = $OSCOM_Db->prepare('select m.manufacturers_image, m.manufacturers_name as catname, mi.manufacturers_description as catdesc from :table_manufacturers m, :table_manufacturers_info mi where m.manufacturers_id = :manufacturers_id and m.manufacturers_id = mi.manufacturers_id and mi.languages_id = :languages_id');
216
      $Qtitle->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
217
      $Qtitle->bindInt(':languages_id', $OSCOM_Language->getId());
218
      $Qtitle->execute();
219
220
      $catname = $Qtitle->value('catname');
221
    } elseif ($current_category_id) {
222
      $Qtitle = $OSCOM_Db->prepare('select c.categories_image, cd.categories_name as catname, cd.categories_description as catdesc from :table_categories c, :table_categories_description cd where c.categories_id = :categories_id and c.categories_id = cd.categories_id and cd.language_id = :language_id');
223
      $Qtitle->bindInt(':categories_id', $current_category_id);
224
      $Qtitle->bindInt(':language_id', $OSCOM_Language->getId());
225
      $Qtitle->execute();
226
227
      $catname = $Qtitle->value('catname');
228
    }
229
?>
230
231
<div class="page-header">
232
  <h1><?php echo $catname; ?></h1>
233
</div>
234
235
<?php
236
if (tep_not_null($Qtitle->value('catdesc'))) {
237
  echo '<div class="well well-sm">' . $Qtitle->value('catdesc') . '</div>';
238
}
239
?>
240
<div class="contentContainer">
241
242
<?php
243
// optional Product List Filter
244
    if (PRODUCT_LIST_FILTER > 0) {
245
      if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
246
        $Qfilter = $OSCOM_Db->prepare('select SQL_CALC_FOUND_ROWS distinct c.categories_id as id, cd.categories_name as name from :table_products p, :table_products_to_categories p2c, :table_categories c, :table_categories_description cd where p.manufacturers_id = :manufacturers_id and p.products_status = "1" and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.categories_id = cd.categories_id and cd.language_id = :language_id order by cd.categories_name');
247
        $Qfilter->bindInt(':language_id', $OSCOM_Language->getId());
248
        $Qfilter->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
249
        $Qfilter->execute();
250
      } else {
251
        $Qfilter = $OSCOM_Db->prepare('select SQL_CALC_FOUND_ROWS distinct m.manufacturers_id as id, m.manufacturers_name as name from :table_products p, :table_products_to_categories p2c, :table_manufacturers m where p.products_status = 1 and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = :categories_id order by m.manufacturers_name');
252
        $Qfilter->bindInt(':categories_id', $current_category_id);
253
        $Qfilter->execute();
254
      }
255
256
      if ($Qfilter->getPageSetTotalRows() > 1) {
257
        echo '<div>' . HTML::form('filter', OSCOM::link('index.php', '', false), 'get', null, ['session_id' => true]) . '<p align="right">' . OSCOM::getDef('text_show') . '&nbsp;';
258
        if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
259
          echo HTML::hiddenField('manufacturers_id', $_GET['manufacturers_id']);
260
          $options = array(array('id' => '', 'text' => OSCOM::getDef('text_all_categories')));
261
        } else {
262
          echo HTML::hiddenField('cPath', $cPath);
263
          $options = array(array('id' => '', 'text' => OSCOM::getDef('text_all_manufacturers')));
264
        }
265
        echo HTML::hiddenField('sort', $_GET['sort']);
266
        while ($Qfilter->fetch()) {
267
          $options[] = array('id' => $Qfilter->valueInt('id'), 'text' => $Qfilter->value('name'));
268
        }
269
        echo HTML::selectField('filter_id', $options, (isset($_GET['filter_id']) ? $_GET['filter_id'] : ''), 'onchange="this.form.submit()"');
270
        echo '</p></form></div>' . "\n";
271
      }
272
    }
273
274
    include('includes/content/product_listing.php');
275
?>
276
277
</div>
278
279
<?php
280
  } else { // default page
281
?>
282
283
<div class="page-header">
284
  <h1><?php echo OSCOM::getDef('heading_title', ['store_name' => STORE_NAME]); ?></h1>
285
</div>
286
287
<?php
288
  if ($messageStack->size('product_action') > 0) {
289
    echo $messageStack->output('product_action');
290
  }
291
?>
292
293
<div class="row">
294
  <?php echo $oscTemplate->getContent('index'); ?>
295
</div>
296
297
<?php
298
  }
299
300
  require($oscTemplate->getFile('template_bottom.php'));
301
302
  main_sub3: // Sites and Apps skip to here
303
304
  require('includes/application_bottom.php');
305
?>
306