PDA

View Full Version : Limit [SIZE] tag


forumdude
07-28-2003, 10:43 PM
I was looking around for a hack to limit how large users can make their text size via the vb tag.

I was looking at the preg_replace() function (
http://us4.php.net/manual/en/function.preg-replace.php ).

I'm not sure what to do because the size tag can be done in two different ways making the replace statement more difficult:


[SIZE=4]Blah
Blah

Size=4
Size=+4


Any help would be appreciated. Size=100 in signatures gets old quick. :(


Thanks!

Zachery
07-29-2003, 11:48 AM
<font size="100">test</font>

html limits dont go past +4 as far as i understood

cirisme
07-29-2003, 01:21 PM
$message = preg_replace("/\(.+)\[\/size\]/siU", "[size=\\1]\\2", $message);
$message = preg_replace("/\(.+)\[\/size\]/siU", "[size=3]\\2", $message);

is what I use to limit it to 3. It makes the + useless. I use it in new reply, new thread, and edit post. Where is kind of irrelevant, as long as it is before $message is saved into the db. ;)

Just experiment with positioning. :)

forumdude
08-04-2003, 11:59 AM
hmmm. I suppose that's a good start but it didn't work completely on my site.

Size=100 still went through (or anything over 13) and some of the other sizes I tried ended up as this character:

Gary King
08-04-2003, 05:19 PM
Today at 08:59 AM forumdude said this in Post #4 (https://vborg.vbsupport.ru/showthread.php?postid=423096#post423096)
hmmm. I suppose that's a good start but it didn't work completely on my site.


Size=100 still went through (or anything over 13) and some of the other sizes I tried ended up as this character: 

Didn't work completely? What's wrong with the code supplied by cirisme?

cirisme
08-04-2003, 06:37 PM
Today at 06:59 AM forumdude said this in Post #4 (https://vborg.vbsupport.ru/showthread.php?postid=423096#post423096)
hmmm. I suppose that's a good start but it didn't work completely on my site.


Size=100 still went through (or anything over 13) and some of the other sizes I tried ended up as this character: 


I just realized that the other day(after a member used 15), so I updated my code to handle it:

$message = preg_replace("/\(.+)\[\/size\]/siU", "[size=\\1]\\2", $message);
$message = preg_replace("/\(.+)\[\/size\]/siU", "[size=3]\\2", $message);

When I get time, I plan on updating and testing this: (it should work, but I haven't tested it just yet :surprised: )

$message = preg_replace("/\\](.+)\[\/size\]/siU", "[size=3]\\1", $message);

It will go to size 999, but you could make it go higher ;)

cirisme
08-04-2003, 06:51 PM
Just tested it, and this works well:

$message = preg_replace("/\*\](.+)\[\/size\]/siU", "[size=3]\\1", $message);

Enjoy :)

forumdude
08-04-2003, 08:07 PM
Today at 03:51 PM cirisme said this in Post #7 (https://vborg.vbsupport.ru/showthread.php?postid=423207#post423207)
Just tested it, and this works well:

$message = preg_replace("/\*\](.+)\[\/size\]/siU", "[size=3]\\1", $message);

Enjoy :)

I tried that code as well and had problems.


Try the statement:

I go to some fast food place and get super size 5.

Size 5 gets replaced with .

cirisme
08-04-2003, 09:26 PM
Make sure you change the \1 to have double slashes(\\1), apparently vb.org's php tags mess up the double slashes.

forumdude
08-04-2003, 09:34 PM
Ahhh thanks.

My only consideration now would be if someone enters the number 1000000 for the size.

Hehehe.

Nice site btw. I registered there under Ibuprofen. Good reading for sure.

cirisme
08-05-2003, 02:05 PM
Yesterday at 04:34 PM forumdude said this in Post #10 (https://vborg.vbsupport.ru/showthread.php?postid=423243#post423243)
Ahhh thanks.

My only consideration now would be if someone enters the number 1000000 for the size.

Heh, at first I thought I had this covered, but I just realized I don't. As long as they don't go to 4 they can still abuse it, so they could do 33(or 3333 for example) and be fine :paranoid:

Let's keep this a secret till I can find a fix ;)

Nice site btw. I registered there under Ibuprofen. Good reading for sure.

Thanks! :bunny:

cirisme
08-05-2003, 03:42 PM
I found a fix and released it as a hack:

https://vborg.vbsupport.ru/showthread.php?s=&threadid=55919

:)

forumdude
08-05-2003, 04:06 PM
Great!

Thanks again.