Yep, but now they're both working. I think it mightve been another mod I had installed.Ger wrote:I don't have any experience with the automod, so I don't have a clue what could be wrong... Can you please post line 30-70 of includes/message_parser.php for me? Perhaps then I can see what's wrong.
(I have the redirect-mod installed myself, it shouldn't have anything to do with it)
Code: Select all
{
var $message = '';
var $warn_msg = array();
var $parsed_items = array();
/**
* Parse BBCode
*/
function parse_bbcode()
{
//Start MOD Convert quoted images to url
preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch );
foreach ($qmatch[2]as $qmatchin){
$qres = preg_replace('#\[url=(.*(jpg|jpeg|gif|png|bmp))\]\[img\].*\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
$qres = preg_replace('#\[url=.*\]\[img\](.*)\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
$qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
$this->message = str_replace($qmatchin, $qres, $this->message);
}
//End MOD Convert quoted images to url
if (!$this->bbcodes)
{
$this->bbcode_init();
}
global $user;
$this->bbcode_bitfield = '';
$bitfield = new bitfield();
foreach ($this->bbcodes as $bbcode_name => $bbcode_data)
{
if (isset($bbcode_data['disabled']) && $bbcode_data['disabled'])
{
foreach ($bbcode_data['regexp'] as $regexp => $replacement)
{
if (preg_match($regexp, $this->message))
{
$this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']');
continue;
Thank you very much, it works and I've learnt something newGer wrote:With the $2 backreference you get the second sample pattern (within ( and ) ).
yep.Ger wrote:So it's working now?
Glad I could help.paciuli wrote:Thank you very much, it works and I've learnt something new
Great.spoda-b.com wrote:yep.Ger wrote:So it's working now?
Source: http://www.phpbb.com/community/viewtopi ... 5#p7627405Ger wrote:Having errors? Read this...
Some users (not all, for a strange reason) encouter an error as reported below by Eragon. Also, I found a small bug when using nested quote-code-img-tags. A solution to both of this is to undo the steps of the MOD and do:
OPEN
./includes/message_parser.php
FINDADD AFTERCode: Select all
/** * Parse BBCode */ function parse_bbcode() { if (!$this->bbcodes) { $this->bbcode_init(); } global $user;
Save, close, upload file.Code: Select all
//Start MOD Convert quoted images to url preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch ); foreach ($qmatch[2]as $qmatchin){ preg_match_all('#\[code\](.*?)\[/code\]#is', $qmatchin, $qcode); $crepl = str_replace('[img]', '[img]', $qcode[1]); $replacement = str_replace($qcode[1], $crepl, $qmatchin); $replacement = preg_replace('#\[url=\n*(.*(jpg|jpeg|gif|png|bmp))\n*\]\n*\[img\]\n*(.*)\n*\[/img\]\n*\[/url\]#iU', '[ [url=$1]'. $user->lang['IMAGE'] .'[/url] ]', $replacement); $replacement = preg_replace('#\[url=\n*(.*)\n*\]\n*\[img\]\n*(.*)\n*\[/img\]\n*\[/url\]#iU', '[ [url=$1]'. $user->lang['IMAGE'] .'[/url] ]', $replacement); $replacement = preg_replace('#\[img\]\n*(.*)\n*\[/img\]#iU', '[ [url=$1]'. $user->lang['IMAGE'] .'[/url] ]', $replacement); $this->message = str_replace($qmatchin, $replacement, $this->message); $this->message = str_replace($$crepl, $qcode[1], $this->message); } //End MOD Convert quoted images to url
When you're still encoutering some errors after this, just post a message in this topic and I'll happily support you.
(please do not PM me for support)
Code: Select all
$this->message = str_replace($$crepl, $qcode[1], $this->message);
Code: Select all
$this->message = str_replace($crepl, $qcode[1], $this->message);
Confirmed this doesnt work. Tried it wit alot of diffrent bbcodes, incl. the standard youtube. No go with either of them.DragonMaster1 wrote:Does not work for meRupertGee wrote:This is a great mod; images in quotes are so annoying.
My board also lets users post YouTube video. That means the video gets quoted too! Argh! So I modded this mod to take care of YouTube too, converting the embedded video player to a text link when quoted. It's my first mod-of-mod....
Look for:Add after:Code: Select all
$qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
My board supports English only and so I hardcorded the text link; you'll want to change that to language specific text for your multi-lingual board.Code: Select all
$replacement = preg_replace('#\[youtube\]\n*(.*)\n*\[/youtube\]#iU', '[url=$1]Writer posted a YouTube video[/url]', $replacement); // RupertGee Addition
Well, that's easyer said then done. Custom BBcodes have the annoying property to be custom. Therefore, I can't predict what the BBcode contains and what to replace. Removing is very easy, but in general I don't expect that you want to remove parts of the post content. But here's a general guide to remove a BBcode:DoYouSpeakWak wrote:To Ger
This is really helpfull, but mostly on plain boards with no extra bbcodes added. Boards today have more and more bbcodes for all kind of stuff. If you somehow could make a guide how to remove or replace custom bbcodes in qoutes it would really enhance the usage of this mod and im pretty sure most people after they insalll this mod will think."How can i add more bbcodes to this"
I hope for somone to post the perfect solution for this.
Code: Select all
/**
* Parse BBCode
*/
function parse_bbcode()
{
if (!$this->bbcodes)
{
$this->bbcode_init();
}
global $user;
Code: Select all
//Start MOD removing BBcode. Replace all the [**bbcode**] and [/**bbcode**] with your bbcode for it to work.
preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch );
foreach ($qmatch[2]as $qmatchin){
preg_match_all('#\[code\](.*?)\[/code\]#is', $qmatchin, $qcode);
$crepl = str_replace('[**bbcode**]', '[**bbcode**]', $qcode[1]);
$replacement = str_replace($qcode[1], $crepl, $qmatchin);
$replacement = preg_replace('#\[**bbcode**\]\n*(.*)\n*\[/**bbcode**\]#iU', '[ Removed custom BBcode ]', $replacement);
$this->message = str_replace($qmatchin, $replacement, $this->message);
$this->message = str_replace($crepl, $qcode[1], $this->message);
}
//End MOD removing BBcode
Code: Select all
$this->message = str_replace($qmatchin, $replacement, $this->message);
Code: Select all
$this->message = str_replace($qmatchin, '<p>'.$replacement.'</p>', $this->message);