Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
Acmlm's Board - I3 Archive - Programming - I want to change my smilies system... How ? | New poll | | |
Pages: 1 2 | Add to favorites | Next newer thread | Next older thread |
User | Post | ||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Here's the deal... I've got an AcmlmBoard v1.A2.
I'd like to make it so smilies aren't displayed if they're surrounded by letters or numbers. It would work with symbols though... and spaces or just nothing too, of course. For example, things would be like: blabla: bla: !! ^^ 25: blabla yes ... Does anyone know how I could do that ? I thought I'd do this because I stumbled on a problem, I had a =D smiley, and I've got a board tag like [ Also, I noticed phpBB2 boards got a smilies system similar to the one I want, but the code is much too different to borrow anything. Thanks. |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
No one ?
Also, one of the many other problems I can't manage to fix myself: it seems like my board (v1.A2) only shows 1 guest at a time... Guest results must get overridden by the last one or something. Is it this a known bug ? Any fix ? |
|||
Randy53215 Melon Bug Since: 11-17-05 From: Greenfield, Wisconsin (U.S.A) Last post: 6432 days Last view: 6431 days |
| ||
Easiest way would to honestly just rename them. I will try and whip up a script tonight. I am currently at school so im kinda limited... | |||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Rename ? Not sure which problem you're referring to... If you mean the smiley, I did change the code from =D to ;D to avoid problems for now.
Well, thanks for trying to help... Looking forward to your next post. (edited by Stifu on 03-16-06 02:18 PM) |
|||
Randy53215 Melon Bug Since: 11-17-05 From: Greenfield, Wisconsin (U.S.A) Last post: 6432 days Last view: 6431 days |
| ||
Well as a temp thing as long as the toolbar is working you could do like
(sad) would equal and so on... Ill post something later on... |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
I don't want to change the codes of my smilies, and they all rarely get in the way of anything anyway...
Not to mention that if it's just temporary, then they wouldn't work anymore later on, once the codes are put back to normal... They can just wait. Oh, and I don't have the toolbar either... I think I only had it with v1.92... (edited by Stifu on 03-16-06 03:05 PM) |
|||
Arthus 140 Since: 11-17-05 From: Australia Last post: 6644 days Last view: 6644 days |
| ||
Why don't you change the str_replace to have a space infront or behind the smiley. So it would only recognize if there was a space infront or behind it.
Change: $msg=str_replace($smilie[0],"",$msg); To: $msg=str_replace(" " . $smilie[0],"",$msg); -or- $msg=str_replace($smilie[0] . " ","",$msg); -or- $msg=str_replace(" " . $smilie[0] . " ","",$msg); THe first one recognizes a space before, the second a space after and the third detects both front and after spaces. |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Originally posted by Arthus I thought about that something similar, but the main problem would be that smilies wouldn't be displayed if there's nothing before or after them... Wrong ? |
|||
Parasyte + Red Paragoomba Since: 01-05-06 Last post: 6753 days Last view: 6753 days |
| ||
Regex to the rescue! Using this, you will have to escape the special characters used in your smilies list. For example, use ":\)" instead of ":)"
$msg=preg_replace("/(^|[^a-z0-9])".$smilie[0]."($|[^a-z0-9])/imx","$1<img src=$smilie[1] align=absmiddle>$2",$msg); |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Hmmm, would that change the content of the messages ?
Like if you edited a message with smilies, would you see extra back slashes ? If not, could you tell me where I'd need to put that line exactly, so I don't mess things up ? Thanks. |
|||
Randy53215 Melon Bug Since: 11-17-05 From: Greenfield, Wisconsin (U.S.A) Last post: 6432 days Last view: 6431 days |
| ||
if (preg_match('/^.*(\\:\\))(?=((?=\\W)(?!\\d))+).*$/m', $message)) {
// DO NOT PUT IN IMAGE } else { // PUT IN IMAGE } That should work just put your variables in. |
|||
Parasyte + Red Paragoomba Since: 01-05-06 Last post: 6753 days Last view: 6753 days |
| ||
Originally posted by Stifu No, it does not insert the additional backslashes. Those are needed to escape the special characters so they are not considered a part of the exp What you would do with the code is replace the line that Arthus showed. |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Originally posted by Randy53215 Hmmmm... I tried that: if (preg_match('/^.*(\\:\\))(?=((?=\\W)(?!\\d))+).*$/m', $message)) { } else { $msg=str_replace($smilie[0],"< } and that: if(!preg_match('/^.*(\\:\\))(?=((?=\\W)(?!\\d))+).*$/m', $message)) $msg=str_replace($smilie[0],"< Didn't work. No error or anything, but I just couldn't see any difference. It's in function function doreplace2, right ? Originally posted by Parasyte + Hmmm... Didn't work either, I may be doing something wrong. Here's the whole function: function doreplace2($msg){ global $smilies; if(!$smilies) $smilies=readsmilies(); for($s=0;$smilies[$s][0];$s++){ $smilie=$smilies[$s]; $msg=preg_replace("/(^|[^a-z0-9])".$smilie[0]."($|[^a-z0-9])/imx","$1< } It gave me many compilation errors... |
|||
Parasyte + Red Paragoomba Since: 01-05-06 Last post: 6753 days Last view: 6753 days |
| ||
Did you edit your smilies list? Remember, you have to escape the special characters within the list. The following characters must be escaped:
[ \ ^ $ . | ? * + ( ) Which means that every instance of these in your smilies list must be preceded by a single backslash: \[ \\ \^ \$ \. \| \? \* \+ \( \) If you skip this step using my code, your smilie identifiers will be interpreted as part of the regex, which will definitely screw things up. If you wish to take the easy way out, you can have php do the escaping for you: $smilie[0]=str_replace("[", "\\[", $smilie[0]); (edited by Parasyte + on 03-18-06 12:05 PM) (edited by Parasyte + on 03-19-06 08:14 AM) |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Hmmmmm...
Any idea ? Thanks. By the way, does anyone know how to fix the bug that makes it so no more than one guest ever appears ? |
|||
Parasyte + Red Paragoomba Since: 01-05-06 Last post: 6753 days Last view: 6753 days |
| ||
I've since updated the code in my last post. It had some errors. :X | |||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Exact same error as before... | |||
Parasyte + Red Paragoomba Since: 01-05-06 Last post: 6753 days Last view: 6753 days |
| ||
I don't know? I tested it on my server, and it works as expected. Unless you are dumping an 8MB post of text into it, it should not be overflowing anything...
I did have to update it once again, though. I had "$milie[0]" in one part... The dollar sign hardly substitutes for the 's', oops. ;( Here, you can see the script in action... view page source to see all of the line breaks and everything: http://parasyte.panicus.org/s.php And if you REALLY need to see the script source as an example, I can post that as well. Then you can test it for yourself? :X (edited by Parasyte + on 03-18-06 12:10 PM) |
|||
Stifu Since: 11-18-05 From: Your mom's bed Last post: 6434 days Last view: 6432 days |
| ||
Still doesn't work... Except the error is different this time.
That's too bad, as your script seems to do exactly what I wanted... |
|||
Parasyte + Red Paragoomba Since: 01-05-06 Last post: 6753 days Last view: 6753 days |
| ||
Hmm, I think I know what it could be, add this to the list of escape codes:
(I have already added it to the 'original' post) $smilie[0]=str_replace("/", "\\/", $smilie[0]); |
Pages: 1 2 | Add to favorites | Next newer thread | Next older thread |
Acmlm's Board - I3 Archive - Programming - I want to change my smilies system... How ? | | |