" . "". ""; } function diff_strings($before, $now) { $tempdir = sys_get_temp_dir(); $afile = tempnam($tempdir, "mtrack"); $bfile = tempnam($tempdir, "mtrack"); file_put_contents($afile, $before); file_put_contents($bfile, $now); static $diff = false; if (!$diff) { require_once 'System.php'; $diff= System::which('diff'); } if (PHP_OS == 'SunOS') { // TODO: make an option to allow use of gnu diff on solaris $diff = shell_exec("$diff -u $afile $bfile"); $diff = str_replace($afile, 'before', $diff); $diff = str_replace($bfile, 'now', $diff); } else { $diff = shell_exec("$diff --label before --label now -u $afile $bfile"); } unlink($afile); unlink($bfile); $diff = htmlentities($diff, ENT_COMPAT, 'utf-8'); return $diff; } }