Forum Moderators: coopster

Message Too Old, No Replies

PHP Templates

         

andrewsmd

2:29 pm on Jan 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use php templates a lot and have a quick question. When you use php templates you have your php file we will call somefile.php and your template file we will call templatefile.html (or tpl). My question is, since you can't have php in your templatefile.html is there some way to redirect a user? What I mean is right now if you go to templatefile.html you will see the html with my tempate tags. So instead of seeing
Hello today's date is Tuesday January 13, 2009.
you would see
Hello today's date is {date}
Is there some way to redirect with HTML or something.

surrealillusions

3:31 pm on Jan 13, 2009 (gmt 0)

10+ Year Member



You could just move the template files out of the root folder, thus no direct access can be done.

:)

andrewsmd

3:39 pm on Jan 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, but they still would be able to access them no matter where I have them if they find the correct file path. For the record, I don't have them in the same folder or even the same machine for that matter. I just did that for simplicity's sake.

janharders

3:55 pm on Jan 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mh, no, unless they're below the doc root, they're not accessible via http. if users have ftp-access (why would they?), they could access them, of course, but in any other scenario, you'd need a script on your server that fetches the file and prints it without running the template-code.

andrewsmd

4:25 pm on Jan 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I never had the thought of moving them up. Thanks,

bkeep

3:15 am on Jan 14, 2009 (gmt 0)

10+ Year Member



another possibility is if you can use htaccess files put this in one

Options -Indexes

<Files ~ "^(.*)\.(inc¦tpl¦sql)$">
Order deny,allow
Deny from all
</Files>

Then if they try and access http://example.com/templates/ or http://example.com/templates/index.tpl they will be hit with a Forbidden error

Regards,
Brandon

andrewsmd

10:22 pm on Jan 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, that is interesting.