1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- SDV($PatchFunction,'SysPatch');
- SDV($SysPatchCmd,'/usr/bin/patch --silent');
- function SysPatch($page,$restore) {
- global $WikiDir,$SysPatchCmd;
- Lock(2);
- $txtfile = tempnam($WikiDir,"txt");
- $patfile = tempnam($WikiDir,"pat");
- if ($txtfp = fopen($txtfile,"w")) {
- fputs($txtfp,$page['text']);
- fclose($txtfp);
- }
- krsort($page); reset($page);
- foreach($page as $k=>$v) {
- if ($k < $restore) break;
- if (!preg_match('/^diff:/',$k)) continue;
- if ($patfp = fopen($patfile,"w")) {
- fputs($patfp,$v);
- fclose($patfp);
- }
- system("$SysPatchCmd $txtfile $patfile");
- }
- $text = implode('',file($txtfile));
- @unlink($txtfile); @unlink($patfile);
- return $text;
- }
- ?>
|