PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > avoid calling php script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
avoid calling php script

Réponse
 
LinkBack Outils de la discussion
Vieux 13/03/2008, 03h55   #1
H u g o H i r a m
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut avoid calling php script

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.
  Réponse avec citation
Vieux 13/03/2008, 04h36   #2
John Comerford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] avoid calling php script

May the get_Browser function could tell you if it's from the .swf ?

http://us.php.net/manual/en/function.get-browser.php


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.
>


  Réponse avec citation
Vieux 13/03/2008, 05h15   #3
Steve Edberg
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] avoid calling php script

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

--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center sbedberg@ucdavis.edu |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
  Réponse avec citation
Vieux 13/03/2008, 05h20   #4
Wolf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] avoid calling php script

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.
>

Install Firebug extension for your Firefox browser
Load your page in the browser with firebug running
Watch the calls being made and that should answer the question

You can also look at the web server logs to see which page is calling
your script.

Wolf

  Réponse avec citation
Vieux 13/03/2008, 21h38   #5
H u g o H i r a m
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] avoid calling php script

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
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h02.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14589 seconds with 13 queries