Question on Include Files
Hello. I have a PHP issue and require some assistance. Iím not sure what caused this issue - going from PHP4 to PHP5, or a PHP configuration setting that my web hosting company made. In PHP4 I was able to include a page of code in my web apps that was hosted on another URL by using the following:
require(" http:// myincludes.mysite.com / inc_myfunctions.php "). This allowed me to have all my common functions and components used by different web applications in one location and not have to have a copy of them in each web app directory. If I made a change to a function, or added a function, I only had to do it in one place and the change became available to all my web apps. Now with PHP5, I cannot include a page that resides on another URL. This means that I am going to have to have a copy of all my function pages and components in the directory of each of my web apps Ė And when I need to make a change, I will need to make that change in each location. Does anyone know of a workaround or have an idea of another way to implement this to meet my needs of having them located in one location? Please note that each web app has itís own URL. Any help will be greatly appreciated.
I'd guess they probably turned off the allow_url_fopen setting (or possibly just allow_url_include if using PHP 5.2+). This is generally a wise security measure if you don't have a good reason to allow it, as hackers will often try to inject an include() to their malicious code. Personally, I'd rather come up with a system to copy your include files to the necessary hosts so you don't have to turn off that setting -- perhaps a cron job that periodically looks for updated include files and then FTPs them onto the sites that need them (either one job pushing from your main site, or a job on each other site pulling from the main one). Or just create a deployment script that will FTP all the relevant files whenever you request it after making changes.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)