Re: avoid calling php script

From: Date: Thu, 13 Mar 2008 20:38:48 +0000
Subject: Re: avoid calling php script
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-271541@lists.php.net to get a copy of this message
HTTP_REFERER will do the job, thanks! Hugo. --- Steve Edberg escribió:
At 3:55 AM +0100 3/13/08, H u g o H i r a m wrote:
Hello I have a swf that runs a PHP script that generates a XML, on the PHP is there any way to detect if the file is being called from the swf or from the browser? because I want to avoid the file being run directly from the browser or from any other file than the swf. regards, Hugo.
You might want to check the HTTP_REFERER value; test the program from a browser and the swf, and see what happens. Alternatively you could use a GET parameter like http://example.com/yourscript.php?calledby=swf Be aware that anything sent back from the client can be spoofed - and HTTP_REFERER can be altered or disabled - so it probably wouldn't be hard for someone to make it appear to your script that it is being called by your SWF. If you're really concerned about restricting the communication between the Flash movie and your server, there might be some way to build a challenge-response mechanism into the flash; I don't know much about it. If, on the other hand, you just don't want to confuse someone who might accidentally run the XML-generating script from the browser, checking a GET parameter as above is probably the safest. If it's not set properly, redirect the user, eg: if (!isset($_GET['calledby']) || $_GET['calledby'] != 'swf') {
      header('Location: http://example.com/thecorrectpage.html');
      exit();
} ...
    - steve


« previous php.general (#271541) next »