Tag: php
PHP – first day of the current month
by Jay on Aug.20, 2010, under PHP
A really quick post mainly for myself, because I will need to remember this at some stage in the future
$startDate=date(“Y-m-d”, strtotime(date(‘m’).’/01/’.date(‘Y’).’ 00:00:00′));
Enjoy!
Getting GPS Data out of your images
by Jay on Jul.21, 2010, under PHP, jQuery
Privacy is important
Your privacy is a big deal. Be it in the physical world or in the virtual world. The unfortunate thing is that because browsing the web can be done in solitude, personal privacy tends to be an after thought. Not too mention that nearly everybody in the western world has access to an internet connected device.
When you take a photo on one of the latest digital cameras, or from a smart phone and if the device has GPS functionality, it can be assumed that the photo has been tagged with the location of where it was taken. This information is stored in a data format call EXIF. You can read all about it here and here.
It is not a huge leap of the imagination that if your photos are published on the internet ( which is public and not private ) that you are enabling others to track your movements without your expressed informed consent. This information can be used against you aswell as for you. The question should arise of how to manage your online profile. I will cover this topic in a later post.
GPS Data
Photo location is encoded using the Global Positioning System. This is a network of satellites orbiting the globe which return positions of devices which request it. If you would like to know more about this see here.
Do your uploaded photos hold GPS data?
There are loads of web apps out there that will answer this question for you. In the spirit of DIY and because I like to program, I decided to put together my own image information parsing system. You can see it in action here. This basically reads the EXIF data from an image supplied via a URL to the image in question.
Next steps…
As you see from the lab, the system generates a link to the search page on http://maps.google.com/ When time permits, I will add a Google Mapping feature which will display the position from the image on a Google map. Watch this space.
This little web app is built using the ExifReader.php class from quiteless.com. You can get it here. It is an elegant PHP class which is now part of my library. Thank you Steve! (quiteless.com)
As always, feedback and comments are more than welcome!
Enjoy!
Cannot use object of type stdClass as array
by Jay on Jul.19, 2010, under PHP, Technology
Problem
I was getting this particular error when decoding JSON data block from a web service.
It basically is trying to assert that the data block is a different type to the variable which it is being assigned to.
Meet solution
Explore the data dump by using something like
echo ‘<pre>’; print_r($dataDump); echo ‘</pre>’;
and you will see the different data types for example:
stdClass Object ( [acc] => Array ….
Drill down through the structure to the data you want and check the data type of it. To prevent this error, simply apply some Type casting during the variable assignment. Bada-bing… problem, meet solution.