vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Miscellaneous Hacks - Replace threadpost characters (https://vborg.vbsupport.ru/showthread.php?t=144585)

kenfuzed 04-10-2007 10:00 PM

Replace threadpost characters
 
Recently I was in search of a way to replace or restrict the use of non-alpha characters used in thread titles. This is useful when adding your thread titles to a welcome header or other area where these characters would look out of place (i.e. '!' or '?' placed mid sentence).

The following is a manual addition of code which will replace specified characters with whatever you want.

Start by finding /includes/class_dm_threadpost.php
You may want to make a backup copy of this file in case you blow things up :eek:

Open class_dm_threadpost.php in an editor and find the following code:

Code:

// replace html-encoded spaces with actual spaces
$title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);

If you only want to replace the characters '?' and '!' with a space, then below the above code you would add:
Code:

$title = preg_replace('/[\?\!]/', ' ', $title);
NOTE: DO NOT delete or change the first piece of code. It is there to prevent html from being added to thread titles. Add all additional code under it.

Between the [brackets] only add the characters you wish to have replaced when a user types it into their thread title. Separate each character with a backslash.

I personally didn't want to see anything except alpha-numeric titles so I included just about every character. The first part replaces the specified character with a space. The next part I added replaces each specific character with a corresponding word (i.e. '&' is replaced by the word 'and').
Below:
Code:

// replace html-encoded spaces with actual spaces
$title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);

I added:
Code:

// replace special characters with actual spaces
$title = preg_replace('/[\?\!\#\$\%\^\*\~\|\:\;\...]/', ' ', $title);
// replace special characters with...
$title = preg_replace('/[\@]/', ' at ', $title);
$title = preg_replace('/[\+]/', ' plus ', $title);
$title = preg_replace('/[\=]/', ' equals ', $title);
$title = preg_replace('/[\&]/', ' and ', $title);

Special thanks to Oleg for helping me locate where to find this file/code.

Hornstar 04-12-2007 12:58 AM

Nice work, i think i may leave this for now tho. dont feel like editing any core files currently lol

gforce75 08-01-2007 11:55 AM

Good Concept. Thanks.

caggla 07-10-2008 02:07 PM

works on 3.7.
thanks


All times are GMT. The time now is 02:31 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01386 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete