Code Duplication    Length = 47-48 lines in 3 locations

require/class.Spotter.php 3 locations

@@ 1301-1347 (lines=47) @@
1298
	* @return Array the spotter information
1299
	*
1300
	*/
1301
	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '')
1302
	{
1303
		global $global_query;
1304
		
1305
		date_default_timezone_set('UTC');
1306
		$additional_query = '';
1307
		$query_values = array();
1308
		
1309
		if ($airport != "")
1310
		{
1311
			if (!is_string($airport))
1312
			{
1313
				return false;
1314
			} else {
1315
				$additional_query .= " AND ((spotter_output.departure_airport_icao = :airport) OR (spotter_output.arrival_airport_icao = :airport))";
1316
				$query_values = array(':airport' => $airport);
1317
			}
1318
		}
1319
		
1320
		if ($limit != "")
1321
		{
1322
			$limit_array = explode(",", $limit);
1323
			
1324
			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1325
			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1326
			
1327
			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1328
			{
1329
				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1330
				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1331
			}
1332
		}
1333
		
1334
		if ($sort != "")
1335
		{
1336
			$search_orderby_array = $this->getOrderBy();
1337
			$orderby_query = $search_orderby_array[$sort]['sql'];
1338
		} else {
1339
			$orderby_query = " ORDER BY spotter_output.date DESC";
1340
		}
1341
1342
		$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." AND ((spotter_output.departure_airport_icao <> 'NA') AND (spotter_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
1343
1344
		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
1345
1346
		return $spotter_array;
1347
	}
1348
1349
1350
@@ 1416-1463 (lines=48) @@
1413
	* @return Array the spotter information
1414
	*
1415
	*/
1416
	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '')
1417
	{
1418
		global $global_query;
1419
		
1420
		date_default_timezone_set('UTC');
1421
		
1422
		$query_values = array();
1423
		$additional_query = '';
1424
		if ($country != "")
1425
		{
1426
			if (!is_string($country))
1427
			{
1428
				return false;
1429
			} else {
1430
				$additional_query .= " AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country))";
1431
				$additional_query .= " OR spotter_output.airline_country = :country";
1432
				$query_values = array(':country' => $country);
1433
			}
1434
		}
1435
		
1436
		if ($limit != "")
1437
		{
1438
			$limit_array = explode(",", $limit);
1439
			
1440
			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1441
			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1442
			
1443
			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1444
			{
1445
				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1446
				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1447
			}
1448
		}
1449
					
1450
		if ($sort != "")
1451
		{
1452
			$search_orderby_array = $this->getOrderBy();
1453
			$orderby_query = $search_orderby_array[$sort]['sql'];
1454
		} else {
1455
			$orderby_query = " ORDER BY spotter_output.date DESC";
1456
		}
1457
1458
		$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1459
1460
		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
1461
1462
		return $spotter_array;
1463
	}	
1464
	
1465
	
1466
	/**
@@ 1472-1519 (lines=48) @@
1469
	* @return Array the spotter information
1470
	*
1471
	*/
1472
	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '')
1473
	{
1474
		global $global_query;
1475
		
1476
		date_default_timezone_set('UTC');
1477
		
1478
		$query_values = array();
1479
		$additional_query = '';
1480
		
1481
		if ($aircraft_manufacturer != "")
1482
		{
1483
			if (!is_string($aircraft_manufacturer))
1484
			{
1485
				return false;
1486
			} else {
1487
				$additional_query .= " AND (spotter_output.aircraft_manufacturer = :aircraft_manufacturer)";
1488
				$query_values = array(':aircraft_manufacturer' => $aircraft_manufacturer);
1489
			}
1490
		}
1491
		
1492
		if ($limit != "")
1493
		{
1494
			$limit_array = explode(",", $limit);
1495
			
1496
			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1497
			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1498
			
1499
			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1500
			{
1501
				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1502
				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1503
			}
1504
		}
1505
1506
		if ($sort != "")
1507
		{
1508
			$search_orderby_array = $this->getOrderBy();
1509
			$orderby_query = $search_orderby_array[$sort]['sql'];
1510
		} else {
1511
			$orderby_query = " ORDER BY spotter_output.date DESC";
1512
		}
1513
1514
		$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1515
1516
		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
1517
1518
		return $spotter_array;
1519
	}
1520
1521
1522