<?

    //include("authentication.php");

	include("conexao_e_agenda.php");

    include("funcoes.php");

//-------------------------------fim da autenticação---------------------//

if (isset($_GET['id_tcomp'])){

	  $id_tcomp=$_GET['id_tcomp'];

  } else {

	  $id_tcomp="";

  }

if ($_SERVER["SERVER_ADDR"] == '127.0.0.1' ){

$filename = "../banners.dat";

}else{

$filename = "/home/afmmcom/public_html/e_clube/banners.dat";

}

$handle = fopen ("$filename", "w");

   

 $sql="SELECT * FROM baner_fotos where destaque='r' order by id desc";

 //EXECUTA A QUERY               

 $sql = mysqli_query($conexao,$sql);

 $linha_f=mysqli_fetch_array($sql);

 $row = mysqli_num_rows($sql);    



//VERIFICA SE VOLTOU ALGO 

 

if($row) { 

    //$xml .= "<pic>\n";  //  name=\"Introducing Seattle\"           

//---

   //PERCORRE ARRAY            

   for($i=0; $i<$row; $i++) { 

   $c = $i + 1; 

      $foto = mysqli_result($sql, $i, "caminho_foto"); 

	  $link = mysqli_result($sql, $i, "link");//datapadrao_data($data_foto)

      $xml .= $foto."|".$link."\n";

   }//FECHA FOR                 

   

   //$xml.= "</pic>\n";

 } //FECHA IF (row)

//} 



   //CABEÇALHO

   //Header("Content-type: application/text; charset=utf-8"); 

     

		if (is_writable($filename)) {



        // Escrevendo $$registro para o arquivo aberto.

        if (!fwrite($handle, $xml, 200024)) {

        print "Erro escrevendo no arquivo ($filename)";

        exit;

    	}

}



    fclose($handle);   

                                     

 header("location:cad_baner_alt.php?id_tcomp=$id_tcomp");           

?>