Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing own headers on HTML 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'd like to make it so that everyone one of my clients sites have a standard header forced on them. ie, banner at the top or a title change.
I have not seen how to do this, if it is possible, or not possible let me know nick@2pscash.com
 
Good luck! I asked the same question a month or so ago, and no one's been able to respond. I thought to ask the Geocities WebMasters, as they seem to do that sort of thing, but have had no luck on that front either. If/when I find out, I'll let you know! :^)

-Ted
-Teddy L. Biesecker, Jr.
Web System Analyst
HQ USSOCOM, MacDill AFB, FL
webmaster@socom.mil
 
Well, without doing any deep research on this, my first response would be to use mod_rewrite to change the requested URL to the url of a frameset or multiple SSI page that contains your header and the original requested URL. There might be a better way, but the mod_rewrite options would be able to to this for you.

Goto: to learn more about mod_rewrite.
 
I believe there might be some confusion regarding the difference between HTTP headers, and the concept of *prepending* a header file on top of all existing files as they are requested.

When discussing webservers and 'headers', that usually means HTTP headers, which are invisible to the viewer, but tell the requesting agent, such as a browser, what type of file this is, and whether it requires authentication, etc... I say this because Apache has a module called mod_headers, which deals with HTTP headers, and thus is not what you are looking for.

Apache doesn't have a standard PREPEND directive, but if you install PHP (mod_php), then in the php.ini file, you can specify a standard prepended file. If you want all .html and .htm files to have this, you must set up httpd.conf to parse those file types as if they are .php files.

However, generally when one wants to prepend some HTML at the beginning of every requested web page, it is in a controlled situation where all the files are written by one team, thus they purposely leave out the <html><head> and <body> tags at the begining, because those are handled by the standard prepended header file. In your case, that wouldn't work, so you would end up with files having two <html> and <body> tags, among others.

So you see that your solution is not that simple. It is possible to make that prepended file include contain some PHP code which will place your banner ad content after the <html> and <body> tags, but it will take a bit of work to perfect it. I suggest you continue this discussion in the PHP forum, if you really want to pursue it.
 
I've never thought of doing it the way rycamor suggested, but that would work pretty slick (in fact I might have to impliment it on some of my VHosts). The only concern that I would have with doing it this way is if your clients are uploading their own files. With the server parsing every file for PHP, a client could possibly upload a file with a destructive PHP script and cause some damage (deleteing files, overloading the cpu, filling up diskspace, etc). If you are doing all the file management, then there should be no problem. But if your clients are doing their own file management, then I would definatly look into some type of security precautions to make sure that nothing bad will happen.
 
You should read the PHP docs on 'escapeshellcmd', and 'htmlspecialchars'. What you really want to do is *always* check for the &quot;<%&quot; opr &quot;<%php&quot; string and if it exists, either delete it or convert it to an HTML character with htmlspecialchars (and don't forget the &quot;%>&quot; string either.

I recommend also setting up php.ini to require 'strict' PHP tags: &quot;<%php&quot;, not &quot;<%&quot;, so that if anyone wants to use XML in the browser (<%xml), you won't run into trouble.

If you optimize PHP, especially with the Zend optimizer and Cache, you will probably see almost no performance hit from doing all this.

Also, PHP has quite a few other features (including auto_append, to add to the end of the document). If you implement your standard prepended header, you then have opportunity to do many other cool things, such as logging, statistics, cookie/session management, etc... You could even give your customers a few special server-side actions, with custom tags; since your prepended file is always reading the file contents anyway, it could check for special tags and do certain carefully controlled options, such as includes, news feeds, etc... (definitelly use Zend cache if you are doing this)

Sound like fun?
 
sigh... I meant &quot;<?&quot;, &quot;?>&quot; &quot;<?php&quot;, and &quot;<?xml&quot; (it was a late night).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top