Highlight Search Keywords

Started by Nathaniel, June 16, 2008, 03:32:22 PM

Previous topic - Next topic

dougiefresh

Thank you for the wonderful mod!  I thought I'd let everybody know that when I updated my forum from 2.0 RC5 to 2.0 Gold, I had to reinstall all my mods.  This mod installed without issues and without emulation.  Hope this info helps someone!

snooks

Nice thanks confirm 2 gold np on install  ;)

Nathaniel

Also confirmed that this mod works for SMF 2.0 gold. Thanks for the feedback. :)
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

btechnix

Hello,

At first, thank you for this great mod, which worked perfectly until now on SMF 2.11 before migrating on PHP 5.5

With PHP 5.5 we have many deprecated errors #8192 reported in log, more than 1000 per day, due code of this mod in "search.php" and "Subs.php":
Quote8192: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
Fichier: .../htdocs/forum/Sources/Search.php
Ligne: 2115
and
Quote8192: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
Fichier: .../htdocs/forum/Sources/Subs.php
Ligne: 4583

I tried to fix it, but, I can not, because I'm not a php developer:
For exemple in subs.php at 4583 there are:
   $message = preg_replace('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''),
         "'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>'",
         $message);

I tried unsuccessfully this change:
         $message =
            preg_replace_callback(
               '/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')' . ($context['utf8'] ? 'u' : ''),         
               //"'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>'",
               function ($m) {
               return "'$m[2]' == '$m[1]' ? stripslashes($m[1]') : '<span style=\"background-color:".$color.";font-weight:bold;\">$m[1]</span>'"
               },
               $message);

I think that i have bad syntax in the second parameter , so I have changed it like this:
               return ($m[2].' == '.$m[1].' ? stripslashes('.$m[1].') : <span style=\"background-color:".$color.";font-weight:bold;\">'.$m[1].'</span>')

but this is the same situation, in twice, my changes have blocked my forum.

At this time, i can only delete logs at each time, any help was welcome
Than you

vbgamer45

I did these changes to get it working on new versions of PHP

Subs.php
Find

$message = preg_replace('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''), "'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>'", $message);
           

Replace with

$context['highlight_color'] = $color;
            $message = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), 'highlightmod__preg_callback', $message);




End of Sources/Subs.php
Add

function highlightmod__preg_callback($matches)
{
    global $context;
return isset($matches[2]) && $matches[2] == $matches[1] ? stripslashes($matches[1]) : '<span style="background-color:' .  $context['highlight_color'] . ';font-weight:bold;">' . $matches[1] . '</span>';
}

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: