Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Google maps BBCode Details »»
Google maps BBCode
Version: 1.1, by oasi oasi is offline
Developer Last Online: Dec 2008 Show Printable Version Email this Page

Category: BB Code Enhancements - Version: 3.7.x Rating:
Released: 10-15-2008 Last Update: Never Installs: 86
Re-useable Code Translations Is in Beta Stage  
No support by the author.

Hi all

I've made a Custom BBcode to be able to insert any kind of google map into the forum posts, so the Plugins I tried were'nt working as we expected.

I post the code, I hope it can be useful for anyone.

Security problems, improvements and tunning will be apreciated...

I used the tag [gmap], and inside you have to copy the code for the HTML inclusion you can copy when you click the link icon in the map:



Code:
<script type="text/javascript">
function ckURL()
  {   if ((u.indexOf("http://")!=u.lastIndexOf("http://"))||u.lastIndexOf("http://")!=0){return false;}
      if (u.indexOf('"')>=0) {return false;}
      if (u.indexOf("http://maps.google")!=0){return false;}
      return true;
  }

t='';incr=0;t_i="{param}";
t_n_q=t_i.replace(/&quot;/g,'"');

if(t_n_q.indexOf("91;url")>0)
{ if(t_n_q.indexOf('91;url="')>0){t=t_n_q.substr(t_n_q.indexOf('91;url="')+8,t_n_q.length);t_n_q='';}
  if(t_n_q.indexOf('91;url=')>0) {t=t_n_q.substr(t_n_q.indexOf('91;url=')+7,t_n_q.length);t_n_q='';a=t.replace(/93;/g,'"');t=a;incr=2;}
  if(t_n_q.indexOf('91;url')>0)  {if (t_n_q.indexOf('93;')==(t_n_q.indexOf('91;url')+8)){t=t_n_q.substr(t_n_q.indexOf('91;url')+11,t_n_q.length);a=t.replace(/91;/g,'"');t=a;}}
}
else
{ t=t_n_q.substr(t_n_q.indexOf('src="')+5,t_n_q.length);}
u=t.substr(0,t.indexOf('"')-incr);
up=u.replace(/amp;/g,'');u=up;

if (ckURL())
{ document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+u+'"></iframe>');}
else
{document.write("<p><b>Wrong map URL, edit the post to change it.</b></p>Reload the page when finished to check if correct.");}
</script>
The others settings for the BBCode are:

Use {option}: -> No
Remove Tag If Empty -> Yes
Disable BB Code Within This BB Code -> Yes
Disable Smilies Within This BB Code -> Yes
Disable Word Wrapping Within This BB Code ->Yes

Please, mark as installed if it worked and you are using it.

Hope it helps!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #82  
Old 11-04-2008, 01:41 PM
Leo Brazil's Avatar
Leo Brazil Leo Brazil is offline
 
Join Date: Dec 2007
Location: Brazil
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oasi, after giving you some headaches to fix it and now that's is working great....

....I was thinking to my self yeasterday....How about to improve this BBCode or even a new one ? I mean, how about to include Google Earth on it ?

Just an idea...lol...
Reply With Quote
  #83  
Old 11-15-2008, 03:34 PM
mattcaswell mattcaswell is offline
 
Join Date: Aug 2006
Location: Mesa, AZ
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oasi View Post
I don't know why your gmap pasted code isn't chaged to html chars...

" should be &quot;
< should ve &lt;

An easy "fix" would be to change this line in the code:

t_i="{param}";

to

t_i='{param}';

But if could fail if there is some ' char into the code of the map...

Try it...
This was the only way I could get this to work on my system. Thanks for all your hard work!

matt
Reply With Quote
  #84  
Old 11-19-2008, 06:01 PM
CThiessen CThiessen is offline
 
Join Date: May 2007
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,
I head the following Problem .
If I test this BBCode in my "Admin Only" Part of the Forum everything was OK.
If I copied the Post to the Forum where I make Announcements it stops working.
Long time ago I set up this Forum with the Possibility of the use of HTML
this is not working together with this BBCode.
Just to let you know, maybe helps somebody if this is not running.
Best regards
Christian
Reply With Quote
  #85  
Old 11-20-2008, 06:32 PM
aciurczak aciurczak is offline
 
Join Date: Jun 2005
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How does it confirm that it is a valid google maps code? Looking at the code, one of the checks seems to be that the URL starts with http://maps.google, and it also confirms that there isn't any other http:// within the code. But if someone posted something like http://maps.google.evildomain.com, would that fail this check or would it be approved?
Reply With Quote
  #86  
Old 11-24-2008, 05:40 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

->Christian,

Could you copy the generated code to see what's wrong?

->aciurczak

The check would fail with the URL you posted, I know that this is not perfect :P
If you try to get a better security check for this please post it here to share it with us.

Thanks!
Reply With Quote
  #87  
Old 11-24-2008, 06:22 AM
aciurczak aciurczak is offline
 
Join Date: Jun 2005
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oasi View Post
The check would fail with the URL you posted, I know that this is not perfect :P
If you try to get a better security check for this please post it here to share it with us.
Hi Oasi -

I changed that check to:

PHP Code:
if (u.indexOf("http://maps.google.com/")!=0){return false;} 
so the code has to include http://maps.google.com/, not just http://maps.google . Still not perfect, but a little better.
Reply With Quote
  #88  
Old 11-24-2008, 06:38 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I hope all your users come from the US or UK ;-)

What about

http://maps.google.it/
http://maps.google.es/
http://maps.google.de/

If all of your users use the .com domain to insert the maps, it's a very valid solution...

Other option would be to check that after the http://maps.google. there are as maximum 4/5 characters, so only a domain could be included, or set an array of valid domains to check that the rest of the URL is one of the domains allowed.
Reply With Quote
  #89  
Old 11-24-2008, 07:20 AM
aciurczak aciurczak is offline
 
Join Date: Jun 2005
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oasi View Post
I hope all your users come from the US or UK ;-)
I'm not worried about anything but .com yet. It will cover 95% of my users, and likely 100% of my users who would be prone to embedding a map. As soon as one of my users tries embedding a google map from a non .com address and runs into a problem, I'll deal with it then.

Also, even if the map or route is not in the US or UK, you can still use maps.google.com to map it or route it. Here's an example route from Berlin to Paris using maps.google.com. Yes, it's in English, but it still works fine.
Reply With Quote
  #90  
Old 11-25-2008, 01:00 PM
zelnik zelnik is offline
 
Join Date: Aug 2008
Posts: 374
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great little code... two questions.

1> Is there a way of adding the directions to the map or a automatic link?
2> Why when i zoom into a map to the highest point can I not use the embed code?

Thanks marked as installed.
Reply With Quote
  #91  
Old 11-26-2008, 06:09 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
1> Is there a way of adding the directions to the map or a automatic link?
I'm not suere if it's that you're asking, but you can add directions, routes or whatever the google maps app let you add. You only have to click the link button when you've finished adding the stuff and put this code into the [gmap] bbcode.

It's not possible to add the link, but you only have to add an html link below...

Quote:
2> Why when i zoom into a map to the highest point can I not use the embed code?
I've been able to add maps with the StreetView inclusive, but it's true that some maps does'nt have the "link" option to add the code to a web or a direct link. You'll have to ask google why, I don't know the reason
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 03:04 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.04622 seconds
  • Memory Usage 2,316KB
  • Queries Executed 25 (?)
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)bbcode_code
  • (1)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete