PHPDiffEngine

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


To create a new cookbook entry, fill in or remove the sections below.

Warning! In the case that there are still bugs in here, you Page History might get corrupted. However, on my own page it worked fine so far.

Goal

The goal is to be able to use the page history and restoring function on systems that run in PHP Safemode. In PHP Safemode, users are not allowed to run system programs, so the GNU diff and GNU Patch don't work (if not in php safe_mode_exec_dir).

Solution

Does not work with pmwiki versions less then 0.6.9

Download Attach:phpdiff.tar.gz and extract it into your local/-Directory. Add

  • include 'phpdiff/difflib.php';
  • include 'phpdiff/phpdiff.php';
  • include 'phpdiff/phppatch.php'; You do not need this line when using pmwiki version 0.6.18 or above (is it really 0.6.18 or 0.6.17)

to your config.php. The system should now use the pure PHP diff function

difflib.php
Contains functions that are needed by both the diff and the patch function
phpdiff.php
Contains the diff function and sets the $DiffFunction-Variable so that PmWiki uses it.
phppatch.php
Contains the patch function and sets the $PatchFunction-Variable so that PmWiki uses it.

Non-optimal diffs

A friend reported a situation where this algorithm doesn't create an optimal diff. If you find such a situation, please send me URL and the exact datetime of the diff that is incorrect. That way, I can check the diffs myself and maybe I can still optimize the algorithm.

I now found an example for a non-optimal diff. The difference between regtest1.1.txt and regtest1.2.txt is correct, but not optimal. Check it out here. When I find some time, I will look at it, but I believe it is an algorithm problem and might not be solvable with my approach.

-- Nils

See Also

History

7.3.2004First version
26.3.2004Major bugfix: Algorithm didn't find differences when something was just appended to the end of a page.
22.9.2004Included slow algorithm in distribution, structure according to complex recipes

Comments & Bugs

  • Thanks für this contribution, it's extremly usful if it's not possible to configure safe_mode_exec_dir /pog
  • omfg i love you! it works! SkeeAtokenDro
  • You bloody ripper! This works quite well on my Win2k system, where I was unable to get the gnu utils to work - PeteG

Contributors

Copyright

phpdiff is distributed under the http://www.opensource.org/licenses/mit-license.html MIT-License, which allows anybody to do anything to it.

  Permission is hereby granted, free of charge, to any person obtaining 
  a copy of this software and associated documentation files (the 
  "Software"), to deal in the Software without restriction, including 
  without limitation the rights to use, copy, modify, merge, publish, 
  distribute, sublicense, and/or sell copies of the Software, and to 
  permit persons to whom the Software is furnished to do so, subject to 
  the following conditions:

  The above copyright notice and this permission notice shall be 
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.

pmwiki-2.3.38 -- Last modified by {{Nils Knappmeier}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons