vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   protect a link from str_ireplace (https://vborg.vbsupport.ru/showthread.php?t=191974)

cosy 09-26-2008 01:53 PM

protect a link from str_ireplace
 
Code:

$this->post['message'] = str_ireplace('hello', '<a href="www . hello . com">hello </a>  ', $this->post['message']);
this code is to add a link for certain words in postbit a link the problem is if a link is posted and contain the word "hello" the link get broken
any way to put a "protection" on links ?

Lynne 09-26-2008 02:38 PM

Hi cosy.

The way I work with this is it only does a string replace for words my Mods write and the phrases they use would not be something they would use in the normal course of posting. For example, we have a Band Restriction Policy on our site in the faq. When a Mod refers a user to that page in the faq, all they have to write is the title and my rewrite will make it a link to the faq - Band Restriction Policy.

However! Something else you can do.... I use "str_ireplace" which replaces the string no matter if the characters are capitalized or not. You could change it to "str_replace" and it is more specific. You could make it so people have to post "HELLO" and it gets replaced and most likely that is going to not replace the url (unless it is written as www. HELLO.com).


All times are GMT. The time now is 03:31 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.01121 seconds
  • Memory Usage 1,711KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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