<?

// utilizo las variables del servidor
include ('plantillas/varnav.inc');
require('plantillas/funciones.php');

$dir="archivos";

//selecciono el idioma de las páginas

/*$path=($path.'_'.$id.'.html');
$path2=($dir.'/'.$dir.'_'.$id.'.html');*/
$fichapath=$dir.'/ListadoProvincias.txt';
include('plantillas/cabecera_'.$id.'.php');

include($dir.'/archivos_'.$id.'.html');
	
?>

<table width="100%">  
  <tr align="left" bgcolor="#CCCCCC"> 
    <td valign="top"><strong><font color="#0000FF">Listado de provincias con archivos sonoros</font></strong></td>
  </tr>
</table>

<?

	$hndl=fopen("$dir/ListadoProvincias.txt","r");
	$contador=0;
	$es_par=1;

	echo "<table width=100% border=1px>";	
	
	// Se lee cada provincia
	while ($buffer=fgets($hndl,4096)){
		
		$titulo=replaceAccents($buffer);
		
		$BASEDIR=trim($dir.'/'.$titulo);
		
		$hndl2=opendir($BASEDIR);
		
		// Se comprueba si la provincia tiene fichas ya subidas
		while($file=readdir($hndl2)){
	
			// No se tienen en cuenta ni el . ni el ..
			if ($file=='.' || $file=='..' || $file=="PueblosSinSubir.txt") 
				continue;
		
			$completepath="$BASEDIR/$file";
			
			//Si tiene ficha se escribe
		
			if (is_file($completepath) && $file!="ListadoPueblos.txt"){
			
				if($es_par)
					echo '<tr><td bgcolor="#FFFFFF"><a href="archivos_pueblos.php?'.$id.'&'.$dir.'&'.$titulo.'">'.$buffer.'</a></td>';
				else
					echo '<td bgcolor="#FFFFFF"><a href="archivos_pueblos.php?'.$id.'&'.$dir.'&'.$titulo.'">'.$buffer.'</a></td></tr>';
			
				$es_par=($es_par+1)%2;
				$contador++;
				
				break;
			
			}
		
		} // end while (archivos de cada provincia)
		
		fclose ($hndl2);

	} // end while (provincia)
	
	fclose($hndl);
	
	if (!$es_par)
		echo "</tr>";
	echo "</table>";

	// Se imprimen la fecha de ultima modificacion y el pie de pagina
	echo '<p>&Uacute;ltima modificación '.date(' j/m/Y, H:i', filemtime ("$fichapath")).'</p>';
	include('plantillas/pie_'.$id.'.inc');

?>		