UseModWiki | WikiPatches | RecentChanges | Preferences

This feature is implemented in 1.0, but is turned off by default. --CliffordAdams
Implements MeatBall:FileReplacement. Assumes you have already applied /PageDeletion.

Usage: On the first line, write

ReplaceFile: <filename on server>

Somewhere later, between <pre></pre> tags, place the file contents.

Example use:

 ReplaceFile?: /home/jrandom/wiki/intermap.txt

 This is a MeatBall:PublicallyEditableInterMap.


 WikiWiki http://c2.com/cgi/wiki?
 MeatBall http://www.usemod.com/cgi-bin/mb.pl?

NOTE: File replacement is a potentially serious security risk. APPLY THIS PATCH AT YOUR OWN RISK. -- SunirShah

 Add $ReplaceFile to use vars qw()

 $DeletedPage = "DeletedPage";   # 0 = disable page deletion; "string" for page  deletion marker text
 $ReplaceFile = "ReplaceFile";   # 0 = disable file replacement; "string" for file replacement marker text

 sub ProcessVetos?

   if( $ReplaceFile && $Text{'text'} =~ /^\s*$ReplaceFile\:\s*(\S+)/o )
     my $fname = $1;
     # Only replace an existing file.
     if( -e $fname ) {
       if( $Text{'text'} =~ /.*<pre>.*?\n(.*?)\s*<\/pre>/ims )
         my $string = $1;
         $string =~ s/\r\n/\n/gms;
         open (OUT, ">$fname") or return 0;
         print OUT $string;
         close OUT;
         return ' (replaced)';

   return 0;

Personally, I'm not entirely satisfied allowing any local file to be replaced willy nilly. What if the administrator is on vacation? Perhaps the answer is to add to the configuration file an array of replaceable files.

 Add @ReplaceableFiles to use vars qw()

 @ReplaceableFiles = ();         # A list of files users are allowed to replace. Set to undef to allow all files to be replaced.


     # Only replace an existing file.
     if( -e $fname ) {


     # Only replace an allowed, existing file.
     if( (grep {$_ eq $fname} @ReplaceableFiles) && -e $fname) {

-- SunirShah

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited April 23, 2007 2:01 pm by MarkusLude (diff)