home

Quickies, by Andrea Olivato

text

Be sure that Ajax calls came from your domain in #php

Useful for be sure nobody steals your resources (cpu ecc) this script checks if the ajax call started from your domain. If not… dies.

$ref_domain = parse_url($_SERVER['HTTP_REFERER']);
if ( $_SERVER['SERVER_NAME'] != $ref_domain['host']) 
    die;

2 years ago

August 24, 2009
Comments (View)