Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: dand on September 06, 2011, 10:52:23 AM

Title: How to force "search" inside BB tags?
Post by: dand on September 06, 2011, 10:52:23 AM
Hi guys,
I am using a custom BB code [pgn]{game text}[/pgn] to add a chess game to the forum. I am using the pgn4web tool: http://code.google.com/p/pgn4web/wiki/User_Notes_simplemachines

When I use forum search to find a specific games, for example "Kasparov", it returns nothing. Could this be fixed somehow?

Thanks.

Title: Re: How to force "search" inside BB tags?
Post by: dand on October 12, 2011, 06:20:21 AM
Anyone?
Title: Re: How to force "search" inside BB tags?
Post by: kat on October 12, 2011, 06:31:29 AM
It can't be fixed, as such, coz it's not broken.

Forum search does exactly that. Searches for text, on your forum.

Maybe you could use this:

http://custom.simplemachines.org/mods/index.php?mod=2566

to make searches of your forum, like this does?

http://www.google.co.uk/search?q=Kasparov+site%3Ahttp%3A%2F%2Fwww.simplemachines.org%2Fcommunity&hl=en&client=opera&rls=en&channel=suggest&num=10&lr=&ft=i&cr=&safe=off&tbs=

(Just thinking out-loud, here.)
Title: Re: How to force "search" inside BB tags?
Post by: dand on October 16, 2011, 04:19:54 PM

No, that doesn't help.  :(

Fix... I ment, could it be implemented, hacked somehow? To fool the search engine to go into BB tags? 
Title: Re: How to force "search" inside BB tags?
Post by: kat on October 16, 2011, 04:49:21 PM
This doesn't help?

http://www.google.co.uk/search?q=Kasparov+site%3Ahttp%3A%2F%2Fwww.simplemachines.org%2Fcommunity&hl=en&client=opera&rls=en&channel=suggest&num=10&lr=&ft=i&cr=&safe=off&tbs=

Not a clue, then, I'm afraid.

Sorry an' all that.
Title: Re: How to force "search" inside BB tags?
Post by: dand on October 17, 2011, 07:19:34 AM
No, that still doesn't search between [pgn] [/pgn] tags.
Title: Re: How to force "search" inside BB tags?
Post by: kat on October 17, 2011, 02:18:40 PM
Not a clue, then, I'm afraid.

Unless you can edit your .htaccess file to cope with this, somehow, I really have no ideas.
Title: Re: How to force "search" inside BB tags?
Post by: IchBin™ on October 17, 2011, 03:13:49 PM
I think the problem is that it doesn't store the tag and what you put in it. BBC converts your tag into what the BBC Tag requires and then stores that information. No real way to make it search for your text if your text is converted into something else.
Title: Re: How to force "search" inside BB tags?
Post by: MrPhil on October 17, 2011, 04:09:38 PM
BBCode is stored in the database "as is". If your post includes [pgn]{game text}[/pgn], that's all that's in the database, which is what Search is looking through. Not until the post is rendered for display does it get turned into the final text (including HTML). If your original post does not include the word "Kasparov" in the game text, there's no way for Search to see it. As far as I know, Search does look within (unexpanded) BBCode tags -- I've always been annoyed by its returning search results from within [code] tags. Has this behavior been recently changed? If your "game text" does include "Kasparov", could Search possibly be failing to pick it up because it's not cleanly separated from other text?

There was a mention of .htaccess -- are there any settings, such as in ModSecurity, that would affect what tags are excluded from searches?
Title: Re: How to force "search" inside BB tags?
Post by: IchBin™ on October 17, 2011, 07:09:07 PM
Sorry I should have been more clear as I can see MrPhil pointed out that what I said wasn't true. I was referring to the search results where I thought the BBC is parsed and saved out into array. Of course it saves BBC directly to the database otherwise that would make all the security checks we have for this type of stuff in vein. lol
Title: Re: How to force "search" inside BB tags?
Post by: dand on October 18, 2011, 04:20:25 AM
Hi guys, 
Thanks so much for the answers, there is hope for chess forum users. :-) 

Yes, the word "Kasparov" is within the tag. This is how it looks:

[pgn]
[White "Kasparov"]
[Black "Short"]
[Result "1-0"]
[Event "Paris Open"]
[Round "7"]
1. c4 e5 2. Nc3 Nc6 3. Nf3 Nf6 4. d3 Bc5 5. Bg5 O-O 6. e3 Be7 7. Be2 Re8 8. O-O a6 9. Qd2 d6 10. h3 Be6 11. e4 Qd7 12. Nd5 Nxd5 13. cxd5 Bxg5 14. Nxg5 Bxd5 15. exd5 Ne7 {1-0}
[/pgn]

Could you be a bit more precise with "htaccess" since I am not too familiar with such things?

Title: Re: How to force "search" inside BB tags?
Post by: IchBin™ on October 18, 2011, 11:57:12 AM
Try disabling mod_security and see if it helps.

Having problems with mod_security? (http://www.simplemachines.org/community/index.php?topic=34270.0)
Title: Re: How to force "search" inside BB tags?
Post by: MrPhil on October 18, 2011, 12:45:29 PM
Does Search find text that is not within square brackets, such as "Nc3"? I don't think that Search excludes tags themselves (I just searched for pgn on this page), although [White] and [Black] may be valid BBCode tags themselves. If Kasparov isn't in "quotes" is it found? It seems to work on this page, too.

Are you on SMF 1.1.x or 2.0.x?

I can't imagine why mod security would flag "Kasparov" as a dangerous term...
Title: Re: How to force "search" inside BB tags?
Post by: IchBin™ on October 18, 2011, 04:09:37 PM
Quote from: MrPhil on October 18, 2011, 12:45:29 PM

I can't imagine why mod security would flag "Kasparov" as a dangerous term...

I don't either, but I've had mod_security bite me with some very weird stuff before not allowing certain param names and even text in the request or resource.
Title: Re: How to force "search" inside BB tags?
Post by: MrPhil on October 18, 2011, 07:32:38 PM
Mebbe "asp" within the name? That's all I can see... Hmm. How about a post that says "Cleopatra did herself in with an asp according to folklore"?  Or "I aspire to greatness." Or "My gate has a clasp on it." It would be interesting to see if any or all of those fail.
Title: Re: How to force "search" inside BB tags?
Post by: dand on February 13, 2012, 06:24:50 AM
I don't know how, but seems like it works now.  :o