Home » Archive

Articles tagged with: script

AJAX, PHP »

[23 Feb 2011 | One Comment | 4,937 views]

If you have an AJAX application that uses a PHP back-end app on a different server as your web front-end server (e.g. load balancing, cdn’s, etc), your PHP script will need to send header variables with the allowed content server name(s).

Web browsers are now following a standard for HTTP Access control to prevent client-side Cross Site scripting attacks.

I tested this with Firefox and it simply blocks the request without any error messages. Google Chrome browser will error out with the following message if the access control origin is not set correctly on your PHP script. (woot!)

“XMLHttpRequest cannot load [PHP URL].. Origin [JAVASCRIPT URL] is not allowed by Access-Control-Allow-Origin.”

For example, if the Javascript is hosted on example.com and your PHP app is on example.org.

Below is the PHP script for fixing this error. [see full message for the solution]

PHP »

[12 Jun 2009 | 3 Comments | 4,716 views]

Here’s what I currently use to determine how long it takes to generate a page in PHP. Its only 8 lines of code.

PHP »

[24 Nov 2008 | No Comment | 4,683 views]

I found a useful script in PHP that can be used for checking uptime of a server. It can be useful for checking when the servers have a such a significant load that pages can’t be displayed. The benefit or running it locally is that I can configure the script to perform failover functionality if necessary. Online uptime services are good too, but most of them aren’t free. Maybe I should force the server to show a failwhale when the site gets too busy… j/k :D

Here’s the link to the script.
http://www.programmingtalk.com/showthread.php?t=34999


// the URL you want to ...