diff --git a/Dockerfile b/Dockerfile index c02e1a40..81c9c9a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG INSTALL_CRON=1 -ARG PHP_EXTENSIONS="mysqli pdo pdo_mysql opcache gd" +ARG PHP_EXTENSIONS="pdo pdo_mysql opcache gd" FROM thecodingmachine/php:7.4-v3-apache # Change back Apache user and group to www-data diff --git a/VERSION b/VERSION index ec22e6ff..84626964 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.236.1 +2.0.237.2 \ No newline at end of file diff --git a/commands/addgym.php b/commands/addgym.php index 88696cde..1607bd0a 100644 --- a/commands/addgym.php +++ b/commands/addgym.php @@ -47,19 +47,19 @@ // Insert / update gym. try { - global $db; + global $dbh; // Build query to check if gym is already in database or not $rs = my_query(" - SELECT COUNT(*) + SELECT COUNT(*) AS count FROM gyms WHERE gym_name = '{$gym_name}' "); - $row = $rs->fetch_row(); + $row = $rs->fetch(); // Gym already in database or new - if (empty($row['0'])) { + if (empty($row['count'])) { // insert gym in table. debug_log('Gym not found in database gym list! Inserting gym "' . $gym_name . '" now.'); $query = ' @@ -122,14 +122,15 @@ } $statement = $dbh->prepare($query); - $statement->bindValue(':gym_name', $gym_name, PDO::PARAM_STR); - $statement->bindValue(':lat', $lat, PDO::PARAM_STR); - $statement->bindValue(':lon', $lon, PDO::PARAM_STR); - $statement->bindValue(':address', $address, PDO::PARAM_STR); - $statement->execute(); + $statement->execute([ + 'gym_name' => $gym_name, + 'lat' => $lat, + 'lon' => $lon, + 'address' => $address + ]); // Get last insert id. - if (empty($row['0'])) { + if (empty($row['count'])) { $gym_id = $dbh->lastInsertId(); } diff --git a/commands/gymaddress.php b/commands/gymaddress.php index 71da26ef..9dc2a31d 100644 --- a/commands/gymaddress.php +++ b/commands/gymaddress.php @@ -61,13 +61,14 @@ } else if($gym && !empty($info)) { debug_log('Adding address for gym with ID: ' . $id); debug_log('Gym note: ' . $info); - my_query( + $stmt = $dbh->prepare( " UPDATE gyms - SET address = '{$db->real_escape_string($info)}' - WHERE id = {$id} + SET address = :info + WHERE id = :id " ); + $stmt->execute(['info' => $info, 'id' => $id]); // Set message. $msg = get_gym_details($gym); diff --git a/commands/gymname.php b/commands/gymname.php index eab87ce4..d6f0a7e2 100644 --- a/commands/gymname.php +++ b/commands/gymname.php @@ -63,13 +63,17 @@ if($gym && !empty($info) && $id > 0) { debug_log('Changing name for gym with ID: ' . $id); debug_log('Gym name: ' . $info); - my_query( + $stmt = $dbh->prepare( " UPDATE gyms - SET gym_name = '{$db->real_escape_string($info)}' - WHERE id = {$id} + SET gym_name = :info + WHERE id = :id " ); + $stmt->execute([ + 'info' => $info, + 'id' => $id + ]); // Set message. $gym = get_gym($id); diff --git a/commands/gymnote.php b/commands/gymnote.php index 68f196a8..f5652dd0 100644 --- a/commands/gymnote.php +++ b/commands/gymnote.php @@ -61,13 +61,17 @@ } else if($gym && !empty($info)) { debug_log('Adding gym note for gym with ID: ' . $id); debug_log('Gym note: ' . $info); - my_query( + $stmt = $dbh->prepare( " UPDATE gyms - SET gym_note = '{$db->real_escape_string($info)}' - WHERE id = {$id} + SET gym_note = :info + WHERE id = :id " ); + $stmt->execute([ + 'info' => $info, + 'id' => $id + ]); // Set message. $msg = get_gym_details($gym); diff --git a/commands/list.php b/commands/list.php index 8bd898d7..b4e790ce 100644 --- a/commands/list.php +++ b/commands/list.php @@ -33,7 +33,7 @@ $keys = []; // Get raids. -while ($raid = $rs->fetch_assoc()) { +while ($raid = $rs->fetch()) { // Set text and keys. $gym_name = $raid['gym_name']; if(empty($gym_name)) { diff --git a/commands/raid.php b/commands/raid.php index 6d0d009d..0f3d8728 100644 --- a/commands/raid.php +++ b/commands/raid.php @@ -31,7 +31,7 @@ // Invalid data received. if (count($data) < 4) { - send_message($update['message']['chat']['id'], 'Invalid input - Paramter mismatch', []); + send_message($update['message']['chat']['id'], 'Invalid input - Parameter mismatch', []); exit; } @@ -73,8 +73,7 @@ LIMIT 1 '; $statement = $dbh->prepare( $query ); - $statement->bindValue(':gym_name', $gym_name, PDO::PARAM_STR); - $statement->execute(); + $statement->execute(['gym_name' => $gym_name]); while ($row = $statement->fetch()) { $gym_id = $row['id']; @@ -111,7 +110,7 @@ ); // Get row. - $row_ex_raid = $rs_ex_raid->fetch_assoc(); + $row_ex_raid = $rs_ex_raid->fetch(); $poke_name = $row_ex_raid['pokemon']; debug_log('Comparing the current pokemon to pokemons from ex-raid list now...'); debug_log('Current Pokemon in database for this raid: ' . $poke_name); @@ -122,25 +121,34 @@ // Ex-Raid! Update only team in raids table. debug_log('Current pokemon is an ex-raid pokemon: ' . $poke_name); debug_log('Pokemon "' .$poke_name . '" will NOT be updated to "' . $boss . '"!'); - my_query( + $stmt = $dbh->prepare( " UPDATE raids - SET gym_team = '{$db->real_escape_string($team)}' - WHERE id = {$raid_id} + SET gym_team = :team + WHERE id = :raid_id " ); + $stmt->execute([ + 'team' => $team, + 'raid_id' => $raid_id + ]); } else { // Update pokemon and team in raids table. debug_log('Current pokemon is NOT an ex-raid pokemon: ' . $poke_name); debug_log('Pokemon "' .$poke_name . '" will be updated to "' . $boss . '"!'); - my_query( + $stmt = $dbh->prepare( " UPDATE raids - SET pokemon = '{$db->real_escape_string($boss)}', - gym_team = '{$db->real_escape_string($team)}' - WHERE id = {$raid_id} + SET pokemon = :boss + gym_team = :team + WHERE id = :raid_id " ); + $stmt->execute([ + 'boss' => $boss, + 'team' => $team, + 'raid_id' => $raid_id + ]); } // Debug log @@ -155,21 +163,27 @@ } // Build the query. -$rs = my_query( +$stmt = $dbh->prepare( " INSERT INTO raids - SET pokemon = '{$db->real_escape_string($boss)}', - user_id = {$update['message']['from']['id']}, + SET pokemon = :boss, + user_id = :user_id, first_seen = DATE_FORMAT(UTC_TIMESTAMP(), '%Y-%m-%d %H:%i:00'), start_time = DATE_ADD(first_seen, INTERVAL {$countdown} MINUTE), end_time = DATE_ADD(start_time, INTERVAL {$endtime} MINUTE), - gym_team = '{$db->real_escape_string($team)}', - gym_id = '{$gym_id}' + gym_team = :team, + gym_id = :gym_id " ); +$stmt->execute([ + 'boss' => $boss, + 'user_id' => $update['message']['from']['id'], + 'team' => $team, + 'gym_id' => $gym_id +]); // Get last insert id from db. -$id = my_insert_id(); +$id = $dbh->lastInsertId(); // Write to log. debug_log('ID=' . $id); @@ -245,4 +259,3 @@ } ?> - diff --git a/commands/raid_from_webhook.php b/commands/raid_from_webhook.php index b9ead054..c684ab83 100644 --- a/commands/raid_from_webhook.php +++ b/commands/raid_from_webhook.php @@ -94,8 +94,7 @@ function isPointInsidePolygon($point, $polygon) { LIMIT 1 '; $statement = $dbh->prepare( $query ); - $statement->bindValue(':gym_id', $gym_id, PDO::PARAM_STR); - $statement->execute(); + $statement->execute(['gym_id' => $gym_id]); while ($row = $statement->fetch()) { $gym_internal_id = $row['id']; @@ -125,13 +124,14 @@ function isPointInsidePolygon($point, $polygon) { gym_id LIKE :gym_id '; $statement = $dbh->prepare( $query ); - $statement->bindValue(':lat', $gym_lat, PDO::PARAM_STR); - $statement->bindValue(':lon', $gym_lon, PDO::PARAM_STR); - $statement->bindValue(':gym_name', $gym_name, PDO::PARAM_STR); - $statement->bindValue(':ex_gym', $gym_is_ex, PDO::PARAM_INT); - $statement->bindValue(':img_url', $gym_img_url, PDO::PARAM_STR); - $statement->bindValue(':gym_id', $gym_id, PDO::PARAM_STR); - $statement->execute(); + $statement->execute([ + 'lat' => $gym_lat, + 'lon' => $gym_lon, + 'gym_name' => $gym_name, + 'gym_id' => $gym_id, + 'ex_gym' => $gym_is_ex, + 'img_url' => $gym_img_url + ]); } catch (PDOException $exception) { @@ -151,13 +151,14 @@ function isPointInsidePolygon($point, $polygon) { VALUES (:lat, :lon, :gym_name, :gym_id, :ex_gym, :img_url, 1) '; $statement = $dbh->prepare( $query ); - $statement->bindValue(':lat', $gym_lat, PDO::PARAM_STR); - $statement->bindValue(':lon', $gym_lon, PDO::PARAM_STR); - $statement->bindValue(':gym_name', $gym_name, PDO::PARAM_STR); - $statement->bindValue(':gym_id', $gym_id, PDO::PARAM_STR); - $statement->bindValue(':ex_gym', $gym_is_ex, PDO::PARAM_INT); - $statement->bindValue(':img_url', $gym_img_url, PDO::PARAM_STR); - $statement->execute(); + $statement->execute([ + 'lat' => $gym_lat, + 'lon' => $gym_lon, + 'gym_name' => $gym_name, + 'gym_id' => $gym_id, + 'ex_gym' => $gym_is_ex, + 'img_url' => $gym_img_url + ]); $gym_internal_id = $dbh->lastInsertId(); } catch (PDOException $exception) { @@ -230,13 +231,14 @@ function isPointInsidePolygon($point, $polygon) { id LIKE :id '; $statement = $dbh->prepare( $query ); - $statement->bindValue(':pokemon', $pokemon, PDO::PARAM_STR); - $statement->bindValue(':gym_team', $team, PDO::PARAM_STR); - $statement->bindValue(':move1', $move_1, PDO::PARAM_STR); - $statement->bindValue(':move2', $move_2, PDO::PARAM_STR); - $statement->bindValue(':gender', $gender, PDO::PARAM_STR); - $statement->bindValue(':id', $raid_id, PDO::PARAM_INT); - $statement->execute(); + $statement->execute([ + 'pokemon' => $pokemon, + 'gym_team' => $team, + 'move1' => $move_1, + 'move2' => $move_2, + 'gender' => $gender, + 'id' => $raid_id + ]); } catch (PDOException $exception) { error_log($exception->getMessage()); @@ -257,8 +259,7 @@ function isPointInsidePolygon($point, $polygon) { WHERE raid_id = :id '; $cleanup_statement = $dbh->prepare( $cleanup_query ); - $cleanup_statement->bindValue(':id', $raid_id, PDO::PARAM_STR); - $cleanup_statement->execute(); + $cleanup_statement->execute(['id' => $raid_id]); while ($row = $cleanup_statement->fetch()) { if($config->RAID_PICTURE) { $url = $config->RAID_PICTURE_URL."?pokemon=".$raid_info['pokemon']."&raid=".$raid_id; @@ -280,17 +281,18 @@ function isPointInsidePolygon($point, $polygon) { VALUES (:pokemon, :user_id, :first_seen, :start_time, :end_time, :gym_team, :gym_id, :move1, :move2, :gender) '; $statement = $dbh->prepare( $query ); - $statement->bindValue(':pokemon', $pokemon, PDO::PARAM_STR); - $statement->bindValue(':user_id', $config->WEBHOOK_CREATOR, PDO::PARAM_STR); - $statement->bindValue(':first_seen', gmdate("Y-m-d H:i:s"), PDO::PARAM_STR); - $statement->bindValue(':start_time', $start, PDO::PARAM_STR); - $statement->bindValue(':end_time', $end, PDO::PARAM_STR); - $statement->bindValue(':gym_team', $team, PDO::PARAM_STR); - $statement->bindValue(':gym_id', $gym_internal_id, PDO::PARAM_INT); - $statement->bindValue(':move1', $move_1, PDO::PARAM_STR); - $statement->bindValue(':move2', $move_2, PDO::PARAM_STR); - $statement->bindValue(':gender', $gender, PDO::PARAM_STR); - $statement->execute(); + $dbh->execute([ + 'pokemon' => $pokemon, + 'user_id' => $config->WEBHOOK_CREATOR, + 'first_seen' => gmdate("Y-m-d H:i:s"), + 'start_time' => $start, + 'end_time' => $end, + 'gym_team' => $team, + 'gym_id' => $gym_internal_id, + 'move1' => $move_1, + 'move2' => $move_2, + 'gender' => $gender + ]); $raid_id = $dbh->lastInsertId(); } catch (PDOException $exception) { diff --git a/commands/start.php b/commands/start.php index 8bcad85b..720dfd84 100644 --- a/commands/start.php +++ b/commands/start.php @@ -45,7 +45,7 @@ " ); - $info = $rs->fetch_assoc(); + $info = $rs->fetch(); $creation_limit = $config->RAID_EVENT_CREATION_LIMIT - 1; // Check raid count diff --git a/config/config.json.example b/config/config.json.example index 596843a3..b52f3292 100644 --- a/config/config.json.example +++ b/config/config.json.example @@ -1,5 +1,5 @@ { - "VERSION":"2.0.236.1", + "VERSION":"2.0.237.2", "DB_HOST":"localhost", "DB_NAME":"your_database_name", "DB_USER":"your_database_user", diff --git a/core b/core index 27ff2de0..30242f3f 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 27ff2de0bf03e6e7b19632c5af68bc6584ff58c3 +Subproject commit 30242f3f96207dcc99f65e92e1f5f258573608fa diff --git a/logic/active_raid_duplication_check.php b/logic/active_raid_duplication_check.php index f72f067a..1938f1a5 100644 --- a/logic/active_raid_duplication_check.php +++ b/logic/active_raid_duplication_check.php @@ -25,7 +25,7 @@ function active_raid_duplication_check($gym_id) // Get row - allow normal and ex-raid at the gym. if($config->RAID_EXCLUDE_EXRAID_DUPLICATION) { - while ($raid = $rs->fetch_assoc()) { + while ($raid = $rs->fetch()) { $active = $raid['active_raid']; if ($active > 0) { // Exclude ex-raid pokemon. @@ -43,7 +43,7 @@ function active_raid_duplication_check($gym_id) } } } else { - $raid = $rs->fetch_assoc(); + $raid = $rs->fetch(); $active_counter = $raid['active_raid']; $active_raid_id = $raid['id']; } diff --git a/logic/alarm.php b/logic/alarm.php index 3c531ed6..a11def45 100644 --- a/logic/alarm.php +++ b/logic/alarm.php @@ -10,18 +10,18 @@ function alarm($raid, $user, $action, $info = '') { // Name of the user, which executes a status update $request = my_query("SELECT * FROM users WHERE user_id = {$user}"); - $answer_quests = $request->fetch_assoc(); + $answer_quests = $request->fetch(); $username = $answer_quests['name']; // Gym name and raid times $request = my_query("SELECT * FROM raids as r left join gyms as g on r.gym_id = g.id WHERE r.id = {$raid}"); - $answer = $request->fetch_assoc(); + $answer = $request->fetch(); $gymname = $answer['gym_name']; $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($answer, false, true))); // Get attend time. $r = my_query("SELECT DISTINCT attend_time FROM attendance WHERE raid_id = {$raid} and user_id = {$user}"); - $a = $r->fetch_assoc(); + $a = $r->fetch(); $attendtime = $a['attend_time']; // Adding a guest diff --git a/logic/delete_overview.php b/logic/delete_overview.php index d4e5ea92..b88148c6 100644 --- a/logic/delete_overview.php +++ b/logic/delete_overview.php @@ -6,8 +6,6 @@ */ function delete_overview($chat_id, $message_id) { - global $db; - // Delete telegram message. debug_log('Deleting overview telegram message ' . $message_id . ' from chat ' . $chat_id); delete_message($chat_id, $message_id); diff --git a/logic/delete_raid.php b/logic/delete_raid.php index 838a1d02..0cb5bdba 100644 --- a/logic/delete_raid.php +++ b/logic/delete_raid.php @@ -5,8 +5,6 @@ */ function delete_raid($raid_id) { - global $db; - // Delete telegram messages for raid. $rs = my_query( " @@ -21,7 +19,7 @@ function delete_raid($raid_id) $counter = 0; // Delete every telegram message - while ($row = $rs->fetch_assoc()) { + while ($row = $rs->fetch()) { // Delete telegram message. debug_log('Deleting telegram message ' . $row['message_id'] . ' from chat ' . $row['chat_id'] . ' for raid ' . $row['raid_id']); delete_message($row['chat_id'], $row['message_id']); diff --git a/logic/delete_trainerinfo.php b/logic/delete_trainerinfo.php index 2a24cc58..46d88d1c 100644 --- a/logic/delete_trainerinfo.php +++ b/logic/delete_trainerinfo.php @@ -6,8 +6,6 @@ */ function delete_trainerinfo($chat_id, $message_id) { - global $db; - // Delete telegram message. debug_log('Deleting trainer info telegram message ' . $message_id . ' from chat ' . $chat_id); delete_message($chat_id, $message_id); diff --git a/logic/edit_pokedex_keys.php b/logic/edit_pokedex_keys.php index fdb7b949..355b0f1a 100644 --- a/logic/edit_pokedex_keys.php +++ b/logic/edit_pokedex_keys.php @@ -32,17 +32,17 @@ function edit_pokedex_keys($limit, $action) // Number of entries $cnt = my_query( " - SELECT COUNT(*) + SELECT COUNT(*) AS count FROM pokemon " ); // Number of database entries found. - $sum = $cnt->fetch_row(); - $count = $sum['0']; + $sum = $cnt->fetch(); + $count = $sum['count']; // List users / moderators - while ($mon = $rs->fetch_assoc()) { + while ($mon = $rs->fetch()) { $pokemon_name = get_local_pokemon_name($mon['pokedex_id'] . '-' . $mon['pokemon_form']); $keys[] = array( 'text' => $mon['pokedex_id'] . SP . $pokemon_name, diff --git a/logic/get_active_raids.php b/logic/get_active_raids.php index 6cf504cd..ecb58ffc 100644 --- a/logic/get_active_raids.php +++ b/logic/get_active_raids.php @@ -21,7 +21,7 @@ function get_active_raids() ); // Get the raids. - $raids = $rs->fetch_assoc(); + $raids = $rs->fetch(); debug_log($raids); diff --git a/logic/get_formatted_pokemon_cp.php b/logic/get_formatted_pokemon_cp.php index 9ad97e37..d8831af5 100644 --- a/logic/get_formatted_pokemon_cp.php +++ b/logic/get_formatted_pokemon_cp.php @@ -28,7 +28,7 @@ function get_formatted_pokemon_cp($pokemon_id_form, $override_language = false) " ); - while($row = $rs->fetch_assoc()) { + while($row = $rs->fetch()) { // CP $cp20 .= ($row['min_cp'] > 0) ? $row['min_cp'] : ''; $cp20 .= (!empty($cp20) && $cp20 > 0) ? ('/' . $row['max_cp']) : ($row['max_cp']); diff --git a/logic/get_gym.php b/logic/get_gym.php index 556a78ca..e75066bf 100644 --- a/logic/get_gym.php +++ b/logic/get_gym.php @@ -15,7 +15,7 @@ function get_gym($id) " ); - $gym = $rs->fetch_assoc(); + $gym = $rs->fetch(); return $gym; } diff --git a/logic/get_gym_by_telegram_id.php b/logic/get_gym_by_telegram_id.php index c4209e2a..d8d77e44 100644 --- a/logic/get_gym_by_telegram_id.php +++ b/logic/get_gym_by_telegram_id.php @@ -17,7 +17,7 @@ function get_gym_by_telegram_id($id) " ); - $gym = $rs->fetch_assoc(); + $gym = $rs->fetch(); return $gym; } diff --git a/logic/get_local_pokemon_name.php b/logic/get_local_pokemon_name.php index 5f06afef..4a189c7f 100644 --- a/logic/get_local_pokemon_name.php +++ b/logic/get_local_pokemon_name.php @@ -49,7 +49,7 @@ function get_local_pokemon_name($pokemon_id_form, $override_language = false) " ); - while ($pokemon = $rs->fetch_assoc()) { + while ($pokemon = $rs->fetch()) { // Pokemon name $pokemon_name = $pokemon['pokemon_name']; // Pokemon form diff --git a/logic/get_overview.php b/logic/get_overview.php index 3803f1de..60bb4f13 100644 --- a/logic/get_overview.php +++ b/logic/get_overview.php @@ -36,7 +36,7 @@ function get_overview($update, $chats_active, $raids_active, $action = 'refresh' ); // Refresh active overview messages. - while ($row_overview = $rs->fetch_assoc()) { + while ($row_overview = $rs->fetch()) { $chat_id = $row_overview['chat_id']; $message_id = $row_overview['message_id']; @@ -127,15 +127,15 @@ function get_overview($update, $chats_active, $raids_active, $action = 'refresh' // Make sure it's not already shared $rs = my_query( " - SELECT COUNT(*) + SELECT COUNT(*) AS count FROM overview WHERE chat_id = '{$previous}' " ); - $dup_row = $rs->fetch_row(); + $dup_row = $rs->fetch(); - if (empty($dup_row['0'])) { + if (empty($dup_row['count'])) { // Not shared yet - Share button $keys[] = [ [ @@ -204,7 +204,7 @@ function get_overview($update, $chats_active, $raids_active, $action = 'refresh' ); // Edit text for all messages, but disable the web preview! - while ($row_msg_id = $rs->fetch_assoc()) { + while ($row_msg_id = $rs->fetch()) { // Set message_id. $message_id = $row_msg_id['message_id']; debug_log('Updating overview:' . CR . 'Chat_ID: ' . $previous . CR . 'Message_ID: ' . $message_id); @@ -305,7 +305,7 @@ function get_overview($update, $chats_active, $raids_active, $action = 'refresh' " ); - $att = $rs_att->fetch_assoc(); + $att = $rs_att->fetch(); // Add to message. if ($att['count'] > 0) { diff --git a/logic/get_pokemon_cp.php b/logic/get_pokemon_cp.php index b03a6fe1..d820e7c9 100644 --- a/logic/get_pokemon_cp.php +++ b/logic/get_pokemon_cp.php @@ -21,7 +21,7 @@ function get_pokemon_cp($pokemon_id_form) " ); - $cp = $rs->fetch_assoc(); + $cp = $rs->fetch(); return $cp; } diff --git a/logic/get_pokemon_weather.php b/logic/get_pokemon_weather.php index 400e2e13..b0e3d7c4 100644 --- a/logic/get_pokemon_weather.php +++ b/logic/get_pokemon_weather.php @@ -23,7 +23,7 @@ function get_pokemon_weather($pokemon_id_form) ); // Fetch the row. - $ww = $rs->fetch_assoc(); + $ww = $rs->fetch(); return $ww['weather']; } else { diff --git a/logic/get_raid.php b/logic/get_raid.php index 245ad37f..6bcbc8a7 100644 --- a/logic/get_raid.php +++ b/logic/get_raid.php @@ -24,7 +24,7 @@ function get_raid($raid_id) ); // Get the row. - $raid = $rs->fetch_assoc(); + $raid = $rs->fetch(); // Inject raid level $raid['level'] = get_raid_level($raid['pokemon']); diff --git a/logic/get_raid_level.php b/logic/get_raid_level.php index f54bf932..27f18494 100644 --- a/logic/get_raid_level.php +++ b/logic/get_raid_level.php @@ -25,7 +25,7 @@ function get_raid_level($pokedex_id) ); $raid_level = '0'; - while ($level = $rs->fetch_assoc()) { + while ($level = $rs->fetch()) { $raid_level = $level['raid_level']; } debug_log($raid_level, 'Per db, level is:'); diff --git a/logic/get_raid_with_pokemon.php b/logic/get_raid_with_pokemon.php index d126ffd5..089ff8af 100644 --- a/logic/get_raid_with_pokemon.php +++ b/logic/get_raid_with_pokemon.php @@ -30,7 +30,7 @@ function get_raid_with_pokemon($raid_id) ); // Get the row. - $raid = $rs->fetch_assoc(); + $raid = $rs->fetch(); debug_log($raid); diff --git a/logic/get_remote_users_count.php b/logic/get_remote_users_count.php index 33edd742..7f335c35 100644 --- a/logic/get_remote_users_count.php +++ b/logic/get_remote_users_count.php @@ -36,7 +36,7 @@ function get_remote_users_count($raid_id, $user_id, $attend_time = false) ); // Get the answer. - $answer = $rs->fetch_assoc(); + $answer = $rs->fetch(); // Write to log. debug_log($answer['remote_users'], 'Remote participants so far:'); diff --git a/logic/get_user.php b/logic/get_user.php index e4e1c551..a534956e 100644 --- a/logic/get_user.php +++ b/logic/get_user.php @@ -16,7 +16,7 @@ function get_user($user_id) ); // Fetch the row. - $row = $rs->fetch_assoc(); + $row = $rs->fetch(); // Build message string. $msg = ''; diff --git a/logic/insert_cleanup.php b/logic/insert_cleanup.php index 6cf80afd..a86d5441 100644 --- a/logic/insert_cleanup.php +++ b/logic/insert_cleanup.php @@ -13,8 +13,6 @@ function insert_cleanup($chat_id, $message_id, $raid_id) debug_log('Message_ID: ' . $message_id); if ((is_numeric($chat_id)) && (is_numeric($message_id)) && (is_numeric($raid_id)) && ($raid_id > 0)) { - global $db; - // Get raid times. $raid = get_raid($raid_id); @@ -34,7 +32,7 @@ function insert_cleanup($chat_id, $message_id, $raid_id) ); // Chat_id and message_id equal to info from database - while ($cleanup = $rs->fetch_assoc()) { + while ($cleanup = $rs->fetch()) { // Leave while loop if cleanup info is already in database if(($cleanup['chat_id'] == $chat_id) && ($cleanup['message_id'] == $message_id)) { debug_log('Cleanup preparation info is already in database!'); diff --git a/logic/insert_gym.php b/logic/insert_gym.php index 073346d7..5c39ec71 100644 --- a/logic/insert_gym.php +++ b/logic/insert_gym.php @@ -8,44 +8,51 @@ */ function insert_gym($name, $lat, $lon, $address) { - global $db; + global $dbh; // Build query to check if gym is already in database or not - $rs = my_query( - " - SELECT COUNT(*) + $stmt = $dbh->prepare(" + SELECT COUNT(*) AS count FROM gyms - WHERE gym_name = '{$name}' - " - ); + WHERE gym_name = :name"); - $row = $rs->fetch_row(); + $row = $stmt->fetch(); // Gym already in database or new - if (empty($row['0'])) { + if (empty($row['count'])) { // Build query for gyms table to add gym to database debug_log('Gym not found in database gym list! Adding gym "' . $name . '" to the database gym list.'); - $rs = my_query( - " + $stmt = $dbh->prepare(" INSERT INTO gyms - SET lat = '{$lat}', - lon = '{$lon}', - gym_name = '{$db->real_escape_string($name)}', - address = '{$db->real_escape_string($address)}' - " - ); + SET lat = :lat, + lon = :lon, + gym_name = :name, + address = :address + "); + $stmt->execute([ + 'lat' => $lat, + 'lon' => $lon, + 'name' => $name, + 'address' => $address + ]); } else { - // Update gyms table to reflect gym changes. + // Update gyms table to reflect gym changes. + // TODO(@Artanicus): using gym name as the selector is bad and doesn't allow updating gym name debug_log('Gym found in database gym list! Updating gym "' . $name . '" now.'); - $rs = my_query( - " + $stmt = $dbh->prepare(" UPDATE gyms - SET lat = '{$lat}', - lon = '{$lon}', - address = '{$db->real_escape_string($address)}' - WHERE gym_name = '{$name}' - " - ); + SET lat = :lat, + lon = :lon, + gym_name = :name, + address = :address + WHERE gym_name = :name + "); + $stmt->execute([ + 'lat' => $lat, + 'lon' => $lon, + 'name' => $name, + 'address' => $address + ]); } } diff --git a/logic/insert_overview.php b/logic/insert_overview.php index 9662ce41..081c1dca 100644 --- a/logic/insert_overview.php +++ b/logic/insert_overview.php @@ -6,21 +6,19 @@ */ function insert_overview($chat_id, $message_id) { - global $db; - // Build query to check if overview details are already in database or not $rs = my_query( " - SELECT COUNT(*) + SELECT COUNT(*) AS count FROM overview WHERE chat_id = '{$chat_id}' " ); - $row = $rs->fetch_row(); + $row = $rs->fetch(); // Overview already in database or new - if (empty($row['0'])) { + if (empty($row['count'])) { // Build query for overview table to add overview info to database debug_log('Adding new overview information to database overview list!'); $rs = my_query( diff --git a/logic/insert_trainerinfo.php b/logic/insert_trainerinfo.php index 29aa7133..210f0e71 100644 --- a/logic/insert_trainerinfo.php +++ b/logic/insert_trainerinfo.php @@ -6,21 +6,19 @@ */ function insert_trainerinfo($chat_id, $message_id) { - global $db; - // Build query to check if trainer info details are already in database or not $rs = my_query( " - SELECT COUNT(*) + SELECT COUNT(*) AS count FROM trainerinfo WHERE chat_id = '{$chat_id}' " ); - $row = $rs->fetch_row(); + $row = $rs->fetch(); // Trainer info already in database or new - if (empty($row['0'])) { + if (empty($row['count'])) { // Build query for trainerinfo table to add trainer info to database debug_log('Adding new trainer information to database trainer info list!'); $rs = my_query( diff --git a/logic/keys_vote.php b/logic/keys_vote.php index 9c151177..ee216855 100644 --- a/logic/keys_vote.php +++ b/logic/keys_vote.php @@ -482,7 +482,7 @@ function keys_vote($raid) " ); - $row = $rs->fetch_assoc(); + $row = $rs->fetch(); // Count participants and participants by pokemon $count_pp = $row['count']; @@ -532,7 +532,7 @@ function keys_vote($raid) $eggs = $GLOBALS['eggs']; // Add key for each raid level - while ($pokemon = $rs->fetch_assoc()) { + while ($pokemon = $rs->fetch()) { if(in_array($pokemon['pokedex_id'], $eggs)) continue; $buttons_pokemon[] = array( 'text' => get_local_pokemon_name($pokemon['pokedex_id'] . '-' . $pokemon['pokemon_form'], true), diff --git a/logic/pokemon_keys.php b/logic/pokemon_keys.php index 8bc25830..8c75796c 100644 --- a/logic/pokemon_keys.php +++ b/logic/pokemon_keys.php @@ -20,7 +20,7 @@ function pokemon_keys($gym_id_plus_letter, $raid_level, $action) ); // Add key for each raid level - while ($pokemon = $rs->fetch_assoc()) { + while ($pokemon = $rs->fetch()) { $keys[] = array( 'text' => get_local_pokemon_name($pokemon['pokedex_id'] . '-' . $pokemon['pokemon_form']), 'callback_data' => $gym_id_plus_letter . ':' . $action . ':' . $pokemon['pokedex_id'] . '-' . $pokemon['pokemon_form'] diff --git a/logic/raid_access_check.php b/logic/raid_access_check.php index 7c37536e..03853762 100644 --- a/logic/raid_access_check.php +++ b/logic/raid_access_check.php @@ -19,7 +19,7 @@ function raid_access_check($update, $data, $permission, $return_result = false) " ); - $raid = $rs->fetch_assoc(); + $raid = $rs->fetch(); // Check permissions if ($update['callback_query']['from']['id'] != $raid['user_id']) { diff --git a/logic/raid_edit_gym_keys.php b/logic/raid_edit_gym_keys.php index 12e0d53b..30931f27 100644 --- a/logic/raid_edit_gym_keys.php +++ b/logic/raid_edit_gym_keys.php @@ -65,7 +65,7 @@ function raid_edit_gym_keys($first, $warn = true, $action = 'edit_raidlevel', $d // Init empty keys array. $keys = []; - while ($gym = $rs->fetch_assoc()) { + while ($gym = $rs->fetch()) { // Add delete argument to keys if ($delete == true) { $arg = $gym['id'] . '-delete'; diff --git a/logic/raid_edit_gyms_first_letter_keys.php b/logic/raid_edit_gyms_first_letter_keys.php index a2c2872e..02d780cc 100644 --- a/logic/raid_edit_gyms_first_letter_keys.php +++ b/logic/raid_edit_gyms_first_letter_keys.php @@ -59,7 +59,7 @@ function raid_edit_gyms_first_letter_keys($action = 'raid_by_gym', $hidden = fal // Init empty keys array. $keys = []; - while ($gym = $rs->fetch_assoc()) { + while ($gym = $rs->fetch()) { // Add first letter to keys array $keys[] = array( 'text' => $gym['first_letter'], diff --git a/logic/raid_edit_raidlevel_keys.php b/logic/raid_edit_raidlevel_keys.php index 26c7b0bf..a695c30d 100644 --- a/logic/raid_edit_raidlevel_keys.php +++ b/logic/raid_edit_raidlevel_keys.php @@ -24,7 +24,7 @@ function raid_edit_raidlevel_keys($gym_id, $gym_first_letter, $admin = false) $keys = []; // Add key for each raid level - while ($level = $rs->fetch_assoc()) { + while ($level = $rs->fetch()) { // Continue if user is not part of the $config->BOT_ADMINS and raid_level is X if($level['raid_level'] == 'X' && $admin === false) continue; @@ -43,7 +43,7 @@ function raid_edit_raidlevel_keys($gym_id, $gym_first_letter, $admin = false) ); // Add key for pokemon - while ($pokemon = $rs_rl->fetch_assoc()) { + while ($pokemon = $rs_rl->fetch()) { $keys[] = array( 'text' => get_local_pokemon_name($pokemon['pokedex_id'] . '-' . $pokemon['pokemon_form']), 'callback_data' => $gym_id . ',' . $gym_first_letter . ':edit_starttime:' . $pokemon['pokedex_id'] . '-' . $pokemon['pokemon_form'] diff --git a/logic/raid_get_gyms_list_keys.php b/logic/raid_get_gyms_list_keys.php index 86f7b01b..5d99b73e 100644 --- a/logic/raid_get_gyms_list_keys.php +++ b/logic/raid_get_gyms_list_keys.php @@ -30,7 +30,7 @@ function raid_get_gyms_list_keys($searchterm) " ); - while ($gym = $rs->fetch_assoc()) { + while ($gym = $rs->fetch()) { $first = strtoupper(substr($gym['gym_name'], 0, 1)); $keys[] = array( 'text' => $gym['gym_name'], diff --git a/logic/raid_list.php b/logic/raid_list.php index b0f6155a..a7db88f6 100644 --- a/logic/raid_list.php +++ b/logic/raid_list.php @@ -41,7 +41,7 @@ function raid_list($update) " ); - while ($answer = $request->fetch_assoc()) { + while ($answer = $request->fetch()) { $rows[] = $answer; } @@ -65,7 +65,7 @@ function raid_list($update) " ); - while ($answer_raids = $request->fetch_assoc()) { + while ($answer_raids = $request->fetch()) { $rows[] = $answer_raids; } diff --git a/logic/run_cleanup.php b/logic/run_cleanup.php index a585157e..c5c0bc0e 100644 --- a/logic/run_cleanup.php +++ b/logic/run_cleanup.php @@ -81,14 +81,14 @@ function run_cleanup ($telegram = 2, $database = 2) { $cleanup_jobs = []; // Fill array with cleanup jobs. - while ($rowJob = $rs->fetch_assoc()) { + while ($rowJob = $rs->fetch()) { $cleanup_jobs[] = $rowJob; } // Cleanup telegram and database? if($telegram == 1 && $database == 1) { // Add database cleanup jobs to array. - while ($rowDBJob = $rs_db->fetch_assoc()) { + while ($rowDBJob = $rs_db->fetch()) { $cleanup_jobs[] = $rowDBJob; } } @@ -119,7 +119,7 @@ function run_cleanup ($telegram = 2, $database = 2) { ); // Fetch raid data. - $raid = $rs->fetch_assoc(); + $raid = $rs->fetch(); // No raid found - set cleanup to 0 and continue with next raid if (!$raid) { @@ -247,7 +247,7 @@ function run_cleanup ($telegram = 2, $database = 2) { ); // Log each cleanup ID which will be deleted. - while($rs_cleanups = $rs_cl->fetch_assoc()) { + while($rs_cleanups = $rs_cl->fetch()) { cleanup_log('Cleanup ID: ' . $rs_cleanups['id'] . ', Former Raid ID: ' . $rs_cleanups['cleaned']); } diff --git a/logic/sendalarm.php b/logic/sendalarm.php index d1086756..6ac26ea3 100644 --- a/logic/sendalarm.php +++ b/logic/sendalarm.php @@ -9,7 +9,7 @@ function sendalarm($text, $raid, $user) { // Will fetch all Trainer, which has subscribed for an alarm and send the message $request = my_query("SELECT DISTINCT user_id FROM attendance WHERE raid_id = {$raid} AND alarm = 1"); - while($answer = $request->fetch_assoc()) + while($answer = $request->fetch()) { // Only send message for other users! if($user != $answer['user_id']) { diff --git a/logic/sendcode.php b/logic/sendcode.php index cc383e8c..2fe1083d 100644 --- a/logic/sendcode.php +++ b/logic/sendcode.php @@ -18,7 +18,7 @@ function sendcode($text, $raid, $user, $who) } $request = my_query("SELECT DISTINCT user_id FROM attendance WHERE raid_id = {$raid} $sql_remote AND attend_time = (SELECT attend_time from attendance WHERE raid_id = {$raid} AND user_id = $user)"); - while($answer = $request->fetch_assoc()) + while($answer = $request->fetch()) { // Only send message for other users! if($user != $answer['user_id']) { diff --git a/logic/show_raid_poll.php b/logic/show_raid_poll.php index c4e99138..6dc3e4b6 100644 --- a/logic/show_raid_poll.php +++ b/logic/show_raid_poll.php @@ -133,7 +133,7 @@ function show_raid_poll($raid) $cnt_latewait = 0; $cnt_remote = 0; - while ($cnt_row = $rs_cnt->fetch_assoc()) { + while ($cnt_row = $rs_cnt->fetch()) { $cnt[$cnt_row['ts_att']] = $cnt_row; $cnt_all = $cnt_all + $cnt_row['count']; $cnt_latewait = $cnt_latewait + $cnt_row['count_late']; @@ -224,7 +224,7 @@ function show_raid_poll($raid) // Init empty count array and count sum. $cnt_pokemon = []; - while ($cnt_rowpoke = $rs_cnt_pokemon->fetch_assoc()) { + while ($cnt_rowpoke = $rs_cnt_pokemon->fetch()) { $cnt_pokemon[$cnt_rowpoke['ts_att'] . '_' . $cnt_rowpoke['pokemon']] = $cnt_rowpoke; } @@ -260,7 +260,7 @@ function show_raid_poll($raid) $previous_pokemon = 'FIRST_RUN'; // For each attendance. - while ($row = $rs_att->fetch_assoc()) { + while ($row = $rs_att->fetch()) { // Set current attend time and pokemon $current_att_time = $row['ts_att']; $dt_att_time = dt2time($row['attend_time']); @@ -392,7 +392,7 @@ function show_raid_poll($raid) $cnt_cancel = 0; $cnt_done = 0; - while ($cnt_row_cancel_done = $rs_cnt_cancel_done->fetch_assoc()) { + while ($cnt_row_cancel_done = $rs_cnt_cancel_done->fetch()) { // Cancel count if($cnt_row_cancel_done['count_cancel'] > 0) { $cnt_cancel = $cnt_cancel + $cnt_row_cancel_done['count_cancel'] + $cnt_row_cancel_done['extra_mystic'] + $cnt_row_cancel_done['extra_valor'] + $cnt_row_cancel_done['extra_instinct']; @@ -443,7 +443,7 @@ function show_raid_poll($raid) $cancel_done = 'CANCEL'; // For each canceled / done. - while ($row = $rs_att->fetch_assoc()) { + while ($row = $rs_att->fetch()) { // Attend time. $dt_att_time = dt2time($row['attend_time']); diff --git a/logic/show_raid_poll_small.php b/logic/show_raid_poll_small.php index 8ddab1a7..27a3eb2e 100644 --- a/logic/show_raid_poll_small.php +++ b/logic/show_raid_poll_small.php @@ -51,7 +51,7 @@ function show_raid_poll_small($raid, $override_language = false) " ); - $row = $rs->fetch_assoc(); + $row = $rs->fetch(); // Add to message. if ($row['count'] > 0) { diff --git a/mods/edit_raidlevel.php b/mods/edit_raidlevel.php index 6233c091..250db3b1 100644 --- a/mods/edit_raidlevel.php +++ b/mods/edit_raidlevel.php @@ -39,7 +39,7 @@ " ); - $shared = $rs_share->fetch_assoc(); + $shared = $rs_share->fetch(); // Add keys for sharing the raid. if($shared['raid_count'] == 0) { diff --git a/mods/edit_time.php b/mods/edit_time.php index e34dbe65..759d2880 100644 --- a/mods/edit_time.php +++ b/mods/edit_time.php @@ -107,7 +107,7 @@ ); // Get last insert id from db. - $raid_id = my_insert_id(); + $raid_id = $dbh->lastInsertId(); // Write to log. debug_log('ID=' . $raid_id); @@ -128,7 +128,7 @@ " ); - $shared = $rs_share->fetch_assoc(); + $shared = $rs_share->fetch(); // Add keys for sharing the raid. if($shared['raid_count'] == 0) { diff --git a/mods/importal.php b/mods/importal.php index f3c91f2e..53b18eae 100644 --- a/mods/importal.php +++ b/mods/importal.php @@ -52,12 +52,12 @@ function escape($value){ SELECT id FROM gyms WHERE gym_name = '{$gym_name_no_spec}' - "); + "); - $row = $rs->fetch_row(); + $row = $rs->fetch(); // Gym already in database or new - if (empty($row['0'])) { + if (empty($row['id'])) { // insert gym in table. debug_log('Gym not found in database gym list! Inserting gym "' . $gym_name . '" now.'); $query = ' @@ -84,12 +84,13 @@ function escape($value){ // Insert / Update. $statement = $dbh->prepare($query); - $statement->bindValue(':gym_name', $gym_name, PDO::PARAM_STR); - $statement->bindValue(':lat', $lat, PDO::PARAM_STR); - $statement->bindValue(':lon', $lon, PDO::PARAM_STR); - $statement->bindValue(':address', $address, PDO::PARAM_STR); - $statement->bindValue(':gym_image', $gym_image, PDO::PARAM_STR); - $statement->execute(); + $statement->execute([ + 'gym_name' => $gym_name, + 'lat' => $lat, + 'lon' => $lon, + 'address' => $address, + 'gym_image' => $gym_image + ]); } catch (PDOException $exception) { error_log($exception->getMessage()); $dbh = null; @@ -97,7 +98,7 @@ function escape($value){ } // Get last insert id. - if (empty($row['0'])) { + if (empty($row['id'])) { $gym_id = $dbh->lastInsertId(); } diff --git a/mods/overview_delete.php b/mods/overview_delete.php index dfe40c34..a8113419 100644 --- a/mods/overview_delete.php +++ b/mods/overview_delete.php @@ -31,7 +31,7 @@ // Count results. $count = 0; - while ($rowOverviews = $request_overviews->fetch_assoc()) { + while ($rowOverviews = $request_overviews->fetch()) { // Counter++ $count = $count + 1; @@ -90,7 +90,7 @@ " ); - $overview = $request_overviews->fetch_assoc(); + $overview = $request_overviews->fetch(); // Delete overview delete_overview($overview['chat_id'], $overview['message_id']); diff --git a/mods/overview_refresh.php b/mods/overview_refresh.php index 7a6c2105..11802006 100644 --- a/mods/overview_refresh.php +++ b/mods/overview_refresh.php @@ -32,7 +32,7 @@ $raid_ids_active = []; // Get all active raids into array. -while ($rowRaids = $request_active_raids->fetch_assoc()) { +while ($rowRaids = $request_active_raids->fetch()) { // Use current raid_id as key for raids array $current_raid_id = $rowRaids['id']; $raids_active[$current_raid_id] = $rowRaids; @@ -78,7 +78,7 @@ ); } - while ($rowOverviews = $request_overviews->fetch_assoc()) { + while ($rowOverviews = $request_overviews->fetch()) { // Set chat_id. $chat_id = $rowOverviews['chat_id']; @@ -94,7 +94,7 @@ ); // Get all chats. - while ($rowChats = $request_active_chats->fetch_assoc()) { + while ($rowChats = $request_active_chats->fetch()) { $chats_active[] = $rowChats; } } diff --git a/mods/overview_share.php b/mods/overview_share.php index 6cf0a7cf..840a219e 100644 --- a/mods/overview_share.php +++ b/mods/overview_share.php @@ -35,7 +35,7 @@ $raid_ids_active = []; // Get all active raids into array. -while ($rowRaids = $request_active_raids->fetch_assoc()) { +while ($rowRaids = $request_active_raids->fetch()) { // Use current raid_id as key for raids array $current_raid_id = $rowRaids['id']; $raids_active[$current_raid_id] = $rowRaids; @@ -84,7 +84,7 @@ } // Get all chats. - while ($rowChats = $request_active_chats->fetch_assoc()) { + while ($rowChats = $request_active_chats->fetch()) { $chats_active[] = $rowChats; } } diff --git a/mods/pokebattler.php b/mods/pokebattler.php index 0d9a2ceb..58682ae2 100644 --- a/mods/pokebattler.php +++ b/mods/pokebattler.php @@ -319,7 +319,7 @@ $keys = []; // Add key for each raid level - while ($pokemon = $rs->fetch_assoc()) { + while ($pokemon = $rs->fetch()) { $levels[$pokemon['pokedex_id'].'-'.$pokemon['pokemon_form']] = $pokemon['raid_level']; } diff --git a/mods/pokedex_disable_raids.php b/mods/pokedex_disable_raids.php index e0d279f3..17bf7b90 100644 --- a/mods/pokedex_disable_raids.php +++ b/mods/pokedex_disable_raids.php @@ -72,7 +72,7 @@ $keys = []; // Add key for each raid level - while ($pokemon = $rs->fetch_assoc()) { + while ($pokemon = $rs->fetch()) { $plevels[$pokemon['pokedex_id'].'-'.$pokemon['pokemon_form']] = $pokemon['raid_level']; } diff --git a/mods/pokedex_list_raids.php b/mods/pokedex_list_raids.php index 14b9f9e0..dc2869e9 100644 --- a/mods/pokedex_list_raids.php +++ b/mods/pokedex_list_raids.php @@ -23,7 +23,7 @@ $keys = []; // Add key for each raid level -while ($pokemon = $rs->fetch_assoc()) { +while ($pokemon = $rs->fetch()) { $levels[$pokemon['pokedex_id'].'-'.$pokemon['pokemon_form']] = $pokemon['raid_level']; } diff --git a/mods/pokedex_set_raid_level.php b/mods/pokedex_set_raid_level.php index fc4216a6..77d0d97c 100644 --- a/mods/pokedex_set_raid_level.php +++ b/mods/pokedex_set_raid_level.php @@ -32,7 +32,7 @@ ); //Get type information - while ($enum = $rs->fetch_assoc()) { + while ($enum = $rs->fetch()) { // Type should be something like this: enum('0','1','2','3','4','5','X') $type = $enum['Type']; } diff --git a/mods/raid_by_location.php b/mods/raid_by_location.php index 3482e706..8f57baf8 100644 --- a/mods/raid_by_location.php +++ b/mods/raid_by_location.php @@ -84,19 +84,19 @@ // Insert / update gym. try { - global $db; + global $dbh; // Build query to check if gym is already in database or not $rs = my_query(" - SELECT COUNT(*) + SELECT COUNT(*) AS count FROM gyms WHERE gym_name = '{$gym_name}' "); - $row = $rs->fetch_row(); + $row = $rs->fetch(); // Gym already in database or new - if (empty($row['0'])) { + if (empty($row['count'])) { // insert gym in table. debug_log('Gym not found in database gym list! Inserting gym "' . $gym_name . '" now.'); $query = ' @@ -116,11 +116,12 @@ } $statement = $dbh->prepare($query); - $statement->bindValue(':gym_name', $gym_name, PDO::PARAM_STR); - $statement->bindValue(':lat', $lat, PDO::PARAM_STR); - $statement->bindValue(':lon', $lon, PDO::PARAM_STR); - $statement->bindValue(':address', $address, PDO::PARAM_STR); - $statement->execute(); + $statement->execute([ + 'gym_name' => $gym_name, + 'lat' => $lat, + 'lon' => $lon, + 'address' => $address + ]); // Get gym id from insert. if($gym_id == 0) { $gym_id = $dbh->lastInsertId(); diff --git a/mods/raid_set_poke.php b/mods/raid_set_poke.php index a82b0f0a..6a9d002a 100644 --- a/mods/raid_set_poke.php +++ b/mods/raid_set_poke.php @@ -79,12 +79,12 @@ // Update the shared raid polls. if($config->RAID_PICTURE) { - while ($raidmsg = $rs->fetch_assoc()) { + while ($raidmsg = $rs->fetch()) { $picture_url = $config->RAID_PICTURE_URL . "?pokemon=" . $raid['pokemon'] . "&raid=". $id; $tg_json[] = editMessageMedia($raidmsg['message_id'], $updated_msg['short'], $updated_keys, $raidmsg['chat_id'], ['disable_web_page_preview' => 'true'], false, $picture_url); } } else { - while ($raidmsg = $rs->fetch_assoc()) { + while ($raidmsg = $rs->fetch()) { $tg_json[] = editMessageText($raidmsg['message_id'], $updated_msg['full'], $updated_keys, $raidmsg['chat_id'], ['disable_web_page_preview' => 'true'], true); } } diff --git a/mods/trainer_add.php b/mods/trainer_add.php index ee0338aa..baf1b208 100644 --- a/mods/trainer_add.php +++ b/mods/trainer_add.php @@ -68,7 +68,7 @@ ); $chats_db = []; -while ($row = $rs->fetch_assoc()) { +while ($row = $rs->fetch()) { $chats_db[] = $row['chat_id']; } $log_chats_db = implode(',', $chats_db); diff --git a/mods/trainer_delete.php b/mods/trainer_delete.php index c18f0bd6..f02deadf 100644 --- a/mods/trainer_delete.php +++ b/mods/trainer_delete.php @@ -26,7 +26,7 @@ " ); - while ($row = $rs->fetch_assoc()) { + while ($row = $rs->fetch()) { // Chat and message ID $chat_id = $row['chat_id']; $message_id = $row['message_id']; @@ -132,7 +132,7 @@ ); // Delete trainer message. - while ($row = $rs->fetch_assoc()) { + while ($row = $rs->fetch()) { delete_trainerinfo($row['chat_id'], $row['message_id']); } } diff --git a/mods/vote_extra.php b/mods/vote_extra.php index 3f2dfa56..de619622 100644 --- a/mods/vote_extra.php +++ b/mods/vote_extra.php @@ -17,7 +17,7 @@ ); // Get the answer. -$answer = $rs->fetch_assoc(); +$answer = $rs->fetch(); // Write to log. debug_log($answer); diff --git a/mods/vote_pokemon.php b/mods/vote_pokemon.php index d7592638..b99a70e7 100644 --- a/mods/vote_pokemon.php +++ b/mods/vote_pokemon.php @@ -21,7 +21,7 @@ $count = 0; // Fill array with attendances. -while ($row = $rs->fetch_assoc()) { +while ($row = $rs->fetch()) { $atts[] = $row; $count = $count + 1; } diff --git a/mods/vote_remote.php b/mods/vote_remote.php index fdb19051..753567cd 100644 --- a/mods/vote_remote.php +++ b/mods/vote_remote.php @@ -17,7 +17,7 @@ ); // Get remote value. -$remote = $rs->fetch_assoc(); +$remote = $rs->fetch(); $remote_status = $remote['remote']; // Check if max remote users limit is already reached! diff --git a/mods/vote_status.php b/mods/vote_status.php index fa714b10..84283674 100644 --- a/mods/vote_status.php +++ b/mods/vote_status.php @@ -17,7 +17,7 @@ ); // Get the answer. -$answer = $rs->fetch_assoc(); +$answer = $rs->fetch(); // Write to log. debug_log($answer); @@ -44,7 +44,7 @@ // request gym name $request = my_query("SELECT * FROM raids as r left join gyms as g on r.gym_id = g.id WHERE r.id = {$data['id']}"); - $answer = $request->fetch_assoc(); + $answer = $request->fetch(); $gymname = '' . $answer['gym_name'] . ''; $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($answer, false, true))); @@ -57,7 +57,7 @@ AND user_id = {$update['callback_query']['from']['id']} " ); - $answer = $rs->fetch_assoc(); + $answer = $rs->fetch(); // Enable alerts message. if($answer['alarm']) { diff --git a/mods/vote_time.php b/mods/vote_time.php index d035b3ad..678344f8 100644 --- a/mods/vote_time.php +++ b/mods/vote_time.php @@ -17,7 +17,7 @@ ); // Get the answer. -$answer = $rs->fetch_assoc(); +$answer = $rs->fetch(); // Write to log. debug_log($answer); diff --git a/raidpicture.php b/raidpicture.php index 30dcaec7..47ba82ee 100644 --- a/raidpicture.php +++ b/raidpicture.php @@ -532,8 +532,5 @@ imagedestroy($img_gym); imagedestroy($img_pokemon); imagedestroy($canvas); - -$db->close(); -$db = null; ?>