general.php ➔ tep_get_file_permissions()   F
last analyzed

Complexity

Conditions 23
Paths > 20000

Size

Total Lines 41
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 23
eloc 33
nc 110592
nop 1
dl 0
loc 41
rs 2.6553
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\Cache;
10
  use OSC\OM\HTML;
11
  use OSC\OM\OSCOM;
12
  use OSC\OM\Registry;
13
14
////
15
// Parse the data used in the html tags to ensure the tags will not break
16
  function tep_parse_input_field_data($data, $parse) {
17
    return strtr(trim($data), $parse);
18
  }
19
20
  function tep_customers_name($customers_id) {
21
    $Qcustomer = Registry::get('Db')->get('customers', [
22
      'customers_firstname',
23
      'customers_lastname'
24
    ], [
25
      'customers_id' => (int)$customers_id
26
    ]);
27
28
    return $Qcustomer->value('customers_firstname') . ' ' . $Qcustomer->value('customers_lastname');
29
  }
30
31
  function tep_get_path($current_category_id = '') {
32
    global $cPath_array;
33
34
    $OSCOM_Db = Registry::get('Db');
35
36
    if ($current_category_id == '') {
37
      $cPath_new = implode('_', $cPath_array);
38
    } else {
39
      if (sizeof($cPath_array) == 0) {
40
        $cPath_new = $current_category_id;
41
      } else {
42
        $cPath_new = '';
43
44
        $Qlast = $OSCOM_Db->get('categories', 'parent_id', ['categories_id' => (int)$cPath_array[(sizeof($cPath_array)-1)]]);
45
46
        $Qcurrent = $OSCOM_Db->get('categories', 'parent_id', ['categories_id' => (int)$current_category_id]);
47
48
        if ($Qlast->valueInt('parent_id') === $Qcurrent->valueInt('parent_id')) {
49 View Code Duplication
          for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
0 ignored issues
show
Duplication introduced by
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...
50
            $cPath_new .= '_' . $cPath_array[$i];
51
          }
52
        } else {
53 View Code Duplication
          for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
0 ignored issues
show
Duplication introduced by
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...
54
            $cPath_new .= '_' . $cPath_array[$i];
55
          }
56
        }
57
58
        $cPath_new .= '_' . $current_category_id;
59
60
        if (substr($cPath_new, 0, 1) == '_') {
61
          $cPath_new = substr($cPath_new, 1);
62
        }
63
      }
64
    }
65
66
    return 'cPath=' . $cPath_new;
67
  }
68
69
  function tep_get_all_get_params($exclude_array = '') {
70
71
    if ($exclude_array == '') {
72
      $exclude_array = array();
73
    } elseif (is_string($exclude_array)) {
74
      $exclude_array = [
75
        $exclude_array
76
      ];
77
    }
78
79
    $get_url = '';
80
81
    foreach ( $_GET as $key => $value ) {
82
      if (($key != session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';
83
    }
84
85
    return $get_url;
86
  }
87
88
  function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
89
    $OSCOM_Db = Registry::get('Db');
90
    $OSCOM_Language = Registry::get('Language');
91
92
    if (!is_array($category_tree_array)) $category_tree_array = array();
93
    if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => OSCOM::getDef('text_top'));
94
95
    if ($include_itself) {
96
      $Qcategory = $OSCOM_Db->get('categories_description', 'categories_name', ['language_id' => $OSCOM_Language->getId(), 'categories_id' => (int)$parent_id]);
97
98
      $category_tree_array[] = [
99
        'id' => $parent_id,
100
        'text' => $Qcategory->value('categories_name')
101
      ];
102
    }
103
104
    $Qcategories = $OSCOM_Db->get([
105
      'categories c',
106
      'categories_description cd'
107
    ], [
108
      'c.categories_id',
109
      'cd.categories_name',
110
      'c.parent_id'
111
    ], [
112
      'c.categories_id' => [
113
        'rel' => 'cd.categories_id'
114
      ],
115
      'cd.language_id' => $OSCOM_Language->getId(),
116
      'c.parent_id' => (int)$parent_id
117
    ], [
118
      'c.sort_order',
119
      'cd.categories_name'
120
    ]);
121
122 View Code Duplication
    while ($Qcategories->fetch()) {
0 ignored issues
show
Duplication introduced by
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...
123
      if ($exclude != $Qcategories->valueInt('categories_id')) $category_tree_array[] = array('id' => $Qcategories->valueInt('categories_id'), 'text' => $spacing . $Qcategories->value('categories_name'));
124
      $category_tree_array = tep_get_category_tree($Qcategories->valueInt('categories_id'), $spacing . '&nbsp;&nbsp;&nbsp;', $exclude, $category_tree_array);
125
    }
126
127
    return $category_tree_array;
128
  }
129
130
  function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {
131
    global $currencies;
132
133
    $OSCOM_Db = Registry::get('Db');
134
    $OSCOM_Language = Registry::get('Language');
135
136
    if ($exclude == '') {
137
      $exclude = array();
138
    }
139
140
    $select_string = '<select name="' . $name . '"';
141
142
    if ($parameters) {
143
      $select_string .= ' ' . $parameters;
144
    }
145
146
    $select_string .= '>';
147
148
    $Qproducts = $OSCOM_Db->get([
149
      'products p',
150
      'products_description pd'
151
    ], [
152
      'p.products_id',
153
      'pd.products_name',
154
      'p.products_price'
155
    ], [
156
      'p.products_id' => [
157
        'rel' => 'pd.products_id'
158
      ],
159
      'pd.language_id' => $OSCOM_Language->getId()
160
    ], 'products_name');
161
162
    while ($Qproducts->fetch()) {
163
      if (!in_array($Qproducts->valueInt('products_id'), $exclude)) {
164
        $select_string .= '<option value="' . $Qproducts->valueInt('products_id') . '">' . $Qproducts->value('products_name') . ' (' . $currencies->format($Qproducts->value('products_price')) . ')</option>';
165
      }
166
    }
167
168
    $select_string .= '</select>';
169
170
    return $select_string;
171
  }
172
173
  function tep_format_system_info_array($array) {
174
175
    $output = '';
176
    foreach ($array as $section => $child) {
177
      $output .= '[' . $section . ']' . "\n";
178
      foreach ($child as $variable => $value) {
179
        if (is_array($value)) {
180
          $output .= $variable . ' = ' . implode(',', $value) ."\n";
181
        } else {
182
          $output .= $variable . ' = ' . $value . "\n";
183
        }
184
      }
185
186
    $output .= "\n";
187
    }
188
    return trim($output);
189
190
  }
191
192
  function tep_options_name($options_id) {
193
    $OSCOM_Db = Registry::get('Db');
194
    $OSCOM_Language = Registry::get('Language');
195
196
    $Qoptions = $OSCOM_Db->get('products_options', 'products_options_name', ['products_options_id' => (int)$options_id, 'language_id' => $OSCOM_Language->getId()]);
197
198
    return $Qoptions->value('products_options_name');
199
  }
200
201
  function tep_values_name($values_id) {
202
    $OSCOM_Db = Registry::get('Db');
203
    $OSCOM_Language = Registry::get('Language');
204
205
    $Qvalues = $OSCOM_Db->get('products_options_values', 'products_options_values_name', ['products_options_values_id' => (int)$values_id, 'language_id' => $OSCOM_Language->getId()]);
206
207
    return $Qvalues->value('products_options_values_name');
208
  }
209
210
  function tep_info_image($image, $alt, $width = '', $height = '') {
211
    if (tep_not_null($image) && is_file(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $image)) {
212
      $image = HTML::image(OSCOM::linkImage('Shop/' . $image), $alt, $width, $height);
213
    } else {
214
      $image = OSCOM::getDef('text_image_nonexistent');
215
    }
216
217
    return $image;
218
  }
219
220 View Code Duplication
  function tep_break_string($string, $len, $break_char = '-') {
0 ignored issues
show
Duplication introduced by
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...
221
    $l = 0;
222
    $output = '';
223
    for ($i=0, $n=strlen($string); $i<$n; $i++) {
224
      $char = substr($string, $i, 1);
225
      if ($char != ' ') {
226
        $l++;
227
      } else {
228
        $l = 0;
229
      }
230
      if ($l > $len) {
231
        $l = 1;
232
        $output .= $break_char;
233
      }
234
      $output .= $char;
235
    }
236
237
    return $output;
238
  }
239
240
  function tep_get_country_name($country_id) {
241
    $Qcountry = Registry::get('Db')->get('countries', 'countries_name', ['countries_id' => (int)$country_id]);
242
243
    if ($Qcountry->fetch() !== false) {
244
      return $Qcountry->value('countries_name');
245
    }
246
247
    return $country_id;
248
  }
249
250 View Code Duplication
  function tep_get_zone_name($country_id, $zone_id, $default_zone) {
0 ignored issues
show
Duplication introduced by
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...
251
    $Qzone = Registry::get('Db')->get('zones', 'zone_name', ['zone_country_id' => (int)$country_id, 'zone_id' => (int)$zone_id]);
252
253
    if ($Qzone->fetch() !== false) {
254
      return $Qzone->value('zone_name');
255
    }
256
257
    return $default_zone;
258
  }
259
260
  function tep_not_null($value) {
261
    if (is_array($value)) {
262
      if (sizeof($value) > 0) {
263
        return true;
264
      } else {
265
        return false;
266
      }
267
    } else {
268
      if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
269
        return true;
270
      } else {
271
        return false;
272
      }
273
    }
274
  }
275
276 View Code Duplication
  function tep_tax_classes_pull_down($parameters, $selected = '') {
0 ignored issues
show
Duplication introduced by
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...
277
    $select_string = '<select ' . $parameters . '>';
278
279
    $Qclasses = Registry::get('Db')->get('tax_class', [
280
      'tax_class_id',
281
      'tax_class_title'
282
    ], null, 'tax_class_title');
283
284
    while ($Qclasses->fetch()) {
285
      $select_string .= '<option value="' . $Qclasses->valueInt('tax_class_id') . '"';
286
287
      if ($selected == $Qclasses->valueInt('tax_class_id')) {
288
        $select_string .= ' SELECTED';
289
      }
290
291
      $select_string .= '>' . $Qclasses->value('tax_class_title') . '</option>';
292
    }
293
294
    $select_string .= '</select>';
295
296
    return $select_string;
297
  }
298
299 View Code Duplication
  function tep_geo_zones_pull_down($parameters, $selected = '') {
0 ignored issues
show
Duplication introduced by
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...
300
    $select_string = '<select ' . $parameters . '>';
301
302
    $Qzones = Registry::get('Db')->get('geo_zones', [
303
      'geo_zone_id',
304
      'geo_zone_name'
305
    ], null, 'geo_zone_name');
306
307
    while ($Qzones->fetch()) {
308
      $select_string .= '<option value="' . $Qzones->valueInt('geo_zone_id') . '"';
309
310
      if ($selected == $Qzones->valueInt('geo_zone_id')) {
311
        $select_string .= ' SELECTED';
312
      }
313
314
      $select_string .= '>' . $Qzones->value('geo_zone_name') . '</option>';
315
    }
316
317
    $select_string .= '</select>';
318
319
    return $select_string;
320
  }
321
322
  function tep_get_geo_zone_name($geo_zone_id) {
323
    $Qzones = Registry::get('Db')->get('geo_zones', 'geo_zone_name', ['geo_zone_id' => (int)$geo_zone_id]);
324
325
    if ($Qzones->fetch() !== false) {
326
      return $Qzones->value('geo_zone_name');
327
    }
328
329
    return $geo_zone_id;
330
  }
331
332
  function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {
333
    $Qaddress = Registry::get('Db')->get('address_format', 'address_format', ['address_format_id' => (int)$address_format_id]);
334
335
    $replace = [
336
      '$company' => HTML::outputProtected($address['company']),
337
      '$firstname' => '',
338
      '$lastname' => '',
339
      '$street' => HTML::outputProtected($address['street_address']),
340
      '$suburb' => HTML::outputProtected($address['suburb']),
341
      '$city' => HTML::outputProtected($address['city']),
342
      '$state' => HTML::outputProtected($address['state']),
343
      '$postcode' => HTML::outputProtected($address['postcode']),
344
      '$country' => ''
345
    ];
346
347 View Code Duplication
    if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
0 ignored issues
show
Duplication introduced by
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...
348
      $replace['$firstname'] = HTML::outputProtected($address['firstname']);
349
      $replace['$lastname'] = HTML::outputProtected($address['lastname']);
350
    } elseif (isset($address['name']) && tep_not_null($address['name'])) {
351
      $replace['$firstname'] = HTML::outputProtected($address['name']);
352
    }
353
354 View Code Duplication
    if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
0 ignored issues
show
Duplication introduced by
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...
355
      $replace['$country'] = tep_get_country_name($address['country_id']);
356
357
      if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
358
        $replace['$state'] = tep_get_zone_code($address['country_id'], $address['zone_id'], $replace['$state']);
359
      }
360
    } elseif (isset($address['country']) && tep_not_null($address['country'])) {
361
      $replace['$country'] = HTML::outputProtected($address['country']);
362
    }
363
364
    $replace['$zip'] = $replace['$postcode'];
365
366 View Code Duplication
    if ($html) {
0 ignored issues
show
Duplication introduced by
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...
367
// HTML Mode
368
      $HR = '<hr />';
369
      $hr = '<hr />';
370
      if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
371
        $CR = '<br />';
372
        $cr = '<br />';
373
        $eoln = $cr;
0 ignored issues
show
Unused Code introduced by
$eoln 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...
374
      } else { // Use values supplied
375
        $CR = $eoln . $boln;
376
        $cr = $CR;
377
      }
378
    } else {
379
// Text Mode
380
      $CR = $eoln;
381
      $cr = $CR;
382
      $HR = '----------------------------------------';
383
      $hr = '----------------------------------------';
384
    }
385
386
    $replace['$CR'] = $CR;
387
    $replace['$cr'] = $cr;
388
    $replace['$HR'] = $HR;
389
    $replace['$hr'] = $hr;
390
391
    $replace['$statecomma'] = '';
392
    $replace['$streets'] = $replace['$street'];
393 View Code Duplication
    if ($replace['$suburb'] != '') $replace['$streets'] = $replace['$street'] . $replace['$cr'] . $replace['$suburb'];
0 ignored issues
show
Duplication introduced by
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...
394
    if ($replace['$state'] != '') $replace['$statecomma'] = $replace['$state'] . ', ';
395
396
    $address = strtr($Qaddress->value('address_format'), $replace);
397
398 View Code Duplication
    if ( (ACCOUNT_COMPANY == 'true') && tep_not_null($replace['$company']) ) {
0 ignored issues
show
Duplication introduced by
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...
399
      $address = $replace['$company'] . $replace['$cr'] . $address;
400
    }
401
402
    return $address;
403
  }
404
405
  ////////////////////////////////////////////////////////////////////////////////////////////////
406
  //
407
  // Function    : tep_get_zone_code
408
  //
409
  // Arguments   : country           country code string
410
  //               zone              state/province zone_id
411
  //               def_state         default string if zone==0
412
  //
413
  // Return      : state_prov_code   state/province code
414
  //
415
  // Description : Function to retrieve the state/province code (as in FL for Florida etc)
416
  //
417
  ////////////////////////////////////////////////////////////////////////////////////////////////
418 View Code Duplication
  function tep_get_zone_code($country, $zone, $def_state) {
0 ignored issues
show
Duplication introduced by
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...
419
    $Qstate = Registry::get('Db')->get('zones', 'zone_code', ['zone_country_id' => (int)$country, 'zone_id' => (int)$zone]);
420
421
    if ($Qstate->fetch() !== false) {
422
      return $Qstate->value('zone_code');
423
    }
424
425
    return $def_state;
426
  }
427
428
  function tep_get_uprid($prid, $params) {
429
    $uprid = $prid;
430
    if ( (is_array($params)) && (!strstr($prid, '{')) ) {
431
      foreach ( $params as $option => $value ) {
432
        $uprid = $uprid . '{' . $option . '}' . $value;
433
      }
434
    }
435
436
    return $uprid;
437
  }
438
439
  function tep_get_prid($uprid) {
440
    $pieces = explode('{', $uprid);
441
442
    return $pieces[0];
443
  }
444
445
  function tep_get_languages() {
446
    $languages_array = [];
447
448
    $Qlanguages = Registry::get('Db')->get('languages', [
449
      'languages_id',
450
      'name',
451
      'code',
452
      'image',
453
      'directory'
454
    ], null, 'sort_order');
455
456 View Code Duplication
    while ($Qlanguages->fetch()) {
0 ignored issues
show
Duplication introduced by
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...
457
      $languages_array[] = [
458
        'id' => $Qlanguages->valueInt('languages_id'),
459
        'name' => $Qlanguages->value('name'),
460
        'code' => $Qlanguages->value('code'),
461
        'image' => $Qlanguages->value('image'),
462
        'directory' => $Qlanguages->value('directory')
463
      ];
464
    }
465
466
    return $languages_array;
467
  }
468
469
  function tep_get_category_name($category_id, $language_id) {
470
    $Qcategory = Registry::get('Db')->get('categories_description', 'categories_name', ['categories_id' => (int)$category_id, 'language_id' => (int)$language_id]);
471
472
    return $Qcategory->value('categories_name');
473
  }
474
475 View Code Duplication
  function tep_get_orders_status_name($orders_status_id, $language_id = '') {
0 ignored issues
show
Duplication introduced by
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...
476
    $OSCOM_Db = Registry::get('Db');
477
    $OSCOM_Language = Registry::get('Language');
478
479
    if (empty($language_id) || !is_numeric($language_id)) $language_id = $OSCOM_Language->getId();
480
481
    $Qstatus = $OSCOM_Db->get('orders_status', 'orders_status_name', ['orders_status_id' => (int)$orders_status_id, 'language_id' => (int)$language_id]);
482
483
    return $Qstatus->value('orders_status_name');
484
  }
485
486
  function tep_get_orders_status() {
487
    $OSCOM_Db = Registry::get('Db');
488
    $OSCOM_Language = Registry::get('Language');
489
490
    $orders_status_array = [];
491
492
    $Qstatus = $OSCOM_Db->get('orders_status', [
493
      'orders_status_id',
494
      'orders_status_name'
495
    ], [
496
      'language_id' => $OSCOM_Language->getId()
497
    ], 'orders_status_id');
498
499
    while ($Qstatus->fetch()) {
500
      $orders_status_array[] = [
501
        'id' => $Qstatus->valueInt('orders_status_id'),
502
        'text' => $Qstatus->value('orders_status_name')
503
      ];
504
    }
505
506
    return $orders_status_array;
507
  }
508
509 View Code Duplication
  function tep_get_products_name($product_id, $language_id = 0) {
0 ignored issues
show
Duplication introduced by
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...
510
    $OSCOM_Db = Registry::get('Db');
0 ignored issues
show
Unused Code introduced by
$OSCOM_Db 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...
511
    $OSCOM_Language = Registry::get('Language');
512
513
    if (empty($language_id) || !is_numeric($language_id)) $language_id = $OSCOM_Language->getId();
514
515
    $Qproduct = Registry::get('Db')->get('products_description', 'products_name', ['products_id' => (int)$product_id, 'language_id' => (int)$language_id]);
516
517
    return $Qproduct->value('products_name');
518
  }
519
520
  function tep_get_products_description($product_id, $language_id) {
521
    $Qproduct = Registry::get('Db')->get('products_description', 'products_description', ['products_id' => (int)$product_id, 'language_id' => (int)$language_id]);
522
523
    return $Qproduct->value('products_description');
524
  }
525
526
  function tep_get_products_url($product_id, $language_id) {
527
    $Qproduct = Registry::get('Db')->get('products_description', 'products_url', ['products_id' => (int)$product_id, 'language_id' => (int)$language_id]);
528
529
    return $Qproduct->value('products_url');
530
  }
531
532
////
533
// Return the manufacturers URL in the needed language
534
// TABLES: manufacturers_info
535
  function tep_get_manufacturer_url($manufacturer_id, $language_id) {
536
    $Qmanufacturer = Registry::get('Db')->get('manufacturers_info', 'manufacturers_url', ['manufacturers_id' => (int)$manufacturer_id, 'languages_id' => (int)$language_id]);
537
538
    return $Qmanufacturer->value('manufacturers_url');
539
  }
540
541
////
542
// Count how many products exist in a category
543
// TABLES: products, products_to_categories, categories
544
  function tep_products_in_category_count($categories_id, $include_deactivated = false) {
545
    $OSCOM_Db = Registry::get('Db');
546
547
    if ($include_deactivated) {
548
      $Qproducts = $OSCOM_Db->get([
549
        'products p',
550
        'products_to_categories p2c'
551
      ], [
552
        'count(*) as total'
553
      ], [
554
        'p.products_id' => [
555
          'rel' => 'p2c.products_id'
556
        ],
557
        'p2c.categories_id' => (int)$categories_id
558
      ]);
559
    } else {
560
      $Qproducts = $OSCOM_Db->get([
561
        'products p',
562
        'products_to_categories p2c'
563
      ], [
564
        'count(*) as total'
565
      ], [
566
        'p.products_id' => [
567
          'rel' => 'p2c.products_id'
568
        ],
569
        'p.products_status' => '1',
570
        'p2c.categories_id' => (int)$categories_id
571
      ]);
572
    }
573
574
    $products_count = $Qproducts->valueInt('total');
575
576
    $Qchildren = $OSCOM_Db->get('categories', 'categories_id', ['parent_id' => (int)$categories_id]);
577
578
    while ($Qchildren->fetch()) {
579
      $products_count += call_user_func(__FUNCTION__, $Qchildren->valueInt('categories_id'), $include_deactivated);
580
    }
581
582
    return $products_count;
583
  }
584
585
////
586
// Count how many subcategories exist in a category
587
// TABLES: categories
588
  function tep_childs_in_category_count($categories_id) {
589
    $categories_count = 0;
590
591
    $Qcategories = Registry::get('Db')->get('categories', 'categories_id', ['parent_id' => (int)$categories_id]);
592
593
    while ($Qcategories->fetch()) {
594
      $categories_count++;
595
596
      $categories_count += call_user_func(__FUNCTION__, $Qcategories->valueInt('categories_id'));
597
    }
598
599
    return $categories_count;
600
  }
601
602
////
603
// Returns an array with countries
604
// TABLES: countries
605
  function tep_get_countries($default = '') {
606
    $countries_array = array();
607
    if ($default) {
608
      $countries_array[] = array('id' => '',
609
                                 'text' => $default);
610
    }
611
612
    $Qcountries = Registry::get('Db')->get('countries', ['countries_id', 'countries_name'], null, 'countries_name');
613
614
    while ($Qcountries->fetch()) {
615
      $countries_array[] = [
616
        'id' => $Qcountries->valueInt('countries_id'),
617
        'text' => $Qcountries->value('countries_name')
618
      ];
619
    }
620
621
    return $countries_array;
622
  }
623
624
////
625
// return an array with country zones
626
  function tep_get_country_zones($country_id) {
627
    $zones_array = array();
628
629
    $Qzones = Registry::get('Db')->get('zones', [
630
      'zone_id',
631
      'zone_name'
632
    ], [
633
      'zone_country_id' => (int)$country_id
634
    ], 'zone_name');
635
636
    while ($Qzones->fetch()) {
637
      $zones_array[] = [
638
        'id' => $Qzones->valueInt('zone_id'),
639
        'text' => $Qzones->value('zone_name')
640
      ];
641
    }
642
643
    return $zones_array;
644
  }
645
646
  function tep_prepare_country_zones_pull_down($country_id = '') {
647
    $zones = tep_get_country_zones($country_id);
648
649
    if (sizeof($zones) > 0) {
650
      $zones_select = array(array('id' => '', 'text' => OSCOM::getDef('please_select')));
651
      $zones = array_merge($zones_select, $zones);
652
    } else {
653
      $zones = array(array('id' => '', 'text' => OSCOM::getDef('type_below')));
654
    }
655
656
    return $zones;
657
  }
658
659
////
660
// Get list of address_format_id's
661
  function tep_get_address_formats() {
662
    $address_format_array = [];
663
664
    $Qaddress = Registry::get('Db')->get('address_format', 'address_format_id', null, 'address_format_id');
665
666
    while ($Qaddress->fetch()) {
667
      $address_format_array[] = [
668
        'id' => $Qaddress->valueInt('address_format_id'),
669
        'text' => $Qaddress->valueInt('address_format_id')
670
      ];
671
    }
672
673
    return $address_format_array;
674
  }
675
676
////
677
// Alias function for Store configuration values in the Administration Tool
678
  function tep_cfg_pull_down_country_list($country_id) {
679
    return HTML::selectField('configuration_value', tep_get_countries(), $country_id);
680
  }
681
682
  function tep_cfg_pull_down_zone_list($zone_id) {
683
    return HTML::selectField('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id);
684
  }
685
686 View Code Duplication
  function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {
0 ignored issues
show
Duplication introduced by
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...
687
    $name = tep_not_null($key) ? 'configuration[' . $key . ']' : 'configuration_value';
688
689
    $tax_class_array = [
690
      [
691
        'id' => '0',
692
        'text' => OSCOM::getDef('text_none')
693
      ]
694
    ];
695
696
    $Qclass = Registry::get('Db')->get('tax_class', ['tax_class_id', 'tax_class_title'], null, 'tax_class_title');
697
698
    while ($Qclass->fetch()) {
699
      $tax_class_array[] = [
700
        'id' => $Qclass->valueInt('tax_class_id'),
701
        'text' => $Qclass->value('tax_class_title')
702
      ];
703
    }
704
705
    return HTML::selectField($name, $tax_class_array, $tax_class_id);
706
  }
707
708
////
709
// Function to read in text area in admin
710
 function tep_cfg_textarea($text, $key = '') {
711
    $name = tep_not_null($key) ? 'configuration[' . $key . ']' : 'configuration_value';
712
713
    return HTML::textareaField($name, 35, 5, $text);
714
  }
715
716 View Code Duplication
  function tep_cfg_get_zone_name($zone_id) {
0 ignored issues
show
Duplication introduced by
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...
717
    $Qzone = Registry::get('Db')->get('zones', 'zone_name', ['zone_id' => (int)$zone_id]);
718
719
    if ($Qzone->fetch()) {
720
      return $Qzone->value('zone_name');
721
    }
722
723
    return $zone_id;
724
  }
725
726
////
727
// Sets the status of a banner
728
  function tep_set_banner_status($banners_id, $status) {
729
    $OSCOM_Db = Registry::get('Db');
730
731
    if ($status == '1') {
732
      return $OSCOM_Db->save('banners', [
733
        'status' => '1',
734
        'expires_impressions' => 'null',
735
        'expires_date' => 'null',
736
        'date_status_change' => 'null'
737
      ], [
738
        'banners_id' => (int)$banners_id
739
      ]);
740
    } elseif ($status == '0') {
741
      return $OSCOM_Db->save('banners', [
742
        'status' => '0',
743
        'date_status_change' => 'now()'
744
      ], [
745
        'banners_id' => (int)$banners_id
746
      ]);
747
    } else {
748
      return -1;
749
    }
750
  }
751
752
////
753
// Sets the status of a product
754 View Code Duplication
  function tep_set_product_status($products_id, $status) {
0 ignored issues
show
Duplication introduced by
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...
755
    $OSCOM_Db = Registry::get('Db');
756
757
    if ($status == '1') {
758
      return $OSCOM_Db->save('products', [
759
        'products_status' => '1',
760
        'products_last_modified' => 'now()'
761
      ], [
762
        'products_id' => (int)$products_id
763
      ]);
764
    } elseif ($status == '0') {
765
      return $OSCOM_Db->save('products', [
766
        'products_status' => '0',
767
        'products_last_modified' => 'now()'
768
      ], [
769
        'products_id' => (int)$products_id
770
      ]);
771
    } else {
772
      return -1;
773
    }
774
  }
775
776
////
777
// Sets the status of a review
778 View Code Duplication
  function tep_set_review_status($reviews_id, $status) {
0 ignored issues
show
Duplication introduced by
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...
779
    $OSCOM_Db = Registry::get('Db');
780
781
    if ($status == '1') {
782
      return $OSCOM_Db->save('reviews', [
783
        'reviews_status' => '1',
784
        'last_modified' => 'now()'
785
      ], [
786
        'reviews_id' => (int)$reviews_id
787
      ]);
788
    } elseif ($status == '0') {
789
      return $OSCOM_Db->save('reviews', [
790
        'reviews_status' => '0',
791
        'last_modified' => 'now()'
792
      ], [
793
        'reviews_id' => (int)$reviews_id
794
      ]);
795
    } else {
796
      return -1;
797
    }
798
  }
799
800
////
801
// Sets the status of a product on special
802 View Code Duplication
  function tep_set_specials_status($specials_id, $status) {
0 ignored issues
show
Duplication introduced by
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...
803
    $OSCOM_Db = Registry::get('Db');
804
805
    if ($status == '1') {
806
      return $OSCOM_Db->save('specials', [
807
        'status' => '1',
808
        'expires_date' => 'null',
809
        'date_status_change' => 'null'
810
      ], [
811
        'specials_id' => (int)$specials_id
812
      ]);
813
    } elseif ($status == '0') {
814
      return $OSCOM_Db->save('specials', [
815
        'status' => '0',
816
        'date_status_change' => 'now()'
817
      ], [
818
        'specials_id' => (int)$specials_id
819
      ]);
820
    } else {
821
      return -1;
822
    }
823
  }
824
825
////
826
// Sets timeout for the current script.
827
// Cant be used in safe mode.
828
  function tep_set_time_limit($limit) {
829
    if (!get_cfg_var('safe_mode')) {
830
      set_time_limit($limit);
831
    }
832
  }
833
834
////
835
// Alias function for Store configuration values in the Administration Tool
836
  function tep_cfg_select_option($select_array, $key_value, $key = '') {
837
    $string = '';
838
839
    for ($i=0, $n=sizeof($select_array); $i<$n; $i++) {
840
      $name = ((tep_not_null($key)) ? 'configuration[' . $key . ']' : 'configuration_value');
841
842
      $string .= '<br /><input type="radio" name="' . $name . '" value="' . $select_array[$i] . '"';
843
844
      if ($key_value == $select_array[$i]) $string .= ' checked="checked"';
845
846
      $string .= ' /> ' . $select_array[$i];
847
    }
848
849
    return $string;
850
  }
851
852
////
853
// Alias function for module configuration keys
854
  function tep_mod_select_option($select_array, $key_name, $key_value) {
855
    foreach ( $select_array as $key => $value ) {
856
      if (is_int($key)) $key = $value;
857
      $string .= '<br /><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"';
0 ignored issues
show
Bug introduced by
The variable $string 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...
858
      if ($key_value == $key) $string .= ' checked="checked"';
859
      $string .= ' /> ' . $value;
860
    }
861
862
    return $string;
863
  }
864
865
////
866
// Retreive server information
867
  function tep_get_system_information() {
868
    $OSCOM_Db = Registry::get('Db');
869
870
    $Qdate = $OSCOM_Db->query('select now() as datetime');
871
872
    @list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
873
874
    $data = array();
875
876
    $data['oscommerce']  = array('version' => OSCOM::getVersion());
877
878
    $data['system'] = array('date' => date('Y-m-d H:i:s O T'),
879
                            'os' => PHP_OS,
880
                            'kernel' => $kernel,
881
                            'uptime' => @exec('uptime'),
882
                            'http_server' => $_SERVER['SERVER_SOFTWARE']);
883
884
    $data['mysql']  = array('version' => $OSCOM_Db->getAttribute(\PDO::ATTR_SERVER_VERSION),
885
                            'date' => $Qdate->value('datetime'));
886
887
    $data['php']    = array('version' => PHP_VERSION,
888
                            'zend' => zend_version(),
889
                            'sapi' => PHP_SAPI,
890
                            'int_size'	=> defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '',
891
                            'safe_mode'	=> (int) @ini_get('safe_mode'),
892
                            'open_basedir' => (int) @ini_get('open_basedir'),
893
                            'memory_limit' => @ini_get('memory_limit'),
894
                            'error_reporting' => error_reporting(),
895
                            'display_errors' => (int)@ini_get('display_errors'),
896
                            'allow_url_fopen' => (int) @ini_get('allow_url_fopen'),
897
                            'allow_url_include' => (int) @ini_get('allow_url_include'),
898
                            'file_uploads' => (int) @ini_get('file_uploads'),
899
                            'upload_max_filesize' => @ini_get('upload_max_filesize'),
900
                            'post_max_size' => @ini_get('post_max_size'),
901
                            'disable_functions' => @ini_get('disable_functions'),
902
                            'disable_classes' => @ini_get('disable_classes'),
903
                            'enable_dl'	=> (int) @ini_get('enable_dl'),
904
                            'filter.default'   => @ini_get('filter.default'),
905
                            'default_charset' => @ini_get('default_charset'),
906
                            'mbstring.func_overload' => @ini_get('mbstring.func_overload'),
907
                            'mbstring.internal_encoding' => @ini_get('mbstring.internal_encoding'),
908
                            'unicode.semantics' => (int) @ini_get('unicode.semantics'),
909
                            'zend_thread_safty'	=> (int) function_exists('zend_thread_id'),
910
                            'opcache.enable' => @ini_get('opcache.enable'),
911
                            'extensions' => get_loaded_extensions());
912
913
    return $data;
914
  }
915
916
  function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {
917
    $OSCOM_Db = Registry::get('Db');
918
    $OSCOM_Language = Registry::get('Language');
919
920
    if (!is_array($categories_array)) {
921
      $categories_array = [];
922
    }
923
924
    if ($from == 'product') {
925
      $Qcategories = $OSCOM_Db->get('products_to_categories', 'categories_id', ['products_id' => (int)$id]);
926
927
      while ($Qcategories->fetch()) {
928
        if ($Qcategories->valueInt('categories_id') === 0) {
929
          $categories_array[$index][] = [
930
            'id' => '0',
931
            'text' => OSCOM::getDef('text_top')
932
          ];
933
        } else {
934
          $Qcategory = $OSCOM_Db->get([
935
            'categories c',
936
            'categories_description cd'
937
          ], [
938
            'cd.categories_name',
939
            'c.parent_id'
940
          ], [
941
            'c.categories_id' => [
942
              'val' => $Qcategories->valueInt('categories_id'),
943
              'rel' => 'cd.categories_id'
944
            ],
945
            'cd.language_id' => $OSCOM_Language->getId()
946
          ]);
947
948
          $categories_array[$index][] = [
949
            'id' => $Qcategories->valueInt('categories_id'),
950
            'text' => $Qcategory->value('categories_name')
951
          ];
952
953 View Code Duplication
          if ($Qcategory->valueInt('parent_id') > 0) {
0 ignored issues
show
Duplication introduced by
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...
954
            $categories_array = call_user_func(__FUNCTION__, $Qcategory->valueInt('parent_id'), 'category', $categories_array, $index);
955
          }
956
957
          $categories_array[$index] = array_reverse($categories_array[$index]);
958
        }
959
960
        $index++;
961
      }
962
    } elseif ($from == 'category') {
963
      $Qcategory = $OSCOM_Db->get([
964
        'categories c',
965
        'categories_description cd'
966
      ], [
967
        'cd.categories_name',
968
        'c.parent_id'
969
      ], [
970
        'c.categories_id' => [
971
          'val' => (int)$id,
972
          'rel' => 'cd.categories_id'
973
        ],
974
        'cd.language_id' => $OSCOM_Language->getId()
975
      ]);
976
977
      $categories_array[$index][] = [
978
        'id' => (int)$id,
979
        'text' => $Qcategory->value('categories_name')
980
      ];
981
982 View Code Duplication
      if ($Qcategory->valueInt('parent_id') > 0) {
0 ignored issues
show
Duplication introduced by
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...
983
        $categories_array = call_user_func(__FUNCTION__, $Qcategory->valueInt('parent_id'), 'category', $categories_array, $index);
984
      }
985
    }
986
987
    return $categories_array;
988
  }
989
990 View Code Duplication
  function tep_output_generated_category_path($id, $from = 'category') {
0 ignored issues
show
Duplication introduced by
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...
991
    $calculated_category_path_string = '';
992
    $calculated_category_path = tep_generate_category_path($id, $from);
993
    for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
994
      for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
995
        $calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
996
      }
997
      $calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '<br />';
998
    }
999
    $calculated_category_path_string = substr($calculated_category_path_string, 0, -6);
1000
1001
    if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = OSCOM::getDef('text_top');
1002
1003
    return $calculated_category_path_string;
1004
  }
1005
1006 View Code Duplication
  function tep_get_generated_category_path_ids($id, $from = 'category') {
0 ignored issues
show
Duplication introduced by
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...
1007
    $calculated_category_path_string = '';
1008
    $calculated_category_path = tep_generate_category_path($id, $from);
1009
    for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
1010
      for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
1011
        $calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_';
1012
      }
1013
      $calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . '<br />';
1014
    }
1015
    $calculated_category_path_string = substr($calculated_category_path_string, 0, -6);
1016
1017
    if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = OSCOM::getDef('text_top');
1018
1019
    return $calculated_category_path_string;
1020
  }
1021
1022
  function tep_remove_category($category_id) {
1023
    $OSCOM_Db = Registry::get('Db');
1024
1025
    $Qimage = $OSCOM_Db->get('categories', 'categories_image', ['categories_id' => (int)$category_id]);
1026
1027
    $Qduplicate = $OSCOM_Db->get('categories', 'categories_id', [
1028
      'categories_image' => $Qimage->value('categories_image'),
1029
      'categories_id' => [
1030
        'op' => '!=',
1031
        'val' => (int)$category_id
1032
      ]
1033
    ], null, 1);
1034
1035 View Code Duplication
    if ($Qduplicate->fetch() === false) {
0 ignored issues
show
Duplication introduced by
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...
1036
      if (!empty($Qimage->value('categories_image')) && is_file(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qimage->value('categories_image'))) {
1037
        unlink(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qimage->value('categories_image'));
1038
      }
1039
    }
1040
1041
    $OSCOM_Db->delete('categories', ['categories_id' => (int)$category_id]);
1042
    $OSCOM_Db->delete('categories_description', ['categories_id' => (int)$category_id]);
1043
    $OSCOM_Db->delete('products_to_categories', ['categories_id' => (int)$category_id]);
1044
1045
    Cache::clear('categories');
1046
    Cache::clear('products-also_purchased');
1047
  }
1048
1049
  function tep_remove_product($product_id) {
1050
    $OSCOM_Db = Registry::get('Db');
1051
1052
    $Qimage = $OSCOM_Db->get('products', 'products_image', ['products_id' => (int)$product_id]);
1053
1054
    $Qduplicate = $OSCOM_Db->get('products', 'products_id', [
1055
      'products_image' => $Qimage->value('products_image'),
1056
      'products_id' => [
1057
        'op' => '!=',
1058
        'val' => (int)$product_id
1059
      ]
1060
    ], null, 1);
1061
1062 View Code Duplication
    if ($Qduplicate->fetch() === false) {
0 ignored issues
show
Duplication introduced by
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...
1063
      if (!empty($Qimage->value('products_image')) && is_file(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qimage->value('products_image'))) {
1064
        unlink(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qimage->value('products_image'));
1065
      }
1066
    }
1067
1068
    $Qimages = $OSCOM_Db->get('products_images', 'image', ['products_id' => (int)$product_id]);
1069
1070
    if ($Qimages->fetch() !== false) {
1071
      do {
1072
        $Qduplicate = $OSCOM_Db->get('products_images', 'id', [
1073
          'image' => $Qimages->value('image'),
1074
          'products_id' => [
1075
            'op' => '!=',
1076
            'val' => (int)$product_id
1077
          ]
1078
        ], null, 1);
1079
1080 View Code Duplication
        if ($Qduplicate->fetch() === false) {
0 ignored issues
show
Duplication introduced by
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...
1081
          if (is_file(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qimages->value('image'))) {
1082
            unlink(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qimages->value('image'));
1083
          }
1084
        }
1085
      } while ($Qimages->fetch());
1086
1087
      $OSCOM_Db->delete('products_images', ['products_id' => (int)$product_id]);
1088
    }
1089
1090
    $OSCOM_Db->delete('specials', ['products_id' => (int)$product_id]);
1091
    $OSCOM_Db->delete('products', ['products_id' => (int)$product_id]);
1092
    $OSCOM_Db->delete('products_to_categories', ['products_id' => (int)$product_id]);
1093
    $OSCOM_Db->delete('products_description', ['products_id' => (int)$product_id]);
1094
    $OSCOM_Db->delete('products_attributes', ['products_id' => (int)$product_id]);
1095
1096
    $Qdel = $OSCOM_Db->prepare('delete from :table_customers_basket where products_id = :products_id or products_id like :products_id_att');
1097
    $Qdel->bindInt(':products_id', (int)$product_id);
1098
    $Qdel->bindInt(':products_id_att', (int)$product_id . '{%');
1099
    $Qdel->execute();
1100
1101
    $Qdel = $OSCOM_Db->prepare('delete from :table_customers_basket_attributes where products_id = :products_id or products_id like :products_id_att');
1102
    $Qdel->bindInt(':products_id', (int)$product_id);
1103
    $Qdel->bindInt(':products_id_att', (int)$product_id . '{%');
1104
    $Qdel->execute();
1105
1106
    $Qreviews = $OSCOM_Db->get('reviews', 'reviews_id', ['products_id' => (int)$product_id]);
1107
1108
    while ($Qreviews->fetch()) {
1109
      $OSCOM_Db->delete('reviews_description', ['reviews_id' => $Qreviews->valueInt('reviews_id')]);
1110
    }
1111
1112
    $OSCOM_Db->delete('reviews', ['products_id' => (int)$product_id]);
1113
1114
    Cache::clear('categories');
1115
    Cache::clear('products-also_purchased');
1116
  }
1117
1118
  function tep_remove_order($order_id, $restock = false) {
1119
    $OSCOM_Db = Registry::get('Db');
1120
1121
    if ($restock == 'on') {
1122
      $Qproducts = $OSCOM_Db->get('orders_products', [
1123
        'products_id',
1124
        'products_quantity'
1125
      ], [
1126
        'orders_id' => (int)$order_id
1127
      ]);
1128
1129
      while ($Qproducts->fetch()) {
1130
        $Qupdate = $OSCOM_Db->prepare('update :table_products set products_quantity = products_quantity + ' . $Qproducts->valueInt('products_quantity') . ', products_ordered = products_ordered - ' . $Qproducts->valueInt('products_quantity') . ' where products_id = :products_id');
1131
        $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id'));
1132
        $Qupdate->execute();
1133
      }
1134
    }
1135
1136
    $OSCOM_Db->delete('orders', ['orders_id' => (int)$order_id]);
1137
    $OSCOM_Db->delete('orders_products', ['orders_id' => (int)$order_id]);
1138
    $OSCOM_Db->delete('orders_products_attributes', ['orders_id' => (int)$order_id]);
1139
    $OSCOM_Db->delete('orders_status_history', ['orders_id' => (int)$order_id]);
1140
    $OSCOM_Db->delete('orders_total', ['orders_id' => (int)$order_id]);
1141
  }
1142
1143
  function tep_get_file_permissions($mode) {
1144
// determine type
1145
    if ( ($mode & 0xC000) == 0xC000) { // unix domain socket
1146
      $type = 's';
1147
    } elseif ( ($mode & 0x4000) == 0x4000) { // directory
1148
      $type = 'd';
1149
    } elseif ( ($mode & 0xA000) == 0xA000) { // symbolic link
1150
      $type = 'l';
1151
    } elseif ( ($mode & 0x8000) == 0x8000) { // regular file
1152
      $type = '-';
1153
    } elseif ( ($mode & 0x6000) == 0x6000) { //bBlock special file
1154
      $type = 'b';
1155
    } elseif ( ($mode & 0x2000) == 0x2000) { // character special file
1156
      $type = 'c';
1157
    } elseif ( ($mode & 0x1000) == 0x1000) { // named pipe
1158
      $type = 'p';
1159
    } else { // unknown
1160
      $type = '?';
1161
    }
1162
1163
// determine permissions
1164
    $owner['read']    = ($mode & 00400) ? 'r' : '-';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$owner was never initialized. Although not strictly required by PHP, it is generally a good practice to add $owner = 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...
1165
    $owner['write']   = ($mode & 00200) ? 'w' : '-';
1166
    $owner['execute'] = ($mode & 00100) ? 'x' : '-';
1167
    $group['read']    = ($mode & 00040) ? 'r' : '-';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$group was never initialized. Although not strictly required by PHP, it is generally a good practice to add $group = 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...
1168
    $group['write']   = ($mode & 00020) ? 'w' : '-';
1169
    $group['execute'] = ($mode & 00010) ? 'x' : '-';
1170
    $world['read']    = ($mode & 00004) ? 'r' : '-';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$world was never initialized. Although not strictly required by PHP, it is generally a good practice to add $world = 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...
1171
    $world['write']   = ($mode & 00002) ? 'w' : '-';
1172
    $world['execute'] = ($mode & 00001) ? 'x' : '-';
1173
1174
// adjust for SUID, SGID and sticky bit
1175
    if ($mode & 0x800 ) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';
1176
    if ($mode & 0x400 ) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S';
1177
    if ($mode & 0x200 ) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T';
1178
1179
    return $type .
1180
           $owner['read'] . $owner['write'] . $owner['execute'] .
1181
           $group['read'] . $group['write'] . $group['execute'] .
1182
           $world['read'] . $world['write'] . $world['execute'];
1183
  }
1184
1185
////
1186
// Output the tax percentage with optional padded decimals
1187 View Code Duplication
  function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) {
0 ignored issues
show
Duplication introduced by
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...
1188
    if (strpos($value, '.')) {
1189
      $loop = true;
1190
      while ($loop) {
1191
        if (substr($value, -1) == '0') {
1192
          $value = substr($value, 0, -1);
1193
        } else {
1194
          $loop = false;
1195
          if (substr($value, -1) == '.') {
1196
            $value = substr($value, 0, -1);
1197
          }
1198
        }
1199
      }
1200
    }
1201
1202
    if ($padding > 0) {
1203
      if ($decimal_pos = strpos($value, '.')) {
1204
        $decimals = strlen(substr($value, ($decimal_pos+1)));
1205
        for ($i=$decimals; $i<$padding; $i++) {
1206
          $value .= '0';
1207
        }
1208
      } else {
1209
        $value .= '.';
1210
        for ($i=0; $i<$padding; $i++) {
1211
          $value .= '0';
1212
        }
1213
      }
1214
    }
1215
1216
    return $value;
1217
  }
1218
1219 View Code Duplication
  function tep_get_tax_class_title($tax_class_id) {
0 ignored issues
show
Duplication introduced by
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...
1220
    if ($tax_class_id == '0') {
1221
      return OSCOM::getDef('text_none');
1222
    } else {
1223
      $Qclass = Registry::get('Db')->get('tax_class', 'tax_class_title', ['tax_class_id' => (int)$tax_class_id]);
1224
1225
      return $Qclass->value('tax_class_title');
1226
    }
1227
  }
1228
1229
  function tep_banner_image_extension() {
1230
    if (function_exists('imagetypes')) {
1231
      if (imagetypes() & IMG_PNG) {
1232
        return 'png';
1233
      } elseif (imagetypes() & IMG_JPG) {
1234
        return 'jpg';
1235
      } elseif (imagetypes() & IMG_GIF) {
1236
        return 'gif';
1237
      }
1238
    } elseif (function_exists('imagecreatefrompng') && function_exists('imagepng')) {
1239
      return 'png';
1240
    } elseif (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) {
1241
      return 'jpg';
1242
    } elseif (function_exists('imagecreatefromgif') && function_exists('imagegif')) {
1243
      return 'gif';
1244
    }
1245
1246
    return false;
1247
  }
1248
1249
////
1250
// Wrapper function for round() for php3 compatibility
1251
  function tep_round($value, $precision) {
1252
    return round($value, $precision);
1253
  }
1254
1255
////
1256
// Add tax to a products price
1257
  function tep_add_tax($price, $tax, $override = false) {
1258 View Code Duplication
    if ( ( (DISPLAY_PRICE_WITH_TAX == 'true') || ($override == true) ) && ($tax > 0) ) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
Duplication introduced by
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...
1259
      return $price + tep_calculate_tax($price, $tax);
1260
    } else {
1261
      return $price;
1262
    }
1263
  }
1264
1265
// Calculates Tax rounding the result
1266
  function tep_calculate_tax($price, $tax) {
1267
    return $price * $tax / 100;
1268
  }
1269
1270
////
1271
// Returns the tax rate for a zone / class
1272
// TABLES: tax_rates, zones_to_geo_zones
1273
  function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {
1274
    global $customer_zone_id, $customer_country_id;
1275
1276
    if ( ($country_id == -1) && ($zone_id == -1) ) {
1277
      $country_id = STORE_COUNTRY;
1278
      $zone_id = STORE_ZONE;
1279
    }
1280
1281
    $Qtax = Registry::get('Db')->prepare('select sum(tax_rate) as tax_rate from :table_tax_rates tr left join :table_zones_to_geo_zones za on tr.tax_zone_id = za.geo_zone_id left join :table_geo_zones tz on tz.geo_zone_id = tr.tax_zone_id where (za.zone_country_id IS NULL OR za.zone_country_id = "0" OR za.zone_country_id = :zone_country_id) AND (za.zone_id IS NULL OR za.zone_id = "0" OR za.zone_id = :zone_id) AND tr.tax_class_id = :tax_class_id group by tr.tax_priority');
1282
    $Qtax->bindInt(':zone_country_id', (int)$country_id);
1283
    $Qtax->bindInt(':zone_id', (int)$zone_id);
1284
    $Qtax->bindInt(':tax_class_id', (int)$class_id);
1285
    $Qtax->execute();
1286
1287
    if ($Qtax->fetch() !== false) {
1288
      $tax_multiplier = 0;
1289
1290
      do {
1291
        $tax_multiplier += $Qtax->value('tax_rate');
1292
      } while ($Qtax->fetch());
1293
1294
      return $tax_multiplier;
1295
    } else {
1296
      return 0;
1297
    }
1298
  }
1299
1300
////
1301
// Returns the tax rate for a tax class
1302
// TABLES: tax_rates
1303
  function tep_get_tax_rate_value($class_id) {
1304
    return tep_get_tax_rate($class_id, -1, -1);
1305
  }
1306
1307
  function tep_call_function($function, $parameter, $object = '') {
1308
    if ($object == '') {
1309
      return call_user_func($function, $parameter);
1310
    } else {
1311
      return call_user_func(array($object, $function), $parameter);
1312
    }
1313
  }
1314
1315 View Code Duplication
  function tep_get_zone_class_title($zone_class_id) {
0 ignored issues
show
Duplication introduced by
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...
1316
    if ($zone_class_id == '0') {
1317
      return OSCOM::getDef('text_none');
1318
    } else {
1319
      $Qclass = Registry::get('Db')->get('geo_zones', [
1320
        'geo_zone_name'
1321
      ], [
1322
        'geo_zone_id' => (int)$zone_class_id
1323
      ]);
1324
1325
      return $Qclass->value('geo_zone_name');
1326
    }
1327
  }
1328
1329 View Code Duplication
  function tep_cfg_pull_down_zone_classes($zone_class_id, $key = '') {
0 ignored issues
show
Duplication introduced by
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...
1330
    $name = !empty($key) ? 'configuration[' . $key . ']' : 'configuration_value';
1331
1332
    $zone_class_array = [
1333
      [
1334
        'id' => '0',
1335
        'text' => OSCOM::getDef('text_none')
1336
      ]
1337
    ];
1338
1339
    $Qclass = Registry::get('Db')->get('geo_zones', [
1340
      'geo_zone_id',
1341
      'geo_zone_name'
1342
    ], null, 'geo_zone_name');
1343
1344
    while ($Qclass->fetch()) {
1345
      $zone_class_array[] = [
1346
        'id' => $Qclass->valueInt('geo_zone_id'),
1347
        'text' => $Qclass->value('geo_zone_name')
1348
      ];
1349
    }
1350
1351
    return HTML::selectField($name, $zone_class_array, $zone_class_id);
1352
  }
1353
1354
  function tep_cfg_pull_down_order_statuses($order_status_id, $key = '') {
1355
    $OSCOM_Db = Registry::get('Db');
1356
    $OSCOM_Language = Registry::get('Language');
1357
1358
    $name = !empty($key) ? 'configuration[' . $key . ']' : 'configuration_value';
1359
1360
    $statuses_array = [
1361
      [
1362
        'id' => '0',
1363
        'text' => OSCOM::getDef('text_default')
1364
      ]
1365
    ];
1366
1367
    $Qstatus = $OSCOM_Db->get('orders_status', [
1368
      'orders_status_id',
1369
      'orders_status_name'
1370
    ], [
1371
      'language_id' => $OSCOM_Language->getId()
1372
    ], 'orders_status_name');
1373
1374
    while ($Qstatus->fetch()) {
1375
      $statuses_array[] = [
1376
        'id' => $Qstatus->valueInt('orders_status_id'),
1377
        'text' => $Qstatus->value('orders_status_name')
1378
      ];
1379
    }
1380
1381
    return HTML::selectField($name, $statuses_array, $order_status_id);
1382
  }
1383
1384 View Code Duplication
  function tep_get_order_status_name($order_status_id, $language_id = '') {
0 ignored issues
show
Duplication introduced by
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...
1385
    $OSCOM_Db = Registry::get('Db');
1386
    $OSCOM_Language = Registry::get('Language');
1387
1388
    if ($order_status_id < 1) return OSCOM::getDef('text_default');
1389
1390
    if (empty($language_id) || !is_numeric($language_id)) $language_id = $OSCOM_Language->getId();
1391
1392
    $Qstatus = $OSCOM_Db->get('orders_status', 'orders_status_name', ['orders_status_id' => (int)$order_status_id, 'language_id' => (int)$language_id]);
1393
1394
    return $Qstatus->value('orders_status_name');
1395
  }
1396
1397
////
1398
// Parse and secure the cPath parameter values
1399 View Code Duplication
  function tep_parse_category_path($cPath) {
0 ignored issues
show
Duplication introduced by
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...
1400
// make sure the category IDs are integers
1401
    $cPath_array = array_map(function ($string) {
1402
      return (int)$string;
1403
    }, explode('_', $cPath));
1404
1405
// make sure no duplicate category IDs exist which could lock the server in a loop
1406
    $tmp_array = array();
1407
    $n = sizeof($cPath_array);
1408
    for ($i=0; $i<$n; $i++) {
1409
      if (!in_array($cPath_array[$i], $tmp_array)) {
1410
        $tmp_array[] = $cPath_array[$i];
1411
      }
1412
    }
1413
1414
    return $tmp_array;
1415
  }
1416
1417
////
1418
// javascript to dynamically update the states/provinces list when the country is changed
1419
// TABLES: zones
1420
  function tep_js_zone_list($country, $form, $field) {
1421
    $OSCOM_Db = Registry::get('Db');
1422
1423
    $num_country = 1;
1424
    $output_string = '';
1425
1426
    $Qcountries = $OSCOM_Db->get('zones', 'distinct zone_country_id', null, 'zone_country_id');
1427
1428
    while ($Qcountries->fetch()) {
1429
      if ($num_country == 1) {
1430
        $output_string .= '  if (' . $country . ' == "' . $Qcountries->valueInt('zone_country_id') . '") {' . "\n";
1431
      } else {
1432
        $output_string .= '  } else if (' . $country . ' == "' . $Qcountries->valueInt('zone_country_id') . '") {' . "\n";
1433
      }
1434
1435
      $num_state = 1;
1436
1437
      $Qstates = $OSCOM_Db->get('zones', [
1438
        'zone_name',
1439
        'zone_id'
1440
      ], [
1441
        'zone_country_id' => $Qcountries->valueInt('zone_country_id')
1442
      ], 'zone_name');
1443
1444
      while ($Qstates->fetch()) {
1445
        if ($num_state == '1') $output_string .= '    ' . $form . '.' . $field . '.options[0] = new Option("' . OSCOM::getDef('please_select') . '", "");' . "\n";
1446
        $output_string .= '    ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $Qstates->value('zone_name') . '", "' . $Qstates->valueInt('zone_id') . '");' . "\n";
1447
        $num_state++;
1448
      }
1449
      $num_country++;
1450
    }
1451
    $output_string .= '  } else {' . "\n" .
1452
                      '    ' . $form . '.' . $field . '.options[0] = new Option("' . OSCOM::getDef('type_below') . '", "");' . "\n" .
1453
                      '  }' . "\n";
1454
1455
    return $output_string;
1456
  }
1457
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
1458