(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-21-24 10:40 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - I want to change my smilies system... How ? New poll | |
Pages: 1 2Add to favorites | Next newer thread | Next older thread
User Post
Stifu









Since: 11-18-05
From: Your mom's bed

Last post: 6303 days
Last view: 6301 days
Posted on 03-13-06 02:03 PM Link | Quote
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:)haha
bla:)
!!
^^
25:)899
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 [quote=username]message[/quote]... So it would display a smiley for people whose name start with a D...
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: 6303 days
Last view: 6301 days
Posted on 03-16-06 12:46 PM Link | Quote
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: 6302 days
Last view: 6301 days
Skype
Posted on 03-16-06 02:44 PM Link | Quote
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: 6303 days
Last view: 6301 days
Posted on 03-16-06 03:18 PM Link | Quote
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: 6302 days
Last view: 6301 days
Skype
Posted on 03-16-06 03:59 PM Link | Quote
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: 6303 days
Last view: 6301 days
Posted on 03-16-06 04:03 PM Link | Quote
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: 6514 days
Last view: 6514 days
Posted on 03-16-06 10:48 PM Link | Quote
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: 6303 days
Last view: 6301 days
Posted on 03-17-06 03:33 AM Link | Quote
Originally posted by Arthus
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.

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: 6623 days
Last view: 6623 days
Posted on 03-17-06 02:29 PM Link | Quote
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: 6303 days
Last view: 6301 days
Posted on 03-17-06 02:58 PM Link | Quote
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: 6302 days
Last view: 6301 days
Skype
Posted on 03-17-06 03:03 PM Link | Quote
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: 6623 days
Last view: 6623 days
Posted on 03-17-06 08:48 PM Link | Quote
Originally posted by Stifu
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.


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 expression. When you edit a post using that code, it will 1) display the img tags if those are not already reverse filtered ... they should be. Or 2) it will just display the smilies exactly as they were originally entered.

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: 6303 days
Last view: 6301 days
Posted on 03-18-06 05:42 AM Link | Quote
Originally posted by Randy53215
if (preg_match('/^.*(\\:\\))(?=((?=\\W)(?!\\d))+).*$/m', $message)) {
// DO NOT PUT IN IMAGE
} else {
// PUT IN IMAGE
}

That should work just put your variables in.

Hmmmm... I tried that:

if (preg_match('/^.*(\\:\\))(?=((?=\\W)(?!\\d))+).*$/m', $message)) {
} else {
$msg=str_replace($smilie[0],"<img src=$smilie[1] align=absmiddle>",$msg);
}

and that:

if(!preg_match('/^.*(\\:\\))(?=((?=\\W)(?!\\d))+).*$/m', $message))
$msg=str_replace($smilie[0],"<img src=$smilie[1] align=absmiddle>",$msg);

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 +
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);


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<img src=$smilie[1] align=absmiddle>$2",$msg);
}

It gave me many compilation errors...
Parasyte +

Red Paragoomba


 





Since: 01-05-06

Last post: 6623 days
Last view: 6623 days
Posted on 03-18-06 12:36 PM Link | Quote
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]);
$smilie[0]=str_replace("\\", "\\\\", $smilie[0]);
$smilie[0]=str_replace("^", "\\^", $smilie[0]);
$smilie[0]=str_replace("$", "\\$", $smilie[0]);
$smilie[0]=str_replace(".", "\\.", $smilie[0]);
$smilie[0]=str_replace("|", "\\|", $smilie[0]);
$smilie[0]=str_replace("?", "\\?", $smilie[0]);
$smilie[0]=str_replace("*", "\\*", $smilie[0]);
$smilie[0]=str_replace("+", "\\+", $smilie[0]);
$smilie[0]=str_replace("(", "\\(", $smilie[0]);
$smilie[0]=str_replace(")", "\\)", $smilie[0]);
$smilie[0]=str_replace("/", "\\/", $smilie[0]);
$msg=preg_replace("/(^|[^a-z0-9])".$smilie[0]."($|[^a-z0-9])/imx","$1<img src=$smilie[1] align=absmiddle>$2",$msg);



(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: 6303 days
Last view: 6301 days
Posted on 03-18-06 12:43 PM Link | Quote
Hmmmmm...


Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6513693 bytes) in /var/www/free.fr/c/8/stifu/Board/lib/function.php on line 219


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: 6623 days
Last view: 6623 days
Posted on 03-18-06 12:46 PM Link | Quote
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: 6303 days
Last view: 6301 days
Posted on 03-18-06 12:55 PM Link | Quote
Exact same error as before...
Parasyte +

Red Paragoomba


 





Since: 01-05-06

Last post: 6623 days
Last view: 6623 days
Posted on 03-18-06 01:09 PM Link | Quote
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: 6303 days
Last view: 6301 days
Posted on 03-18-06 01:43 PM Link | Quote
Still doesn't work... Except the error is different this time.


Warning: Compilation failed: unmatched parentheses at offset 30 in /var/www/free.fr/c/8/stifu/Board/lib/function.php on line 219

Warning: Unknown modifier '(' in /var/www/free.fr/c/8/stifu/Board/lib/function.php on line 219


That's too bad, as your script seems to do exactly what I wanted...
Parasyte +

Red Paragoomba


 





Since: 01-05-06

Last post: 6623 days
Last view: 6623 days
Posted on 03-19-06 09:13 AM Link | Quote
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 2Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - I want to change my smilies system... How ? |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.022 seconds; used 446.05 kB (max 572.70 kB)