Code Duplication    Length = 4-6 lines in 4 locations

htdocs/search.php 4 locations

@@ 610-615 (lines=6) @@
607
                $sql_select[] = '`caches`.`cache_id` `cache_id`';
608
                $sql_from = '`caches`';
609
                $sql_where[] = '`user_id`=\'' . sql_escape($options['ownerid']) . '\'';
610
            } else {
611
                $sql_select[] = '`caches`.`cache_id` `cache_id`';
612
                $sql_from = '`caches`';
613
                $sql_innerjoin[] = '`user` ON `caches`.`user_id`=`user`.`user_id`';
614
                $sql_where[] = '`user`.`username`=\'' . sql_escape($options['owner']) . '\'';
615
            }
616
        } elseif (($options['searchtype'] == 'byplz') || ($options['searchtype'] == 'byort')) {
617
            $locid = $options['locid'];
618
@@ 1000-1004 (lines=5) @@
997
                }
998
                $sql_where[] = '`cache_logs`.`type` IN (' . $idNumbers . ')';
999
            }
1000
        } elseif ($options['searchtype'] == 'bycacheid') {
1001
            $sql_select[] = '`caches`.`cache_id` `cache_id`';
1002
            $sql_from = '`caches`';
1003
            $sql_where[] = '`caches`.`cache_id`=\'' . sql_escape($options['cacheid']) . '\'';
1004
        } elseif ($options['searchtype'] == 'bywp') {
1005
            $sql_select[] = '`caches`.`cache_id` `cache_id`';
1006
            $sql_from = '`caches`';
1007
            $sql_where[] = '`caches`.`wp_oc`=\'' . sql_escape($options['wp']) . '\'';
@@ 1213-1216 (lines=4) @@
1210
        if (!isset($options['adm2'])) {
1211
            $options['adm2'] = '';
1212
        }
1213
        if ($options['adm2'] != '') {
1214
            $sql_innerjoin[] = '`cache_location` ON `cache_location`.`cache_id`=`caches`.`cache_id`';
1215
            $sql_where[] = '`cache_location`.`code2`=\'' . sql_escape($options['adm2']) . '\'';
1216
        }
1217
1218
        if ($options['cachetype'] != '') {
1219
            $types = explode(';', $options['cachetype']);
@@ 1252-1255 (lines=4) @@
1249
        if ($options['terrainmax'] != 0) {
1250
            $sql_where[] = '`caches`.`terrain`<=\'' . sql_escape($options['terrainmax']) . '\'';
1251
        }
1252
        if ($options['recommendationmin'] > 0) {
1253
            $sql_innerjoin[] = '`stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`';
1254
            $sql_where[] = '`stat_caches`.`toprating`>=\'' . sql_escape($options['recommendationmin']) . '\'';
1255
        }
1256
1257
        if (isset($options['cache_attribs']) && count($options['cache_attribs']) > 0) {
1258
            foreach ($options['cache_attribs'] as $attr) {