Version: 1.1, by oasi
Developer Last Online: Dec 2008
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(/"/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.
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
How does it confirm that it is a valid googlemaps 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?
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.
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;}
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.
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.
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?
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 googlemaps 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