<html>
<?php
include("header.php");
$db = db_init ();

// CREATE TABLE packages (package varchar(20) NOT NULL, idTranslator tinyint(4), 
// PRIMARY KEY (package));

$result = db_query("SELECT * FROM packages",$db);

//echo "<table border=1>\n";
//echo "<tr><td>Package</td><td>Maintainer</tr>\n";

$c=0;
	while ($myrow = db_fetch_row($result)) 
	{
		$arrout = 0;
		exec("cat lista-pot | sed -e 's#docs/#docs-#' -e 's#./##' -e 's#\.pot#\.po#' 
		| grep  -e \"^$myrow[0]/\"",$arrout);	
		$i = 0;
		$c = 0;
		echo "<b>$myrow[0]:</b>";
			while($arrout[$i])
			{
				//	echo "$arrout[$i]<br>";
				//	$pacchetto=`echo $arrout[$i] | awk -F/ '{printf "%s",$2}'`;	
				//	$file=`echo $arrout[$i] | awk -F/ '{printf "%s",$3}'`;
				//	$full= "$pacchetto/$file";
				$arrout1=0;
				exec("cat lista-po | sed -e 's#docs/#docs-#'  -e 's#./##' | grep  -e 
				\"^$myrow[0]/\" | grep $arrout[$i]",$arrout1);
				if($arrout[$i]==$arrout1[0]) 
				{
					$status=gettext("new");
				}
				else
				{
					$status=gettext("no translation");
				}  
				//	echo "$status #$arrout[$i]# #$arrout1[0]#\n<br>";
			$result2 = db_query("SELECT COUNT(*) FROM files WHERE pofile=\"$arrout[$i]\"",$db);
				if(db_result($result2,0)==0) 
				{
					$result1 = db_query("INSERT INTO files(pofile,package,status,idTranslator) VALUES(\"$arrout[$i]\",\"$myrow[0]\",\"$status\",\"$myrow[1]\")",$db);
	 				$c++;
				}    
			$i = $i + 1;   
			}
		if($c == 0) print (gettext("No new packages")."<p>");
		if($c >= 1)  printf (ngettext("%d new package<p>", "%d new packages<p>", $c), $c);	
		//       echo "$pacchetto $file $full<p>";    
	}
	//echo "</table>\n";

include("footer.php");
?>
</body>
</html>
