vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   regex help regarding img tags (https://vborg.vbsupport.ru/showthread.php?t=80998)

Jenta 05-05-2005 12:30 AM

regex help regarding img tags
 
to prevent hotlinking to unauthorized domains im trying to limit the img tag to only a couple
mysite.com and somefreeimagesite.com

functions_bbcodeparse.php, you have this
PHP Code:

// do [img]https://vborg.vbsupport.ru/[/img]
        
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_img_match('\\1')"$bbcode); 

i have modified it to this and it makes it so only mysite.com will work
(added www.mysite.com after the http:// part )

PHP Code:

// do [img]https://vborg.vbsupport.ru/[/img]
        
$bbcode preg_replace('#\[img\]\s*(http://www.mysite.com([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_img_match('\\1')"$bbcode); 

how would i go about adding an additional domain?
the urls from the 2nd domain are in this format:
HTML Code:

http://img(somenumbers and other stuff).cx
just making it work with
HTML Code:

http://img
will be fine if thats all that can be done

ideally, i would like for it to jumble up anything posted that does not fit the two formats
like if someone does
HTML Code:

[img]http://google.com/image.type[/img]
it will not parse it but will also replace it with some random characters like
HTML Code:

[img]hqroiqrq9212o424229uy92r2252[/img]

sabret00the 05-05-2005 07:03 PM

wouldn't it be easier to use .htaccess to do this?

Jenta 05-06-2005 08:06 AM

not sure what u mean
.htaccess only stops hotlinking on my domain, not google's, cnn's, etc
unless i am missing something
can u explain?
thanks

sabret00the 05-06-2005 10:24 AM

hold on, you're NOT trying to stop people hotlinking your images, but rather stop your site from hotlinking to other sites images?

Jenta 05-06-2005 01:02 PM

right
other domains

Quote:

to prevent hotlinking to unauthorized domains im trying to limit the img tag to only a couple
mysite.com and somefreeimagesite.com

so if they type some other domain functions_bbcodeparse.php
will jumble things up

i think i see where to do it but any help would be appreciated
its a bit below $bbcode = preg_replace that it actually starts outputting whats shown in the post

btw, i got the first part working by just duplicating that line with the 2nd domain
so i now have 2 $bbcode = preg_replace..... lines one above the other and it works but ????

i was reading for a day trying things and it said the | character is like a either or but when i tried the regex on the single line it did not work
domain1|domain2...rest of line

so now i have to lines with the only diff being domain 1 and domain 2
but its still will allow anything that starts with http://img
would rather it match the http://img (somthing here) .cx

Ratchet 06-24-2005 03:38 PM

We had a problem with this awhile ago with people posting links to innapropriate material. The easiest solution we found was to simply add the domain to the censor list, that way anytime someone tries to post a link to a bad site it just comes out as, for example, http://www.********.com.


All times are GMT. The time now is 04:17 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.01114 seconds
  • Memory Usage 1,730KB
  • 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_html_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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