diff --git a/includes/functions.php b/includes/functions.php index 8322d1cd..6b6f8f14 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -70,32 +70,24 @@ function set_portal_config($config_name, $config_value) } /** -* Get portal modules -*/ + * Get portal modules + */ function obtain_portal_modules() { - global $db, $cache, $portal_modules; + global $db; - if (($portal_modules = $cache->get('portal_modules')) === false || defined('DEBUG')) + $portal_modules = array(); + + $sql = 'SELECT * + FROM ' . PORTAL_MODULES_TABLE . ' + ORDER BY module_order ASC'; + $result = $db->sql_query($sql, 3600); + + while ($row = $db->sql_fetchrow($result)) { - $portal_modules = $portal_cached_modules = array(); - - $sql = 'SELECT * - FROM ' . PORTAL_MODULES_TABLE . ' - ORDER BY module_order ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $portal_cached_modules[] = $row; - - $portal_modules[] = $row; - } - $db->sql_freeresult($result); - - $cache->put('portal_modules', $portal_cached_modules); + $portal_modules[] = $row; } - + $db->sql_freeresult($result); return $portal_modules; } diff --git a/modules/announcements.php b/modules/announcements.php index 60c19b88..d80f4c05 100644 --- a/modules/announcements.php +++ b/modules/announcements.php @@ -225,7 +225,7 @@ class announcements extends module_base AND topic_moved_id = 0 ' . $post_time . ' ' . $str_where; - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 300); $total_announcements = (int) $this->db->sql_fetchfield('num_topics'); $this->db->sql_freeresult($result); } diff --git a/modules/attachments.php b/modules/attachments.php index cc0ca551..45614527 100644 --- a/modules/attachments.php +++ b/modules/attachments.php @@ -53,10 +53,10 @@ class attachments extends module_base /** @var \phpbb\request\request */ protected $request; - /** @var \phpbb\template */ + /** @var \phpbb\template\template */ protected $template; - /** @var \phpbb\db\driver */ + /** @var \phpbb\db\driver\driver_interface */ protected $db; /** @var string PHP file extension */ @@ -74,8 +74,8 @@ class attachments extends module_base * @param \phpbb\auth\auth $auth phpBB auth service * @param \phpbb\config\config $config phpBB config * @param \board3\portal\includes\modules_helper $helper Modules helper - * @param \phpbb\template $template phpBB template - * @param \phpbb\db\driver $db Database driver + * @param \phpbb\template\template $template phpBB template + * @param \phpbb\db\driver\driver_interface $db Database driver * @param \phpbb\request\request $request phpBB request * @param string $phpEx php file extension * @param string $phpbb_root_path phpBB root path @@ -281,7 +281,7 @@ class attachments extends module_base ' . $where . ' ORDER BY filetime ' . ((!$this->config['display_order']) ? 'DESC' : 'ASC') . ', post_msg_id ASC'; - $result = $this->db->sql_query_limit($sql, $this->config['board3_attachments_number_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_attachments_number_' . $module_id], 0, 600); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/modules/birthday_list.php b/modules/birthday_list.php index f3c174ab..3df8512e 100644 --- a/modules/birthday_list.php +++ b/modules/birthday_list.php @@ -119,7 +119,7 @@ class birthday_list extends module_base 'ORDER BY' => $order_by, ); $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 3600); $today = sprintf('%2d-%2d-', $now['mday'], $now['mon']); while ($row = $this->db->sql_fetchrow($result)) diff --git a/modules/latest_bots.php b/modules/latest_bots.php index a48d0094..1188a097 100644 --- a/modules/latest_bots.php +++ b/modules/latest_bots.php @@ -49,10 +49,10 @@ class latest_bots extends module_base /** @var \phpbb\config\config */ protected $config; - /** @var \phpbb\db\driver */ + /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\template */ + /** @var \phpbb\template\template */ protected $template; /** @var \phpbb\user */ @@ -62,8 +62,8 @@ class latest_bots extends module_base * Construct a latest bots object * * @param \phpbb\config\config $config phpBB config - * @param \phpbb\db\driver $db phpBB db driver - * @param \phpbb\template $template phpBB template + * @param \phpbb\db\driver\driver_interface $db phpBB db driver + * @param \phpbb\template\template $template phpBB template * @param \phpbb\user $user phpBB user object */ public function __construct($config, $db, $template, $user) @@ -85,7 +85,7 @@ class latest_bots extends module_base WHERE user_type = ' . USER_IGNORE . ' AND user_lastvisit > 0 ORDER BY user_lastvisit DESC'; - $result = $this->db->sql_query_limit($sql, $this->config['board3_last_visited_bots_number_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_last_visited_bots_number_' . $module_id], 0, 600); $show_module = false; diff --git a/modules/latest_members.php b/modules/latest_members.php index 8dc37de9..e391d144 100644 --- a/modules/latest_members.php +++ b/modules/latest_members.php @@ -44,10 +44,10 @@ class latest_members extends module_base /** @var \phpbb\config\config */ protected $config; - /** @var \phpbb\db\driver */ + /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\template */ + /** @var \phpbb\template\template */ protected $template; /** @var \phpbb\user */ @@ -57,8 +57,8 @@ class latest_members extends module_base * Construct a latest_members object * * @param \phpbb\config\config $config phpBB config - * @param \phpbb\db\driver $db phpBB db driver - * @param \phpbb\template $template phpBB template + * @param \phpbb\db\driver\driver_interface $db phpBB db driver + * @param \phpbb\template\template $template phpBB template * @param \phpbb\user $user phpBB user object */ public function __construct($config, $db, $template, $user) @@ -79,7 +79,7 @@ class latest_members extends module_base WHERE user_type <> ' . USER_IGNORE . ' AND user_inactive_time = 0 ORDER BY user_regdate DESC'; - $result = $this->db->sql_query_limit($sql, $this->config['board3_max_last_member_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_max_last_member_' . $module_id], 0, 600); while(($row = $this->db->sql_fetchrow($result)) && ($row['username'])) { diff --git a/modules/leaders.php b/modules/leaders.php index 5d43676c..ad2e2895 100644 --- a/modules/leaders.php +++ b/modules/leaders.php @@ -118,7 +118,7 @@ class leaders extends module_base AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $this->user->data['user_id'] . ') ORDER BY g.group_name ASC'; } - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 600); while ($row = $this->db->sql_fetchrow($result)) { @@ -144,7 +144,7 @@ class leaders extends module_base ug.user_id = u.user_id AND '. $this->db->sql_in_set('ug.group_id', $legends) . ' ORDER BY u.username_clean ASC'; - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 600); while ($row = $this->db->sql_fetchrow($result)) { @@ -201,7 +201,7 @@ class leaders extends module_base 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC' )); - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 600); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/modules/news.php b/modules/news.php index c73a2bba..fa5c15d8 100644 --- a/modules/news.php +++ b/modules/news.php @@ -218,7 +218,7 @@ class news extends module_base AND topic_visibility = ' . ITEM_APPROVED . ' AND topic_moved_id = 0 ' . $str_where; - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 300); $total_news = (int) $this->db->sql_fetchfield('num_topics'); $this->db->sql_freeresult($result); } diff --git a/modules/recent.php b/modules/recent.php index 300da3a0..905853a1 100644 --- a/modules/recent.php +++ b/modules/recent.php @@ -121,7 +121,7 @@ class recent extends module_base $forum_sql = ' AND ' . $this->db->sql_in_set('t.forum_id', $forum_ary, true); } - $result = $this->db->sql_query_limit($sql, 1); + $result = $this->db->sql_query_limit($sql, 1, 0, 600); $g_forum_id = (int) $this->db->sql_fetchfield('forum_id'); $this->db->sql_freeresult($result); @@ -134,9 +134,9 @@ class recent extends module_base AND topic_visibility = ' . ITEM_APPROVED . ' AND (topic_type = ' . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ') AND topic_moved_id = 0 - ' . $sql_where . '' . $forum_sql . ' + ' . $sql_where . $forum_sql . ' ORDER BY topic_time DESC'; - $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0 , 600); while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) { @@ -160,9 +160,9 @@ class recent extends module_base WHERE topic_visibility = ' . ITEM_APPROVED . ' AND topic_posts_approved >' . $this->config['hot_threshold'] . ' AND topic_moved_id = 0 - ' . $sql_where . '' . $forum_sql . ' + ' . $sql_where . $forum_sql . ' ORDER BY topic_time DESC'; - $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 600); while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) { @@ -187,9 +187,9 @@ class recent extends module_base AND topic_visibility = ' . ITEM_APPROVED . ' AND topic_type = ' . POST_NORMAL . ' AND topic_moved_id = 0 - ' . $sql_where . '' . $forum_sql . ' + ' . $sql_where . $forum_sql . ' ORDER BY topic_time DESC'; - $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 600); while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) { diff --git a/modules/stylechanger.php b/modules/stylechanger.php index 637199f6..ae9a7fb7 100644 --- a/modules/stylechanger.php +++ b/modules/stylechanger.php @@ -90,7 +90,7 @@ class stylechanger extends module_base FROM ' . STYLES_TABLE . ' WHERE style_active = 1 ORDER BY LOWER(style_name) ASC'; - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 3600); while ($row = $this->db->sql_fetchrow($result)) { $style = $this->request->variable('style', 0); @@ -113,7 +113,7 @@ class stylechanger extends module_base // Assign specific vars $this->template->assign_vars(array( - 'S_STYLE_OPTIONS' => ($this->config['override_user_style'] || $style_count < 2) ? '' : style_select($this->user->data['user_style']), + 'S_STYLE_OPTIONS' => ($this->config['override_user_style'] || $style_count < 2) ? '' : $style_select, )); return 'stylechanger_side.html'; diff --git a/modules/topposters.php b/modules/topposters.php index 66305e6f..669d7fd0 100644 --- a/modules/topposters.php +++ b/modules/topposters.php @@ -44,10 +44,10 @@ class topposters extends module_base /** @var \phpbb\config\config */ protected $config; - /** @var \phpbb\db\driver */ + /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\template */ + /** @var \phpbb\template\template */ protected $template; /** @var string PHP file extension */ @@ -60,8 +60,8 @@ class topposters extends module_base * Construct a topposers object * * @param \phpbb\config\config $config phpBB config - * @param \phpbb\db\driver $db phpBB db driver - * @param \phpbb\template $template phpBB template + * @param \phpbb\db\driver\driver_interface $db phpBB db driver + * @param \phpbb\template\template $template phpBB template * @param string $phpbb_root_path phpBB root path * @param string $phpEx php file extension */ @@ -85,7 +85,7 @@ class topposters extends module_base AND user_posts <> 0 AND username <> '' ORDER BY user_posts DESC"; - $result = $this->db->sql_query_limit($sql, $this->config['board3_topposters_' . $module_id]); + $result = $this->db->sql_query_limit($sql, $this->config['board3_topposters_' . $module_id], 0, 600); while (($row = $this->db->sql_fetchrow($result))) { diff --git a/modules/user_menu.php b/modules/user_menu.php index b29c0161..f40c77ed 100644 --- a/modules/user_menu.php +++ b/modules/user_menu.php @@ -125,13 +125,13 @@ class user_menu extends module_base $m_approve_fid_sql = ' AND p.post_visibility = 1'; } - $sql = 'SELECT COUNT(distinct t.topic_id) as total + $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total FROM ' . TOPICS_TABLE . ' t WHERE t.topic_last_post_time > ' . $this->user->data['user_lastvisit'] . ' AND t.topic_moved_id = 0 ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 600); $new_posts_count = (int) $this->db->sql_fetchfield('total'); $this->db->sql_freeresult($result); diff --git a/portal/fetch_posts.php b/portal/fetch_posts.php index cc7b8a24..fd22bbf9 100644 --- a/portal/fetch_posts.php +++ b/portal/fetch_posts.php @@ -19,7 +19,7 @@ class fetch_posts /** * phpBB cache - * @var \phpbb\cache\driver + * @var \phpbb\cache\driver\driver_interface */ protected $cache; @@ -31,7 +31,7 @@ class fetch_posts /** * phpBB db driver - * @var \phpbb\db\driver_interface + * @var \phpbb\db\driver\driver_interface */ protected $db; @@ -263,13 +263,14 @@ class fetch_posts $sql_array['SELECT'] .= ', tp.topic_posted'; $sql = $this->db->sql_build_query('SELECT', $sql_array); + // Cache queries for 10 minutes if ($number_of_posts != 0) { - $result = $this->db->sql_query_limit($sql, $number_of_posts, $start); + $result = $this->db->sql_query_limit($sql, $number_of_posts, $start, 600); } else { - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query($sql, 600); } return $result;