|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
carsten888 Smarty Rookie
Joined: 26 Feb 2005 Posts: 13 Location: Tilburg, Holland
|
Posted: Tue Dec 13, 2005 7:12 pm Post subject: hide your templates with php |
|
|
(something like this has been posted here before, but can't find it anymore. this is a refinement of that code)
to prevent search-engines and viewings from browsers in your templates, put this code above the <html>-tag and save it as a php file:
{if $youAreTryingToLookAtMyTemplate == true}
<?php buggerOff(); ?>
{/if}
<html>
if the template is properly called for by php the smarty will read the code, conclude that crazy variable does not exist and happily go on.
if someone requests the page(.php) from a broser, the smarty is not read but the php is. this will trow an error because the function buggerOff() is unknown.
a nice bonus is that this code will not mess up code-colors in Dreamweaver. |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Wed Dec 14, 2005 1:48 pm Post subject: |
|
|
put your templates outside of your document_root and you won`t have any Problems. |
|
Back to top |
|
Milkman Smarty Regular
Joined: 21 Nov 2005 Posts: 57 Location: Loughborough, UK
|
Posted: Thu Dec 15, 2005 3:00 am Post subject: |
|
|
carsten888 wrote: | to prevent search-engines and viewings from browsers in your templates, put this code above the <html>-tag and save it as a php file: |
Surely if you are using a file extention that does not map to a mime-type of application/x-httpd-php this will not help? If you cannot put your templates outside of the document root (as kills suggests) perhaps you could add an apache RewriteRule (or similar which ever httpd you use) to send a 403 when someone requests a template file. Putting the following in a .htaccess file would do the trick (replace .tpl with your template extension).
Code: | RewriteEngine on
RewriteCond %{REQUEST_URI} \.tpl$
RewriteRule .* - [F] |
Edit: I've just re-read your post and I now see that you use .php as your template extension. |
|
Back to top |
|
avataru Smarty Rookie
Joined: 09 Jan 2006 Posts: 7
|
Posted: Sat Jan 14, 2006 11:21 am Post subject: |
|
|
In most places mod_rewrite is not available but there is another way to do it from .htaccess.
Make a .htaccess file and put it in the root dir. Then, add this:
<Files *.tpl>
order allow,deny
deny from all
</Files> |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|