Friday, April 19, 2013

Get File Last Modified Date-Time

<?php

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}

?>

this file modify date is used for the mobile application to get updates are available or not on the server file.

Get County from User Lat Long

In Mobile application how the server knows about the posted device country and response then as per the location.

Get the current location of the device and use google map api to get user location. Get location from the ipaddress is a worth thing now. because all the internet user use proxy network.

PHP:

<?php

$cur_lat =$_REQUEST['lat'];
$cur_lon = $_REQUEST['lon'];

Stop Copy Text from Phonegap Applications

Hello,

Phonegap application is based on the HTML, CSS and JQuery. So if the user double tap on the app content then it will select the text and give option to copy and select text.

So for the application privacy if app admin does not want to copy application text then here is a way to stop selection of text.

Friday, April 12, 2013

Get Distance Between Two Lat Long

Create function to calculate distance. and pass lat long of first place and second place. and one parameter for the distance type.

function calculateDistance($lat1,$lng1,$lat2,$lng2,$miles = true)
{
    $pi80 = M_PI / 180;
    $lat1 *= $pi80;
    $lng1 *= $pi80;
    $lat2 *= $pi80;
    $lng2 *= $pi80;

Monday, April 1, 2013

Image store in Database.

Get the image URL that you want to store in the database.

$file= "http://sitename.com/image1.jpg";

$imgdata = base64_encode(file_get_content($file));

Above syntax give you a image in encoded formate. Store image data as a text in the database.

Use of image data in html app.
Get data from the database and append "data:image/jpeg:base64," before the data string like below:

data:image/jpeg:base64,imgdata

Use appended string as a source of the image like below:

<img src="data:image/jpeg:base64,skadadjsiweryerjtkHRUWNHDDhASDJKKSDHD=" />

It will display image to the application.. in mobile applications does not need to load image from the server. and its also use for the offline application.