Code Duplication    Length = 33-35 lines in 2 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

@@ 225-259 (lines=35) @@
222
		return $array;
223
	}
224
225
	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
226
		$inmap_pkms_filter = "";
227
		$where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = " . $pokemon_id;
228
229
		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where;
230
		$resultTestIv = $this->mysqli->query($reqTestIv);
231
		$testIv = $resultTestIv->fetch_object();
232
		if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) {
233
			foreach ($_POST['inmap_pokemons'] as $inmap) {
234
				$inmap_pkms_filter .= "'".$inmap."',";
235
			}
236
			$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
237
			$where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") ";
238
		}
239
		if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) {
240
			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") ";
241
		}
242
		if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) {
243
			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") ";
244
		}
245
		$req = "SELECT pokemon_id, lat AS latitude, lon AS longitude,
246
    					FROM_UNIXTIME(expire_timestamp) AS disappear_time,
247
    					FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
248
    					atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina,
249
   						move_1, move_2
250
					FROM sightings " . $where . "
251
					ORDER BY disappear_time DESC
252
					LIMIT 5000";
253
		$result = $this->mysqli->query($req);
254
		$spawns = array();
255
		while ($data = $result->fetch_object()) {
256
			$spawns[] = $data;
257
		}
258
		return $spawns;
259
	}
260
261
	public function getPokemonSliderMinMax() {
262
		$req = "SELECT FROM_UNIXTIME(MIN(expire_timestamp)) AS min, FROM_UNIXTIME(MAX(expire_timestamp)) AS max FROM sightings";

core/process/queries/QueryManagerMysqlRocketmap.php 1 location

@@ 227-259 (lines=33) @@
224
		return $array;
225
	}
226
227
	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
228
		$inmap_pkms_filter = "";
229
		$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id;
230
231
		$reqTestIv = "SELECT MAX(individual_attack) AS iv FROM pokemon ".$where;
232
		$resultTestIv = $this->mysqli->query($reqTestIv);
233
		$testIv = $resultTestIv->fetch_object();
234
		if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) {
235
			foreach ($_POST['inmap_pokemons'] as $inmap) {
236
				$inmap_pkms_filter .= "'".$inmap."',";
237
			}
238
			$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
239
			$where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") ";
240
		}
241
		if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) {
242
			$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") ";
243
		}
244
		if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) {
245
			$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <= (".$ivMax.") ";
246
		}
247
		$req = "SELECT pokemon_id, encounter_id, latitude, longitude, disappear_time,
248
						(CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
249
						individual_attack, individual_defense, individual_stamina, move_1, move_2
250
						FROM pokemon ".$where."
251
						ORDER BY disappear_time DESC
252
						LIMIT 5000";
253
		$result = $this->mysqli->query($req);
254
		$spawns = array();
255
		while ($data = $result->fetch_object()) {
256
			$spawns[] = $data;
257
		}
258
		return $spawns;
259
	}
260
261
	public function getPokemonSliderMinMax() {
262
		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";