[2.0.20] 50 characters in message

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
7
88%
Very Good
0
No votes
Good
0
No votes
Fair
0
No votes
Poor
1
13%
 
Total votes: 8

Underhill
Registered User
Posts: 154
Joined: Tue Sep 27, 2005 1:54 pm

Post by Underhill » Mon Jul 24, 2006 5:35 pm

Hi,
ZoliveR wrote: Is this fix you provided is working also with auto shorten url?

Yes - both mods look very similar for me..

Reg.
Underhill
batlh ghajbe' De'wI'mey!

ZoliveR
Former Team Member
Posts: 11899
Joined: Sun Jul 14, 2002 7:36 pm
Location: floating in the light, never forgotten

Post by ZoliveR » Mon Jul 24, 2006 7:28 pm

Ok it works, many thanks to you dude! I rated your mod excellent ^^

Hint for the future guys: don't miss one blank line after each line (else, it will cause you an error message in the function post)

You're a good modder ;)
No more Team Chocolate Member. I decided to leave, it's my choice. Thanks to all for all these years.
I'm always near if you need news of me. But no more support is given (private notification disabled)

NoDeity
Registered User
Posts: 148
Joined: Thu Jul 17, 2003 9:43 am
Contact:

Post by NoDeity » Tue Jul 25, 2006 3:24 am

ZoliveR wrote: You're a good modder ;)

Agreed. I appreciate the fact that he follows up on problems and fixes them.

Underhill
Registered User
Posts: 154
Joined: Tue Sep 27, 2005 1:54 pm

Post by Underhill » Sun Dec 31, 2006 1:01 pm

Hi,

this MOD is compatible to phpBB 2.0.22.

I changed the version to 1.4.6 - This is not a required update...

This version is not submitted to the phpBB.com MOD-Database...

Reg.
Underhill
batlh ghajbe' De'wI'mey!

User avatar
DizzyDazzle
Registered User
Posts: 39
Joined: Sun Oct 08, 2006 11:50 pm

Re: [2.0.20] 50 characters in message

Post by DizzyDazzle » Thu Aug 16, 2007 7:07 am

Cool MOD! you got my "Exellent" vote, does exactly as described in the title :D

Thanks for the add-on to make it compatible with the Chunk Long URLs MOD too!

Very cool 8-)
Thanks

MibuKyoshiro
Registered User
Posts: 3
Joined: Thu Mar 08, 2007 3:11 pm

Re: [2.0.20] 50 characters in message

Post by MibuKyoshiro » Sun Dec 23, 2007 3:01 pm

Hi,

I was on the verge of writing a similar mod to avoid ugly layouts when people say "AAAAA...AAH" when I found yours. I've poked in the code and other contributions here for people using shorten-url-type mods like me and there's still a case which goes through your mod unnoticed.

With your mod only, text URLs are broken
With the code changes from Underhill they're not broken, but if someone posts a text with both a very loooooooong word and an URL on the same line, it'll pass through unchanged.

I propose you this code (for the whole thing) :
In includes/functions_post.php, add this function :

Code: Select all

function split50chars($a) {
        if (preg_match("%^(http://|https://|ftp://|www.)%", $a))
                return $a;
        return preg_replace("/([^\[\]\/]{50})/m", "\\1 ", $a);
}
In includes/functions_post.php, after :

Code: Select all

        $message = trim($message);
Add :

Code: Select all

        $message = preg_replace("%(^| )([^ \n]{50,})%em", "'\\1' . split50chars('\\2')", $message);
The function will receive the very long word as argument, and return the replacement :
- send it back as is if it begins with an URL-type prefix,
- else send it back with spaces between chunks of 50 chars

Btw, I use [ \n] instead of [:blank:] -(which should be synonyms) because either : or / are considered as blank characters by PHP and it wasn't breaking lines like AAAAAAAAAAAAAAAAA://:AAAAAAAAAAAAAAAAA ...

If you want to test it first, open a test.php file somewhere, fill it with this code and test it on a webserver which whatever text you want to test :

Code: Select all

function split50chars($a) {
        if (preg_match("%^(http://|https://|ftp://|www.)%", $a))
                return $a;
        return preg_replace("/([^\[\]\/]{50})/m", "\\1 ", $a);
}

function test($message) {
        print "BEFORE:\n$message\nAFTER:\n";
        print preg_replace("%(^| )([^ \n]{50,})%em", "'\\1' . split50chars('\\2')", $message);
        print "\n";
}

test("blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah");
Regards
Kyoshiro

Post Reply

Return to “[2.0.x] MOD Database Releases”