vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Stripping text... (https://vborg.vbsupport.ru/showthread.php?t=35521)

Palmer ofShinra 02-28-2002 06:05 AM

Stripping text...
 
Well... we use the notorious [glow] code over on our forums.... which a sizable number of people love

And an equal number hate.

So to cater to both sides... I'm making a tiny hack to let people turn it off.

Basically... what I need... is whatever little snippet of code it is that will strip

[glow=color] and [/glow] out of posts before parsing.

Mind you, it has to compensate for 'color' being most anything.

I'm sure it has something to do with regexes... and those still hurt my head.

So umm... help?

Admin 02-28-2002 09:55 AM

Where is the glow code defined? From the CP or directly in the code?

Reeve of shinra 02-28-2002 12:32 PM

Glow was added as a vb tag through the the CP....
We are using the one listed in the thread by Ozone over at vb.com.

Reeve of shinra 02-28-2002 12:35 PM

actually here's the link, its the first post.

http://www.vbulletin.com/forum/showt...threadid=24595

Thanks!

Palmer ofShinra 03-03-2002 06:24 AM

I don't see how the code is defined mattering at all...

All I need is the commands to remove [glow=color] and [/glow] from the message body...

Then i'll slide it into bbcodeparse2 and have it triggered by the user option being set.

I have a very clumsy kludge in place at the moment, which siomply skips parsing the glow code specifically.

But then that leaves the unparsed code in the post, which looks bad.

Admin 03-03-2002 08:49 AM

This should work:
Code:

$text = preg_replace("#\[(/{0,1})glow(=[^\]]*){0,1}\]#i", "", $test);
Yup:
PHP Code:

<?php

$text 
'[glow=color]blbla[/glow] some more and [glow=color]blbla[/glow]';

echo 
preg_replace("#\\[(/?)glow(=[^\\]]*)?\\]#i"""$text);

?>


Palmer ofShinra 03-04-2002 10:31 AM

Thanks... except it doesn't seem to be working.

I put this line into the bbcodeparse2 function in functions.php
PHP Code:

      if ($bbuserinfo[disablecodes]) {
        
$bbcode preg_replace("#\[(/?)glow(=[^\]]*)?\]#i"""$bbcode);
      } 

DIsablecodes is a new user option field I added and I know it works because my previous kludge works (just badly)

But for some reason, the above line (even using the other regex... you have 2 different regexes in your post) fails to have any effect whatsoever.

I hate regexes

Admin 03-04-2002 11:23 AM

Did you globalize $bbuserinfo in bbcodeparse2()?

Palmer ofShinra 03-05-2002 04:29 AM

1 Attachment(s)
Yeah... because a different snippet of code using that same bbuserinfo field DOES work...

However, it leaves the unparsed code visible in the post, as shown in the attachment.

PHP Code:

      if ($bbuserinfo[disablecodes]) {
        
$disablesql="WHERE candisable=0";
      } else {
      
$disablesql="";
      } 

THAT code works, and in the end produces the effect shown in the attachment... namely that certain codes aren't pulled from the DB and thus not parsed.

However, this code does nothing

PHP Code:

      if ($bbuserinfo[disablecodes]) {
        
$bbcode preg_replace("/(\[)(glow)(])(\r\n)*([^\"]*)(\[\/glow\])/siU"""$bbcode);
      }

// #\[(/{0,1})glow(=[^\]]*){0,1}\]#i      
// #\[(/?)glow(=[^\]]*)?\]#i 

(the 2 comment lines are other regexes that didn't work as well)

The line is inserted into the function just before this:
PHP Code:

      $bbcodes=$DB_site->query("SELECT bbcodetag,bbcodereplacement,twoparams FROM bbcode $disablesql");

      while(
$bbregex=$DB_site->fetch_array($bbcodes)) { 


Admin 03-05-2002 02:07 PM

PHP Code:

if ($bbuserinfo[disablecodes]) {
        
$bbcode preg_replace("/\\[(\\/?)glow(=[^\\]]*)?\\]/siU"""$bbcode);
      } 

vBulletin removes some \ so \] became ] which ruined the regex.


All times are GMT. The time now is 08:11 AM.

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.01866 seconds
  • Memory Usage 1,743KB
  • 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
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete