Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2002, 06:05 AM
Palmer ofShinra's Avatar
Palmer ofShinra Palmer ofShinra is offline
 
Join Date: Oct 2001
Location: Vancouver, BC, Canada
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 02-28-2002, 09:55 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where is the glow code defined? From the CP or directly in the code?
Reply With Quote
  #3  
Old 02-28-2002, 12:32 PM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 02-28-2002, 12:35 PM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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

Thanks!
Reply With Quote
  #5  
Old 03-03-2002, 06:24 AM
Palmer ofShinra's Avatar
Palmer ofShinra Palmer ofShinra is offline
 
Join Date: Oct 2001
Location: Vancouver, BC, Canada
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 03-03-2002, 08:49 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);

?>
Reply With Quote
  #7  
Old 03-04-2002, 10:31 AM
Palmer ofShinra's Avatar
Palmer ofShinra Palmer ofShinra is offline
 
Join Date: Oct 2001
Location: Vancouver, BC, Canada
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 03-04-2002, 11:23 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you globalize $bbuserinfo in bbcodeparse2()?
Reply With Quote
  #9  
Old 03-05-2002, 04:29 AM
Palmer ofShinra's Avatar
Palmer ofShinra Palmer ofShinra is offline
 
Join Date: Oct 2001
Location: Vancouver, BC, Canada
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)) { 
Attached Images
File Type: jpg pic1.jpg (3.2 KB, 0 views)
Reply With Quote
  #10  
Old 03-05-2002, 02:07 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($bbuserinfo[disablecodes]) {
        
$bbcode preg_replace("/\\[(\\/?)glow(=[^\\]]*)?\\]/siU"""$bbcode);
      } 
vBulletin removes some \ so \] became ] which ruined the regex.
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 07:37 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.05110 seconds
  • Memory Usage 2,289KB
  • Queries Executed 14 (?)
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
  • (6)bbcode_php
  • (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
  • (1)postbit_attachment
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete