Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts

    XML php file help

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

    PHP Code:
    <?php
    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...
    Last edited by funnymoney; 10-10-2009 at 04:18 PM. Reason: code typos

  • #2
    Regular Coder
    Join Date
    Apr 2009
    Location
    somewhere over the rainbow
    Posts
    105
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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.
    :. -= | Eran | =- .:
    __________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •