Code Duplication    Length = 33-35 lines in 2 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

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

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