Click to See Complete Forum and Search --> : includes & variables
harmsen
03-06-2005, 01:00 PM
Hello,
I am attempting to setup a second site that is very similar to my first site. I would like to have a directory on one of the two sites with the scripts that both will use.
For instance, I have a page that includes a title script, a masthead script, a statement to set the $sql variable ($sql="SELECT * FROM table WHERE color='blue'";), and then it calls a script to execute the query and loops to display the results.
This system works just fine for the site that houses the shared scripts, but when I include it externally for the other site (e.g., include 'http://192.168.0.150/sharedscripts/tablescript.php';), the query is unsuccessful. I assume that I have a problem with the $sql variable being available, but not sure how to solve it.
Any help would be greatly appreciated!
ShrineDesigns
03-06-2005, 01:51 PM
if you read up on the limitaion of the inculde() function from the php manual, if the included document is on another server, the document is parsed firstly on that server before being included
http://www.php.net/manual/en/features.remote-files.php
harmsen
03-06-2005, 01:54 PM
ok, gotcha. Same server, different domain.. but apparently there is no way to make this happen? Any ideas on a different strategy?
ShrineDesigns
03-06-2005, 01:59 PM
copy the "shared" scripts to the other site
harmsen
03-06-2005, 05:21 PM
Thanks, I appreciate the responses very much!
Copying the "shared" files to the other site is not going to work in the long-run. There will eventually be 25 sites using the same scripts and I shutter to think about copying the files to all 25 sites each time I make a change.
I did find a workaround.. I converted the shared php scripts to .txt and included them as plain text. They were included in the target domain before they were parsed. Of course, I realize that the information in the scripts isn't really secure, but I think that's alright. The login script is local to each site, so all that I have exposed is the names of the MySQL Tables and Fields.
1. My new question: Is this really dangerous?
2. Can I connect with a secure socket from one site to the other that would protect the .txt files? (I don't have SSL experience, so I'm a bit ignorant on this topic)
ShrineDesigns
03-07-2005, 02:00 PM
Is this really dangerous?yes, this exposes your php code to the internetCan I connect with a secure socket from one site to the other that would protect the .txt files?it won't do you any good, ssl adds a little security for dynamic web pages and nothing for staic web pages
bokeh
03-07-2005, 02:33 PM
If the files are all hosted by the same server you should be able to access them directly. Lets say for example that http://domain1.tld is in the directory apache/httpd/domain1 and http://domain2.tld is in apache/httpd/domain2. The file "http://domain1.tld/index.php" could call the file "http://domain2.tld/other_file.php" like this: include('../domain2/other_file.php'). Or vice versa The file "http://domain2.tld/other_file.php" could call the file "http://domain1.tld/index.php" like this: include('../domain1/index.php'). The above assumes you are in charge of the server and no one has restricted access between these two folders.