From 608c9ef711f9e63f857a4e4d03a4f6ab9a11b3fe Mon Sep 17 00:00:00 2001 From: Clayton Brown <45186932+Whit3XLightning@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:31:52 -0600 Subject: [PATCH] check if file shared before assigning variables. Fixed an issue that produced warnings in the event a file had not been shared. The program was attempting to access a null ($row) array. Also fixed an issue where the author of an uploaded file ($file_uploaded_by) had not been declared in the scope it was being called. --- client_files.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/client_files.php b/client_files.php index 3d15566ee..5cbe6d15e 100644 --- a/client_files.php +++ b/client_files.php @@ -473,6 +473,7 @@ function display_folders($parent_folder_id, $client_id, $indent = 0) { $file_size_KB = number_format($file_size / 1024); $file_mime_type = nullable_htmlentities($row['file_mime_type']); $file_size = intval($row['file_size']); + $file_uploaded_by = nullable_htmlentities($row['user_name']); $file_has_thumbnail = intval($row['file_has_thumbnail']); $file_has_preview = intval($row['file_has_preview']); $file_created_at = nullable_htmlentities($row['file_created_at']); @@ -490,19 +491,22 @@ function display_folders($parent_folder_id, $client_id, $indent = 0) { AND item_related_id = $file_id LIMIT 1" ); - $row = mysqli_fetch_array($sql_shared); - $item_id = intval($row['item_id']); - $item_active = nullable_htmlentities($row['item_active']); - $item_key = nullable_htmlentities($row['item_key']); - $item_type = nullable_htmlentities($row['item_type']); - $item_related_id = intval($row['item_related_id']); - $item_note = nullable_htmlentities($row['item_note']); - $item_recipient = nullable_htmlentities($row['item_recipient']); - $item_views = nullable_htmlentities($row['item_views']); - $item_view_limit = nullable_htmlentities($row['item_view_limit']); - $item_created_at = nullable_htmlentities($row['item_created_at']); - $item_expire_at = nullable_htmlentities($row['item_expire_at']); - $item_expire_at_human = timeAgo($row['item_expire_at']); + $file_shared = (mysqli_num_rows($sql_shared) > 0) ? true : false; + if ($file_shared) { + $row = mysqli_fetch_array($sql_shared); + $item_id = intval($row['item_id']); + $item_active = nullable_htmlentities($row['item_active']); + $item_key = nullable_htmlentities($row['item_key']); + $item_type = nullable_htmlentities($row['item_type']); + $item_related_id = intval($row['item_related_id']); + $item_note = nullable_htmlentities($row['item_note']); + $item_recipient = nullable_htmlentities($row['item_recipient']); + $item_views = nullable_htmlentities($row['item_views']); + $item_view_limit = nullable_htmlentities($row['item_view_limit']); + $item_created_at = nullable_htmlentities($row['item_created_at']); + $item_expire_at = nullable_htmlentities($row['item_expire_at']); + $item_expire_at_human = timeAgo($row['item_expire_at']); + } ?> @@ -533,7 +537,7 @@ function display_folders($parent_folder_id, $client_id, $indent = 0) {
- 0) { ?> +
Shared