Re: how to use one file for static sites...

From: Date: Thu, 12 Apr 2001 15:42:31 +0000
Subject: Re: how to use one file for static sites...
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-533@lists.php.net to get a copy of this message
I like to look at my php code and understand exactly what is going to happen, thus the switch mapping. I also don't have a need for dynamic template mapping, at least I've never needed it in any of my projects. Once the templates are in place, that is it. In your example, they could try something like this: http://www.yoursite.com/display.php?target=..%2F..%2F..%2F..%2Fetc%2Fpasswd@" I'm not sure if the "@" will break away from the extension, but there might be a way to do it. You can do all sorts of munging of the data like stripping slashes and periods, but why bother? I avoid the risk altogether. As a rule of thumb, never use this kind of data directly in a file mapping, sql query, etc. If you really need to, be sure to check it for validity first. Monte Alain Fontaine wrote: > > Hi, > > I agree that using data sent from the browser to build file paths -can- be > dangerous, however, I think my example code pretty much eliminates -any- > kind of tampering possible. Correct me if I'm wrong, because in that case I > need to fix my application too ! ;) > > > -----Message d'origine----- > > De : mohrt@basie.ispi.net [mailto:mohrt@basie.ispi.net]De la part de > > Monte Ohrt > > Envoye : jeudi 12 avril 2001 17:20 > > A : alain@nvision.lu > > Cc : Oguz Altun; smarty@lists.ispi.net > > Objet : [smarty] Re: how to use one file for static sites... > > > > > > You can do that if you want to. I don't like the idea of using data sent > > from the browser to assemble file paths. With the switch, you can map > > values to whatever template names you want. The switch gives me more > > control and visual managability. To each their own :-) > > > > Alain Fontaine wrote: > > > > > > Hi, > > > > > > Why the switch() ? How about this : > > > > > > Example > > > http://www.yoursite.com/display.php?target=home > > > > > > <--> > > > // display.php > > > $smarty = new Smarty; > > > $filename = $target . $smarty->tpl_file_ext; > > > if( file_exists( "/somestuff/ . $smarty->template_dir . "/" . > > $filename) ) > > > $smarty->display($filename); > > > else > > > $smarty->display("index.tpl"); > > > <--> > > > > > > Dynamic, extensible, auto-managing :) > > > > > > > -----Message d'origine----- > > > > De : mohrt@basie.ispi.net [mailto:mohrt@basie.ispi.net]De la part de > > > > Monte Ohrt > > > > Envoye : jeudi 12 avril 2001 16:47 > > > > A : Oguz Altun > > > > Cc : Hojtsy Gabor; smarty@lists.ispi.net > > > > Objet : [smarty] Re: how to use one file for static sites... > > > > > > > > > > > > You can code it however you want. You can have a php script for each > > > > template, But that quickly becomes unmanagable for large applications > > > > imho. > > > > > > > > You can easily have one point-of-entry on the site, and > > depending on the > > > > parameters passed to that script, it calls different templates. > > > > > > > > simplified example: > > > > > > > > http://www.yoursite.com/display.php?target=home > > > > > > > > > > > > // display.php > > > > > > > > $smarty = new Smarty; > > > > > > > > switch($target) { > > > > case "news": > > > > $smarty->display("news.tpl"); > > > > break; > > > > case "faq": > > > > $smarty->display("faq.tpl"); > > > > break; > > > > case "home": > > > > default: > > > > $smarty->display("index.tpl"); > > > > break; > > > > } > > > > > > > > > > --- > > > You are currently subscribed to smarty as: monte@ispi.net > > > To unsubscribe send a blank email to $subst('Email.Unsub') > > > Visit Smarty's homepage at > > > http://www.phpinsider.com/php/code/Smarty/ > > > > -- > > Monte Ohrt <monte@ispi.net> > > http://www.ispi.net/ > > > > --- > > You are currently subscribed to smarty as: alain@nvision.lu > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > --- > You are currently subscribed to smarty as: monte@ispi.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

« previous php.smarty.general (#533) next »