class Banner
{
private function Pegar_Fotos()
{
$dir = "\banner";
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 "";
$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 "";
}
}
}
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();
?>