Code Duplication    Length = 33-35 lines in 2 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

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

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