Implementare script esplora risorse

  • Creatore Discussione Creatore Discussione atonyc
  • Data di inizio Data di inizio

atonyc

Utente Attivo
10 Dic 2008
67
0
0
Ciao a tutti, con questo post chiedo aiuto a chi riesce a aiutarmi a implementare il classico script di esplora risorse, quello che impostando una directory è in grado di postare cartelle e sottocartelle.
L'obbiettivo è quello di implementare le funzioni:
1) inserire un'icona che permetta una volta clicckata di aprire il client mail e di inserire come allegato il file in questione.

Posto lo script da implementare
<?php
/******************** Define Variables for main code ****************************/
// Declare some variables that are going to be needed later on


$basedir="Archivio";
if(!isset($d))
$d="";
else
{
$d = rawurldecode($d);
$dir_array2 = explode("*",$d);
}
if(!isset($dir_array2))
$dir_array2[0] = $basedir;

$dir_array = $dir_array2;
$dir = $dir_array[0];

if(!isset($opened))
$opened = 0;
else
$opened = 1;
if(!isset($closed))
$closed = 0;
else
$closed = 1;

if($basedir != $dir_array[0])
die("Sorry, Page cannot be displayed "); //<script>history.go(-1)</script>");


/*********************************************************************************/
// That should be good enough next define what to do if a directory has been opened or closed

if($closed == 1)
{
$fold = rawurldecode($fold);
$size2 = sizeof($dir_array)-1;
while($dir_array[$size2] != $fold)
{
array_pop($dir_array);
$size2--;
}
array_pop($dir_array);
$opened =1;
}

if($opened == 1)
{
if($closed != 1)
{
$fold = rawurldecode($fold);
$dir_array[] = $fold;
}
// Above we just added the new folder on and we are going to check and see if it the array still makes a vaild directory. If it doesn't - unload the array back to the base directory and add the new folder on again.

$tmp_dir = implode("/" , $dir_array);
if(!($tmp = @opendir($tmp_dir)))
{
$size2 = sizeof($dir_array) - 1;
while(!($tmp = @opendir($tmp_dir)))
{
array_pop($dir_array);
array_pop($dir_array);
$dir_array[] = $fold;
$tmp_dir = implode("/" , $dir_array);
}
}
}

/*********************************************************************************************/
?>
<tr>
<td>&nbsp;</td>
</tr>
<table width="100%" >

<?php
/*********************************************************************************************/




// Thats it for the opened and closed code we need now were going to execute the initial directory traversion on the base directory.


if(sizeof($dir_array)-1 == 0)
$size = 0;
else
$size = 1;

if(!($dp = opendir($dir)))
die("Sorry, Page cannot be displayed "); //<script>history.go(-1)</script>");
$lastfile = getlastfile($dir);
$d=rawurlencode(implode("*",$dir_array));
$Ivar = "images/tree_split.gif";
echo "<tr><a href='$PHP_SELF'><img border=0 src='images/drive.gif'></a><b><a class=top href='$PHP_SELF'></a></b></tr>";
while($file = readdir($dp))
if($file != '.' && $file != '..')
{
$files = filesize("$dir/$file");
$filep = rawurlencode($file);
if($lastfile == $file)
$Ivar = "images/tree_end.gif";
if( (is_dir("$dir/$file")) && ("$dir/$dir_array[$size]" == "$dir/$file") )
{
echo "<tr><img src=$Ivar><a class=top href='$PHP_SELF?closed=1&fold=$filep&d=$d'><img border=0 src='images\folderopen.gif'></a><b><a class=top href='$PHP_SELF?closed=1&fold=$filep&d=$d'>$file</a></b></tr>";
traverse_dir($dir,$dir_array,1);
}

else if(is_dir("$dir/$file"))
echo "<tr><img src=$Ivar><a class=top href='$PHP_SELF?opened=1&fold=$filep&d=$d'><img border=0 src='images\folder.gif'></a><b><a class=top href='$PHP_SELF?opened=1&fold=$filep&d=$d'>$file</a></b></tr>";
else
echo "<tr><img src=$Ivar><a class=top target=_blank href='$basedir/$file'><img border=0 src='images\file.gif'></a><a class=top target=_blank href='$basedir/$file'>$file</a></tr>";
}


?>
 
l'artenativa sarebbe quella di inviare direttamente l'allegato ma la mail di destinazione deve essere impostata volta per volta
 

Discussioni simili