How make this code in phalcon?
$domain = parse_url($_SERVER['HTTP_REFERER']);\n
$domain = $domain['host'];
if($domain != $_SERVER['SERVER_NAME'])
die();
I want to Ajax requests were only available with the local domain...but code not work:
class AjaxController extends AjaxResponse
{
public function initialize()
{
$request = new Phalcon\Http\Request();
$host = $request->getHttpHost();
// return string(10) "localhost3"
$referer = $request->getHTTPReferer();
// return string(0) ""
die(var_dump($referer));
}
public function indexAction()
{
$this->view->disable();
die("0");
}
public function authenticationAction()
{
$this->setJsonResponse();
return array("ajax" => false, "details" => "test" );
}
public function dAction()
{
$this->setJsonResponse();
return array("ajax" => false, "details" => "test" );
}
}
Maybe there are other ways to improve the security of ajax requests?