diff options
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/bbcode.php | 6 | ||||
| -rw-r--r-- | phpBB/includes/db/mysql.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/functions.php | 31 | ||||
| -rw-r--r-- | phpBB/includes/functions_admin.php | 10 | ||||
| -rw-r--r-- | phpBB/includes/functions_display.php | 5 | ||||
| -rw-r--r-- | phpBB/includes/functions_posting.php | 100 |
6 files changed, 142 insertions, 12 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 537199fb57..144dafbb30 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -40,15 +40,15 @@ class bbcode if ($bbcode_bitfield !== FALSE) { $this->bbcode_bitfield = $bbcode_bitfield; + // Init those added with a new bbcode_bitfield (already stored codes will not get parsed again) + $this->bbcode_cache_init(); } + if (!$this->bbcode_bitfield) { return $message; } - // Init those added with a new bbcode_bitfield (already stored codes will not get parsed again) - $this->bbcode_cache_init(); - $str = array('search' => array(), 'replace' => array()); $preg = array('search' => array(), 'replace' => array()); diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index ccaca5e884..8b08b33458 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -131,7 +131,7 @@ class sql_db if ($cache_ttl && method_exists($cache, 'sql_save')) { $cache->sql_save($query, $this->query_result, $cache_ttl); - @mysql_free_result($this->query_result); + // mysql_free_result happened within sql_save() } elseif (preg_match('/^SELECT/', $query)) { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 29b627bccc..9b399312c7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -117,6 +117,29 @@ function get_userdata($user) return ($row = $db->sql_fetchrow($result)) ? $row : false; } +// Create forum rules for given forum +function generate_forum_rules($forum_data) +{ + if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link']) + { + return; + } + + global $template, $phpbb_root_path, $phpEx; + + if ($forum_data['forum_rules']) + { + include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + $text_flags = explode(':', $forum_data['forum_rules_flags']); + } + + $template->assign_vars(array( + 'S_FORUM_RULES' => true, + 'U_FORUM_RULES' => $forum_data['forum_rules_link'], + 'FORUM_RULES' => (!$forum_data['forum_rules_link']) ? parse_text_display($forum_data['forum_rules'], $forum_data['forum_rules_flags']) : '') + ); +} + // Create forum navigation links for given forum, create parent // list if currently null, assign basic forum info to template function generate_forum_nav(&$forum_data) @@ -235,7 +258,7 @@ function get_moderators(&$forum_moderators, $forum_id = false) } // User authorisation levels output -function gen_forum_rules($mode, &$forum_id) +function gen_forum_auth_level($mode, &$forum_id) { global $SID, $template, $auth, $user; @@ -1098,6 +1121,7 @@ function login_box($s_action, $s_hidden_fields = '', $login_explain = '', $ucp_l } $s_hidden_fields .= ($ucp_login && !empty($_SERVER['HTTP_REFERER'])) ? '<input type="hidden" name="redirect" value="' . htmlspecialchars($_SERVER['HTTP_REFERER']) . '" />' : '<input type="hidden" name="redirect" value="' . $s_action . '" />'; + $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $SID . '" />'; $template->assign_vars(array( 'LOGIN_ERROR' => $err, @@ -1285,7 +1309,7 @@ function extension_allowed($forum_id, $extension) function msg_handler($errno, $msg_text, $errfile, $errline) { global $cache, $db, $auth, $template, $config, $user; - global $phpEx, $phpbb_root_path, $starttime, $display_header; + global $phpEx, $phpbb_root_path, $starttime, $display_header, $show_prev_info; switch ($errno) { @@ -1349,10 +1373,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); $display_header = (!isset($display_header)) ? false : (bool) $display_header; + $show_prev_info = (!isset($show_prev_info)) ? true : (bool) $show_prev_info; if (defined('IN_ADMIN')) { - adm_page_message($msg_title, $msg_text, $display_header); + adm_page_message($msg_title, $msg_text, $display_header, $show_prev_info); adm_page_footer(); } else diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 35f1dc2cc0..913962f566 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -779,12 +779,20 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, } else { + if (!sizeof($where_ids)) + { + return; + } $where_sql = 'WHERE ' . $mode{0} . ".$where_type IN (" . implode(', ', $where_ids) . ')'; $where_sql_and = $where_sql . "\n\tAND"; } } else { + if (!sizeof($where_ids)) + { + return; + } $where_sql = 'WHERE ' . $mode{0} . ".$where_type IN (" . implode(', ', $where_ids) . ')'; $where_sql_and = $where_sql . "\n\tAND"; } @@ -807,7 +815,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = FALSE, FROM ' .TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 WHERE t1.topic_moved_id = t2.topic_id AND t1.forum_id = t2.forum_id"; - $result = $db->sql_query($result); + $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 3bd9aba370..1932e2d2df 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -13,7 +13,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) { - global $config, $db, $template, $auth, $user, $phpEx, $SID, $forum_moderators; + global $config, $db, $template, $auth, $user, $phpEx, $SID, $forum_moderators, $phpbb_root_path; // Get posted/get info $mark_read = request_var('mark', ''); @@ -300,11 +300,10 @@ function display_forums($root_data = '', $display_moderators = TRUE) 'S_IS_CAT' => false, 'S_IS_LINK' => ($row['forum_type'] != FORUM_LINK) ? false : true, - 'FORUM_IMG' => $row['forum_image'], 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), 'FORUM_ID' => $row['forum_id'], - 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), + 'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $folder_alt . '" border="0" />' : $user->img($folder_image, $folder_alt), 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => $row['forum_desc'], $l_post_click_count => $post_click_count, diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4b2f2f2c71..00d521d412 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -101,7 +101,10 @@ function format_display(&$message, &$signature, $uid, $siguid, $enable_html, $en } // Second parse bbcode here - $bbcode->bbcode_second_pass($message, $uid); + if ($enable_bbcode) + { + $bbcode->bbcode_second_pass($message, $uid); + } // If we allow users to disable display of emoticons we'll need an appropriate // check and preg_replace here @@ -128,6 +131,101 @@ function format_display(&$message, &$signature, $uid, $siguid, $enable_html, $en return $message; } +// Three simple functions we use for bbcode/smilie/url capable text + +// prepare text to be inserted into db... +function parse_text_insert($text, $allow_bbcode, $allow_smilies, $allow_magic_url, &$text_flags) +{ + global $message_parser; + + $text_flags += ($allow_bbcode) ? 1 : 0; + $text_flags += ($allow_smilies) ? 2 : 0; + $text_flags += ($allow_magic_url) ? 4 : 0; + + $match = array('#\r\n?#', '#sid=[a-z0-9]*?&?#', "#([\n][\s]+){3,}#", '#&(\#[0-9]+;)#'); + $replace = array("\n", '', "\n\n", '&\1'); + $text = preg_replace($match, $replace, $text); + + // Parse BBCode + if (!method_exists('parse_message', 'parse_message') || !isset($message_parser)) + { + global $phpbb_root_path, $phpEx; + include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); + $message_parser = new parse_message(); + } + + $message_parser->message = $text; + + if ($allow_bbcode && strpos($text, '[') !== false) + { + $message_parser->bbcode_init(); + $message_parser->bbcode(); + } + + // Parse Emoticons + $message_parser->emoticons($allow_smilies); + + // Parse URL's + $message_parser->magic_url($allow_magic_url); + + $text_flags = $text_flags . ':' . $message_parser->bbcode_uid . ':' . $message_parser->bbcode_bitfield; + + return $message_parser->message; +} + +// prepare text to be displayed/previewed... +function parse_text_display($text, $text_rules) +{ + global $bbcode, $user; + + $text_flags = explode(':', $text_rules); + + $allow_bbcode = (int) $text_flags[0] & 1; + $allow_smilies = (int) $text_flags[0] & 2; + $allow_magic_url = (int) $text_flags[0] & 4; + + $bbcode_uid = trim($text_flags[1]); + $bbcode_bitfield = (int) $text_flags[2]; + + if (!$bbcode && $allow_bbcode) + { + global $phpbb_root_path, $phpEx; + + include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); + $bbcode = new bbcode(); + } + + // Second parse bbcode here + if ($allow_bbcode) + { + $bbcode->bbcode_second_pass($text, $bbcode_uid, $bbcode_bitfield); + } + + // If we allow users to disable display of emoticons we'll need an appropriate + // check and preg_replace here + if ($allow_smilies) + { + $text = smilie_text($text, !$allow_smilies); + } + + // Replace naughty words such as farty pants + $text = str_replace("\n", '<br />', censor_text($text)); + + return $text; +} + +// prepare text to be displayed within a form (fetched from db) +function parse_text_form_display($text, $text_rules) +{ + // We use decode_text here... + $text_rules = explode(':', $text_rules); + $bbcode_uid = trim($text_rules[1]); + + decode_text($text, $bbcode_uid); + + return $text; +} + // Update Last Post Informations function update_last_post_information($type, $id) { |
