|
From: FlorinCB <ory...@us...> - 2008-10-07 02:33:13
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb3 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13061 Modified Files: bbcode.php Log Message: fixed smilies bbcode Index: bbcode.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb3/bbcode.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bbcode.php 4 Oct 2008 07:04:25 -0000 1.1 --- bbcode.php 7 Oct 2008 02:30:31 -0000 1.2 *************** *** 40,43 **** --- 40,44 ---- var $smiley_path_url = ''; var $smiley_root_path = ''; + var $smilies_path = ''; var $smiley_url = 'smiley_url'; *************** *** 72,75 **** --- 73,78 ---- $this->smiley_root_path = $phpbb_root_path; //same here $board_config['smilies_path'] = str_replace("smiles", "smilies", $board_config['smilies_path']); + $this->smilies_path = str_replace("//", "/", $board_config['smilies_path']); + } *************** *** 86,90 **** 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) --- 89,93 ---- 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) *************** *** 884,888 **** // Remove the uid from tags that have not been transformed into HTML ! //$text = str_replace(':' . $uid, '', $text); // Remove our padding from the string.. --- 887,891 ---- // Remove the uid from tags that have not been transformed into HTML ! $text = str_replace(':' . $uid, '', $text); // Remove our padding from the string.. *************** *** 1388,1399 **** /** ! * phpBB Smilies pass. * - * Hacking smilies_pass from phpbb/includes/bbcode.php * * @param string $message * @return string * ! */ function smilies_pass($message) { --- 1391,1401 ---- /** ! * Smilies pass. * * * @param string $message * @return string * ! */ function smilies_pass($message) { *************** *** 1411,1435 **** mx_message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql); } ! ! $smilies = $db->sql_fetchrowset($result); ! ! if (count($smilies)) { ! @usort($smilies, 'smiley_sort'); } ! for ($i = 0; $i < count($smilies); $i++) { ! $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; ! $repl[] = '<img src="' . $this->smiley_path_url . $board_config['smilies_path'] . '/' . $smilies[$i][$this->smiley_url] . '" alt="' . $smilies[$i][$this->emotion] . '" border="0" />'; ! } ! } ! if (count($orig)) ! { ! $message = preg_replace($orig, $repl, ' ' . $message . ' '); ! $message = substr($message, 1, -1); } return $message; } --- 1413,1452 ---- mx_message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql); } ! ! while ($row = $db->sql_fetchrow($result)) { ! if (empty($row['code'])) ! { ! continue; ! } ! ! // (assertion) ! $match[] = '(?<=^|[\n .])' . preg_quote($row['code'], '#') . '(?![^<>]*>)'; ! $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILIES_PATH}/' . $row['smiley_url'] . '" alt="' . $row['code'] . '" title="' . $row['emotion'] . '" /><!-- s' . $row['code'] . ' -->'; } + $db->sql_freeresult($result); ! if (sizeof($match)) { ! if ($max_smilies) ! { ! $num_matches = preg_match_all('#' . implode('|', $match) . '#', $message, $matches); ! unset($matches); ! if ($num_matches !== false && $num_matches > $max_smilies) ! { ! $this->warn_msg[] = sprintf($mx_user->lang['TOO_MANY_SMILIES'], $max_smilies); ! return; ! } ! } ! ! // Make sure the delimiter # is added in front and at the end of every element within $match ! $message = trim(preg_replace(explode(chr(0), '#' . implode('#' . chr(0) . '#', $match) . '#'), $replace, $message)); ! } } + $message = str_replace("{SMILIES_PATH}", $this->smiley_path_url . $this->smilies_path . '/' . $smilies[$i][$this->smiley_url], ' ' . $message . ' '); + $message = substr($message, 1, -1); + return $message; } *************** *** 1652,1693 **** } - /* - $result = $db->sql_query($sql, 3600); - - $smilies = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (empty($smilies[$row['smiley_url']])) - { - $smilies[$row['smiley_url']] = $row; - } - } - $db->sql_freeresult($result); - - if (sizeof($smilies)) - { - foreach ($smilies as $row) - { - $template->assign_block_vars('smiley', array( - 'SMILEY_CODE' => $row['code'], - 'A_SMILEY_CODE' => addslashes($row['code']), - 'SMILEY_IMG' => $this->smiley_root_path . $board_config['smilies_path'] . '/' . $row['smiley_url'], - 'SMILEY_WIDTH' => $row['smiley_width'], - 'SMILEY_HEIGHT' => $row['smiley_height'], - 'SMILEY_DESC' => $row['emotion']) - ); - } - } - - //What we do here with forum_id versus page_id ? - if ($mode == 'inline' && $display_link) - { - $template->assign_vars(array( - 'S_SHOW_SMILEY_LINK' => true, - 'U_MORE_SMILIES' => mx3_append_sid(PHPBB_URL . "posting.$phpEx", 'mode=smilies&f=' . $forum_id)) - ); - } - */ - if ($mode == 'window') { --- 1669,1672 ---- |