View Full Version : XML php file help

10-10-2009, 04:16 PM
I created XML php file to generate some data from database, and then use it on website. I'm wondering is there a way to limit execution of that .php file so that only scripts from specific servers can reach that XML file.

Of course there will be some public RSS feeds generated with public XML file, but also i would like that some of the content from specific files can only be accessed from server.

This is how i generate XML file..

header ("Content-Type:text/xml");
print '<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="xsl.xsl"?>';
print "<users>";
$users = array("dave", "franco", "mccloud");

foreach ($users as $user) {
print "<name>$user</name>";

print "</users>";

i would like to deny outsiders access to this script, and allow it only for scripts from my server.

there is .htacess solution, but i'm wondering is there PHP one. also, i know about sessions, and "login" part of XML is protected but for some of the public xml like comments or similar.. well you know what i mean...

10-10-2009, 08:09 PM
it's the same as the .htacess solution.
just look here: http://php.net/manual/en/reserved.variables.server.php

you can use 'REMOTE_ADDR' to specify your servers, any other ip's will get rejected.