From 7774fd7cb59b56d4c75eaa9793c530961c165714 Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 09:50:54 +0100 Subject: [PATCH 1/8] Improve code --- acpcleanup/cleanup.php | 2 +- acpimport/acp/main_module.php | 4 ++-- core/album/display.php | 28 +++++++++++++++------------- core/log.php | 9 ++++----- core/search.php | 1 + exif/exif.php | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/acpcleanup/cleanup.php b/acpcleanup/cleanup.php index 9bba3518..9f062d70 100644 --- a/acpcleanup/cleanup.php +++ b/acpcleanup/cleanup.php @@ -226,7 +226,7 @@ public function delete_pegas($unwanted_pegas, $obsolete_pegas) ), ), - 'WHERE' => 'a.album_user_id <> ' . $this->album->get_public() . ' AND a.parent_id = 0', + 'WHERE' => 'a.album_user_id <> ' . (int) $this->album->get_public() . ' AND a.parent_id = 0', 'ORDER_BY' => 'a.album_id DESC', ); $sql = $this->db->sql_build_query('SELECT', $sql_array); diff --git a/acpimport/acp/main_module.php b/acpimport/acp/main_module.php index 8ed40442..0798646e 100644 --- a/acpimport/acp/main_module.php +++ b/acpimport/acp/main_module.php @@ -302,7 +302,7 @@ function import() $sql = 'SELECT username, user_colour, user_id FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; + WHERE user_id = ' . (int) $user_id; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -339,7 +339,7 @@ function import() // Where do we put them to? $sql = 'SELECT album_id, album_name FROM ' . $table_prefix . 'gallery_albums - WHERE album_id = ' . $album_id; + WHERE album_id = ' . (int) $album_id; $result = $db->sql_query($sql); $album_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); diff --git a/core/album/display.php b/core/album/display.php index e1875bd7..8fb9c556 100644 --- a/core/album/display.php +++ b/core/album/display.php @@ -137,7 +137,7 @@ public function generate_navigation($album_data) $album_parents = $this->get_parents($album_data); // Display username for personal albums - if ($album_data['album_user_id'] > \phpbbgallery\core\block::PUBLIC_ALBUM) + if ($album_data['album_user_id'] > (int) \phpbbgallery\core\block::PUBLIC_ALBUM) { $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' @@ -179,9 +179,9 @@ public function generate_navigation($album_data) 'ALBUM_ID' => $album_data['album_id'], 'ALBUM_NAME' => $album_data['album_name'], 'ALBUM_DESC' => generate_text_for_display($album_data['album_desc'], $album_data['album_desc_uid'], $album_data['album_desc_bitfield'], $album_data['album_desc_options']), - 'ALBUM_CONTEST_START' => ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_START' . ((($album_data['contest_start']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start']), false, true)) : '', - 'ALBUM_CONTEST_RATING' => ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_RATING_START' . ((($album_data['contest_start'] + $album_data['contest_rating']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_rating']), false, true)) : '', - 'ALBUM_CONTEST_END' => ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_END' . ((($album_data['contest_start'] + $album_data['contest_end']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_end']), false, true)) : '', + 'ALBUM_CONTEST_START' => ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_START' . ((($album_data['contest_start']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start']), false, true)) : '', + 'ALBUM_CONTEST_RATING' => ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_RATING_START' . ((($album_data['contest_start'] + $album_data['contest_rating']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_rating']), false, true)) : '', + 'ALBUM_CONTEST_END' => ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_END' . ((($album_data['contest_start'] + $album_data['contest_end']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_end']), false, true)) : '', 'U_VIEW_ALBUM' => $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_data['album_id'])), )); @@ -199,7 +199,8 @@ public function generate_navigation($album_data) */ public function get_parents($album_data) { - $album_parents = array(); + $album_parents = []; + if ($album_data['parent_id'] > 0) { if ($album_data['album_parents'] == '') @@ -210,11 +211,12 @@ public function get_parents($album_data) AND right_id > ' . (int) $album_data['right_id'] . ' AND album_user_id = ' . (int) $album_data['album_user_id'] . ' ORDER BY left_id ASC'; + $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $album_parents[$row['album_id']] = array($row['album_name'], (int) $row['album_type']); + $album_parents[$row['album_id']] = [$row['album_name'], (int) $row['album_type']]; } $this->db->sql_freeresult($result); @@ -344,8 +346,8 @@ public function display_albums($root_data = '', $display_moderators = true, $ret { $mark_read = 'all'; } - $root_data = array('album_id' => \phpbbgallery\core\block::PUBLIC_ALBUM); - $sql_where = 'a.album_user_id = ' . \phpbbgallery\core\block::PUBLIC_ALBUM; + $root_data = array('album_id' => (int) \phpbbgallery\core\block::PUBLIC_ALBUM); + $sql_where = 'a.album_user_id = ' . (int) \phpbbgallery\core\block::PUBLIC_ALBUM; } else if ($root_data == 'personal') { @@ -354,7 +356,7 @@ public function display_albums($root_data = '', $display_moderators = true, $ret $mark_read = 'all'; } $root_data = array('album_id' => 0); - $sql_where = 'a.album_user_id > ' . \phpbbgallery\core\block::PUBLIC_ALBUM; + $sql_where = 'a.album_user_id > ' . (int) \phpbbgallery\core\block::PUBLIC_ALBUM; $num_pegas = $this->config['phpbb_gallery_num_pegas']; $first_char = $this->request->variable('first_char', ''); if ($first_char == 'other') @@ -601,7 +603,7 @@ public function display_albums($root_data = '', $display_moderators = true, $ret foreach ($album_rows as $row) { // Empty category - if (($row['parent_id'] == $root_data['album_id']) && ($row['album_type'] == \phpbbgallery\core\block::TYPE_CAT)) + if (($row['parent_id'] == $root_data['album_id']) && ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT)) { $this->template->assign_block_vars('albumrow', array( 'S_IS_CAT' => true, @@ -676,7 +678,7 @@ public function display_albums($root_data = '', $display_moderators = true, $ret $folder_alt = ($album_unread) ? 'NEW_IMAGES' : 'NO_NEW_IMAGES'; $folder_image = ($album_unread) ? 'forum_unread' : 'forum_read'; } - if ($row['album_status'] == \phpbbgallery\core\block::ALBUM_LOCKED) + if ($row['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED) { $folder_image = ($album_unread) ? 'forum_unread_locked' : 'forum_read_locked'; $folder_alt = 'ALBUM_LOCKED'; @@ -721,12 +723,12 @@ public function display_albums($root_data = '', $display_moderators = true, $ret $s_subalbums_list = (string) implode(', ', $s_subalbums_list); $catless = ($row['parent_id'] == $root_data['album_id']) ? true : false; - $s_username_hidden = ($lastimage_album_type == \phpbbgallery\core\block::TYPE_CONTEST) && $lastimage_contest_marked && !$this->gallery_auth->acl_check('m_status', $album_id, $row['album_user_id']) && ($this->user->data['user_id'] != $row['album_last_user_id'] || $row['album_last_user_id'] == ANONYMOUS); + $s_username_hidden = ($lastimage_album_type == (int) \phpbbgallery\core\block::TYPE_CONTEST) && $lastimage_contest_marked && !$this->gallery_auth->acl_check('m_status', $album_id, $row['album_user_id']) && ($this->user->data['user_id'] != $row['album_last_user_id'] || $row['album_last_user_id'] == ANONYMOUS); $this->template->assign_block_vars('albumrow', array( 'S_IS_CAT' => false, 'S_NO_CAT' => $catless && !$last_catless, - 'S_LOCKED_ALBUM' => ($row['album_status'] == \phpbbgallery\core\block::ALBUM_LOCKED) ? true : false, + 'S_LOCKED_ALBUM' => ($row['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED) ? true : false, 'S_UNREAD_ALBUM' => ($album_unread) ? true : false, 'S_LIST_SUBALBUMS' => ($row['display_subalbum_list']) ? true : false, 'S_SUBALBUMS' => (sizeof($subalbums_list)) ? true : false, diff --git a/core/log.php b/core/log.php index 150244d6..feb63393 100644 --- a/core/log.php +++ b/core/log.php @@ -127,13 +127,13 @@ public function delete_logs($mark) * @param array $additional * @internal param int $start start count used to build paging */ - public function build_list($type, $limit = 0, $page = 1, $album = 0, $image = 0, $additional = array()) + public function build_list($type, $limit = 0, $page = 1, $album = 0, $image = 0, $additional = []) { if ($limit == 0) { $limit = $this->gallery_config->get('items_per_page'); } - $this->language->add_lang(array('info_acp_gallery_logs'), 'phpbbgallery/core'); + $this->language->add_lang(['info_acp_gallery_logs'], 'phpbbgallery/core'); $this->gallery_auth->load_user_permissions($this->user->data['user_id']); $sql_array = array( @@ -147,7 +147,7 @@ public function build_list($type, $limit = 0, $page = 1, $album = 0, $image = 0, ) ) ); - $sql_where = array(); + $sql_where = []; if ($type != 'all') { $sql_where[] = "l.log_type = '" . $this->db->sql_escape($type) . "'"; @@ -261,8 +261,7 @@ public function build_list($type, $limit = 0, $page = 1, $album = 0, $image = 0, 'U_LOG_IP' => $var['ip'], 'U_ALBUM_LINK' => $var['album'] != 0 ? $this->helper->route('phpbbgallery_core_album', array('album_id' => $var['album'])) : false, 'U_IMAGE_LINK' => $var['image'] != 0 ? $this->helper->route('phpbbgallery_core_image', array('image_id' => $var['image'])) : false, - //'U_LOG_ACTION' => $description, - 'U_LOG_ACTION' => $this->language->lang($var['description'][0], isset($var['description'][1]) ? $var['description'][1] : false, isset($var['description'][2]) ? $var['description'][2] : false, isset($var['description'][3]) ? $var['description'][3] : false), + 'U_LOG_ACTION' => isset($var['description']) && is_array($var['description']) ? $this->language->lang($var['description'][0], $var['description'][1] ?? false, $var['description'][2] ?? false, $var['description'][3] ?? false) : '', 'U_TIME' => $this->user->format_date($var['time']), )); } diff --git a/core/search.php b/core/search.php index db2fb5ef..753796dc 100644 --- a/core/search.php +++ b/core/search.php @@ -223,6 +223,7 @@ public function random($limit, $user = 0, $fields = 'rrc_gindex_display', $block ), 'WHERE' => 'i.image_status <> ' . \phpbbgallery\core\block::STATUS_ORPHAN . ' AND ' . $sql_where, + 'WHERE' => 'i.image_status <> ' . (int) \phpbbgallery\core\block::STATUS_ORPHAN . ' AND ' . $sql_where, 'GROUP_BY' => 'i.image_id, a.album_name, a.album_status, a.album_user_id, a.album_id', 'ORDER_BY' => $sql_order, ); diff --git a/exif/exif.php b/exif/exif.php index 4058ddbb..86f9da7a 100644 --- a/exif/exif.php +++ b/exif/exif.php @@ -315,7 +315,7 @@ public function set_status() $update_data = ($this->status == self::DBSAVED) ? ", image_exif_data = '" . $db->sql_escape($this->serialized) . "'" : ''; $sql = 'UPDATE ' . $table_prefix . 'gallery_images SET image_has_exif = ' . $this->status . $update_data . ' - WHERE image_id = ' . $this->image_id; + WHERE image_id = ' . (int) $this->image_id; $db->sql_query($sql); } From 1fdbbbbc21621143aed2db87b083cc7ec1969b69 Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 09:51:28 +0100 Subject: [PATCH 2/8] Fix request var deprecated code --- exif/event/exif_listener.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exif/event/exif_listener.php b/exif/event/exif_listener.php index fb2038e0..2f177bf2 100644 --- a/exif/event/exif_listener.php +++ b/exif/event/exif_listener.php @@ -212,10 +212,12 @@ public function user_get_default_values($event) public function ucp_set_settings_submit($event) { + global $request; + $additional_settings = $event['additional_settings']; if (!in_array('user_viewexif', $additional_settings)) { - $additional_settings['user_viewexif'] = request_var('viewexifs', false); + $additional_settings['user_viewexif'] = $request->variable('viewexifs', false); $event['additional_settings'] = $additional_settings; } } From 244b4c6f97e3684c4cd49db3e76652582c51520e Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 09:52:17 +0100 Subject: [PATCH 3/8] Make sure id_ary is int --- core/search.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/search.php b/core/search.php index 753796dc..e6d3761f 100644 --- a/core/search.php +++ b/core/search.php @@ -209,6 +209,8 @@ public function random($limit, $user = 0, $fields = 'rrc_gindex_display', $block return; } + $id_ary = array_map('intval', $id_ary); + $sql_where = $this->db->sql_in_set('i.image_id', $id_ary); $sql_array = array( From 46e7141c380444ddfffe4c06acc48bd1ae8005e8 Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 09:54:57 +0100 Subject: [PATCH 4/8] Fix recent comments --- core/controller/index.php | 2 +- core/search.php | 71 ++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/core/controller/index.php b/core/controller/index.php index 8dcb9623..4355bd24 100644 --- a/core/controller/index.php +++ b/core/controller/index.php @@ -225,7 +225,7 @@ public function base() 'S_RECENT_COMMENTS' => $this->helper->route('phpbbgallery_core_search_commented'), 'COMMENTS_EXPAND' => $this->gallery_config->get('rrc_gindex_comments') ? true : false, )); - $this->gallery_search->recent_comments($this->gallery_config->get('items_per_page'), 0); + $this->gallery_search->recent_comments($this->gallery_config->get('items_per_page'), 0, false); } } $this->display_legend(); diff --git a/core/search.php b/core/search.php index e6d3761f..678f16b6 100644 --- a/core/search.php +++ b/core/search.php @@ -253,10 +253,8 @@ public function recent_count() { $this->gallery_auth->load_user_permissions($this->user->data['user_id']); - $sql = 'SELECT COUNT(image_id) as count - FROM ' . $this->images_table . ' - WHERE image_status <> ' . \phpbbgallery\core\block::STATUS_ORPHAN; - $exclude_albums = array(); + $exclude_albums = []; + if (!$this->gallery_config->get('rrc_gindex_pegas')) { $sql_no_user = 'SELECT album_id FROM ' . $this->albums_table . ' WHERE album_user_id > 0'; @@ -267,20 +265,55 @@ public function recent_count() } $this->db->sql_freeresult($result); } + $exclude_albums = array_merge($exclude_albums, $this->gallery_auth->get_exclude_zebra()); - $sql .= ' AND ((' . $this->db->sql_in_set('image_album_id', array_diff($this->gallery_auth->acl_album_ids('i_view'), $exclude_albums), false, true) . ' AND image_status <> ' . \phpbbgallery\core\block::STATUS_UNAPPROVED . ') - OR ' . $this->db->sql_in_set('image_album_id', array_diff($this->gallery_auth->acl_album_ids('m_status'), $exclude_albums), false, true) . ')'; + + // Get allowed album ids for view and mod permissions excluding excluded albums + $view_album_ids = array_diff($this->gallery_auth->acl_album_ids('i_view'), $exclude_albums); + $mod_album_ids = array_diff($this->gallery_auth->acl_album_ids('m_status'), $exclude_albums); + + if (empty($view_album_ids) && empty($mod_album_ids)) + { + return 0; + } + + $sql = 'SELECT COUNT(image_id) AS count + FROM ' . $this->images_table . ' + WHERE image_status <> ' . (int) \phpbbgallery\core\block::STATUS_ORPHAN; + + $conditions = []; + + if (!empty($view_album_ids)) + { + $conditions[] = '(' . $this->db->sql_in_set('image_album_id', $view_album_ids) . ' + AND image_status <> ' . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED . ')'; + } + + if (!empty($mod_album_ids)) + { + $conditions[] = $this->db->sql_in_set('image_album_id', $mod_album_ids); + } + + if (!empty($conditions)) + { + $sql .= ' AND (' . implode(' OR ', $conditions) . ')'; + } + $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + return (int) $row['count']; } + + /** * recent comments - * @param (int) $limit How many imagese to query + * @param (int) $limit How many images to query * @param int $start */ - public function recent_comments($limit, $start = 0) + public function recent_comments($limit, $start = 0, $pagination = true) { $this->gallery_auth->load_user_permissions($this->user->data['user_id']); $sql_limit = $limit; @@ -305,7 +338,7 @@ public function recent_comments($limit, $start = 0) 'GROUP_BY' => 'c.comment_id, c.comment_time, i.image_id', 'ORDER_BY' => 'comment_time DESC' ); - $sql_array['WHERE'] .= ' AND ((' . $this->db->sql_in_set('image_album_id', array_diff($this->gallery_auth->acl_album_ids('i_view'), $exclude_albums), false, true) . ' AND image_status <> ' . \phpbbgallery\core\block::STATUS_UNAPPROVED . ') + $sql_array['WHERE'] .= ' AND ((' . $this->db->sql_in_set('image_album_id', array_diff($this->gallery_auth->acl_album_ids('i_view'), $exclude_albums), false, true) . ' AND image_status <> ' . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED . ') OR ' . $this->db->sql_in_set('image_album_id', array_diff($this->gallery_auth->acl_album_ids('m_status'), $exclude_albums), false, true) . ')'; $sql_array['SELECT'] = 'COUNT(c.comment_id) as count'; @@ -364,17 +397,20 @@ public function recent_comments($limit, $start = 0) 'SEARCH_MATCHES' => $this->language->lang('TOTAL_COMMENTS_SPRINTF', $count), 'SEARCH_TITLE' => $this->language->lang('RECENT_COMMENTS'), )); - $this->pagination->generate_template_pagination(array( - 'routes' => array( - 'phpbbgallery_core_search_commented', - 'phpbbgallery_core_search_commented_page',), - 'params' => array()), 'pagination', 'page', $count, $limit, $start - ); + if ($pagination) + { + $this->pagination->generate_template_pagination(array( + 'routes' => array( + 'phpbbgallery_core_search_commented', + 'phpbbgallery_core_search_commented_page',), + 'params' => array()), 'pagination', 'page', $count, $limit, $start + ); + } } /** * Generate recent images and populate template - * @param (int) $limit How many imagese to query + * @param (int) $limit How many images to query * @param int $start * @param int $user * @param string $fields @@ -501,6 +537,8 @@ public function recent($limit, $start = 0, $user = 0, $fields = 'rrc_gindex_disp return; } + $id_ary = array_map('intval', $id_ary); + $sql_where = $this->db->sql_in_set('i.image_id', $id_ary); $sql_array = array( @@ -515,6 +553,7 @@ public function recent($limit, $start = 0, $user = 0, $fields = 'rrc_gindex_disp ), 'WHERE' => 'i.image_status <> ' . \phpbbgallery\core\block::STATUS_ORPHAN . ' AND ' . $sql_where, + 'WHERE' => 'i.image_status <> ' . (int) \phpbbgallery\core\block::STATUS_ORPHAN . ' AND ' . $sql_where, 'ORDER_BY' => $sql_order, ); $sql = $this->db->sql_build_query('SELECT', $sql_array); From 99bf913145c3e79739c6a691867fe472284997a2 Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 09:56:40 +0100 Subject: [PATCH 5/8] Refactor moderate switch --- core/controller/moderate.php | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/core/controller/moderate.php b/core/controller/moderate.php index 7b94a4d2..f7c1b15b 100644 --- a/core/controller/moderate.php +++ b/core/controller/moderate.php @@ -3,7 +3,7 @@ /** * * @package phpBB Gallery Core -* @copyright (c) 2014 nickvergessen +* @copyright (c) 2014 nickvergessen | 2025 Leinad4Mind * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -425,56 +425,51 @@ public function album_overview($album_id, $page) { if (confirm_box(true) || $moving_target) { + $message = ''; switch ($action) { case 'approve': $this->image->approve_images($actions_array, $album_id); $this->album->update_info($album_id); - $message = $this->language->lang('WAITING_APPROVED_IMAGE', count($actions_array)); - $this->url->meta_refresh(3, $back_link); - trigger_error($message); break; + case 'unapprove': $this->image->unapprove_images($actions_array, $album_id); $this->album->update_info($album_id); - $message = $this->language->lang('WAITING_UNAPPROVED_IMAGE', count($actions_array)); - $this->url->meta_refresh(3, $back_link); - trigger_error($message); break; + case 'lock': $this->image->lock_images($actions_array, $album_id); $this->album->update_info($album_id); - $message = $this->language->lang('WAITING_LOCKED_IMAGE', count($actions_array)); - $this->url->meta_refresh(3, $back_link); - trigger_error($message); break; + case 'delete': $this->moderate->delete_images($actions_array); $this->album->update_info($album_id); - $message = $this->language->lang('DELETED_IMAGES', count($actions_array)); - $this->url->meta_refresh(3, $back_link); - trigger_error($message); break; + case 'move': $this->image->move_image($actions_array, $moving_target); $this->album->update_info($album_id); $this->album->update_info($moving_target); - $message = $this->language->lang('MOVED_IMAGES', count($actions_array)); - $this->url->meta_refresh(3, $back_link); - trigger_error($message); break; + case 'report': $this->report->close_reports_by_image($actions_array); $message = $this->language->lang('WAITING_REPORTED_DONE', count($actions_array)); - $this->url->meta_refresh(3, $back_link); - trigger_error($message); break; } + + if (!empty($message)) + { + $this->url->meta_refresh(3, $back_link); + trigger_error($message); + } } else { From 5b3475c158630b49543aadd508c06542efcbb1cc Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 09:57:10 +0100 Subject: [PATCH 6/8] refactor assign_block with bitwise --- core/image/image.php | 55 ++++++++++---------------------------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/core/image/image.php b/core/image/image.php index 61cac549..31e34cfa 100644 --- a/core/image/image.php +++ b/core/image/image.php @@ -3,7 +3,7 @@ /** * * @package phpBB Gallery Core -* @copyright (c) 2014 nickvergessen +* @copyright (c) 2014 nickvergessen | Leinad4Mind 2025 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -613,50 +613,19 @@ public function get_last_image() return $row; } - public function assign_block($image_block_name, $image_data, $display_option = 0, $thumbanil_link = 'image_page', $imagename_link = 'image_page') + public function assign_block($image_block_name, $image_data, $display_option = 0, $thumbnail_link = 'image_page', $imagename_link = 'image_page') { // Now let's get display options - $show_ip = $show_ratings = $show_username = $show_views = $show_time = $show_imagename = $show_comments = $show_album = false; - if ($display_option >= self::IMAGE_SHOW_IP) - { - $show_ip = true; - $display_option = $display_option - self::IMAGE_SHOW_IP; - } - if ($display_option >= self::IMAGE_SHOW_RATINGS) - { - $show_ratings = true; - $display_option = $display_option - self::IMAGE_SHOW_RATINGS; - } - if ($display_option >= self::IMAGE_SHOW_USERNAME) - { - $show_username = true; - $display_option = $display_option - self::IMAGE_SHOW_USERNAME; - } - if ($display_option >= self::IMAGE_SHOW_VIEWS) - { - $show_views = true; - $display_option = $display_option - self::IMAGE_SHOW_VIEWS; - } - if ($display_option >= self::IMAGE_SHOW_TIME) - { - $show_time = true; - $display_option = $display_option - self::IMAGE_SHOW_TIME; - } - if ($display_option >= self::IMAGE_SHOW_IMAGENAME) - { - $show_imagename = true; - $display_option = $display_option - self::IMAGE_SHOW_IMAGENAME; - } - if ($display_option >= self::IMAGE_SHOW_COMMENTS) - { - $show_comments = true; - $display_option = $display_option - self::IMAGE_SHOW_COMMENTS; - } - if ($display_option == self::IMAGE_SHOW_ALBUM) - { - $show_album = true; - } - switch ($thumbanil_link) + $show_ip = ($display_option & self::IMAGE_SHOW_IP) !== 0; + $show_ratings = ($display_option & self::IMAGE_SHOW_RATINGS) !== 0; + $show_username = ($display_option & self::IMAGE_SHOW_USERNAME) !== 0; + $show_views = ($display_option & self::IMAGE_SHOW_VIEWS) !== 0; + $show_time = ($display_option & self::IMAGE_SHOW_TIME) !== 0; + $show_imagename = ($display_option & self::IMAGE_SHOW_IMAGENAME) !== 0; + $show_comments = ($display_option & self::IMAGE_SHOW_COMMENTS) !== 0; + $show_album = ($display_option & self::IMAGE_SHOW_ALBUM) !== 0; + + switch ($thumbnail_link) { case 'image_page': $action = $this->helper->route('phpbbgallery_core_image', array('image_id' => (int) $image_data['image_id'])); From 993334e9aa5bf45abfe2bcf47155c41e52b3eef4 Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 10:00:49 +0100 Subject: [PATCH 7/8] Update readme --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 83 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 72a11ea6..478862c5 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,11 @@ [![Tests](https://github.com/satanasov/phpbbgallery/actions/workflows/tests.yml/badge.svg)](https://github.com/satanasov/phpbbgallery/actions/workflows/tests.yml) [![Code Coverage](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/?branch=master) -© 2012 - [nickvergessen](http://www.flying-bits.org) +© 2008 - 2012 - [nickvergessen](https://web.archive.org/web/20131104154014/http://www.flying-bits.org/index.php) -© 2014 - 2022 - [Lucifer](http://www.anavaro.com) +© 2014 - 2025 - [Lucifer](https://www.anavaro.com) + +© 2019 - 2025 [Leinad4Mind](https://leinad4mind.top/forum) Welcome to phpBB Gallery version 3.3.x @@ -12,14 +14,14 @@ This is direct port of [nickvergessen](https://github.com/nickvergessen)'s phpBB This project will include only base core code and functioning add-ons which will expand this code. -##Donate -If you like my code - buy me a beer/coffee/license for PhpStorm :D +## Donate +If you like this extension or just like my code - buy me a beer/coffee/license for PhpStorm :D + +[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3JQ8HDK6Y7A2N) - BTC: 12afvCTp1dRrQdHaavzthZ1dNWMoi8eyc8 - ETH: 0x363abc8edf41ac89906b20e90cf7fdc71fe78cd5 -[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XQ6USSXCSUM5W) - ## Known Issues MSSQL is not ok. I don't have a MSSQL instance to test different functions. If you want to use with MSSQL - we can debug and do stuff. @@ -31,7 +33,7 @@ MSSQL is not ok. I don't have a MSSQL instance to test different functions. If y ### Exif -Allows saving and visualization of EXIF (Exchangeable image file format) image information. Basicly a bunch of stuff about the image - F-stop, ISO, appature, speed, usage of flash ... it could hold GPS coordinates ... +Allows saving and visualization of EXIF (Exchangeable image file format) image information. Basically a bunch of stuff about the image - F-stop, ISO, aperture, speed, usage of flash... it could hold GPS coordinates... ### ACP Import @@ -39,9 +41,77 @@ Allows bulk import of images. ### ACP cleanup -Bunch of functions related to DB and file system maintenence. Allows you to purge albums, move pictures, clean orphaned images, albums and comments ... - -## Adding a new feture? +Bunch of functions related to DB and file system maintenance. Allows you to purge albums, move pictures, clean orphaned images, albums and comments... + + +## Current features (grabbed from 1.1.6 - To be reviewed) + +### Configurations/Misc: + - Filetypes: gif, jpg, jpeg, png & webp (new) + - Imagesize: filesize, image-height, image-width + - Resize images on upload + - Global control about comment & rating system (dis-/enable) + - Thumbnails: GD-version, quality and size + - Images available in 3 sizes (thumbnail, medium, full) + - Several options to thumbnail-displaying album.php: number of rows & columns, options to display (username, rating, comments, upload-time...) + - RRC (recent-random-comment): display the recent images, random images and/or recent comments on the gallery/index.php with full ACP-Control + - Sub-folder name adjustable (default: gallery/) + - Search function (also available in the album) (page for Recent/Random/Top-Rated/Last comments/Own images) + - Available in more languages: Bulgarian, Dutch, French, German and Russian + - Available Addons: ACP Cleanup, ACP Import and EXIF + +### Integration in phpBB: + - Link to personal gallery on viewtopic (ACP-Option) + - Number of user-images on viewtopic (ACP-Option) + - Number of images on index (ACP-Option) + - Recent/Random images in user-profile (with full ACP-Control) + - BBcode to use gallery images in postings + - Available for prosilver styles + +### Album / Permission-management: + - Unlimited sub... subalbums depth + - Copy permissions on create/edit album + - Album-types: Category, album, contest (see later for more information) + - "Album locked"-Option + - Inherit function on setting permissions + - Group- & User-based permissions + - Image-permissions: view, view without watermark, upload, upload with approval, edit, delete, report, rate + - Comment-permissions: view, post, edit, delete + - Moderate-permissions: moderate comments, image: delete, edit, move, handle reports, approve/lock + - Misc-permissions: View album, Number of allowed images (also unlimited), albums (for personal galleries) + - Personal galleries (upload by owner only), with subalbums and management through UCP + +### Images / Comments: + - Hotlink prevention: also with whitelist + - Display exif-data + - Watermark: with min-width and min-height, to avoid little images from being fully covered + - Report function + - Upload more images at once (Number settable in the ACP) + - Full user-profile on comments + - BBCodes, Custom-BBCodes and Smilies on comments & image-description + - Notification (via notification only) on new images/comments/reports/approvals + - Option to favorite images + - Next/Previous link (with imagename and thumbnail) + - Unread-markup of albums with new images + +### ACP: + - Statistical overview + - Resync-Options for several dynamic values + - Reset rating for album + - Mass-Import (With Addon) + - CleanUp (With Addon): Ability to delete images/comments of deleted users (or set to anonymous/guest), and personal albums + +### Contests: + - First timeperiod: Upload only, ratings and comments are not allowed, upload-username is hidden + - Second timeperiod: No more upload, ratings are allowed, comments are not allowed, upload-username is hidden + - End of contest: No more upload and ratings, comments are allowed, upload-username is displayed + +### TODO + +Make plugins work again [Highslide JS](https://highslide.com/download.php), [Shadowbox](https://www.shadowbox-js.com/download.html) and [Lytebox](https://web.archive.org/web/20130430051404/http://lytebox.com) support (These scripts must be downloaded separately because of the license) or maybe remove and add new ones. +Points Ext. Compatibility (Addon) + +## Adding a new feature? If you can make me think of it as core function I will add it. Such function is going to be the contests, the plupload support and jQuery based visualization libraries. @@ -53,7 +123,7 @@ If you want to contribute to this project do it as you will any other project - ## Development roadmap? -As I said the 1.2 version will be primarly targeted as backword compatible with phpBB Gallery 1.1.6 MOD (DB will be the same but you will have to manualy move your images to the new location). +As I said the 1.2 version will be primarily targeted as backwards compatible with phpBB Gallery 1.1.6 MOD (DB will be the same but you will have to manually move your images to the new location). 3.2.x is providing phpBB 3.2 compatibility and some code optimization. When initial release is done I will start adding features. @@ -61,7 +131,7 @@ Version 3.3.x will be compatible to phpBB 3.3 and will have new features. ## Installation -This ext installs as evry other phpBB extension: +This ext installs as every other phpBB extension: - Clone the repo to ext folder OR download the zip file and copy phpbbgallery to your ext folder - Go to ACP -> Customise -> Manage extensions @@ -75,10 +145,4 @@ This is task that could not be automated. You will have to do some work. Just fo Regards, Stanislav Atanasov -P.S.: You can get more support here - [Forum](http://lab.anavaro.com/forum/viewforum.php?f=4) - -P.P.S: If you like this extension - you could alway donate: - -[![alt text](http://lab.anavaro.com/forum/images/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3JQ8HDK6Y7A2N) - -![alt text](http://www.xe.com/themes/xe/images/symbols/xbt.gif) 12afvCTp1dRrQdHaavzthZ1dNWMoi8eyc8 +P.S.: You can get more support here - [Forum](https://www.phpbb.com/customise/db/extension/phpbb_gallery/support) From 4a84931b272e731ce338a60852325b10f52d649b Mon Sep 17 00:00:00 2001 From: Leinad4Mind Date: Thu, 31 Jul 2025 10:02:11 +0100 Subject: [PATCH 8/8] Revert "Update readme" This reverts commit 993334e9aa5bf45abfe2bcf47155c41e52b3eef4. --- README.md | 102 ++++++++++-------------------------------------------- 1 file changed, 19 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 478862c5..72a11ea6 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,9 @@ [![Tests](https://github.com/satanasov/phpbbgallery/actions/workflows/tests.yml/badge.svg)](https://github.com/satanasov/phpbbgallery/actions/workflows/tests.yml) [![Code Coverage](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/satanasov/phpbbgallery/?branch=master) -© 2008 - 2012 - [nickvergessen](https://web.archive.org/web/20131104154014/http://www.flying-bits.org/index.php) +© 2012 - [nickvergessen](http://www.flying-bits.org) -© 2014 - 2025 - [Lucifer](https://www.anavaro.com) - -© 2019 - 2025 [Leinad4Mind](https://leinad4mind.top/forum) +© 2014 - 2022 - [Lucifer](http://www.anavaro.com) Welcome to phpBB Gallery version 3.3.x @@ -14,14 +12,14 @@ This is direct port of [nickvergessen](https://github.com/nickvergessen)'s phpBB This project will include only base core code and functioning add-ons which will expand this code. -## Donate -If you like this extension or just like my code - buy me a beer/coffee/license for PhpStorm :D - -[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3JQ8HDK6Y7A2N) +##Donate +If you like my code - buy me a beer/coffee/license for PhpStorm :D - BTC: 12afvCTp1dRrQdHaavzthZ1dNWMoi8eyc8 - ETH: 0x363abc8edf41ac89906b20e90cf7fdc71fe78cd5 +[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XQ6USSXCSUM5W) + ## Known Issues MSSQL is not ok. I don't have a MSSQL instance to test different functions. If you want to use with MSSQL - we can debug and do stuff. @@ -33,7 +31,7 @@ MSSQL is not ok. I don't have a MSSQL instance to test different functions. If y ### Exif -Allows saving and visualization of EXIF (Exchangeable image file format) image information. Basically a bunch of stuff about the image - F-stop, ISO, aperture, speed, usage of flash... it could hold GPS coordinates... +Allows saving and visualization of EXIF (Exchangeable image file format) image information. Basicly a bunch of stuff about the image - F-stop, ISO, appature, speed, usage of flash ... it could hold GPS coordinates ... ### ACP Import @@ -41,77 +39,9 @@ Allows bulk import of images. ### ACP cleanup -Bunch of functions related to DB and file system maintenance. Allows you to purge albums, move pictures, clean orphaned images, albums and comments... - - -## Current features (grabbed from 1.1.6 - To be reviewed) - -### Configurations/Misc: - - Filetypes: gif, jpg, jpeg, png & webp (new) - - Imagesize: filesize, image-height, image-width - - Resize images on upload - - Global control about comment & rating system (dis-/enable) - - Thumbnails: GD-version, quality and size - - Images available in 3 sizes (thumbnail, medium, full) - - Several options to thumbnail-displaying album.php: number of rows & columns, options to display (username, rating, comments, upload-time...) - - RRC (recent-random-comment): display the recent images, random images and/or recent comments on the gallery/index.php with full ACP-Control - - Sub-folder name adjustable (default: gallery/) - - Search function (also available in the album) (page for Recent/Random/Top-Rated/Last comments/Own images) - - Available in more languages: Bulgarian, Dutch, French, German and Russian - - Available Addons: ACP Cleanup, ACP Import and EXIF - -### Integration in phpBB: - - Link to personal gallery on viewtopic (ACP-Option) - - Number of user-images on viewtopic (ACP-Option) - - Number of images on index (ACP-Option) - - Recent/Random images in user-profile (with full ACP-Control) - - BBcode to use gallery images in postings - - Available for prosilver styles - -### Album / Permission-management: - - Unlimited sub... subalbums depth - - Copy permissions on create/edit album - - Album-types: Category, album, contest (see later for more information) - - "Album locked"-Option - - Inherit function on setting permissions - - Group- & User-based permissions - - Image-permissions: view, view without watermark, upload, upload with approval, edit, delete, report, rate - - Comment-permissions: view, post, edit, delete - - Moderate-permissions: moderate comments, image: delete, edit, move, handle reports, approve/lock - - Misc-permissions: View album, Number of allowed images (also unlimited), albums (for personal galleries) - - Personal galleries (upload by owner only), with subalbums and management through UCP - -### Images / Comments: - - Hotlink prevention: also with whitelist - - Display exif-data - - Watermark: with min-width and min-height, to avoid little images from being fully covered - - Report function - - Upload more images at once (Number settable in the ACP) - - Full user-profile on comments - - BBCodes, Custom-BBCodes and Smilies on comments & image-description - - Notification (via notification only) on new images/comments/reports/approvals - - Option to favorite images - - Next/Previous link (with imagename and thumbnail) - - Unread-markup of albums with new images - -### ACP: - - Statistical overview - - Resync-Options for several dynamic values - - Reset rating for album - - Mass-Import (With Addon) - - CleanUp (With Addon): Ability to delete images/comments of deleted users (or set to anonymous/guest), and personal albums - -### Contests: - - First timeperiod: Upload only, ratings and comments are not allowed, upload-username is hidden - - Second timeperiod: No more upload, ratings are allowed, comments are not allowed, upload-username is hidden - - End of contest: No more upload and ratings, comments are allowed, upload-username is displayed - -### TODO - -Make plugins work again [Highslide JS](https://highslide.com/download.php), [Shadowbox](https://www.shadowbox-js.com/download.html) and [Lytebox](https://web.archive.org/web/20130430051404/http://lytebox.com) support (These scripts must be downloaded separately because of the license) or maybe remove and add new ones. -Points Ext. Compatibility (Addon) - -## Adding a new feature? +Bunch of functions related to DB and file system maintenence. Allows you to purge albums, move pictures, clean orphaned images, albums and comments ... + +## Adding a new feture? If you can make me think of it as core function I will add it. Such function is going to be the contests, the plupload support and jQuery based visualization libraries. @@ -123,7 +53,7 @@ If you want to contribute to this project do it as you will any other project - ## Development roadmap? -As I said the 1.2 version will be primarily targeted as backwards compatible with phpBB Gallery 1.1.6 MOD (DB will be the same but you will have to manually move your images to the new location). +As I said the 1.2 version will be primarly targeted as backword compatible with phpBB Gallery 1.1.6 MOD (DB will be the same but you will have to manualy move your images to the new location). 3.2.x is providing phpBB 3.2 compatibility and some code optimization. When initial release is done I will start adding features. @@ -131,7 +61,7 @@ Version 3.3.x will be compatible to phpBB 3.3 and will have new features. ## Installation -This ext installs as every other phpBB extension: +This ext installs as evry other phpBB extension: - Clone the repo to ext folder OR download the zip file and copy phpbbgallery to your ext folder - Go to ACP -> Customise -> Manage extensions @@ -145,4 +75,10 @@ This is task that could not be automated. You will have to do some work. Just fo Regards, Stanislav Atanasov -P.S.: You can get more support here - [Forum](https://www.phpbb.com/customise/db/extension/phpbb_gallery/support) +P.S.: You can get more support here - [Forum](http://lab.anavaro.com/forum/viewforum.php?f=4) + +P.P.S: If you like this extension - you could alway donate: + +[![alt text](http://lab.anavaro.com/forum/images/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3JQ8HDK6Y7A2N) + +![alt text](http://www.xe.com/themes/xe/images/symbols/xbt.gif) 12afvCTp1dRrQdHaavzthZ1dNWMoi8eyc8