« Does spam poison prevent comment spam? | Index | Bluetooth: ieder voordeel heb zijn nadeel »

June 16, 2005, by Léon Krijnen

Randomizing revisited   

movabletype3bible.gifExploring all possibilities in MovableType is kind of a neverending trip. Another good help is The Movable Type 3 Bible by Rogers Cadenhead, that's lying next to my machine these days. And of course there's always the daily trip tot Plugins Directory on the MovableType website, that every developer should visit regularly.
That's where I noticed the Perl plugin, and I found out that a lot of things I've always done by server side includes (hence most extensions on my blog are .shtml) can also be build and done by MovableType tagging.

For example this line of code that executes a .cgi script in my cgi-local to randomize the logo on top of the blog:

<!--#exec cgi="/cgi-local/randombop.cgi" -->

After installing the Perl plugin from Brad Coates I could include the Perl code straight forward in a template:

$random_file = "randombop.dat";
open (file, $random_file);
print "content-type: text/html; charset=cp1250\n\n";
print "@lines[int rand(@lines)]\n";

Which executes the Perl code from the page. Beautiful, but dangerous.

Brad Choate: Be very careful who you give access to edit your templates if you have this plugin installed. Anyone who can edit templates on your server can basically control your web site with this plugin under the hood. The Perl code contained within your PerlScript tags is not sandboxed at all: file and database operations can be performed, infinite loops can tie up your server— any number of things can go wrong. I cannot be held responsible for any damage to your web site or web server due to the improper use of this plugin.

Some other things become very simple, like:

print localtime();

While I'm thinking about this plug-in and its security issues, I ran into another interesting tag in the Movable Type 3 Bible: randomizer tags.

At first I thought it not very useful, as the randomizer only works once; when the page is build from the template, and I'd like the randomizer to work continiously, for every new visitor or refresh. While that problem would be solved by installing the Perl script module, the MovableType random tag can be very, ver useful for other things;

for example:

<MT include module="My Google Ads">


<MTinclude file="GoogleAds.htmll">

Headers, footers, modules, layout tags, advertorials, think about it, possibillities are endless.

Previous posts about randomizing:

How to randomize

Another way leading to Rome

Posted: June 16, 2005 08:12 AM (391 words).   

Comment over here or on my Facebook wall . . .