Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2011, 06:15 PM
Gripi Gripi is offline
 
Join Date: Jul 2009
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Thread title only alphanumeric and space

hi...

could someone help me to make the thread title in every new thread can only use "alphanumeric and space" ?

i dont want any special character in the thread title.

thanks alot
Reply With Quote
  #2  
Old 08-26-2011, 06:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Create a new plugin using hook location newpost_process and this code:

PHP Code:
if (!preg_match('/^[A-Za-z0-9\s]+$/'$post['title']))
    
$errors[] = "Only letters, number, and spaces are allowed in title."
Reply With Quote
  #3  
Old 08-27-2011, 03:45 AM
Gripi Gripi is offline
 
Join Date: Jul 2009
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you very2 much
Reply With Quote
  #4  
Old 08-27-2011, 04:20 AM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Create a new plugin using hook location newpost_process and this code:

PHP Code:
if (!preg_match('/^[A-Za-z0-9\s]+$/'$post['title']))
    
$errors[] = "Only letters, number, and spaces are allowed in title."
I think plugin hook should be changed to newthread_post_start

OR

code should be modified to

PHP Code:
iif (!preg_match('/^[A-Za-z0-9\s]+$/'$post['title']) AND $type == 'thread')
    
$errors[] = "Only letters, number, and spaces are allowed in title."

Because the present code will check for new reply also. and generally new reply title are like this

Code:
Re: //title
Reply With Quote
  #5  
Old 08-27-2011, 05:25 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sherif View Post
Because the present code will check for new reply also. and generally new reply title are like this
Good point. But changing the hook to newthread_post_start doesn't seem to work. Your second suggestion works except that you have 'iff' at the beginning (is that a typo?).

Checking for $type == 'thread' will allow any characters in reply titles, but the OP does specifically say "thread titles", so maybe that's OK.

Gripi, sorry for any problems this may have caused on your forum.

Edit: I also figured out that it only quotes the title with "Re:" if you have set the "Automatically Quote Post / Thread Title" to true, otherwise title is blank by default (which also caused a problem since the pattern didn't allow blank titles). So I have the following suggestion (using newpost_process):

PHP Code:
if ($type != 'thread' && $vbulletin->options['quotetitle'])
    
$titlepat '/^(' preg_quote($vbphrase['reply_prefix'], "/") . ')?[A-Za-z0-9\s]*$/';
else
    
$titlepat '/^[A-Za-z0-9\s]*$/';
if (!
preg_match($titlepat$post['title']))
    
$errors[] = "Only letters, number, and spaces are allowed in title."
Reply With Quote
  #6  
Old 08-27-2011, 05:53 AM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Good point. But changing the hook to newthread_post_start doesn't seem to work. Your second suggestion works except that you have 'iff' at the beginning (is that a typo?).

Checking for $type == 'thread' will allow any characters in reply titles, but the OP does specifically say "thread titles", so maybe that's OK.

Gripi, sorry for any problems this may have caused on your forum.
YA ITS IF NOT IIF

PHP Code:
if (!preg_match('/^[A-Za-z0-9\s]+$/'$post['title']) AND $type == 'thread')
    
$errors[] = "Only letters, number, and spaces are allowed in title."

For newthread_post_start hook we need to modify the code to this


PHP Code:
if (!preg_match('/^[A-Za-z0-9\s]+$/'$vbulletin->GPC[subject]))
    
standard_error("Only letters, number, and spaces are allowed in title."); 
Reply With Quote
  #7  
Old 08-28-2011, 04:56 PM
Gripi Gripi is offline
 
Join Date: Jul 2009
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

once again thanks, i'm thinking to put the code in the beta forum this monday, i will let you know if the code works or not.
Reply With Quote
  #8  
Old 10-22-2011, 08:12 AM
Gripi Gripi is offline
 
Join Date: Jul 2009
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi again...

could you please tell me how to automaticly remove any character beside alphanumeric and space in the title when someone post a new thread or a new post?

i dont want any warning error msg, just submit the post / thread to database, and remove any ilegal character.

thanks

--------------- Added [DATE]1319275153[/DATE] at [TIME]1319275153[/TIME] ---------------

and is it possible to make the plugin to work like this:

not just allowing alphanumeric and space, but remove character that i choose.
Reply With Quote
  #9  
Old 10-22-2011, 12:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you want to replace any non-alphanumeric or space chars you can use preg_replace() like:

PHP Code:
$pattern '/[^a-zA-Z0-9 ]/';
$replace ' ';
$post['title'] = preg_replace($pattern$replace$post['title']); 

$replace is a space in that example, you can make it a null string if you want to delete the char instead.

If you want to only eliminate one or a set of chars you could change $pattern to a list of the chars to delete, like:

PHP Code:
$pattern '/[@#*$]/';
... 
Reply With Quote
Благодарность от:
Simon Lloyd
  #10  
Old 10-23-2011, 06:12 PM
Gripi Gripi is offline
 
Join Date: Jul 2009
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you
Reply With Quote
Reply


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 11:16 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.06760 seconds
  • Memory Usage 2,276KB
  • 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
  • (1)bbcode_code
  • (8)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete