".implode("\n", $output).""; die; } $html = ''; function genera_link($params){ return $_SERVER['REQUEST_URI']."&".http_build_query($params); } function htmlentities_utf8($string){ return htmlentities($string, ENT_COMPAT | ENT_HTML401, "UTF-8"); } $output = []; exec("ls -tal --full-time $path", $output); $allFilesByDate = []; foreach($output as $k=>$o) if($k > 1){//la prima riga è "total" la seconda è l'entry "." $o = explode(" ", preg_replace("/\s+/", " ", $o));//le date con cifra singola hanno un doppio spazio /* [0] => -rw-r--r-- [1] => 1 [2] => www-data [3] => www-data [4] => 287736 [5] => Sep [6] => 14 [7] => 15:33 [8] => less_7d84624ae2b222a7c974791b8f843651.min.css [0] => -rw-r--r-- [1] => 1 [2] => www-data [3] => www-data [4] => 131 [5] => 2024-11-11 [6] => 17:43:13.594412167 [7] => +0100 [8] => _FW_container_701ea67888d68a967ded0be661637803.min.css */ // print_r_tnx($o, $_SERVER['REMOTE_ADDR'] == '192.168.0.177') || die; $o[6] = explode(".", $o[6]); $allFilesByDate[] = [ 'n' => $o[8], 's' => $o[4], 'd' => $o[5]." ".$o[6][0], ]; } $stampati = 0; foreach($allFilesByDate as $f1){ $files = []; foreach($allFilesByDate as $f2) if($f1['s'] == $f2['s']) $files[] = $f2; if(count($files) > 1){ foreach($files as $k=>$v){ foreach($files as $k1=>$v1) if($k1 > $k){ exec('sed "s/[;},]/\n/g" '.$path.$v['n'].' > /tmp/1'); exec('sed "s/[;},]/\n/g" '.$path.$v1['n'].' > /tmp/2'); $cmd = 'diff -C 1 /tmp/1 /tmp/2'; $output = []; exec($cmd, $output, $ret); $html .= "

".$v['n']."
".$v['d']."

".$v1['n']."
".$v1['d']."

"; if(!$output) $html .= "

identici



"; else{ // $debugBacktrace = debug_backtrace(); array_unshift($debugBacktrace, array('file'=>__FILE__, 'line'=>__LINE__, 'function'=>'debugTnx')); foreach($debugBacktrace as $debugLine) $html .= "".str_replace("/tnx/www/html/www/", "", $debugLine['file']).""." ".$debugLine['function']."()
"; // $printMe = $output; ob_start(); if(is_object($printMe)||is_array($printMe)) print_r($printMe); else var_dump($printMe); $html .= htmlentities(ob_get_clean(), ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE, 'UTF-8'); $r = count($table) - 1; $c = 0; $numeroPrimaRiga = 0; foreach($output as $k=>$o) if($k > 1){ $primi4 = substr($o, 0, 4); if($primi4 == "****"){//separa un blocco variato dall'altro (***************) $r++; } else if(in_array($primi4, array("*** ", "--- "))){//separa la parte file1 dalla file2 e indica le righe $c = $primi4 == "*** " ? 0 : 1;//colonna sx/dx file1/2 $numeroPrimaRiga = substr($o, 4, strpos($o, ",")-4); } else{ if(!${"isFile".($c+1)."UTF8"}) $o = utf8_encode($o); $numeroRiga = $numeroPrimaRiga+(count($table[$r][$c])); $tipo = substr($o, 0, 1); $class = ''; if($tipo == '!') $class = 'variazione'; else if($tipo == '+') $class = 'aggiunta'; else if($tipo == '-') $class = 'rimozione'; $table[$r][$c][] = "
". ''.$numeroRiga."". str_replace("\t", '', htmlentities_utf8(substr($o, 2))). '
' ; } // if($c==1){ // for($i=0; $i<2; $i++) if(!$table[$r][$i]){ // $table[$r][$i][] = '-'; // } // } } foreach($table as $row) $html .= "
".@implode($row[0])."
".@implode($row[1])."
"; } } $html .= "
"; if($stampati++ > 50) break 2; } } } ?>