From ab0d2133d45c04f4ca6f843bac9a04730c7a52a5 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 24 Jul 2023 12:55:46 +0700 Subject: [PATCH] Minor improvements (#843) --- install/upgrade/changes.txt | 4 +++- library/includes/functions.php | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/install/upgrade/changes.txt b/install/upgrade/changes.txt index fa40750d9..44cb57932 100644 --- a/install/upgrade/changes.txt +++ b/install/upgrade/changes.txt @@ -62,4 +62,6 @@ ALTER TABLE `bb_users` CHANGE `user_newpasswd` `user_newpasswd` VARCHAR(255) NOT INSERT INTO bb_config VALUES ('show_board_start_index', '1'); // 2.4.0-beta2 -INSERT INTO `bb_cron` VALUES (NULL, '1', 'PM cleanup', 'clean_pm.php', 'daily', '', '05:00:00', '70', '', '', '', '1', '', '0', '1', '0'); +INSERT INTO `bb_cron` (`cron_active`, `cron_title`, `cron_script`, `schedule`, `run_day`, `run_time`, `run_order`, + `last_run`, `next_run`, `run_interval`, `log_enabled`, `log_file`, `log_sql_queries`, + `disable_board`, `run_counter`) VALUES ('1', 'PM cleanup', 'clean_pm.php', 'daily', '', '05:00:00', '70', '', '', '', '1', '', '0', '1', '0'); diff --git a/library/includes/functions.php b/library/includes/functions.php index 4ba538476..c2a44df95 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -34,8 +34,8 @@ function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 1000 function delete_avatar($user_id, $avatar_ext_id) { - $avatar_file = $avatar_ext_id ? get_avatar_path($user_id, $avatar_ext_id) : ''; - return ($avatar_file && file_exists($avatar_file)) ? @unlink($avatar_file) : false; + $avatar_file = $avatar_ext_id ? get_avatar_path($user_id, $avatar_ext_id) : false; + return ($avatar_file && file_exists($avatar_file) && unlink($avatar_file)); } function get_tracks($type) @@ -739,8 +739,12 @@ function get_user_id($username) if (empty($username)) { return false; } - $row = DB()->fetch_row("SELECT user_id FROM " . BB_USERS . " WHERE username = '" . DB()->escape($username) . "' LIMIT 1"); - return $row['user_id']; + + if ($row = DB()->fetch_row("SELECT user_id FROM " . BB_USERS . " WHERE username = '" . DB()->escape($username) . "' LIMIT 1")) { + return $row['user_id']; + } + + return false; } function str_short($text, $max_length, $space = ' ')