I’m new to this forum and new to web programming, but I am trying to learn.
I’m trying to do something and I want multiple web sites on different hosts to be able to draw some common information from a single site.
Not really sure how this can be done, but I’ve looked at this from the perspective of wanting to include one file into another.
That brought me to this:
How do I include one HTML file inside another?
This opened the topics of Server Side Include, CGI, JavaScript, and Perl. I’m also thinking that as it seems to come to using Perl, that I might want to use PHP instead. So I’ve been trying things and reading books.
- <!–#include FILE=“b.inc” –>
This works. I wasn’t sure which extension to use on the file to be included. So I picked .ssi. Looks like there is some acceptance of this.
But then for the file to do the including, one is to set the execution bit or use an extension which indicates that it is to be executed.
I am doing this on free web site hosting accounts so I have no Unix shell login. Not sure how to set the execution bit, but from Unix experience long ago I think it not the same as the permissions mask. I do make sure that I have 755 permissions which does allow execution.
I use the file extension .shtml instead of .html and this seems to work. Server Side Include is already doing a great deal for me in terms of making sites easier to maintain.
- But, Server Side Include does not seem to allow taking stuff off of another server. It does not even seem to allow absolute URLs, even if they just point back to the starting place.
With one free account you get multiple subdomains and they each have their own subdirectories. It does not seem possible to use Server Side Include to get any files from another of the subdomains, instead of those in its own tree.
-
With one server I have not been able to get Server Side Include to work. It looked like it was working. I thought it was. But now it seems to just skip it. No error message, it just skips it. This server has a .htaccess file. So I presume that I need to add something to this file, and maybe make another such file in subdirectories where it is needed?
-
<script src=“b.js” type=“text/javascript”> </script>
I try Notenboom’s next suggestion. Yes, I was able to get a JavaScript file and in that file I used document.write statements to make HTML and this worked. I was able to take the JavaScript file off of another server!
But I was not able to take it off of the Apache server though, as Notenboom says. I did try it.
Didn’t try drawing it in to the Apache server from elsewhere.
JavaScript requires a separate document.write for each line of HTML/CSS?
I tried just including a big block with the carriage returns and it seemed not to work.
- So I want to do something like Notenboom’s CGI method:
use LWP::Simple;
print "Content-type:text/html
";
getprint ($ENV{‘QUERY_STRING’});
We’ll call it “proxy.pl”. Proxy.pl must be appropriately installed on your server into your cgi-bin directory or its equivalent. By being local to your server, Include directives can reference it.
Proxy.pl simply fetches the contents of the URL passed as a parameter. This means we can perform an apache remote include this way:
<!–#include VIRTUAL=“/cgi-bin/proxy.pl?http://example.com/b.inc” –>
So first of all I have had to do some reading to even understand what this all means. I have been reading about Perl and about PHP.
It looks like PHP is on more free web site hosts and looks like maybe more people are using it for somethings today.
Can I do something like above with PHP instead of Perl? Is there any reason I should be learning Perl instead of just PHP?
- So I read about GET and POST, ways to pass data from HTML forms to server scripts. Looks like both Perl and PHP do both just fine. GET is like what Google does, adding characters after the web address, and then they show up in an environment variable. POST uses the Stdin stream. I’m familiar with both of these from decades ago writing C langauge programs for Unix, and also for DOS. Never have liked Windows.
So the above uses GET.
All of the books about CGI talk about it relative to Perl. I even read one book which lists about 8 computer langauges where CGI is also used. But they don’t mention PHP.
Does PHP use CGI, just about the same as Perl? Does it have some other way to do things, so you don’t need CGI? They never seem to talk about it in the PHP books.
-
Looking at what I want, some common HTML to be used by a bunch of sites, all on free hosts, is some CGI and PHP based remote include the way to do it?
-
Microsoft seems to have lots of proprietary programming langauges, protocols, etc. They always have this. I got burned in the late 1980’s with their OS/2. I had lived under the 640k limit for MS-DOS and was ready for something multitasking, with more memory, and with virtual memory and planned to be involved with it. I got burned.
Most of the Microsoft proprietary stuff never seems to work very well and eventually craters.
- Perl seems to allow printing big blogs of text, with the carriage returns, from a signal print statement. You just have to make sure there are no spaces or blank lines. Does PHP allow something like this? Seems like it should.
Thanks