Jump to content


Photo

Como Ordenar Arquivos Do Diretorio?


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 nbr2004

nbr2004

    Novato no fórum

  • Usuários
  • 19 posts
  • Sexo:Não informado

Posted 28/04/2006, 13:36

boa tarde pessoal estou com um problema, meu eu troquei de servidor e meu codigo ficou louco...
exemplo ele tem que ordenar as fotos em sequencia, só que agora ele está misturando tudo..
ele tá buscando tudo que é JPG em uma determinada pasta aí ele tinha que exibir assim oh

001.jpg 002.jpg
003.jpg 004.jpg
005.jpg 006.jpg
007.jpg 008.jpg
e assim por diante alguém poderia me ajudar??
as informacoes do meu servidor são:
Apache :: MySql 4.1.18-standard-log :: PHP 4.4.2

segue o codigo abaixo

<?php

// titulo da pagina
$title = ":: Portal Una&iacute; :: O Site feito para Voc&ecirc";

// variável que define o diretório das imagens 
$dir = "./imagem";

?> 

<html>

<head>
<style>
a {text-decoration:none; color:black;}
a:hover {text-decoration:none; color:blue;}
.lnk {font-family: Tahoma; font-size: 8pt; color:black}
.lnk:hover {font-family: Tahoma; font-size: 8pt; color:ffdd00}
body { scrollbar-face-color: #DFEBFF; scrollbar-shadow-color: #006699; scrollbar-highlight-color: #006699; scrollbar-3dlight-color: #DFEBFF; scrollbar-darkshadow-color: #DFEBFF; scrollbar-track-color: #DFEBFF; scrollbar-arrow-color: #006699; }
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-style: italic;
	font-size: 10px;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-style: italic; font-size: 14px; }
</style>
<title><? echo "$title"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#DFEBFF">
<TABLE width="770" border=0 align="center" cellPadding=0 cellSpacing=0>
  <TBODY>
	<TR> 
	  <TD align=left><table height="19" border="0" align="center" cellpadding="0" cellspacing="0">
		  <tr> 
			<td> <div align="center"></div>
			  <div align="center"> 
				<? include "../banner_festas.php"; ?>
			  </div></td>
		  </tr>
		</table></TD>
	</TR>
  </TBODY>
</TABLE>
<? 
# pegando a pasta da festa atual
$onde = getcwd();
$diretorioatual = str_replace("/home/portalun/public_html/", "", $onde);
# fim pegando a pasta da festa atual
echo "<center>";
?>
<?
if (strstr($pg,".")== TRUE)
	{
		$pg=ceil($pg);
		$pg=$pg-1;
	}
if (!$pg==0)
	{
		$cont=$pg * 12;
	}
	else
		{
			$cont=0;
		}
?>
<div align="center">
  <table width="779" border="0" align="center">
	<tr> 
	  <td width="589" height="20" background="../imagens/curva_menu.jpg" bgcolor="#FFFFFF"> 
		<div align="center"><font face="verdana" size="1"> 
		  <script language=JavaScript>
<!-- 
var d = new Date()
var h = d.getHours()
if (h < 12)
document.write("Bom dia! ")
else
if (h < 18)
document.write("Boa tarde! ")
else
document.write("Boa noite! ")
// -->
</SCRIPT>
		  Unaí-MG, 
		  <script language=JavaScript>
<!-- 
today = new Date()
document.write(" ",today.getHours(),":",today.getMinutes(),"h")
document.write(
" do dia: ",today.getDate(),"/",today.getMonth()+1,"/",today.getYear());
//  -->
</SCRIPT>
		  </font> </div></td>
	</tr>
  </table>
  <TABLE width="777" 
			border=0 align=center cellPadding=0 cellSpacing=0>
	<TBODY>
	  <TR vAlign=bottom bgcolor="#E1E1E1"> 
		<TD width=155 height=15> <DIV align=center> 
			<TABLE cellSpacing=0 cellPadding=0 width="155" align=center 
				  border=0>
			  <TBODY>
				<TR> 
				  <TD width="27%" bgcolor="#E1E1E1"> <div align="left"></div></TD>
				</TR>
			  </TBODY>
			</TABLE>
		  </DIV></TD>
		<TD width=113 height=15 vAlign=center> <div align="center"><FONT 
				  face="Verdana, Arial, Helvetica, sans-serif"><FONT size=1><A 
				  href="../../index.php"><strong>&nbsp;&nbsp;P&aacute;gina Inicial</strong></A></FONT></FONT></div></TD>
		<TD width=93 height=15 vAlign=center bgcolor="#E1E1E1"> <div align="center"><FONT 
				  face="Verdana, Arial, Helvetica, sans-serif"><FONT size=1><A 
				  href="../../categoria.php?cat=anuncios"><strong>&nbsp;&nbsp;An&uacute;ncios</strong></A></FONT></FONT></div></TD>
		<TD width=117 height=15 vAlign=center bgcolor="#E1E1E1"> <div align="center"><FONT 
				  face="Verdana, Arial, Helvetica, sans-serif"><FONT size=1><A 
				  href="../../categoria.php?cat=galeria_fotos"><strong>&nbsp;Galeria 
			de Fotos</strong></A></FONT></FONT></div></TD>
		<TD width=124 height=15 vAlign=center> <DIV align=center><FONT 
				  face="Verdana, Arial, Helvetica, sans-serif"><FONT size=1><A 
				  href="../../categoria.php?cat=fale_conosco"><strong>Fale Conosco</strong></A></FONT></FONT></DIV></TD>
		<TD width=24 height=15 vAlign=center> <DIV align=center><FONT 
				  face="Verdana, Arial, Helvetica, sans-serif"><FONT size=1></FONT></FONT></DIV></TD>
		<TD width=26 height=15 vAlign=center> <div align="left"><FONT 
				  face="Verdana, Arial, Helvetica, sans-serif"><FONT size=1><A 
				  href="http://www.factu.br/fale_conosco.php"> </A><a href="#" onClick="this.style.behavior='url(#default#homepage)';this.sethomepage('http://www.portalunai.com.br');" onMouseOver="window.status='Adicionar à Página Inicial';return true" onMouseout="window.status='';return true">&nbsp;</a></FONT></FONT></div></TD>
		<TD width=125 vAlign=center>&nbsp;</TD>
	  </TR>
	</TBODY>
  </TABLE>
		
  <TABLE width="770" border=0 align="center" cellPadding=0 cellSpacing=0>
	<TBODY>
	  <TR>
		<TD align=left><table height="19" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
			  <td><div align="center"></div>
				  <div align="center">
					<? include "../inc/banner_central.php"; ?>
				</div></td>
			</tr>
		</table></TD>
	  </TR>
	</TBODY>
  </TABLE>
  <br>
  <?
$handle = opendir($dir);
$ext = "jpg";
$indice = 0;
$ipp = 30;

while (false !== ($file = readdir($handle)))
{
   $pathdata = pathinfo($file);
   if (!is_dir($file) && ($pathdata["extension"] == strtolower($ext)) || ($pathdata["extension"] == strtoupper($ext)))
   {
	   $imagens[$indice] = $file;
	   $indice++;
   }
}
$pagina = 1;
if ($_GET['pg'])
   $pagina = $_GET['pg'];

	$paginas = ceil(count($imagens) / $ipp);
	$inicio = $pg * $ipp;
echo '<center>';
	for ($i=$inicio; $i<($inicio+$ipp); $i++)
		if($imagens[$i] != "")
			{ ?>
  <? $cont=$cont+1; ?>
  <?  echo "
  <tr> 
	<td>
		<img src=$dir/$imagens[$i] width=350 height=263 cellSpacing=0 cellPadding=0 border=1></a>
	</td>
  </tr>
"; ?>
  <? }echo '</center>'; ?>
</div>
<div align="center">
  <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr> 
	  <td width="230" align="center" valign="top"> <div align="right"> </div>
		<HR width="779" size="1" noshade color="<? echo $cortexto?>"> 
		<table width="779" border="0" cellspacing="0" cellpadding="0">
		  <tr> 
			<td width="166" valign="top"><div align="center"><font color="<? echo $cortexto?>" size="<? echo $tfonte?>" face="<? echo $fonte?>"><strong> 
				<? $total = ceil(count($imagens)); echo $total; ?>
				Fotos.</strong></font></div></td>
			<td width="378" align="right" valign="top"> <div align="center"><font color="<? echo $cortexto?>" size="<? echo $tfonte?>" face="<? echo $fonte?>"><strong>Galerias:</strong> 
				| 
				<? //aki moastra a quantidade de páginas
for($i=0; $i<$paginas; $i++){
$url = "?pg=$i";
  if ($i==$pg) {
  echo " <b>".($i+1)."</b> |";
  } else {
  echo " <a href='$url'>".($i+1)."</a> |";
  }
} 
?>
				</font> </div></td>
			<td width="235" align="right" valign="top"><div align="left"><strong></strong></div></td>
		  </tr>
		</table></td>
	</tr>
  </table>
  <TABLE width="770" border=0 align="center" cellPadding=0 cellSpacing=0>
	<TBODY>
	  <TR>
		<TD align=left><table height="19" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
			  <td><div align="center"></div>
				  <div align="center">
					<? include "../inc/banner_central.php"; ?>
				</div></td>
			</tr>
		</table></TD>
	  </TR>
	</TBODY>
  </TABLE>
  <div align="center"></div>
  <table width="770" border="0" align="center">
	<tr> 
	  <td width="738"><div align="center"> 
		  <? include "../inc/direitos_autorais.inc"; ?>
		  <a target="_blank" href="http://www.nedstatbasic.net/stats?ACiCyw8vf/o48EwQ7onL2I5WHraQ"><img
src="http://m1.nedstatbasic.net/n?id=ACiCyw8vf/o48EwQ7onL2I5WHraQ"
border="0" width="1" height="1"
alt="Nedstat Basic - Free web site statistics
Personal homepage website counter"></a></div></td>
	</tr>
  </table>
</div>
</body>
</html>





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq