Web Hosting Talk







View Full Version : template powered websitez


[Avarice]
09-17-2000, 02:32 AM
how do i make a template powered website where unique content is insterted into a static template? is there an easy how-to?

kunal
09-17-2000, 02:44 AM
you could use a database to insert the data. Php would be an easy way to do that!

Chicken
09-17-2000, 03:26 AM
pHp would be the best way to do that, but if you are like me, and are just starting to get into pHp, then you could use SSI calls. This is much easier to understand as really there isn't much to it. You can insert html or txt files using the INCLUDE SSI tag. Of course if you are going to use pHp, you'd need a pHp enabled account, and likewise with SSI.

MattF
09-17-2000, 06:51 AM
Here's a very basic example in PHP.


<html>
<body>
<toptemplatestuff>
<?php

include($action.".inc");

?>
<bottomtemplatestuff>
</body>
</html>


You would then call index.php?action=mainmenu or so for your page. You could also open the $action as a textfile, parse the contents (e.g. $content = ereg_replace("<font>","<font face="arial">",$content)), etc...


Don't use the above syntax it's probably wrong.

Chicken
09-17-2000, 12:31 PM
Now see, that just looks like alien writing to me. I really haven't had the time to start exploring it, and am going to wait until I do to even try to make sense of that. I'm already on this thing enough, and learning php would probably cause my girl to leave. I might not even realize she left for a few days, heh.

*thinks to self*
"Why are there so many dishes piled up? Honeysnookums... snookums???"
*decides to stick with HTML*

diyoha
09-17-2000, 12:42 PM
howdy,

ASP is another way to go for dynamic content in static templates, that are database driven. In this case you would have to be running an NT server etc.

David

MattF
09-17-2000, 01:19 PM
I have used both PHP (unix) and ASP (nt). I coded Host Investigator in ASP using templates/databases and after working with PHP for some weeks I've realised I can do exactly the same with PHP, in fact easier (and probably faster) to do it with PHP. Just an insight for you.

diyoha
09-17-2000, 01:31 PM
I agree. I am a *nix guy so I would always go with PHP (although I think there might be a PHP version for NT ... not sure)

The reason I mentioned ASP was just to provide alternative options for Avarice ;) especially if he is running NT.

later

David

eva2000
09-17-2000, 02:17 PM
Originally posted by [Avarice]
how do i make a template powered website where unique content is insterted into a static template? is there an easy how-to? check out http://www.back-end.org

Félix C.Courtemanche
09-17-2000, 02:56 PM
If you include pages called from an external POST variable
(for example: main.php?url=something <= 'url' is a variable with the value 'something') make sure that you insert some security mechanism... else you could easily have someone override your script and have your web page include...
/etc/passwd and see all the users on the system for example.

The same apply to ASP or CFM or whatever else you use.

SSI doesn't have this problem since you will most likely insert a header and a footer to each page seperately, instead of including the content.

When using powerfull scripting language... ALWAYS be carefull to do safe stuff... displaying hidden files, secret stuff is never a good thing, and someone with bad intention will definately try your script some time and see if it is safe.

JTY
09-17-2000, 03:08 PM
Security is very important, like Felix said.

Hard coding file paths will help.

diyoha
09-17-2000, 03:21 PM
I never like to hard code anything! TO me that is a loss in flexibility.

I hope there are other security measures that can be taken in PHP to get around having to hardcode anything.

David

Félix C.Courtemanche
09-17-2000, 08:41 PM
simple trick...
prepend a certain dir (we will call it "include") before the files you automatically include... and / or a certain extension.

for example, NEVER use the following to call a web page:

?url=main.html

because someone could then easily override the system
but if you do:
?url=main

wich actually do:
modify $url to be:
/path/to/your/root/web/site/include/main.inc.php

That would already protect you more.

Other trick:
-Verify if the called file exists
-Make the included file impossible to read directly
-if the file does not exist, redirect to a default web page.

You can try that with my current system on can-host.com

If you enter a weird url, anything that is not directly found on the specified path it will return you the homepage of the section you are in.

That mean no more 404 errors either :)

JTY
09-17-2000, 10:26 PM
What I was trying to say, Felix just said.

Learner
09-18-2000, 12:29 AM
Originally posted by SysAdmin
...can do exactly the same with PHP, in fact easier (and probably faster) to do it with PHP...

What SysAdmin really meant was that pHp generally requires much fewer lines of code than ASP. I have noticed that ASP code runs into a lot more lines of code to acheive exactly yhe same things pHp achieves with much lesser code.

And Felix, that was another very insightful post of yours here! Thanks.

Learner

Félix C.Courtemanche
09-18-2000, 10:44 AM
Learner... PHP is faster to _write_ as you said, but also when it is executed... plus... YES! IT'S FREE!!!

Sorry, my *screw* M$ popping up :)