[Pmwiki-users] page revisions not working

Clinton R. Nixon clinton
Wed Oct 8 08:47:41 CDT 2003


Carlo Strozzi said:
> On Wed, Oct 08, 2003 at 12:03:33PM +0200, Sylvain Grisot wrote:
>> Hello,
>> page revision is not working on my website (http://www.pistou.net), as
nothing is recorded in the file ex :
>> ...
>> diff:1065604983:1065604086=
>>
>> is there any known issue on that function ?
>
> It may be that the PHP interpreter that you are using is configured to
not allow php scripts to call external programs (such as 'diff' and
'patch').

This happened to me. My webhost (Dreamhost.com) is infamous for their
strange PHP setup. Their normal PHP setup doesn't allow you to call
external programs, and their PHP-CGI setup, which does, messes up URLs.
(http://www.anvilwerks.com/index.php/Anvilwerks/Anvilwerks/ would come out
as http://www.anvilwerks.com/index.php?Group=Anvilwerks&Page=Anvilwerks).

The solution I used follows.

In pmwiki.php, replace the line:

system("$SysPatchCmd $txtfile $patfile");

with:

chmod($txtfile, 0664);
chmod($patfile, 0664);
@readfile("http://www.anvilwerks.com/patch.cgi?txtfile=$txtfile&patfile=$patfile");

patch.cgi is a Perl script I wrote to execute diff. I used Perl because
their normal CGI setup is fine, although I could have used PHP, gave the
file an extension of .pcgi, and set Apache to execute .pcgi as PHP-CGI
scripts. The Perl code follows:
-----
#!/usr/bin/perl

use CGI;

my $q = new CGI;
print $q->header('text/plain');

# Make sure others aren't calling this script
if ($q->referer !~ /^http:\/\/(www\.)?anvilwerks\.com\/index\.php/) {
        print $q->referer;
}

$cmd = "/usr/bin/patch " . $q->param('txtfile') . " " .
$q->param('patfile'); open (IN, "|$cmd");
while (<IN>) {
        $output .= $_;
}
close (IN);
-----

- Clinton R. Nixon
Anvilwerks.com




More information about the pmwiki-users mailing list