splash
Welcome
Here is where you could put something about you. You can edit this text in "featured-block.php" in the theme directory.
No Post Found. Add the tag featured to the post you want displayed here.
This will pull the latest post tagged featured.
 

Archive for February, 2009

Google Map Tip: Prevent direct linking to your XML data

Posted By bran on February 13th, 2009

I have been recently working on a project integrating Google Maps API. It’s pretty straight forward and Google provides an excellent documention.  After working with the API and developing the custom mapping application, I noticed that the implemention exposes the name of the data file (xml, csv, text, etc) in the JavaScript code, example below (can be seen by viewing page source):

        GDownloadUrl("address.xml", function(data) {
...
)}

Notice the bold area. “address.xml” is the file that contains all the xml data that has been collected and organized. I can pretty much download the file by entering in my address bar:  http://root url/address.xml. Voila, I have basically ripped off someone else’s data to be used as I see fit. Perhaps to create my own map!

I personally do not want to expose the location of my data file and allow others to download it.  To get around this issue, I have implemented a simple solution.

Rather than “address.xml”, I have created a new separate .php file. Let’s call it address.php. In that file, I check the referrer information to ensure that the request comes from the proper location. If it does, write the xml contents. If not, redirect them somewhere else.

<?php

    // prevent direct linking to xml files

 if($_SERVER['HTTP_REFERER'] != '') {

          $xml_string = file_get_contents("xml_location/address.xml");

        echo $xml_string;  

 }else{    
     // redirect them somewhere if they try to direct link to this page
      header( 'Location: http://www.google.com' ) ;

 }

?>

For the Google map, replace xml file with php file

GDownloadUrl(“address.xml“, function(data) {  to:  GDownloadUrl(“address.php“, function(data) {

Simple as that. So if a curious viewer decides to enter “address.php” into there browser, they won’t get any data, just be redirected to some location you decide on.

There are also other ways to do this but IMO this is probably the simplilest and most effective.

Posted in tech

Toronto Food Trends

Posted By bran on February 4th, 2009

I’ve noticed that Toronto is a city of trends, especially when it comes to food takeout There’s always times where a certain type of food is suddenly hot and popular and takeout shops start to pop up everywhere

  1. Pizza. The original take out food and still stands the test of time. The only real changes are that there are more “gourmet” varieties around with special cheeses, breads and weird combos of meat and vegetables.
  2. Wraps/Pitas. I remember when they were so popular after a night out at the bar. Exteme Pita, Mega Wraps and clones started to pop up everywhere pitching healthy eating. They seemed to kind of die out but I guess people realized that you could buy the ingredients at a grocery store and make it exactly the same at half the price.
  3. Sushi. Enough said. So many out there it’s hard to tell which one is good.
  4. Asian Fusion. Add chicken, noodles, peanut sauce with big plates and you have a new restaurant.
  5. Salad Places. Nothing better to capitalize on trendy Toronto then healthy $10 salads!
  6. Burritos. Burrito Boyz is the king right now, but the service sucks and it’s not worth a 45 minute wait.
  7. Shawarmas. It’s almost a revival to the old wraps/pitas trend but with one huge difference, hummus.

So what’s the next trend? Rotis? Poutine?

Always use server side scripting extensions

Posted By bran on February 4th, 2009

Just a quick tip for all the web designers/developers who do not really program in a scripting language (php, asp, jsp, etc) and mainly stick with HTML (client-side scripting). Assuming your server handles it, when creating your page, always use the server-side scripting (.php, .jsp, etc), and don’t use .html. Even if don’t plan on adding or perhaps never will add any server side code to your page.

Why should you do this even though you don’t actually utilize any programming on the page?

  • Browsers cache pages. if a returning visitor comes back to that same page and you’ve made some changes to that page, that person may not see the change. They will only see their saved cache version. Yes there’s meta tags and tricks to try to get around it but it’s not guaranteed and not a very elegant solution. Server side scripting pages always serve up the latest content because when viewed because at each call to the page, the
  • Don’t pigeon hole yourself. You never know when you may actually use some scripting on the page. If you suddenly need to add some scripting in the future, you’ll have to delete that page and create a brand new one.  Say goodbye to any links you’ve established with the client-side language pages.
  • More powerful, flexible and gives you room to grow and learn. Similar to the above, it just gives you more options. Simple as that. It can also inspire you to learn some programming and more creative/advanced techniques in regards to web development.

In my opinion, creating standard client-side .html pages is basically useless nowadays and prevents your site from growing.

Special thanks to freddie.ca who inspired me to post this.

Posted in tech