Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2004, 04:29 PM
julius julius is offline
 
Join Date: Nov 2001
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default BB Code Font Size: Limit to max size=5

I changed the Available Sizes of the Toolbar Menu Options to

1 2 3 4 5

but in standard mode when you post, you can manually change [SIZE=5] to [SIZE=7].

How can I fix it so users cannot change [SIZE=5] to [SIZE=7] or, even if they change it, the parse is no more than size=5?
Reply With Quote
  #2  
Old 01-12-2004, 04:54 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this hack (it's for RC2, might also work for earlier versions)

File functions_newpost.php

Before
PHP Code:
if ($post['preview'] OR sizeof($errors) > 0
Insert
PHP Code:
// PostSizeHack
// Make sure user does not user too large fonts
$pattern "/\[size=[6-9]\].*\[\/size\]/si";            // Check for SIZE=6-9
$pattern2 "/\[size=\+[5-9]\].*\[\/size\]/si";         // Check for SIZE=+5-9
$pattern3 "/\[size=\+*[1-9][0-9]+\].*\[\/size\]/si";  // Check for SIZE=[+]10-xxxxx
if (preg_match($pattern$post['message']) or
  
preg_match($pattern2$post['message']) or
  
preg_match($pattern3$post['message'])) {
  
$post['preview'] = 1;
  eval(
'$errors[] = "Font size too large - max is 5";');
}
// PostSizeHack 
Colud be also made configurable via CP & phrased, but would make the hack a bit more "difficult"
Reply With Quote
  #3  
Old 01-12-2004, 06:15 PM
julius julius is offline
 
Join Date: Nov 2001
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks.

It works, but if I put [size=07] or 08, 09, 10, 11 until [size=99] it always parses as [size=7] instead of [size=5].
Reply With Quote
  #4  
Old 01-12-2004, 06:50 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm ... ok. Haven't thought of leading zeros.
Give it another try then:

PHP Code:
// PostSizeHack
// Make sure user does not user too large fonts
$pattern "/\[size=0*[6-9]\].*\[\/size\]/si";            // Check for SIZE=[0]6-9
$pattern2 "/\[size=\+0*[5-9]\].*\[\/size\]/si";         // Check for SIZE=+[0]5-9
$pattern3 "/\[size=\+*0*[1-9][0-9]+\].*\[\/size\]/si";  // Check for SIZE=[+][0]10-xxxxx
if (preg_match($pattern$post['message']) or
  
preg_match($pattern2$post['message']) or
  
preg_match($pattern3$post['message'])) {
  
$post['preview'] = 1;
  eval(
'$errors[] = "Font size too large - max is 5";');
}
// PostSizeHack 
Reply With Quote
  #5  
Old 01-12-2004, 07:05 PM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you should post that up in the Mini-Mods subforum.
Reply With Quote
  #6  
Old 01-12-2004, 07:10 PM
julius julius is offline
 
Join Date: Nov 2001
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Link14716, it works fine now when you enter a new post, but if after you have posted you edit the post, you can still change the size to a bigger size.
Reply With Quote
  #7  
Old 01-12-2004, 07:32 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For edit it's almost the same:

File editpost.php

Before
PHP Code:
if (sizeof($errors) > 0
Add
PHP Code:
// PostSizeHack
// Make sure user does not user too large fonts
$pattern "/\[size=0*[6-9]\].*\[\/size\]/si";            // Check for SIZE=[0]6-9
$pattern2 "/\[size=\+0*[5-9]\].*\[\/size\]/si";         // Check for SIZE=+[0]5-9
$pattern3 "/\[size=\+*0*[1-9][0-9]+\].*\[\/size\]/si";  // Check for SIZE=[+][0]10-xxxxx
if (preg_match($pattern$edit['message']) or
  
preg_match($pattern2$edit['message']) or
  
preg_match($pattern3$edit['message'])) {
  
$post['preview'] = 1;
  eval(
'$errors[] = "Font size too large - max is 5";');
}
// PostSizeHack 
@Link14716: I think i'll make a more "advanced" version with CP-configurable size (instead of hard-coded) and then post it there maybe
Reply With Quote
  #8  
Old 01-12-2004, 09:00 PM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Go for it.
Reply With Quote
  #9  
Old 01-13-2004, 09:01 AM
julius julius is offline
 
Join Date: Nov 2001
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, it works now.
Reply With Quote
  #10  
Old 11-27-2004, 02:00 PM
MickDoneDee MickDoneDee is offline
 
Join Date: Mar 2003
Location: Sydney
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by julius
How can I fix it so users cannot change [SIZE=5] to [SIZE=7] or, even if they change it, the parse is no more than size=5?
On my forum I wanted size 4,5,6,&7 to parse as size 2 so I used Replacement Variables as follows:

variable string: <font size="7"> or [size=7] etc
replacement string: <font size="2"> or [size=2] etc

Admin CP > Styles & Templates > Replacement Variable Manager > Add New Replacement Variable > Search for Text: [size=7]
Replace with Text: [size=2]

Repeat the above with:
Search for Text: [size=6]; [size=5]; [size=4]; <font size="7">; <font size="6">; <font size="5">; <font size="4"> in turn.
Replace with Text: [size=2] or <font size="2"> for vbcode or html.

Works a treat for signatures and posts. Of course, a persistent and clever user can edit the size tag to size=100 and size 7 will be parsed but that should rarely happen.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:42 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04101 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete