Code Duplication    Length = 15-19 lines in 9 locations

require/class.SpotterArchive.php 6 locations

@@ 100-117 (lines=18) @@
97
        * @return Array the spotter information
98
        *
99
        */
100
        public function getAllArchiveSpotterDataById($id)
101
        {
102
                date_default_timezone_set('UTC');
103
                $id = filter_var($id, FILTER_SANITIZE_STRING);
104
                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
105
106
//              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
107
108
                try {
109
                        $sth = $this->db->prepare($query);
110
                        $sth->execute(array(':id' => $id));
111
                } catch(PDOException $e) {
112
                        return "error";
113
                }
114
                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
115
116
                return $spotter_array;
117
        }
118
119
        /**
120
        * Gets coordinate & time spotter information based on a particular id
@@ 125-142 (lines=18) @@
122
        * @return Array the spotter information
123
        *
124
        */
125
        public function getCoordArchiveSpotterDataById($id)
126
        {
127
                date_default_timezone_set('UTC');
128
                $id = filter_var($id, FILTER_SANITIZE_STRING);
129
                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
130
131
//              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
132
133
                try {
134
                        $sth = $this->db->prepare($query);
135
                        $sth->execute(array(':id' => $id));
136
                } catch(PDOException $e) {
137
                        return $e->getMessage();
138
                }
139
                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
140
141
                return $spotter_array;
142
        }
143
144
145
        /**
@@ 151-168 (lines=18) @@
148
        * @return Array the spotter information
149
        *
150
        */
151
        public function getAltitudeArchiveSpotterDataByIdent($ident)
152
        {
153
154
                date_default_timezone_set('UTC');
155
156
                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
157
                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
158
159
                try {
160
                        $sth = $this->db->prepare($query);
161
                        $sth->execute(array(':ident' => $ident));
162
                } catch(PDOException $e) {
163
                        return "error";
164
                }
165
                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
166
167
                return $spotter_array;
168
        }
169
170
        /**
171
        * Gets altitude information based on a particular id
@@ 176-193 (lines=18) @@
173
        * @return Array the spotter information
174
        *
175
        */
176
        public function getAltitudeArchiveSpotterDataById($id)
177
        {
178
179
                date_default_timezone_set('UTC');
180
181
                $id = filter_var($id, FILTER_SANITIZE_STRING);
182
                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
183
184
                try {
185
                        $sth = $this->db->prepare($query);
186
                        $sth->execute(array(':id' => $id));
187
                } catch(PDOException $e) {
188
                        return "error";
189
                }
190
                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
191
192
                return $spotter_array;
193
        }
194
195
        /**
196
        * Gets altitude & speed information based on a particular id
@@ 201-218 (lines=18) @@
198
        * @return Array the spotter information
199
        *
200
        */
201
        public function getAltitudeSpeedArchiveSpotterDataById($id)
202
        {
203
204
                date_default_timezone_set('UTC');
205
206
                $id = filter_var($id, FILTER_SANITIZE_STRING);
207
                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
208
209
                try {
210
                        $sth = $this->db->prepare($query);
211
                        $sth->execute(array(':id' => $id));
212
                } catch(PDOException $e) {
213
		        return "error : ".$e->getMessage();
214
                }
215
                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
216
217
                return $spotter_array;
218
        }
219
220
221
        /**
@@ 227-245 (lines=19) @@
224
        * @return Array the spotter information
225
        *
226
        */
227
        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
228
        {
229
230
                date_default_timezone_set('UTC');
231
232
                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
233
                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
234
//                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
235
236
                try {
237
                        $sth = $this->db->prepare($query);
238
                        $sth->execute(array(':ident' => $ident));
239
                } catch(PDOException $e) {
240
                        return "error";
241
                }
242
                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
243
244
                return $spotter_array;
245
        }
246
247
248

require/class.SpotterLive.php 3 locations

@@ 321-339 (lines=19) @@
318
	* @return Array the spotter information
319
	*
320
	*/
321
	public function getAltitudeLiveSpotterDataByIdent($ident)
322
	{
323
324
		date_default_timezone_set('UTC');
325
326
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
327
                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
328
329
    		try {
330
			
331
			$sth = $this->db->prepare($query);
332
			$sth->execute(array(':ident' => $ident));
333
		} catch(PDOException $e) {
334
			return "error";
335
		}
336
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
337
338
		return $spotter_array;
339
	}
340
341
        /**
342
	* Gets all the spotter information based on a particular id
@@ 347-364 (lines=18) @@
344
	* @return Array the spotter information
345
	*
346
	*/
347
	public function getAllLiveSpotterDataById($id)
348
	{
349
		date_default_timezone_set('UTC');
350
		$id = filter_var($id, FILTER_SANITIZE_STRING);
351
		$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
352
//		$spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
353
354
    		try {
355
			
356
			$sth = $this->db->prepare($query);
357
			$sth->execute(array(':id' => $id));
358
		} catch(PDOException $e) {
359
			return "error";
360
		}
361
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
362
363
		return $spotter_array;
364
	}
365
366
        /**
367
	* Gets all the spotter information based on a particular ident
@@ 372-386 (lines=15) @@
369
	* @return Array the spotter information
370
	*
371
	*/
372
	public function getAllLiveSpotterDataByIdent($ident)
373
	{
374
		date_default_timezone_set('UTC');
375
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
376
		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
377
    		try {
378
			
379
			$sth = $this->db->prepare($query);
380
			$sth->execute(array(':ident' => $ident));
381
		} catch(PDOException $e) {
382
			return "error";
383
		}
384
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
385
		return $spotter_array;
386
	}
387
388
389
	/**