Jump to content

Cross domain includes


aleX_hill

Recommended Posts

Ok, here is the situation. I have a few sites which all use the same functions (while connected to different dbs) to display content. Instead of updating each site when there is a change, I want to include all the display functions in one file, hosted on a different domain, and include that file on each site.

 

So, being on shared hosting, allow_url_fopen isnt an option.

 

I havent used CURL before, but I tried the code below, but that doesnt work either:

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://myurl.com/functions/siteFunctions1.0.php');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,10);
curl_exec($curl_handle);
curl_close($curl_handle);

 

Is CURL an option for this, or is there another way that I can go about it?

 

Cheers,

Alex

Link to comment
Share on other sites

There is no way of doing this without placing the files in question within a specific drive and network mounting it.

 

Making a request for the file via http will simply have the remote server execute the php and send you the resulting output.

Link to comment
Share on other sites

Well doesnt that suck. I wont be able to mount drives being on a hosted server. Looks like I am stuck with editing 10 files each time I make a small change :(

 

Unless I write a cron to periodically replace the PHP files with the content from the "master" PHP file... now there is an idea

Link to comment
Share on other sites

A better option would be to automate your build process. Assuming your using a version control system (which you should be) it wouldn't be too difficult to ftp or scp your files to each server when there is a commit.

Link to comment
Share on other sites

I dont use a version control system, I just upload the files from dreamweaver. Much of the time there are edits to the other files on the website, ie the actual page structure, css files etc, the only similar file is the one holding the functions.

 

Can you suggest a decent (preferably freeware) version control system for Windows?

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.