Google maps BBCode

mastram

New Member
Version: 3.7.x

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:

usmapes.jpg





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

tot='{param}';
tot=tot.substr(tot.indexOf("src="")+10,tot.length);
url=tot.substr(0,tot.indexOf("""));
urlp=url.replace(/;amp;/g,';');
url=urlp;

if (checkURL())
{   
    document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+url+'"></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>
Hope it helps!
 
Top