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 05-05-2005, 12:30 AM
Jenta Jenta is offline
 
Join Date: Dec 2004
Posts: 377
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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]
Reply With Quote
  #2  
Old 05-05-2005, 07:03 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wouldn't it be easier to use .htaccess to do this?
Reply With Quote
  #3  
Old 05-06-2005, 08:06 AM
Jenta Jenta is offline
 
Join Date: Dec 2004
Posts: 377
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 05-06-2005, 10:24 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hold on, you're NOT trying to stop people hotlinking your images, but rather stop your site from hotlinking to other sites images?
Reply With Quote
  #5  
Old 05-06-2005, 01:02 PM
Jenta Jenta is offline
 
Join Date: Dec 2004
Posts: 377
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 06-24-2005, 03:38 PM
Ratchet Ratchet is offline
 
Join Date: May 2002
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
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 01:06 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.07976 seconds
  • Memory Usage 2,218KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete