|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Quick Coding Question For Ythan
#15741426 - 01/31/12 02:53 AM (3 months, 27 days ago) |
|
|
Didn't feel right sending a private message... Anyways, with the emoticon code, I really enjoy the fact that the code will produce the emoticon even if there is no space between the code itself and the next word, for example: see my point? No space between and see and yet the emoticon displays...
Problem is that I'm working on a forum, using Simple Machines 2.0.2, and it doesn't work like this. If there's no space, it doesn't recognize the code.
My question is did you have to modify the board manually to achieve this, or is this inherent with vbulletin? I've of course inquired into this on their support forums, but with stuff like this it's hard to get a good response...
If you have any indication as a general php fix for this type of situation, it'd be greatly appreciated!
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
Edited by fireworks_god (01/31/12 04:05 AM)
|
koraks

Registered: 06/02/03
Posts: 16,174
|
|
Shroomery doesn't use phpBB, does it? I bet phpBB by default parses posts in a different way than vBulletin.
I guess you'll have to look into how phpBB parses messages. This might be a good place to start: http://area51.phpbb.com/docs/code/31x/phpbb3/parse_message.html
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: koraks]
#15741540 - 01/31/12 04:09 AM (3 months, 27 days ago) |
|
|
I'm not sure what it uses; I scrolled down to look at the bottom but didn't see anything, so I tried to recall and phpbb is what came to mind.
I'm using Simple Machines... I had went digging before in the sources files and found code that determines how emoticons are parsed, but I have no real understanding of this stuff and couldn't find anything that I was capable of modifying. I've been able to make a lot of other changes, but this has more to do with adding or removing certain things referring more to the layout of the forum and how it appears...
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
Glad you didn't sent a PM, I probably wouldn't have seen it. Currently 1,681 unread messages hehe. 
This forum is actually based on UBBThreads 6.5 (not vBulletin), which is so friggin old and has been modified so many times that I do not remember whether the emoticon behavior was changed or not.
Looks like you want to modify the parsesmileys function in Subs.php. You need to modify the $smileyPregSearch regex. I think if you just get rid of the '\s' right before the $non_breaking_space that should give you the behavior you want. I've never used SMF 2 and I haven't tested this change though, so good luck.
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15741810 - 01/31/12 07:16 AM (3 months, 27 days ago) |
|
|
I found one instance of what seems to be what you were referring to, and I removed the \s, but it made it so that no emoticons would show at all. Here's the part in particular I was working with:
Code:
// This smiley regex makes sure it doesn't parse smileys within code tags (so [url=mailto:David@bla.com] doesn't parse the :D smiley) $smileyPregReplacements = array(); $searchParts = array(); for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) { $smileyCode = '<img src="' . htmlspecialchars($modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i]) . '" alt="' . strtr(htmlspecialchars($smileysfrom[$i], ENT_QUOTES), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr(htmlspecialchars($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley" />';
$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; $smileyPregReplacements[htmlspecialchars($smileysfrom[$i], ENT_QUOTES)] = $smileyCode; $searchParts[] = preg_quote($smileysfrom[$i], '~'); $searchParts[] = preg_quote(htmlspecialchars($smileysfrom[$i], ENT_QUOTES), '~'); }
$smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~e' . ($context['utf8'] ? 'u' : '');
This is the part I modified by simply removing \s - $smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space .
Like I said though, I've gotten good with finding relevant parts of code, adding and removing stuff, but I don't actually know php. Does this code look like the right spot to be in, though?
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
Yeah that looks like the right place... it's a little hard to wrap my head around that regex without having SMF installed though. Can you echo $smileyPregSearch and print_r($smileyPregReplacements) and let me know what the output is?
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15741924 - 01/31/12 08:28 AM (3 months, 27 days ago) |
|
|
Not to waste your time even more but how would I do that? I mean, I know how to make a file to tell it to echo and everything and then view the file to see how it displays, but I wouldn't know how to write that file in the right way to access "$smileyPregSearch" and everything... How would I point to that so it can actually echo it?
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
Sorry man I think this may actually be more of a question for the SMF support forums.
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15750788 - 02/02/12 06:59 AM (3 months, 25 days ago) |
|
|
Well, I didn't want to give up, so I tried figuring out how to get you the output you were requesting; didn't have any luck finding someone to explain it to me... 
So, a few minutes ago, I was fooling around with that portion of the code, removing little symbols and combinations thereof here and there, inspired by your suggestion to remove the /s. I was working with this line here: $smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~e'
Sometimes the page wouldn't load due to parse errors, sometimes all emoticons wouldn't show, sometimes they would show regardless that I had removed something, sometimes all the text completely disappeared...
Until I removed the $ from near the end, and - voila! All emoticons displayed, even the ones that didn't have space between their code and the next word. 
I knew you are a busy man, so that's why I was just asking if you had remembered making an edit and if it was a matter of just some general code, and not something proprietary to SMF, so thanks for the help you did offer, because it invariably led to me fooling around and resolving the matter.
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
|
Afterward I realized that there's still a problem if there is coding in front of the emoticon code. So I kept messing around and resolved that problem by pulling the ^ from this section here: '[\]()*\\\;]|^) after the $non_breaking_space. Can't seem to find any unintended consequences of these changes...
It'd be nice to know what I actually changed though! I surmise that they are some kind of markers that determine how text is searched to identify the emoticon code from the rest...
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
Heh... yeah man your chance of creating a working regex by randomly substituting characters is not that great. Lots of control characters and modifiers and character classes and stuff that you need to understand. Eg. ^ forces a match at the beginning of the string. That's why I wanted the output of the final regex after the variables were added, it's hard to look at an incomplete regex and understand what's going on. RegexBuddy is a really helpful tool for working with regular expressions and it's what I was going to use to dissect that regex.
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15750886 - 02/02/12 07:42 AM (3 months, 25 days ago) |
|
|
Gotcha. I'm going to leave it like this and watch for unintended consequences, and if they appear I can just revert back. In the meantime, I'm hoping to figure out how to produce that output, the final regex as you describe it to be. I had asked around but got no responses. If I do produce some quality output I'll let you know.
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
You should just be able to put Code:
exit($smileyPregSearch); right after the variable is set, and then do something on the BB which will invoke the parsesmileys function. Just making a post would probably do it.
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15750953 - 02/02/12 08:07 AM (3 months, 25 days ago) |
|
|
Meaning right after the code I posted above, right?
If that's the right spot, than this is what it turned up, in place of the entire post area, including the poster area on the left...
Quote:
~(?<=[>:\?\.\s\x{A0}[\]()*\\;]|)(\:drinkingbuds\:|\:drinkingbuds\:|\:strokebeard\:|\:strokebeard\:|\:fingernails\:|\:fingernails\:|\:flipthebird\:|\:flipthebird\:|\:goodmorning\:|\:goodmorning\:|\:bunnypeace\:|\:bunnypeace\:|\:eskimokiss\:|\:eskimokiss\:|\:thumbdown\:|\:thumbdown\:|\:bottledup\:|\:bottledup\:|\:crazyeyes\:|\:crazyeyes\:|\:facepalm3\:|\:facepalm3\:|\:intardnet\:|\:intardnet\:|\:bunnyhug\:|\:bunnyhug\:|\:sherlock\:|\:sherlock\:|\:rolleyes\:|\:rolleyes\:|\:loveeyes\:|\:loveeyes\:|\:levitate\:|\:levitate\:|\:headbang\:|\:headbang\:|\:confused\:|\:confused\:|\:banghead\:|\:banghead\:|\:beartrap\:|\:beartrap\:|\:bigkiss2\:|\:bigkiss2\:|\:birdfeed\:|\:birdfeed\:|\:birthday\:|\:birthday\:|\:congrats\:|\:congrats\:|\:drooling\:|\:drooling\:|\:facepalm\:|\:facepalm\:|\:failboat\:|\:failboat\:|\:gangsta2\:|\:gangsta2\:|\:goinsane\:|\:goinsane\:|\:goodluck\:|\:goodluck\:|\:hissyfit\:|\:hissyfit\:|\:iloveyou\:|\:iloveyou\:|\:bigkiss\:|\:bigkiss\:|\:yinyang\:|\:yinyang\:|\:tongue2\:|\:tongue2\:|\:thumbup\:|\:thumbup\:|\:shocked\:|\:shocked\:|\:naughty\:|\:naughty\:|\:inlove3\:|\:inlove3\:|\:bunster\:|\:bunster\:|\:ashamed\:|\:ashamed\:|\:awesome\:|\:awesome\:|\:biggrin\:|\:biggrin\:|\:bouncey\:|\:bouncey\:|\:crankey\:|\:crankey\:|\:cuddles\:|\:cuddles\:|\:dumblol\:|\:dumblol\:|\:flowers\:|\:flowers\:|\:hotidea\:|\:hotidea\:|\:inlove2\:|\:inlove2\:|\:yesnod\:|\:yesnod\:|\:tongue\:|\:tongue\:|\:stoned\:|\:stoned\:|\:shroom\:|\:shroom\:|\:inlove\:|\:inlove\:|\:hehehe\:|\:hehehe\:|\:heart2\:|\:heart2\:|\:cuckoo\:|\:cuckoo\:|\:crazy2\:|\:crazy2\:|\:joking\:|\:joking\:|\:cheers\:|\:cheers\:|\:cloud9\:|\:cloud9\:|\:crazy3\:|\:crazy3\:|\:crying\:|\:crying\:|\:dancer\:|\:dancer\:|\:drool2\:|\:drool2\:|\:emocry\:|\:emocry\:|\:google\:|\:google\:|\:handth\:|\:handth\:|\:hippie\:|\:hippie\:|\:imslow\:|\:imslow\:|\:insano\:|\:insano\:|\:blush\:|\:blush\:|\:whoah\:|\:whoah\:|\:sorry\:|\:sorry\:|\:smirk\:|\:smirk\:|\:smile\:|\:smile\:|\:shrug\:|\:shrug\:|\:rofl2\:|\:rofl2\:|\:laugh\:|\:laugh\:|\:heart\:|\:heart\:|\:frown\:|\:frown\:|\:earth\:|\:earth\:|\:crazy\:|\:crazy\:|\:biker\:|\:biker\:|\:bitch\:|\:bitch\:|\:bliss\:|\:bliss\:|\:bored\:|\:bored\:|\:bunny\:|\:bunny\:|\:evil2\:|\:evil2\:|\:yawn\:|\:yawn\:|\:wink\:|\:wink\:|\:nono\:|\:nono\:|\:mad2\:|\:mad2\:|\:grin\:|\:grin\:|\:evil\:|\:evil\:|\:cool\:|\:cool\:|\:argh\:|\:argh\:|\:bow2\:|\:bow2\:|\:dead\:|\:dead\:|\:grrr\:|\:grrr\:|\:wtf\:|\:wtf\:|\:sun\:|\:sun\:|\:nut\:|\:nut\:|\:mad\:|\:mad\:|\:lol\:|\:lol\:|\:hug\:|\:hug\:|\:hip\:|\:hip\:|\:eek\:|\:eek\:|\:ass\:|\:ass\:|\:ban\:|\:ban\:|\:boo\:|\:boo\:|\:box\:|\:box\:|\:bye\:|\:bye\:|\:doh\:|\:doh\:|\:hi\:|\:hi\:|\:bow\:|\:bow\:|\:justdontknow\:|\:justdontknow\:|\:lame\:|\:lame\:|\:leafpile\:|\:leafpile\:|\:lecture\:|\:lecture\:|\:lipsrsealed\:|\:lipsrsealed\:|\:love\:|\:love\:|\:mafioso\:|\:mafioso\:|\:mod\:|\:mod\:|\:monkeydance\:|\:monkeydance\:|\:muahaha\:|\:muahaha\:|\:nerd\:|\:nerd\:|\:ninja\:|\:ninja\:|\:nonono\:|\:nonono\:|\:noob\:|\:noob\:|\:oldman\:|\:oldman\:|\:oogle\:|\:oogle\:|\:peace\:|\:peace\:|\:pimp\:|\:pimp\:|\:pimp2\:|\:pimp2\:|\:pimp3\:|\:pimp3\:|\:pimpslap2\:|\:pimpslap2\:|\:pipesmoke\:|\:pipesmoke\:|\:pirate\:|\:pirate\:|\:pm\:|\:pm\:|\:poke\:|\:poke\:|\:popcorn\:|\:popcorn\:|\:protest\:|\:protest\:|\:puke\:|\:puke\:|\:punish\:|\:punish\:|\:rainyday\:|\:rainyday\:|\:rant\:|\:rant\:|\:raver\:|\:raver\:|\:razz\:|\:razz\:|\:redpanda\:|\:redpanda\:|\:rofl\:|\:rofl\:|\:runaway\:|\:runaway\:|\:sadeyes\:|\:sadeyes\:|\:satansmoking\:|\:satansmoking\:|\:seeya\:|\:seeya\:|\:seniors\:|\:seniors\:|\:serenade\:|\:serenade\:|\:shake\:|\:shake\:|\:sherlock2\:|\:sherlock2\:|\:shrug2\:|\:shrug2\:|\:snub\:|\:snub\:|\:stirthepot\:|\:stirthepot\:|\:strokebeard3\:|\:strokebeard3\:|\:strong\:|\:strong\:|\:suckit\:|\:suckit\:|\:sunny\:|\:sunny\:|\:super\:|\:super\:|\:tardhi\:|\:tardhi\:)(?=[^[:alpha:]0-9]|)~eu
You'll notice that, naturally, I've jacked all my favorite Shroomery emoticons.
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
Alright well here's the breakdown of your smiley regex. Are you sure you don't like it how it is? It looks pretty well thought out to me. It will match a smiley at the end of a sentence (eg. Hello.:somesmiley:) or in the middle of a sentence between spaces (eg. Hello :somesmiley: how are you?) it just don't match a smiley that's right up next to a word (eg. Hello:somesmiley: or :somesmiley:hello). But if you want to make sure your smileys match no matter what, you should just be able to change:
Code:
$smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~e' . ($context['utf8'] ? 'u' : '');
to:
Code:
$smileyPregSearch = '~(' . implode('|', $searchParts) . ')~e' . ($context['utf8'] ? 'u' : '');
This is equivalent to what you did by removing the $ and ^ characters, as it made those regexes optional. It's just a little cleaner since it removes the code which isn't being used.
As they say in comment, the original regex makes sure it doesn't parse smileys within code tags (so [url=mailto:David@bla.com] doesn't parse the :D smiley). But I don't think that will be a problem with you since all your smileys are :words:.
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15754532 - 02/03/12 01:02 AM (3 months, 24 days ago) |
|
|
Hey, thanks a lot! I put it in and it works fine.
Yeah, the fact that it wouldn't match a smiley that was right up against a word was a total deal breaker. I hate putting spaces between an emoticon that appears at the end of something in parentheses and the ), for example, but in case someone accidentally doesn't leave a space, I'd also hate to not have it display. And, like you said, since I'm using the : on both sides of the emoticon code, I won't have problems with smileys appearing where they shouldn't.
But really I was just setting out to have it work just like it does here on the Shroomery , like a lot of other things that have needed fixed (like the horrendous default they have for private messages, ) or the really stupid preview post function (doesn't load on a new page, loads above the post area, but it doesn't even move your screen up for you to realize that it's actually done something when you press the button! ). Fixed the pm stuff with the help of a mod and changing some settings in phpadmin, but that preview thing I think is going to allude me until I learn more php...
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
Ythan
٩(●̮̮̃•̃)۶


 Registered: 08/08/97
Posts: 14,939
Loc: NY/MA/VT Border
|
|
Hey that's how I picked up web development, and it's not a bad way to learn. You just find a script that's 95% of what you want, and you work on that last 5%. In the process you can pick up a lot of knowledge. I know some people find books and classes helpful but I don't think there's any substitute for actually coding something that you're enthusiastic about. That said, you picked a complex piece of software to get started with, so it may be a bit tricky at times. And this method of learning does leave some gaps in your understanding, so make sure you at least read up on the most common web security problems and how to avoid them. This is a good introduction but it's not the final word on the subject by any means.
|
fireworks_god
SexyButt McDanger



Registered: 03/12/02
Posts: 23,674
Loc: Red Panda Village
Last seen: 2 hours, 52 minutes
|
Re: Quick Coding Question For Ythan [Re: Ythan]
#15767666 - 02/06/12 08:29 AM (3 months, 21 days ago) |
|
|
Yep, SMF definitely seems complex, and the people using their support forums really don't seem to really chime in with help when you're trying to make modifications. For instance, SMF doesn't load a post preview in a new page, but above the box in which you're posting... and it doesn't even force the window to scroll up so you even know that the preview is being generated there. I assume it should be an easy thing to code, I even cite another mod that allowed private messages to be viewed in a new window when you click one in the index, but no one responds. But there were ten other much more simple matters that I was ultimately able to solve and no one said anything... Now I'm trying to figure out a way to code a meta tag so that facebook will put the share description from the post from which the share button was clicked (I modified something so that I have them for every post), and I think I'd die if someone replied to that one.
Thanks a lot for the link concerning security, I'll definitely make use of it.
--------------------
 
If I should die this very moment
I wouldn't fear
For I've never known completeness
Like being here
Wrapped in the warmth of you
Loving every breath of you
|
|