Include function help

Discussion in 'PHP' started by simon369, Sep 23, 2007.

  1. #1
    Can the include function be used to grab files which arnt on the main domain

    E.g. i have a proxy and it loads most of the variables from /config.php

    I want it to load others from simon369.info/whatever.php

    Can i have a mixture of things loading from different places

    At the moment it uses <?php echo($net); ?> to grab information from the /config.php file

    What code would i place to get it to grab information from certain other files e.g. for footer. I want it to grab information from simon369.info/footer.php so i can update them all at ones

    Please help me

    Thanks
     
    simon369, Sep 23, 2007 IP
  2. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can only include local files. Unless they are on the same server, you will have to do something else. You can do it even though the scripts are on different websites but still reside on the same physical server. Just use absolute paths.

    If they are on different servers and you call them via http they will be parsed by the webserver before your script gets them.
     
    tamen, Sep 23, 2007 IP
  3. simon369

    simon369 Active Member

    Messages:
    1,712
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #3
    How would i go about the following:


    If they are on different servers and you call them via http they will be parsed by the webserver before your script gets them

    Thanks
     
    simon369, Sep 23, 2007 IP
  4. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't really understand your question. But I can tell you how I send info between PHP-scripts.

    If I have a script that needs to send some info to another script on another server. I put the info in an array, like this:

    
    $config = array();
    $config['someinfo'] = 'Something in here';
    $config['someotherinfo'] = 'Something intirely different in here';
    
    PHP:
    And then serialize it and url encode it.

    
    $config = urldecode(serialize($config));
    
    PHP:
    Then send it to the other server, or just give it to the script when it requests it via curl, or something similar.

    On the other server the script unpacks $config like this:
    
    $config = unserialize(urldecode($config));
    
    PHP:
    And has the same array as the first step has.

    Be careful though, there is no encryption so everything is send in clear text.

    Hope this helps.
     
    tamen, Sep 24, 2007 IP
  5. ErectADirectory

    ErectADirectory Guest

    Messages:
    656
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Text in the footer could easily be scraped and displayed using file_get_contents() or cURL

    As for your config files that need to pass variable information, my suggestion would be to set up a cron job to scrape every so often (1 minute / 1 hour / 1 day) using one of the above methods. This file must be in text, not just the .php page that will render nothing after being processed on the server. From there you can save that text on your local server and name the file with a .php extension ... that file can now be called locally and the variables inside it used.

    I've never tried that specifically but I can't see any reason that would not work in this situation and it would only take minimal time to implement.

    Do yourself a favor and don't do this with sensitive information that you wouldn't want others to see. Basic config stuff should be fine but I wouldn't want my db login information floating around the internet.
     
    ErectADirectory, Sep 24, 2007 IP
  6. simon369

    simon369 Active Member

    Messages:
    1,712
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Thanks for your help and it wasnt secret information

    it was only the footer i wanted doing and also a bar with all the sites in my proxy network on

    Thanks a lot
     
    simon369, Sep 24, 2007 IP