Code Duplication    Length = 9-10 lines in 8 locations

catalog/admin/includes/functions/general.php 5 locations

@@ 311-320 (lines=10) @@
308
    return $output;
309
  }
310
311
  function tep_get_country_name($country_id) {
312
    $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");
313
314
    if (!tep_db_num_rows($country_query)) {
315
      return $country_id;
316
    } else {
317
      $country = tep_db_fetch_array($country_query);
318
      return $country['countries_name'];
319
    }
320
  }
321
322
  function tep_get_zone_name($country_id, $zone_id, $default_zone) {
323
    $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
@@ 322-330 (lines=9) @@
319
    }
320
  }
321
322
  function tep_get_zone_name($country_id, $zone_id, $default_zone) {
323
    $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
324
    if (tep_db_num_rows($zone_query)) {
325
      $zone = tep_db_fetch_array($zone_query);
326
      return $zone['zone_name'];
327
    } else {
328
      return $default_zone;
329
    }
330
  }
331
332
  function tep_not_null($value) {
333
    if (is_array($value)) {
@@ 733-742 (lines=10) @@
730
    return tep_draw_textarea_field('configuration_value', false, 35, 5, $text);
731
  }
732
733
  function tep_cfg_get_zone_name($zone_id) {
734
    $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");
735
736
    if (!tep_db_num_rows($zone_query)) {
737
      return $zone_id;
738
    } else {
739
      $zone = tep_db_fetch_array($zone_query);
740
      return $zone['zone_name'];
741
    }
742
  }
743
744
////
745
// Sets the status of a banner
@@ 1193-1202 (lines=10) @@
1190
    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
1191
  }
1192
1193
  function tep_get_tax_class_title($tax_class_id) {
1194
    if ($tax_class_id == '0') {
1195
      return TEXT_NONE;
1196
    } else {
1197
      $classes_query = tep_db_query("select tax_class_title from " . TABLE_TAX_CLASS . " where tax_class_id = '" . (int)$tax_class_id . "'");
1198
      $classes = tep_db_fetch_array($classes_query);
1199
1200
      return $classes['tax_class_title'];
1201
    }
1202
  }
1203
1204
  function tep_banner_image_extension() {
1205
    if (function_exists('imagetypes')) {
@@ 1288-1297 (lines=10) @@
1285
    }
1286
  }
1287
1288
  function tep_get_zone_class_title($zone_class_id) {
1289
    if ($zone_class_id == '0') {
1290
      return TEXT_NONE;
1291
    } else {
1292
      $classes_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$zone_class_id . "'");
1293
      $classes = tep_db_fetch_array($classes_query);
1294
1295
      return $classes['geo_zone_name'];
1296
    }
1297
  }
1298
1299
  function tep_cfg_pull_down_zone_classes($zone_class_id, $key = '') {
1300
    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

catalog/includes/functions/general.php 3 locations

@@ 277-285 (lines=9) @@
274
////
275
// Returns the zone (State/Province) name
276
// TABLES: zones
277
  function tep_get_zone_name($country_id, $zone_id, $default_zone) {
278
    $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
279
    if (tep_db_num_rows($zone_query)) {
280
      $zone = tep_db_fetch_array($zone_query);
281
      return $zone['zone_name'];
282
    } else {
283
      return $default_zone;
284
    }
285
  }
286
287
////
288
// Returns the zone (State/Province) code
@@ 290-298 (lines=9) @@
287
////
288
// Returns the zone (State/Province) code
289
// TABLES: zones
290
  function tep_get_zone_code($country_id, $zone_id, $default_zone) {
291
    $zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
292
    if (tep_db_num_rows($zone_query)) {
293
      $zone = tep_db_fetch_array($zone_query);
294
      return $zone['zone_code'];
295
    } else {
296
      return $default_zone;
297
    }
298
  }
299
300
////
301
// Wrapper function for round()
@@ 435-443 (lines=9) @@
432
////
433
// Returns the address_format_id for the given country
434
// TABLES: countries;
435
  function tep_get_address_format_id($country_id) {
436
    $address_format_query = tep_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");
437
    if (tep_db_num_rows($address_format_query)) {
438
      $address_format = tep_db_fetch_array($address_format_query);
439
      return $address_format['format_id'];
440
    } else {
441
      return '1';
442
    }
443
  }
444
445
////
446
// Return a formatted address