Jump to content

PHP include() and require_once()


azampagl

Recommended Posts

So here is my question / problem...

 

I have an external site (let's call it site 1) that needs to remotely connect to an Access Database on a remote server (lets call it site 2).  This access database can only be accessed by scripts on the server (its in a secure, non-public directory).  My thought was just create a PHP script on the remote server (site 2) which let me access the information I needed through a function, and I would use another php script with the include or require once function to access it (on site 1).

 

So what I'm getting at... Any one know any good tutorials for making secure SSI for remote access.

Link to comment
Share on other sites

include() and require_once() are not really appropriate here.  In any case, all you will be able to access is the output of the remote script, not the functions within the script.

 

What you can do however, is have the remote script take the necessary arguments, and return the output your script needs.  So the script itself is like a single function (or many functions, with an argument to select which function).

 

The simple method here is to use functions like file("https://remotesite.com/script.php?arg=foo"), providing your php supports https wrappers.  The more complex but more configurable method is using Curl (about which much information can be found through google, and in the forum here).

Link to comment
Share on other sites

you want to call the php page on the second server from the first server using the file_get_contents() php function:

http://us2.php.net/manual/en/function.file-get-contents.php

 

if that doesn't work on your server because 'fopen wrappers have not been enabled', then use the curl library to make the call to the second server:

http://us2.php.net/manual/en/ref.curl.php

The advantage to using curl functions is that you can encode normal form fields to send as your security tokens which will keep them off the url.

 

if you are returning quite a bit of data, you might consider wrapping it up in xml before transmittal using the simpleXML functions:

http://us2.php.net/manual/en/ref.simplexml.php

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.