Fork me on GitHub

PHP Fine Diff: Online Diff Viewer

The page you are looking for has expired.

', "\n"; } } $exec_time = gettimeofday(true) - $start_time; } // new diff else { if ( isset($_POST['granularity']) && ctype_digit($_POST['granularity']) ) { $granularity = max(min(intval($_POST['granularity']),3),0); } if ( !empty($_POST['from']) || !empty($_POST['to'])) { if ( !empty($_POST['from']) ) { $from_text = $_POST['from']; } if ( !empty($_POST['to']) ) { $to_text = $_POST['to']; } } // limit input $from_text = substr($from_text, 0, 1024*100); $to_text = substr($to_text, 0, 1024*100); // ensure input is suitable for diff $from_text = mb_convert_encoding($from_text, 'HTML-ENTITIES', 'UTF-8'); $to_text = mb_convert_encoding($to_text, 'HTML-ENTITIES', 'UTF-8'); $granularityStacks = array( FineDiff::$paragraphGranularity, FineDiff::$sentenceGranularity, FineDiff::$wordGranularity, FineDiff::$characterGranularity ); $diff_opcodes = FineDiff::getDiffOpcodes($from_text, $to_text, $granularityStacks[$granularity]); $diff_opcodes_len = strlen($diff_opcodes); $exec_time = gettimeofday(true) - $start_time; if ( $diff_opcodes_len ) { $data_key = sha1(serialize(array('granularity' => $granularity, 'from_text' => $from_text, 'diff_opcodes' => $diff_opcodes))); $filename = "{$data_key}{$compressed_serialized_filename_extension}"; if ( !file_exists("./cache/{$filename}") ) { // purge cache if too many files if ( !(time() % 100) ) { $files = glob("./cache/*{$compressed_serialized_filename_extension}"); $num_files = $files ? count($files) : 0; if ( $num_files > $cache_hi_water_mark ) { $sorted_files = array(); foreach ( $files as $file ) { $sorted_files[strval(@filemtime("./cache/{$file}")).$file] = $file; } ksort($sorted_files); foreach ( $sorted_files as $file ) { @unlink("./cache/{$file}"); $num_files -= 1; if ( $num_files < $cache_lo_water_mark ) { break; } } } } // save diff in cache $data_to_serialize = array( 'granularity' => $granularity, 'from_text' => $from_text, 'diff_opcodes' => $diff_opcodes, 'data_key' => $data_key, ); $serialized_data = serialize($data_to_serialize); @file_put_contents("./cache/{$filename}", gzcompress($serialized_data)); @chmod("./cache/{$filename}", 0666); } } } $rendered_diff = FineDiff::renderDiffToHTMLFromOpcodes($from_text, $diff_opcodes); $from_len = strlen($from_text); $to_len = strlen($to_text); if ( !empty($data_key) ) { echo '

Tempolink: http://', $_SERVER['HTTP_HOST'], '/viewdiff.php?data=', $data_key, ' (This link is not viewable by others, unless it has been explicitly shared by the creator. This link will exist for a limited period of time, which depends on how often it is visited.)

', "\n"; } ?>

Diff (diff: seconds, diff len: chars) / Show Deletions only All Insertions only

Enter text to diff below:

From

To

Granularity:> Paragraph/lines > Sentence > Word > Character 

Go to main page