Code Duplication    Length = 5-9 lines in 4 locations

htdocs/search.php 4 locations

@@ 1452-1456 (lines=5) @@
1449
1450
    if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog') {
1451
        $sql .= '`lastLog`';
1452
        if (isset($options['sortorder']) && $options['sortorder'] == 'asc') {
1453
            $sql .= ' ASC, `caches`.`date_created` DESC,';
1454
        } else {
1455
            $sql .= ' DESC, `caches`.`date_created` DESC,';
1456
        }
1457
        $sortby = 'bydistance';
1458
    }
1459
@@ 1462-1466 (lines=5) @@
1459
1460
    if (isset($lat_rad) && isset($lon_rad) && $sortby == 'bydistance') {
1461
        $sql .= '`distance`';
1462
        if (isset($options['sortorder']) && $options['sortorder'] == 'desc') {
1463
            $sql .= ' DESC';
1464
        } else {
1465
            $sql .= ' ASC';
1466
        }
1467
    } else {
1468
        if ($sortby == 'bycreated') {
1469
            $sql .= '`caches`.`date_created`';
@@ 1470-1474 (lines=5) @@
1467
    } else {
1468
        if ($sortby == 'bycreated') {
1469
            $sql .= '`caches`.`date_created`';
1470
            if (isset($options['sortorder']) && $options['sortorder'] == 'asc') {
1471
                $sql .= ' ASC';
1472
            } else {
1473
                $sql .= ' DESC';
1474
            }
1475
        } else { // by name
1476
            $sql .= '`caches`.`name`';
1477
            if (isset($options['sortorder']) && $options['sortorder'] == 'desc') {
@@ 1475-1483 (lines=9) @@
1472
            } else {
1473
                $sql .= ' DESC';
1474
            }
1475
        } else { // by name
1476
            $sql .= '`caches`.`name`';
1477
            if (isset($options['sortorder']) && $options['sortorder'] == 'desc') {
1478
                $sql .= ' DESC';
1479
            } else {
1480
                $sql .= ' ASC';
1481
            }
1482
        }
1483
    }
1484
1485
    // range of output
1486
    $startat = isset($_REQUEST['startat']) ? floor($_REQUEST['startat'] + 0) : 0;