Advertisement:

Author Topic: Highlight Search Keywords  (Read 14197 times)

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,815
  • Mod King
    • XPtsp.com Community
Re: Highlight Search Keywords
« Reply #20 on: June 15, 2011, 03:02:55 PM »
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!

Offline snooks

  • Jr. Member
  • **
  • Posts: 201
    • Bradfordsnooker
Re: Highlight Search Keywords
« Reply #21 on: June 15, 2011, 03:20:08 PM »
Nice thanks confirm 2 gold np on install  ;)

Offline Nathaniel

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,117
  • Gender: Male
    • Verbtest.com
Re: Highlight Search Keywords
« Reply #22 on: June 16, 2011, 02:35:32 AM »
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.

Offline btechnix

  • Newbie
  • *
  • Posts: 8
Re: Highlight Search Keywords
« Reply #23 on: June 18, 2016, 03:31:43 AM »
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":
Quote
8192: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
Fichier: .../htdocs/forum/Sources/Search.php
Ligne: 2115
and
Quote
8192: 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:
Code: [Select]
   $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:
Code: [Select]
         $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:
Code: [Select]
               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

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,643
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Highlight Search Keywords
« Reply #24 on: August 05, 2018, 11:33:23 AM »
I did these changes to get it working on new versions of PHP

Subs.php
Find
Code: [Select]
$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
Code: [Select]
$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
Code: [Select]
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