Hola te paso el código php:
function
recursive_remove_directory($directory, $empty=FALSE)
{
// if the path has
a slash at the end we remove it here
if(substr($directory,-1) == '/')
{
$directory = substr($directory,0,-1);
}
// if the path is
not valid or is not a directory ...
if(!file_exists($directory) || !is_dir($directory))
{
// ... we return false and exit the function
return FALSE;
// ... if the path
is not readable
}elseif(!is_readable($directory))
{
// ... we return false and exit the function
return FALSE;
// ... else if the
path is readable
}else{
// we open the directory
$handle = opendir($directory);
// and scan through the items inside
while (FALSE !== ($item = readdir($handle)))
{
// if the filepointer is not the current directory
// or the parent directory
if($item != '.' && $item != '..')
{
// we build the new path to delete
$path = $directory.'/'.$item;
// if the new path is a directory
if(is_dir($path))
{
// we call this function with the new path
recursive_remove_directory($path);
// if the new path is a file
}else{
// we remove the file
unlink($path);
}
}
}
// close the directory
closedir($handle);
// if the option to empty is not set to true
if($empty == FALSE)
{
// try to delete the now empty directory
if(!rmdir($directory))
{
// return false if not possible
return FALSE;
}
}
// return success
return TRUE;
}
}
recursive_remove_directory('/home/vhost/gis.com/html/b2/kacache/gmun/100000000/TEMATICO');
recursive_remove_directory('/home/vhost/gis.com/html/b2/kacache/gmun/60000000/TEMATICO');
recursive_remove_directory('/home/vhost/
gis.com /html/b2/kacache/gmun/30000000/TEMATICO');
recursive_remove_directory('/home/vhost/
gis.com /html/b2/kacache/gmun/5000000/TEMATICO');
Al final se borra para cada nivel de zoom, espero te sirva.
Respecto de los privilegios por usuario, creamos un dir
previo al del propio kamap por ejem:
Antes pudo haber sido
..Apache/htdocs/app/…. (donde app=kamap)
Le colocamos un dir previo
..Apache/htdocs/jerarquias/app/…
Y en ese dir le colocamos los php para que se loguee
El php de inicio con el respectivo form:
…<form id='form1' class='inicio' name='form1' method='post'
action='validacion.php'>
<div id='ingreso' align='left'>
<table width='200' border='0'>
<tr>
<td width='100'></td>
<td width='30' align='left'>Usuario:</td>
<td width='233'><div align='left'><input class='txt'
id='usuario' name='usuario' value=''….
El php de validacion con:
function ValidarSesion($nombre,$clave) {
$consulta="SELECT * FROM Usuarios WHERE nombre='" . $nombre . "'
AND clave='" . $clave . "'";
$resultado=pg_Exec($consulta);
$numerodefilas=pg_num_rows($resultado);
$registro=pg_fetch_array($resultado,null,PGSQL_ASSOC);
if ($numerodefilas!=0)
return $registro[tipo];
else
return 0;
}
session_start();
if ($_POST) { //&& !empty($_POST['usuarios'])
$_SESSION['usuario'] = $_POST['usuario'];
$_SESSION['clave'] = $_POST['clave'];
}
$_SESSION['tipousuario']=ValidarSesion($_SESSION['usuario'],$_SESSION['clave']);
if ($_SESSION['tipousuario']==0 or
$_SESSION['clave']=="") {
echo "<div>Usuario o clave incorrecta</div>";
echo "<br><br>";
echo "<a href='inicio.php'>Regresar</a>";
}
else {
?>
<script type='text/javascript'>
location.href="app/index.php";
</script>
<?
}
Donde puedes ver que recién llama al index del kamap, donde
ya esta pasando el tipo de usuario de sesión y que lo validamos en el archivo
config.php que normalmente esta en el dir include y que lo carga el
init.php donde colocamos:
…
$aszGMap1 = array (
'title' => 'Mapa1',
'path' => 'C:/Program Files/ms4w/Apache/htdocs/jerarquias/app/lima1.map',
'scales' => array(200000, 60000, 30000, 10000, 5000),
'format' => 'PNG'
);
$aszGMap2 = array (
'title' => 'Mapa2',
'path' => 'C:/Program Files/ms4w/Apache/htdocs/jerarquias/app/lima2.map',
'scales' => array(200000, 60000, 30000, 10000, 5000),
'format' => 'PNG'
);
$aszGMap3 = array (
'title' => 'Mapa3',
'path' => 'C:/Program Files/ms4w/Apache/htdocs/jerarquias/app/lima3.map',
'scales' => array(200000, 60000, 30000, 10000, 5000),
'format' => 'PNG'
);
$aszGMap4 = array (
'title' => 'Mapa4',
'path' => 'C:/Program Files/ms4w/Apache/htdocs/jerarquias/app/lima4.map',
'scales' => array(200000, 60000, 30000, 10000, 5000),
'format' => 'PNG'
);
$aszMapFiles = array( 'gmapj1' => $aszGMap1, 'gmapj2'
=> $aszGMap2, 'gmapj3' => $aszGMap3, 'gmapj4' => $aszGMap4 );
session_start();
switch ($_SESSION['tipousuario']) {
case 1: $szMap = "gmapj1";
break;
case 2: $szMap = "gmapj2";
break;
case 3: $szMap = "gmapj3";
break;
case 4: $szMap = "gmapj4";
break;
}
//echo "usuario: ".$_SESSION['tipousuario'];
Finalmente como ya ‘sabe’ que tipo de usuario es, se le
asigna el mapfile respectivo. Espero les ayude!
Saludos