|
From: Paul S. O. <ps...@us...> - 2002-07-14 14:41:15
|
Update of /cvsroot/phpbb/phpBB2/includes
In directory usw-pr-cvs1:/tmp/cvs-serv14027/includes
Modified Files:
bbcode.php
Log Message:
Various updates and alterations
Index: bbcode.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/includes/bbcode.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** bbcode.php 10 Jun 2002 01:52:16 -0000 1.39
--- bbcode.php 14 Jul 2002 14:41:12 -0000 1.40
***************
*** 22,29 ****
if ( !defined('IN_PHPBB') )
{
! die("Hacking attempt");
}
! define("BBCODE_UID_LEN", 10);
// global that holds loaded-and-prepared bbcode templates, so we only have to do
--- 22,29 ----
if ( !defined('IN_PHPBB') )
{
! die('Hacking attempt');
}
! define('BBCODE_UID_LEN', 10);
// global that holds loaded-and-prepared bbcode templates, so we only have to do
***************
*** 44,48 ****
{
global $template;
! $tpl_filename = $template->make_filename('bbcode.tpl');
$tpl = fread(fopen($tpl_filename, 'r'), filesize($tpl_filename));
--- 44,48 ----
{
global $template;
! $tpl_filename = $template->make_filename('bbcode.html');
$tpl = fread(fopen($tpl_filename, 'r'), filesize($tpl_filename));
***************
*** 110,114 ****
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
! define("BBCODE_TPL_READY", true);
return $bbcode_tpl;
--- 110,114 ----
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
! define('BBCODE_TPL_READY', true);
return $bbcode_tpl;
***************
*** 121,134 ****
* correct UID as used in first-pass encoding.
*/
! function bbencode_second_pass($text, $uid)
{
! global $lang, $bbcode_tpl;
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
! $text = " " . $text;
// First: If there isn't a "[" and a "]" in the message, don't bother.
! if (! (strpos($text, "[") && strpos($text, "]")) )
{
// Remove padding, return.
--- 121,134 ----
* correct UID as used in first-pass encoding.
*/
! function bbencode_second_pass($text, $uid, $enable_img = true)
{
! global $acl, $board_config, $lang, $bbcode_tpl;
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
! $text = ' ' . $text;
// First: If there isn't a "[" and a "]" in the message, don't bother.
! if (! (strpos($text, '[') && strpos($text, ']')) )
{
// Remove padding, return.
***************
*** 138,142 ****
// Only load the templates ONCE..
! if (!defined("BBCODE_TPL_READY"))
{
// load templates from file into array.
--- 138,142 ----
// Only load the templates ONCE..
! if (!defined('BBCODE_TPL_READY'))
{
// load templates from file into array.
***************
*** 195,200 ****
// [img]image_url_here[/img] code..
// This one gets first-passed..
! $patterns[0] = "#\[img:$uid\](.*?)\[/img:$uid\]#si";
! $replacements[0] = $bbcode_tpl['img'];
// [url]xxxx://www.phpbb.com[/url] code..
--- 195,203 ----
// [img]image_url_here[/img] code..
// This one gets first-passed..
! if ( $enable_img )
! {
! $patterns[0] = "#\[img:$uid\](.*?)\[/img:$uid\]#si";
! $replacements[0] = $bbcode_tpl['img'];
! }
// [url]xxxx://www.phpbb.com[/url] code..
***************
*** 227,237 ****
} // bbencode_second_pass()
- // Need to initialize the random numbers only ONCE
- mt_srand( (double) microtime() * 1000000);
function make_bbcode_uid()
{
! // Unique ID for this message..
$uid = md5(mt_rand());
$uid = substr($uid, 0, BBCODE_UID_LEN);
--- 230,240 ----
} // bbencode_second_pass()
function make_bbcode_uid()
{
! // Need to initialize the random numbers only ONCE
! mt_srand( (double) microtime() * 1000000);
+ // Unique ID for this message..
$uid = md5(mt_rand());
$uid = substr($uid, 0, BBCODE_UID_LEN);
***************
*** 244,248 ****
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
! $text = " " . $text;
// [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
--- 247,251 ----
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
! $text = ' ' . $text;
// [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
***************
*** 256,269 ****
// [list] and [list=x] for (un)ordered lists.
$open_tag = array();
! $open_tag[0] = "[list]";
// unordered..
! $text = bbencode_first_pass_pda($text, $uid, $open_tag, "[/list]", "[/list:u]", false, 'replace_listitems');
! $open_tag[0] = "[list=1]";
! $open_tag[1] = "[list=a]";
// ordered.
! $text = bbencode_first_pass_pda($text, $uid, $open_tag, "[/list]", "[/list:o]", false, 'replace_listitems');
// [color] and [/color] for setting text color
--- 259,272 ----
// [list] and [list=x] for (un)ordered lists.
$open_tag = array();
! $open_tag[0] = '[list]';
// unordered..
! $text = bbencode_first_pass_pda($text, $uid, $open_tag, '[/list]', '[/list:u]', false, 'replace_listitems');
! $open_tag[0] = '[list=1]';
! $open_tag[1] = '[list=a]';
// ordered.
! $text = bbencode_first_pass_pda($text, $uid, $open_tag, '[/list]', '[/list:o]', false, 'replace_listitems');
// [color] and [/color] for setting text color
***************
*** 288,292 ****
$text = substr($text, 1);
-
return $text;
--- 291,294 ----
***************
*** 742,770 ****
static $smilies;
! if( empty($smilies) )
{
$sql = "SELECT code, smile_url
FROM " . SMILIES_TABLE;
! if( !$result = $db->sql_query($sql) )
! {
! message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
! }
! if( !$db->sql_numrows($result) )
{
return $message;
}
! $smilies = $db->sql_fetchrowset($result);
}
- usort($smilies, 'smiley_sort');
for($i = 0; $i < count($smilies); $i++)
{
! $orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W$)/";
! $repl[] = '<img src="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />';
}
! if( $i > 0 )
{
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
--- 744,768 ----
static $smilies;
! if ( empty($smilies) )
{
$sql = "SELECT code, smile_url
FROM " . SMILIES_TABLE;
! $result = $db->sql_query($sql);
! if ( !($smilies = $db->sql_fetchrowset($result)) )
{
return $message;
}
! 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="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" width="' . $smilies[$i]['smile_width'] . '" height="' . $smilies[$i]['smile_height'] . '" alt="' . $smilies[$i]['smile_url'] . '" title="' . $smilies[$i]['smile_url'] . '" border="0" />';
}
! if ( $i > 0 )
{
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
***************
*** 782,788 ****
}
! return ( strlen($a['code']) > strlen($b['code']) ) ? -1 : 1;
}
!
! ?>
--- 780,785 ----
}
! return ( strlen($a['code']) > strlen($b['code']) ) ? - 1 : 1;
}
! ?>
\ No newline at end of file
|