loading
Please wait while loading...

Read more PHP Geo

A nice library to calculate geographical distances for PHP.

example code:

use Location\Coordinate;
use Location\Distance\Haversine;

$coordinate1 = new Coordinate(19.820664, -155.468066); // Mauna Kea Summit
$coordinate2 = new Coordinate(20.709722, -156.253333); // Haleakala Summit

echo $coordinate1->getDistance($coordinate2, new Haversine()); // returns 128384.515 (meters; ≈128 kilometers)
...........

Read more Post request show 404 not found on php with IIS

May related to:
1.
This line in my web.config file was causing the issue:
<trace enabled="true" localOnly="false" pageOutput="false" requestLimit="40" />

2.
I had this same problem. Any PHP POST to another PHP page was hanging. In the process of rebuilding the web.config file from scratch, I found an error message that suggested running the AppPool Managed pipeline mode in Classic mode.
After making the above change, my PHP code is working as expected.

 

 

Reference:
http://stackoverflow.com/questions/4357636/iis7-php-http-post-hang

Read more A nice way to output csv with temporary file

In php programming, we always need to output data with csv format, fputcsv is good function to do that. However, it require a file handler which means you must do fopen to open a file write the content to it. But usually we just need to generate the output file for download and don't need to save in server. Today I find a better way to write csv with php memory as shown below.

// output up to 5MB is kept in memory, if it becomes bigger
// it will automatically be written to a temporary file
$csv = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+');

fputcsv($csv, array('blah','blah'));

rewind($csv);

// put it all in a variable
$output = stream_get_contents($csv);

Read more GD Enhancer

A good php class for image editing

http://www.gdenhancer.com/index.php?content=home

Read more Google Oauth 2.0 ask permission every time

I have made a application using google account for login. Reference to google's example, it's easy make the login work well. However, I'm face to a serious problem that google ask for permission approval every time. For a openid login, like facebook, we will ask permission in the first time only and for the next time, it should automatically complete the login and no need to approve by user again. For this purpose, I search from the internet and finally found the solution as following:

To make the application just ask permission for once, add the following line in the config

$client->setApprovalPrompt(auto);
...........
1 2