Newsgroup: it.comp.www.php
Titolo: Modifica script per indexer in ordine alfabetico

Uso php 4.1 e vorrei modificare il seguente script per evitare che l'elenco
dei files in una cartella compaia in ordine i inode piuttosto che
alfabetico.
Dove devo intervenire secondo voi?
<?php
//$HidePaths = False;
$HidePaths = True;
$HideRelatedFiles = True;
$AlternateColors = False;
$ImgBack = "back.gif";
$ImgCartella = "cartellina.gif";
$ImgFile = "file.gif";
$CssFile = "mystile.css";
$VoidFile = "quadratino.gif";
$i = "0";
$d = "0";
$myi = "0";
$myd = "0";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>indexer</TITLE>
<link href="mystile.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
      <table width="100%" border="0">
        <tr>
          <td colspan="3"><div class="testo18pxgorange"><a
href="javascript:history.back()"><img src="back.gif" border="0"></a>
Cartella <?php echo stripslashes($directory) ; ?></div></td>
        </tr>
<?php
$TheDir = opendir(".");
        while($File = readdir($TheDir)){
			if(is_dir($File)){
				if(($File == "." || $File == "..") && (isset($HidePaths) && $HidePaths)){
					$AllowPaths = False;
				} else {
					$AllowPaths = True;
				}
				if($AllowPaths){
					if($File != "." && $File != ".."){$myd++;}
				}
			}
		}
closedir($TheDir);
$TheDir = opendir(".");
		while($File = readdir($TheDir)){
			if(($HideRelatedFiles) && ($File == basename($PHP_SELF) || $File == $ImgBack
OR $File == $ImgFile OR $File == $ImgCartella OR $File == $CssFile OR $File
== $VoidFile)){
				$AllowFile = False;
			} else {
				$AllowFile = True;
			}
			 if($File != "." && $File != ".." && !is_dir($File) && $AllowFile){$myi++;}
		}
closedir($TheDir);
if($myd != 0){ ?>
		<tr>
          <td colspan="3"> <div class="testo13pxgorange">Sottocartelle:</div></td>
        </tr>
<?php
} else {
}
$TheDir = opendir(".");
		while($File = readdir($TheDir)){
			if(is_dir($File)){
				if(($File == "." || $File == "..") && (isset($HidePaths) && $HidePaths)){
					$AllowPaths = False;
				} else {
					$AllowPaths = True;
				}
				if($AllowPaths){ ?>
        <tr valign="middle" bgcolor="<?php if
($BRB_rowcounter++%2==0){?>#F5F5F5<?php }else{ ?>#FFFFFF<?php }?>">
          <td colspan="3"><img src="cartellina.gif" width="14" height="13"><span
class="testo10pxg"><a class="grayleft" href="<?php echo $File;
?>?directory=<?php echo $File; ?>">
            <?php echo $File; ?></a>
<?php
$mycounter = -8;
$mydir = opendir($File);
while (false !== ($filename = readdir($mydir))) {
$mycounter++;
}
?>
<span class="testo10px">
<?php
echo " (";
if ($mycounter <= 0) { ?><span class="testo10px"><?php echo 0 ;
?></span><?php } else { ?><span class="testo10pxgorange"><?php echo
$mycounter ;?></span><?php }
echo ")";
?>
</span>
<?php
closedir($mydir);
$mycounter = -8;
 ?>
</span></td>
        </tr>
        <?php } if($File != "." && $File != ".."){$d++;}
				}
			}
closedir($TheDir);
 
if($myd != 0) { ?>
        <tr>
          <td height="5" colspan="3">
            <div class="testo11pxg"><img src="quadratino.gif" width="10"
height="10"></div></td>
        </tr>
<?php } else {
}
if($myi != 0) { ?>
		<tr>
          <td colspan="3"> <div class="testo13pxgorange">Documenti:</div></td>
        </tr>
        <tr>
          <td width="67%" bgcolor="#CCCCCC">
            <div class="testo10pxg">Nome File</div></td>
          <td width="20%" bgcolor="#CCCCCC">
            <div class="testo10pxg" align="right">Data</div></td>
          <td width="13%" bgcolor="#CCCCCC">
            <div class="testo10pxg" align="right">Dim.</div>
           </td>
        </tr>
<?php } else {
}
$TheDir = opendir(".");
	while($File = readdir($TheDir)){
			if(($HideRelatedFiles) && ($File == basename($PHP_SELF) || $File == $ImgBack
OR $File == $ImgFile OR $File == $ImgCartella OR $File == $CssFile OR $File
== $VoidFile)){
				$AllowFile = False;
			} else {
				$AllowFile = True;
			}
			 if($File != "." && $File != ".." && !is_dir($File) && $AllowFile){
?>
        <tr bgcolor="<?php if ($BRB_rowcounter++%2==0){?>#FFFFFF<?php }else{
?>#F5F5F5<?php }?>">
          <td><img src="file.gif" width="15" height="13"><span class="testo10pxg"><a
class="grayleft" href="<?php echo $File; ?>">
            <?php echo $File; ?></a></span></td>
            <?php if($File != "." && $File != ".."){ ?>
                <td class="testo10px" align="right"><?php echo date("d-m-Y",
filemtime($File)); ?> <?php echo date("H:i", filemtime($File)); ?></td>
            <?php } else {
			}?>
          <td class="testo10px" align="right">
            <?php if($File != "." && $File != ".."){echo round(filesize($File)/1024,1)/*
number_format(filesize($File), 0, ".", ",")*/; ?>
            Kb
            <?php } else { } ?>
          </td>
        </tr>
        <?php $i++;}
		}
        closedir($TheDir);
if($myi != 0) { ?>
        <tr>
          <td height="5" colspan="3" class="testo11pxg"><div class="testo11pxg"><img
src="quadratino.gif" width="10" height="10"></div></td>
        </tr>
<?php } else {
}
if($myi == 0 AND $myd == 0) { ?>
        <tr>
          <td height="5" colspan="3" class="testo11pxg"><img src="quadratino.gif"
width="10" height="10"></td>
        </tr>
        <tr>
          <td height="5" colspan="3" class="testo11pxg"><div class="testo13pxgred">In
        questa cartella non sono presenti documenti</div></td>
        </tr>
        <tr>
          <td height="5" colspan="3" class="testo11pxg"><img src="quadratino.gif"
width="10" height="10"></td>
        </tr>
<?php } ?>
		<tr bgcolor="#CCCCCC">
          <td colspan="3" class="testo10pxg"> Contenuto: <?php if ($d==0) { echo
"Nessuna"; } else { echo $d; }?> sottocartell<?php if ($d==0) { echo "a"; }
else { echo "e"; }?> - <?php if ($i==0) { echo "Nessun"; } else { echo $i;
}?> document<?php if ($i==0 OR $i==1) { echo "o"; } else { echo "i"; }?>
          </td>
        </tr>
     </table>
</BODY>
--------------------------------
Inviato via 
http://arianna.libero.it/usenet/

 Dove devo intervenire secondo voi?
[stracut]
Dove devi intervenire non lo so, il tuo codice è ingarbugliato
come i miei capelli dopo due settimane che non li lavo, però sappi
che php ti mette a disposizione ben due funzioni:
http://it2.php.net/manual/it/function.fileinode.php
http://it2.php.net/manual/it/function.stat.php
sta a te usarle nel modo appropriato.
raenkrus