Code Duplication    Length = 34-37 lines in 4 locations

require/class.Spotter.php 4 locations

@@ 4039-4073 (lines=35) @@
4036
	* @return Array the aircraft list
4037
	*
4038
	*/
4039
	public function countAllAircraftRegistrationByAircraft($aircraft_icao)
4040
	{
4041
		$Image = new Image($this->db);
4042
		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4043
4044
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4045
				FROM spotter_output
4046
				WHERE spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
4047
				GROUP BY spotter_output.registration 
4048
				ORDER BY registration_count DESC";
4049
4050
		$sth = $this->db->prepare($query);
4051
		$sth->execute(array(':aircraft_icao' => $aircraft_icao));
4052
4053
		$aircraft_array = array();
4054
		$temp_array = array();
4055
        
4056
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4057
		{
4058
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4059
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4060
			$temp_array['registration'] = $row['registration'];
4061
			$temp_array['airline_name'] = $row['airline_name'];
4062
			$temp_array['image_thumbnail'] = "";
4063
			if($row['registration'] != "")
4064
			{
4065
				$image_array = $Image->getSpotterImage($row['registration']);
4066
				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4067
			}
4068
			$emp_array['registration_count'] = $row['registration_count'];
4069
4070
			$aircraft_array[] = $temp_array;
4071
		}
4072
		return $aircraft_array;
4073
	}
4074
4075
4076
	/**
@@ 4116-4149 (lines=34) @@
4113
	* @return Array the aircraft list
4114
	*
4115
	*/
4116
	public function countAllAircraftRegistrationByAirline($airline_icao)
4117
	{
4118
		$Image = new Image($this->db);
4119
		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4120
4121
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4122
				FROM spotter_output
4123
				WHERE spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
4124
				GROUP BY spotter_output.registration 
4125
				ORDER BY registration_count DESC";
4126
4127
		$sth = $this->db->prepare($query);
4128
		$sth->execute(array(':airline_icao' => $airline_icao));
4129
4130
		$aircraft_array = array();
4131
		$temp_array = array();
4132
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4133
		{
4134
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4135
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4136
			$temp_array['registration'] = $row['registration'];
4137
			$temp_array['airline_name'] = $row['airline_name'];
4138
			$temp_array['image_thumbnail'] = "";
4139
			if($row['registration'] != "")
4140
			{
4141
				$image_array = $Image->getSpotterImage($row['registration']);
4142
				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4143
			}
4144
			$temp_array['registration_count'] = $row['registration_count'];
4145
4146
			$aircraft_array[] = $temp_array;
4147
		}
4148
		return $aircraft_array;
4149
	}
4150
4151
4152
	/**
@@ 4571-4606 (lines=36) @@
4568
	* @return Array the aircraft list
4569
	*
4570
	*/
4571
	public function countAllAircraftRegistrationByIdent($ident)
4572
	{
4573
		$Image = new Image($this->db);
4574
		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4575
4576
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4577
                    FROM spotter_output
4578
                    WHERE spotter_output.registration <> '' AND spotter_output.ident = :ident   
4579
                    GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
4580
		    ORDER BY registration_count DESC";
4581
4582
		
4583
		$sth = $this->db->prepare($query);
4584
		$sth->execute(array(':ident' => $ident));
4585
      
4586
		$aircraft_array = array();
4587
		$temp_array = array();
4588
        
4589
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4590
		{
4591
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4592
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4593
			$temp_array['registration'] = $row['registration'];
4594
			$temp_array['airline_name'] = $row['airline_name'];
4595
			$temp_array['image_thumbnail'] = "";
4596
			if($row['registration'] != "")
4597
			{
4598
				$image_array = $Image->getSpotterImage($row['registration']);
4599
				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4600
				else $temp_array['image_thumbnail'] = '';
4601
			}
4602
			$temp_array['registration_count'] = $row['registration_count'];
4603
			$aircraft_array[] = $temp_array;
4604
		}
4605
		return $aircraft_array;
4606
	}
4607
4608
4609
	/**
@@ 4808-4844 (lines=37) @@
4805
	* @return Array the aircraft list
4806
	*
4807
	*/
4808
	public function countAllAircraftRegistrationByCountry($country)
4809
	{
4810
		$Image = new Image($this->db);
4811
		$country = filter_var($country,FILTER_SANITIZE_STRING);
4812
4813
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4814
                    FROM spotter_output
4815
                    WHERE spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)    
4816
                    GROUP BY spotter_output.registration 
4817
					ORDER BY registration_count DESC";
4818
4819
		
4820
		$sth = $this->db->prepare($query);
4821
		$sth->execute(array(':country' => $country));
4822
      
4823
		$aircraft_array = array();
4824
		$temp_array = array();
4825
        
4826
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4827
		{
4828
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4829
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4830
			$temp_array['registration'] = $row['registration'];
4831
			$temp_array['airline_name'] = $row['airline_name'];
4832
			$temp_array['image_thumbnail'] = "";
4833
			if($row['registration'] != "")
4834
			{
4835
				$image_array = $Image->getSpotterImage($row['registration']);
4836
				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4837
			}
4838
			$temp_array['registration_count'] = $row['registration_count'];
4839
          
4840
			$aircraft_array[] = $temp_array;
4841
		}
4842
4843
		return $aircraft_array;
4844
	}
4845
	
4846
	
4847
	/**