PHP + Flash
Moderator: General Moderators
PHP + Flash
I'm currently making a website entirely out of flash with php for the backend, and I'm fairly new to PHP. Is there any way to tell if a PHP document is being accessed by a flash file to verify if I can pass on the information?
Say flash has to access the file register.php, and it should be able to do so with no problems, however when you go to register.php in your browser, it'll display a message saying you cannot access this page.
Any ideas?
Thanks in advance.
Say flash has to access the file register.php, and it should be able to do so with no problems, however when you go to register.php in your browser, it'll display a message saying you cannot access this page.
Any ideas?
Thanks in advance.
chmod error
try changing the CHMOD permissions
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
There is no error, I think i might have been misunderstood. I have a flash (.swf) file that reads data from a PHP file. I want that flash object to be the only thing able to access the PHP file. So when they go to site.com/register.php it'll say access denied, but allows flash to access it. I don't think I can do this with CHMODS, I was thinking more along the lines of a function in php that tells what is accessing the file, I know there is the $_SERVER['http_user_agent'] but that returns the browser, I wanted something that returns something along the lines of "Flash" or "ActiveX". Any ideas?ole wrote:Specifically, what is the error you get from the web server?
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Yes sorry.There is no error, I think i might have been misunderstood.
Well I don't think that is going to work even if you could get the permissions sorted. The way I understand it, and I may be wrong about this, is that PHP is only executed when requested via the webserver by means of an apache mod or CGI. If you try to access it any other way you will just get source code; its still just a file after all not a binary. For this reason you cannot use flash to execute PHP and get a response. So instead what is done is to request some PHP via a browser and have that generate flash output. Again, I could be wrong, I've no experience of flash with PHP.I have a flash (.swf) file that reads data from a PHP file.
Here's a work around. Make a large string key/token to pass between your action script and your PHP script. So both sides have the key. Using Flash's sendAndRecieve method to pass data, pass the key back and forth. The all you need is a simple if statement in both scripts. It'll work. I use a similar method in a Flash movie I created to stop the movie from playing off server. If it's not playing playing in the browser on my server no play....
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
That is a similar procedure to keeping unwanted scripts from calling your other included scripts. In the calling script (say index.php), I add in a constant, then in the included file, I check if that constant is defined. If so, continue with the script. If not, die.
index.php
include.php
index.php
Code: Select all
<?php
define('IN_SCRIPT', true);
include 'include.php';
?>Code: Select all
<?php
if ( !defined('IN_SCRIPT') )
{
die("You are so not authorized to use this page");
}
?>- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK