From 2fa463cdeb5d8e4f2373aa834154ca27ea21c97a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 16 Sep 2004 18:33:22 +0000 Subject: - more updates, mostly bugfixes to the bbcode parser - changed current_user in sessions (please review) - give more flexibility to style authors in regard to the pagination elements - profile fields updates (included a sample constuct into viewtopic_body.html - have to be documented extensivly) - code optimizations (use of strpos, sizeof, loops not iterating functions on every call, memory savings...) - and last but not least --- hopefully not introduced more bugs than healthy (*cough*) git-svn-id: file:///svn/phpbb/trunk@4984 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 69 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 33dd4f2295..6589f804bd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -118,7 +118,7 @@ function get_userdata($user) } // Create forum rules for given forum -function generate_forum_rules($forum_data) +function generate_forum_rules(&$forum_data) { if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link']) { @@ -750,7 +750,8 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) // Pagination routine, generates page number sequence -function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE) +// tpl_prefix is for using different pagination blocks at one page +function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = true, $tpl_prefix = '') { global $template, $user; @@ -765,7 +766,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add $on_page = floor($start_item / $per_page) + 1; - $page_string = ($on_page == 1) ? '1' : '' . $user->lang['PREVIOUS'] . '  1'; + $page_string = ($on_page == 1) ? '1' : '1'; if ($total_pages > 5) { @@ -799,13 +800,17 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add } } - $page_string .= ($on_page == $total_pages) ? '' . $total_pages . '' : '' . $total_pages . '  ' . $user->lang['NEXT'] . ''; - + $page_string .= ($on_page == $total_pages) ? '' . $total_pages . '' : '' . $total_pages . ''; // $page_string = $user->lang['GOTO_PAGE'] . ' ' . $page_string; - $page_string = '' . $user->lang['GOTO_PAGE'] . ' ' . $page_string; +// $page_string = '' . $user->lang['GOTO_PAGE'] . ' ' . $page_string; - $template->assign_var('BASE_URL', $base_url); - $template->assign_var('PER_PAGE', $per_page); + $template->assign_vars(array( + $tpl_prefix . 'BASE_URL' => $base_url, + $tpl_prefix . 'PER_PAGE' => $per_page, + + $tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . '&start=' . (($on_page - 2) * $per_page), + $tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . '&start=' . ($on_page * $per_page)) + ); return $page_string; } @@ -1005,7 +1010,7 @@ function redirect($url) $url = str_replace('&', '&', $url); // Local redirect? If not, prepend the boards url - $url = (!strstr($url, '://')) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url; + $url = (strpos($url, '://') === false) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url; // Redirect via an HTML form for PITA webservers if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE'))) @@ -1165,7 +1170,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'U_PRIVACY' => "{$phpbb_root_path}ucp.$phpEx$SID&mode=privacy", 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_LOGIN_ACTION' => $redirect_page, + 'S_LOGIN_ACTION' => (!$admin) ? "{$phpbb_root_path}ucp.$phpEx$SID&mode=login" : "index.$phpEx$SID", 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); @@ -1303,6 +1308,38 @@ function smilie_text($text, $force_option = false) return ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) ? preg_replace('#PHP Notice: in file $errfile on line $errline: $msg_text
"; @@ -1430,6 +1468,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit; break; +/* remove me default: if (defined('DEBUG_EXTRA')) { @@ -1438,7 +1477,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo "Another Error: in file $errfile on line $errline: $msg_text
"; } } - break; + break;*/ } } @@ -1732,21 +1771,23 @@ function page_footer() $db->sql_report('display'); } - $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime); + $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime); - if ($auth->acl_get('a_')) + if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) { if (function_exists('memory_get_usage')) { if ($memory_usage = memory_get_usage()) { + global $base_memory_usage; + $memory_usage -= $base_memory_usage; $memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']); $debug_output .= ' | Memory Usage: ' . $memory_usage; } } - $debug_output .= ' | Explain'; + $debug_output .= ' | Explain'; } } -- cgit v1.2.1