hi all, I cobbled this together in hopes someone would be able to use it or improve it (please post your code OR a link to something better (like there could possibly BE something better than this ), it takes the linux "diff" command and presents it graphically somewhat (I have a hard time reading diff myself):
<?php
$left='/home/cpm104/public_html/cgi_2.8.5';
$right='/home/dev/public_html/cgi_2.8.5';
$output=`diff $left $right`;
if($output){
$output=explode("\n",$output);
foreach($output as $v){
switch(true){
//identifiers - don't write into $diff array
case preg_match('/^diff \//',$v):
$a=explode(' ',$v);
$left=$v[1];
$right=$v[2];
$comparison++;
//for table rows
$compList[$comparison]=preg_replace('/^diff/','Comparing: ',$v);
continue(2);
break;
case preg_match('/^[,0-9a-z]+$/',trim($v)) && strlen(trim($v))<30:
$i++;
$node=$i.':'.trim($v);
continue(2);
//clean lines
case substr($v,0,1)=='<';
$ref='left';
$v=preg_replace('/^< /','',$v);
break;
case substr($v,0,1)=='>';
$ref='right';
$v=preg_replace('/^> /','',$v);
break;
//not needed
case preg_match('/---/',$v): continue(2);
}
$diff[$comparison][$node][$ref].=htmlentities(trim($v))."\n";
}
#echo '<pre>';
#print_r($diff);
#exit;
?>
<style type="text/css">
.diff{
border-collapse:collapse;
}
.diff td{
border:1px dotted #333;
padding:8px;
}
.diff td .code{
background-color:aliceblue;
width:450px;
font-family:"Courier New", Courier, monospace;
font-size:12px;
}
</style><table cellpadding="0" cellspacing="0" class="diff"><?php
foreach($diff as $comparison=>$node){
?><tr>
<td colspan="100%">
<?php echo $compList[$comparison];?>
</td>
</tr>
<tr>
<?php
foreach($node as $n=>$v){
if(!trim($n))continue;
?><tr>
<td colspan="100%"><?php echo $n?></td>
</tr>
<tr>
<td class="code"><?php echo $v['left'];?></td>
<td class="code"><?php echo $v['right'];?></td>
</tr><?php
}
}
?></table><?php
}else{
echo 'nothing to compare';
}
?>