bushkilldogo Posted January 2, 2008 Share Posted January 2, 2008 Hello, I am currently creating a few sites that I wish to include a set of functions hosted on a separate site so that I only have to update on one site instead of a few. My problem is that when i try to include the file from the remote site, the functions are not read but everything else is... ie... remote file contents ------------------- echo "TEST"; works when I use the include function but when i put it as a function... function doTest() { echo "test"; } then call it on the main site... <? echoTest(); ?> i get "Fatal error: Call to undefined function" how can i fix this? Quote Link to comment https://forums.phpfreaks.com/topic/84112-including-functions-from-another-website/ Share on other sites More sharing options...
trq Posted January 2, 2008 Share Posted January 2, 2008 how can i fix this? You can't. You cannot include functionality from a remote file, only output. Quote Link to comment https://forums.phpfreaks.com/topic/84112-including-functions-from-another-website/#findComment-428146 Share on other sites More sharing options...
bushkilldogo Posted January 2, 2008 Author Share Posted January 2, 2008 wow, now thats not fun. :'( any plans to add this in php later? Better yet is there a workaround? Quote Link to comment https://forums.phpfreaks.com/topic/84112-including-functions-from-another-website/#findComment-428149 Share on other sites More sharing options...
trq Posted January 2, 2008 Share Posted January 2, 2008 any plans to add this in php later? I doupt it, imagine the security implications. Anyone would be able to include functionality from other peoples code base into there own sites. The only real workaround I can see would be using nfs to mount the remote filesystems to a mountpoint on your servers. Quote Link to comment https://forums.phpfreaks.com/topic/84112-including-functions-from-another-website/#findComment-428155 Share on other sites More sharing options...
bushkilldogo Posted January 2, 2008 Author Share Posted January 2, 2008 ok thanks. Quote Link to comment https://forums.phpfreaks.com/topic/84112-including-functions-from-another-website/#findComment-428193 Share on other sites More sharing options...
PFMaBiSmAd Posted January 2, 2008 Share Posted January 2, 2008 By making the file extension something that is not parsed by php, you could do this, but as thorpe has already written, it presents a huge security hole as anyone who finds the files can see the code and data they contain. So, you would not be able to place any security related code or data in the files, such as a mysql username or password or email account information, any security exploits present in the code could be found and used, and things like database table and column names would be exposed which would make sql injection easier. Not to mention that every include using this method on a web page will generate a separate http request to the web server where the files are located, then that web server must serve up the file requested and send it back to the requesting web server, thereby slowing down the loading of the main web page., by a varying amount of time for each include. I suppose you could have the contents encrypted and then decrypt them on the receiving server, but this would increase the size of the data transferred, which would make the loading of the page even slower, and then the decryption would add even more processing time. Short answer - For the include() method (assuming you can work out all the security problems) the small amount of your time you would save by being able to update files on one common site, will be wasted many times over because each time a page is displayed that is including that code, will be slower. You could also write a php script that uses FTP functions to write the files from the common server to each site that needs the files or use FTP to read the files from the common server to each site that needs the files. But, don't try to include() the files remotely. Quote Link to comment https://forums.phpfreaks.com/topic/84112-including-functions-from-another-website/#findComment-428220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.