phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Problem Mod on Install [SOLVED]


 
Search this topic... | Search phpBB2 Discussion... | Search Box
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Author Message
MWE_001
Board Member



Joined: 29 Jul 2011

Posts: 12



PostPosted: Sat Aug 11, 2018 1:23 pm 
Post subject: Problem Mod on Install [SOLVED]

SO I have a phpBB 2.x install , namely the one being maintained on github now as of recently and all is well in life. mysqli works a treat on it and so far so good on php 7.0.29.

Now here is where the problem mod install comes in to play. Acronyms mod. Does anyone have this mod installed and if so, how bad of a headache is it for you? Once I installed it, all but every page on my website was throwing warnings due to bbcode.php.

In particular the trouble line is :

Code:
$message .= str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig, \$repl, '\\0')", '>' . $seg . '<'), 1, -1));


Once this part of the acronym mod is added, we get this:

( ! ) Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in C:\wamp64\www\development\includes\bbcode.php on line 825

Fair enough, that is to be expected. And all of our forum posts disappear. We still get signatures but that is it. If I add the callback, I get this:

( ! ) Warning: preg_replace_callback(): Requires argument 2, 'preg_replace($orig, $repl, '\0')', to be a valid callback in C:\wamp64\www\development\includes\bbcode.php on line 825

Also, we get our posts back but the acronyms do not work. The original will showup for example , LOL, but it will not tell you what LOL is on a mouse over.

The truth is I have fixed more than a dozen of these errors on the website I am working on but this one error is eating my ass up. I literally can not solve it. I know the answer is right in front of me. It needs 2 arguments. I have added 2 arguments every which way but loose and still nothing. 5 days now on the same error. It is time to pass it on. I have a few other errors to fix but the really depend on me fixing this one first.

Anyhow, take care all. Stay cool and don't work to hard in all this daggum heat.
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 428
Location: Québec


flag
PostPosted: Sat Aug 11, 2018 4:24 pm 
Post subject: Re: Problem Mod on Install

As far as I can gather from the manual, it doesn't need 2 arguments but 3 as it used to, the issue here is instead that the second argument needs to be some kind of function.
Replacing
Code:
"preg_replace(\$orig, \$repl, '\\0')"

with
Code:
function ($matches) {return preg_replace($orig, $repl, $matches)}

might get you somewhere? So the whole callback would look like this:
Code:
               preg_replace_callback(
                  '#(\>(((?>([^><]+|(?R)))*)\<))#s',
                  function ($matches) {return preg_replace($orig, $repl, $matches)},
                  '>' . $seg . '<'
               ),


I have no idea if this will work, but it's what the manual seems to imply.
Back to top
MWE_001
Board Member



Joined: 29 Jul 2011

Posts: 12



PostPosted: Sat Aug 11, 2018 5:04 pm 
Post subject: Re: Problem Mod on Install

Syntax Errors but Hmmmmm You are on to something for sure.

http://prntscr.com/khfz4k


http://prntscr.com/khfzcb

This may help a bit. Here is the complete snippet of code that I am working with.

Code:
function acronym_pass($message)
{
   static $orig, $repl;

   if( !isset($orig) )
   {
      global $db, $board_config;
      $orig = $repl = array();

      $sql = 'SELECT * FROM ' . ACRONYMS_TABLE;
      if( !$result = $db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, "Couldn't obtain acronyms data", "", __LINE__, __FILE__, $sql);
      }
      
      $acronyms = $db->sql_fetchrowset($result);

      if( count($acronyms) )
      {
         usort( $acronyms, 'acronym_sort' );
      }

      for ($i = 0; $i < count($acronyms); $i++)
      {
         $orig[] = '#\b(' . phpbb_preg_quote( $acronyms[$i]['acronym'], "/") . ')\b#';
         //$orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($acronyms[$i]['acronym'], "/") . "(?=.\W|\W.|\W$)/";
         $repl[] = '<acronym title="' . $acronyms[$i]['description'] . '">' . $acronyms[$i]['acronym'] . '</acronym>'; ;
      }
   }
   
   if( count( $orig ) )
   {
      $segments = preg_split( '#(<acronym.+?>.+?</acronym>|<.+?>)#s' , $message, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);

      $message = '';

      foreach( $segments as $seg )
      {
         if( $seg[0] != '<' && $seg[0] != '[' )
         {
            $message .= str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig, \$repl, '\\0')", '>' . $seg . '<'), 1, -1));
         }
         else
         {
            $message .= $seg;
         }
      }
   }
   
   return $message;
}
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 428
Location: Québec


flag
PostPosted: Sat Aug 11, 2018 5:23 pm 
Post subject: Re: Problem Mod on Install

Yeah, definitely missing a semicolon after the return there.
Back to top
MWE_001
Board Member



Joined: 29 Jul 2011

Posts: 12



PostPosted: Sat Aug 11, 2018 5:37 pm 
Post subject: Re: Problem Mod on Install

Yeah somewhere. Got to lay down for now. back is screaming at me. Fresh fusion and PC chair time do not mix well.
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 428
Location: Québec


flag
PostPosted: Sat Aug 11, 2018 5:44 pm 
Post subject: Re: Problem Mod on Install

After the parentheses, specifically:
Code:
function ($matches) {return preg_replace($orig, $repl, $matches);},
Back to top
MWE_001
Board Member



Joined: 29 Jul 2011

Posts: 12



PostPosted: Sat Aug 11, 2018 8:02 pm 
Post subject: Re: Problem Mod on Install

Sytax error unexpected } above the else

I'm working in it. As we all know usually the syntax being reported is something a line or two above. I am trying every combo of everything the manual tells me I can try.
Back to top
MWE_001
Board Member



Joined: 29 Jul 2011

Posts: 12



PostPosted: Sun Aug 12, 2018 1:55 am 
Post subject: Re: Problem Mod on Install [SOLVED]

I am marking this one as solved.

Vendethiel has suggested a fix and it worked a treat.

Code:
$message .= str_replace('\"', '"', substr(preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#', function ($matches) use ($orig, $repl) {
  return preg_replace($orig, $repl, $matches[0]);
}, '>' . $seg . '<'), 1, -1));


There it is in case anyone else attempts to install the acronym mod.
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 428
Location: Québec


flag
PostPosted: Sun Aug 12, 2018 1:59 am 
Post subject: Re: Problem Mod on Install [SOLVED]

Thanks for the assist, Vendethiel icon_smile.gif I wasn't sure about the variable scope in the function and whether to use $matches or $matches[0].
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 78



PostPosted: Sun Aug 12, 2018 12:24 pm 
Post subject: Re: Problem Mod on Install [SOLVED]

Yeah this bit of code is really a mouthful, took me a bit to figure the order out.
_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
ABDev
Board Member



Joined: 01 Jun 2009

Posts: 38


flag
PostPosted: Sun Aug 19, 2018 3:33 pm 
Post subject: Re: Problem Mod on Install [SOLVED]

@Vendethiel : Please contact me on phpBB-fr.com, I have many preMODs to give you icon_smile.gif.
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0350 seconds using 16 queries. (SQL 0.0065 Parse 0.0009 Other 0.0275)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo