Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Resource Plugins wont work without a returned timestamp

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
regnastor
Smarty Rookie


Joined: 25 May 2003
Posts: 16

PostPosted: Sun May 25, 2003 11:47 pm    Post subject: Resource Plugins wont work without a returned timestamp Reply with quote

Hi,
i'm member of a the Scoutnet-Calendar team (http://kalender.scoutnet.de) and im using a rescource-plugin to use templates from any Webserver, because we need this for the soon coming template enabled Version 2.0 of the Calendar.

The rescourceplugin works, but only if i set the returnvalue "pluginname_get_timestamp" as true, otherwise get a warning:
Quote:
Warning: Smarty error: unable to read template resource: "http://chris.adacwg.de/testtemplate.htm" in c:\wampp2\htdocs\utils\smarty\Smarty.class.php on line 1042


Try http://chris.adacwg.de/smarty/http2.php to cause the Warning or http://chris.adacwg.de/smarty/show_http2.php to see the code. (Ignore the first two Warnings, they are caused by the provider, i dont have these at home, but the third Warning)

I can't really access the time of a file on a webserver (or can I?) so I set "$tpl_timestamp = time();", but why is the timestamp required?

Thx,
Christopher
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun May 25, 2003 11:57 pm    Post subject: Reply with quote

smarty compiles your resource's source-code just like a local file. the timestamp is required for smarty to determine if it has to recompile the resource (a computationally expensive thing) on a second fetch, or if it can use it's already compiled version.

if pluginname_get_timestamp() returns false it indicates an error obtaining the resources modification-time, this is fatal for smarty and it doesn't try to recover from such a condition.

if you really cannot obtain a timestamp (via the Last-Modified-header of the web-page for example) you are 100% right in returning true and setting the timestamp to "now". but be aware, that this means, the template is recompiled on every display.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon May 26, 2003 3:29 am    Post subject: Reply with quote

hmm, interesting.

1) I noticed two safemode restrictions -- are they related?

2) your file name appears to be http:// ... how is your template resource handling the loading? I posted a simplistic plugin to read streams that also does some simple handling for timestamp. Note that it relies on your web-server returning a last-modified http header, or otherwise it simply returns back the timestamp for the current time, causing recompilation (as messju noted earlier). You may not want to use this technique, though since you probably don't have a lot of control over the metadata returned by the remote webserver (or do you??). Performance is not great, either.

By-the-way: this is NOT a bug and has been moved to the general forum.
Back to top
View user's profile Send private message
regnastor
Smarty Rookie


Joined: 25 May 2003
Posts: 16

PostPosted: Mon May 26, 2003 2:40 pm    Post subject: Reply with quote

First of all: Thx for the fast and exact replies, you can't find this often Very Happy ...

@boots:
1) The safemode restrictions are caused by the provider telling me that he has to use safemode for securityreasons. I don't have these on my wampp2 (http://www.apachefriends.org) under WinXP.

2) No i don't have any control over the servers, because the idea is that any calendaruser can pass an url to the wished template over the urlparameters when calling the calendarscript, so thats the reason why i need remote templates. In the other thread you said that "user-land streams compare even worse with a PHP cache". What do you mean exactly? Is it faster if you let smarty simply recpomlie the template everytime instead of retrieving the time using streams and let smarty use the cache?
My Script (see the link in the first posting) ist the same like your's except for that time-thing.

I still have some questions about the secure and the trusted function and securityproblems in general when using reomtetemplates elected by the users but i'll start a new thread for that.

By-the-way2 Wink : thx for moving the thread, i wasn't sure where to post it.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP