• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

web page programming advice needed

dbarton

Senior member
some web page programming advice needed, please.

I have a page with a menu for navigation.
example at http://skylab2000.com/test/main9.htm

In order to have the left navigation menu stay on each page I could use frames, but people seem to not like em? not sure why.
I could just duplicate the code on each page, but kinda sloppy.

Any idea what to use to have that menu on each page? shtml? asp? php? cfm?
any code on a page I can have look at?



 
You can do an include inside .shtml pages that are otherwise just "normal" HTML

... your html ...

< !--#include virtual="/includes/menu.htm"-- >

...more html ...

That can be easier that using php, perl etc. which must include code to generate / print HTML instead of you just typing it in like with an .htm page.
 
Originally posted by: DaveSimmons
You can do an include inside .shtml pages that are otherwise just "normal" HTML

... your html ...

< !--#include virtual="/includes/menu.htm"-- >

...more html ...

That can be easier that using php, perl etc. which must include code to generate / print HTML instead of you just typing it in like with an .htm page.


Not all the time, you could do like the following.

 
Ah, makes sense. I've worked with PHP exactly once, to fix a bug in a contractor's script. When I do something on a server it's usually in Perl, but 99% of my time is spent on Windows C++ coding so I'm no expert there either.
 
Server side includes are turned off (for good reason) with a lot of web hosts, php is much more likely to be operational for this sort of work.
 
Originally posted by: lilcam
Search google for "server side include vulnerability" and you'll know.

The vulnerablities exist because the scripter/programmer does not include any kind of data verification into the scripts.

For example, say I have an index page which can take a parameter either through post or get that is the name of a file to include. Let's use ASP for example

http://mysite.com/index.asp?inc=test.asp

if my asp code was the following,
<%
if Request("inc") = "test.asp" then %> <!-- #include file="test.asp" --> <% end if %>

Then no matter what people tried to put as a value for inc, it would only include files that i specified, and that is only test.asp.

One of the most important things to remember as a programmer is to NEVER trust the user to give you valid input. Always check the input to make sure it is valid before using it in any way shape or form.

 
Originally posted by: MCrusty
Originally posted by: lilcam
Search google for "server side include vulnerability" and you'll know.

The vulnerablities exist because the scripter/programmer does not include any kind of data verification into the scripts.

For example, say I have an index page which can take a parameter either through post or get that is the name of a file to include. Let's use ASP for example

http://mysite.com/index.asp?inc=test.asp

if my asp code was the following,
<%
if Request("inc") = "test.asp" then %> <!-- #include file="test.asp" --> <% end if %>

Then no matter what people tried to put as a value for inc, it would only include files that i specified, and that is only test.asp.

One of the most important things to remember as a programmer is to NEVER trust the user to give you valid input. Always check the input to make sure it is valid before using it in any way shape or form.

^ what he said

 
I did some googling and so far I haven't noticed anything that isn't either a bug in IIS (or Apache) or that couldn't be done the same using php. I mean in the example you gave, MCrusty, if the programmer was dumb enough to put Request("inc") straight into the ssi he/she could easily do the same thing with a php include() right? Or is it that ssi processors run with a higher permission level than php?
 
Make a "config.php" file with these contents:

<?php

$header = "/var/www/html/header.html";
$menu = "/var/www/html/menu.html";

?>

Then edit index.php, page1.php, page2.php and the rest of the pages and add this code at the beginning:

<?php
require_once($header);
require_once($menu);
?>
<html>
blah blah blah your page blah blah blah whatever blah
</html>

Then you just open header.php and menu.php and make whatever kind of banner (header.php) for your site and create the menu (menu.php).

What this does is assign specific pages to a variables. You tell the webserver what variables exist and what static pages those variables refer to (config.php). Each time you type "require_once("/var/www/html/config.php");" the webserver will load those variables into memory so it knows where to look if you call those variables.

Then, in your individual website pages, typing "require_once($header);" will call copy whatever code is in that file that's assigned to the $header variable and paste it into the file, right where you called it.

As an example, let's say you have this for your header.php file:
<html>
<center>
<img src="website_banner_picture.jpg">
</center>
</html>

Let's also say that you have this for your menu.php file:
<html>
<a href="page1.php">Page 1</a>
<a href="page2.php">Page 2</a>
<a href="page3.php">Page 3</a>
</html>

Let's also say that you have this in your index.php file:
<?php
require_once($header);
require_once($menu);
?>
<html>
Hello World
</html>

When someone goes to your domain, they're going to see a page much larger than just those few lines of code in your index file because it's pulling all the code from those $header and $menu files. They'll see this code:

<html>
<center>
<img src="website_banner_picture.jpg">
</center>
</html>
<html>
<a href="page1.php">Page 1</a>
<a href="page2.php">Page 2</a>
<a href="page3.php">Page 3</a>
</html>
<html>
Hello World
</html>

Make sense? With some creativity and tables, you can create quite the complicated website with just a few lines of code instead of hard-coding each individual page. You just have to include that first bit in each file, which you don't even have to change at all later if you want to change the content of the menu or the header or whatever other kinds of pages that you want to have included all in one page. You just edit those header.php, menu.php, footer.php, or whatever and because it's all dynamically called, all of your pages get updated. 🙂

Let your creativity take this and run with it. It's a very simple idea once understood and very powerful.
 
Back
Top