[ PHPXref.com ] [ Generated: Sun Jul 20 21:04:14 2008 ] [ WikkiTikkiTavi 0.26 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/lib/ -> diff.php (source)

   1  <?php
   2  // $Id: diff.php,v 1.11 2003/12/16 18:07:46 holroy Exp $
   3  
   4  // Compute the difference between two sets of text.
   5  function diff_compute($text1, $text2)
   6  {
   7    global $TempDir, $DiffCmd;
   8  
   9    $num = function_exists('posix_getpid') ? posix_getpid() : rand();
  10  
  11    $temp1 = $TempDir . '/wiki_' . $num . '_1.txt';
  12    $temp2 = $TempDir . '/wiki_' . $num . '_2.txt';
  13  
  14    if(!($h1 = fopen($temp1, 'w')) || !($h2 = fopen($temp2, 'w')))
  15      { die(LIB_ErrorCreatingTemp); }
  16  
  17    if(fwrite($h1, $text1) < 0 || fwrite($h2, $text2) < 0)
  18      { die(LIB_ErrorWritingTemp); }
  19  
  20    fclose($h1);
  21    fclose($h2);
  22  
  23    if (ini_get('safe_mode') and
  24       (ini_get('safe_mode_exec_dir') != dirname($DiffCmd))) 
  25      { $diff = LIB_NoDiffAvailableSafeMode; }
  26    else if (!file_exists($DiffCmd) or !is_readable($DiffCmd)) 
  27      { $diff = LIB_NoDiffAvailable; }
  28    else {
  29      $output = array();
  30      exec("$DiffCmd $temp1 $temp2", $output);
  31      $diff = join("\n", $output);
  32    }
  33  
  34    unlink($temp1);
  35    unlink($temp2);
  36  
  37    return $diff;
  38  }
  39  
  40  // Parse diff output into nice HTML.
  41  function diff_parse($text)
  42  {
  43    global $DiffEngine;
  44  
  45    return parseText($text, $DiffEngine, '');
  46  }
  47  
  48  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]