<?

    include("authentication.php");

	include("conexao_e_agenda.php");

    include("funcoes.php");

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



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

$filename = "../gallery.xml";

}else{

$filename = "/home/msoftx/www/kuriyama/site/gallery.xml";

}

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

//$dominio_cliente = "www.mariotiveiculos.com";          

   //XML

   $xml  = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";

   $xml .= "<gallery title=\"www.kuriyamaartemoda.com\" thumbDir=\"./fotos_galerias/mini/\" imageDir=\"./fotos_galerias/\" random=\"true\">\n";

   

   $sql_c="select * from galerias where situacao='d' order by id asc";

   $result_c=mysqli_query($conexao,$sql_c) or die (mysqli_error($conexao));

   while($linha=mysqli_fetch_array($result_c)) { 

   $galeria = $linha['id'];

   

 $sql="select * from galerias_fotos where fk_galeria='$galeria' order by id asc";

 //EXECUTA A QUERY               

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

 $linha_f=mysqli_fetch_array($sql);

 $row = mysqli_num_rows($sql);    

 $descgaleria = $linha_f["evento"];

 $descgaleria_local = $linha["local"];

//VERIFICA SE VOLTOU ALGO 

 

if($row) { 

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

//---

   //PERCORRE ARRAY            

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

   $c = $i + 1; 

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

	  $data_foto = mysqli_result($sql, $i, "dt_foto");

	  $titulo = mysqli_result($sql, $i, "evento");

	  $modelo = mysqli_result($sql, $i, "local");

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

      $xml .= "<image>\n";     

      $xml .= "<date>".datapadrao_data($data_foto)."</date>\n";                  

      $xml .= "<title>".$c." ".$titulo."</title>\n";

      $xml .= "<desc>".$descgaleria_local."</desc>\n";                  

      $xml .= "<thumb>".$foto."</thumb>\n";

      $xml .= "<img>".$foto."</img>\n";         

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

   }//FECHA FOR                 

   

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

 } //FECHA IF (row)

} 

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

   //CABEÇALHO

   Header("Content-type: application/xml; charset=iso-8859-1"); 

     

		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_galeria_alt.php?id_c=$_GET[id_c]");           

?>