Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Banner Rotativo usando txt
sistema automatico basta passar o path onde esta a pasta das fotos
ele exibe as fotos na sequencia e nao aleatoriamente pratico e nao usa banco mysql usa txt
[tr]
PHP [/tr][tr]
php
class Banner
{
private function Pegar_Fotos()
{
$dir = "c:/root/banner/img/";
if ($dh = opendir($dir))
{
$i = 0;
$fotos = "";
$banco = "";
while (($file = readdir($dh)) !== false)
{
if ($file != "." && $file != ".." && $file != "Thumbs.db")
{
if(filetype($dir . $file) != "dir")
{
$fotos .= "$i|$file\r\n";
$banco .= "$i|\r\n";
$i++;
}
}
}
closedir($dh);
$fp = fopen("fotos.txt", "w+");
fputs($fp, $fotos);
fclose($fp);
$fp = fopen("banco.txt", "w+");
fputs($fp, $banco);
fclose($fp);
}
}
public function Exibir_Foto()
{
if(!file_exists("fotos.txt"))
{
$this->Pegar_Fotos();
}
else
{
$i = $this->Ultimo_Banner();
$foto = file("fotos.txt");
$conta = count($foto);
$i++;
if($i == $conta)
{
$i = 0;
}
if($i $conta
) {
$img = explode("|", $foto[$i]);
echo "/applications/core/interface/imageproxy/imageproxy.php?img=%5C%22img/%24img%5B1%5D%5C%22&key=3fc61ecfb455cc073f7cba2e699dac965f262b7ce77325553d016767fe7883f4" alt='$img[1]\"'>";
$fp = fopen("tmp.txt", "w+");
fputs($fp, $i);
fclose($fp);
}
else
{
$fp = fopen("tmp.txt", "w+");
fputs($fp, 0);
fclose($fp);
$img = explode("|", $foto[0]);
echo "/applications/core/interface/imageproxy/imageproxy.php?img=%5C%22img/%24img%5B1%5D%5C%22&key=3fc61ecfb455cc073f7cba2e699dac965f262b7ce77325553d016767fe7883f4" alt='$img[1]\"'>";
}
}
}
public function Ultimo_Banner()
{
if(file_exists("tmp.txt"))
{
$fp = file("tmp.txt");
return $fp[0];
}
else
{
$fp = fopen("tmp.txt", "w+");
fputs($fp, 0);
fclose($fp);
return 0;
}
}
}
$banner = new Banner();
$banner->Exibir_Foto();
?>
[/tr]
é usei isso mas da pra usar expressoes tbm fica melhor:
if(eregi("\.(jpg|jpeg|bmp|gif|png){1}$", $nomearq)){
beleza
eheheh
esse thumbs.db...