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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Included HTML

Status
Not open for further replies.

theniteowl

Programmer
May 24, 2005
1,975
US
Hi All,
I have a PHP driven template system that forces all page requests to a site to be pushed through my own template that handles page layout, sets up the dynamic navigation and then loads the requested page in a content window of the template page.

The content pages are created by faculty members at the school this site is for. My template page contains all of the html, head, body, etc, tags.
If the content creator creates a full HTML page with all of those tags in it and it is included into the body of my template page is that going to cause issues with the browser or later on with any scripts on the pages?

Optimally the content should be created solely as markup to go within the existing body but I have no control over what they eventually do and wonder what problems are likely to occur if any.


At my age I still learn something new every day, but I forget two others.
 
Well, technically it will probably render ok in most of today's browsers, though any of the rendering issues that you might experience could originate from the duplicate tags. I would suggest going against that, especially since it is pretty simple to do so. Just read whatever the people post and strip the tags you don't like -- use strip_tags().
 
If you are doing what I think you are doing can I urge you to be very careful regarding security.

I once managed a site that did what you describe. Each page was actually called into the same script which acted as a wrapper - providing the html, head tags etc.

When viewing logfiles I would always find instances where people were using the master template to call in pages from outside domains. These pages often contained a number of "tools" that would attempt to compromise the server.

So, make sure you do a check to ensure that only pages from your domain are loaded into the master template.

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Earl & Thompson Marketing - Marketing Agency Services in Gloucestershire
 
It looks like strip_tags() will only strip the tags themselves but not any content contained within them which could cause all the content between those tags to render as text on the page.
I think what I would need to do is parse out the page grabbing only the content contained within the body tags and discarding the rest.
I have very little experience with PHP though so this is a bit beyond me at the moment.

The way I see it I would have to first figure out how to read the content of the requested page into a string, then parse that string to get just the contents of but not inclduing the body tags, then I can write it out to the page.
It is probably fairly easy to do once I figure out what commands are available.

I have to get the site up and running right away so if the pages render OK now I will work on the parsing piece later. It is just currently a matter of getting the site working so the teachers can begin putting in the content and seeing that it works correctly but not actually going live yet.



At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top