<?

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

    //include("authentication.php");

	include("conexao.php");

	//include("conexao_e_agenda.php");

	include("funcoes.php");



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

 /// tarefa do cron : php /home/afmmcom/public_html/e_clube/adm/executando_envio_infs_cron.php



  $select_cadm = "SELECT * FROM informativo_hora WHERE rodou='n' ORDER BY id ASC LIMIT 1"; 

  $result_cadm = mysqli_query($conexao,$select_cadm) or die(mysqli_error($conexao));

//-----------------------------------------------------------------------

//continuar o codigo...

  //while ($linha_cadm=mysqli_fetch_array($result_cadm)){ 

  $tr = mysqli_num_rows($result_cadm);  

  $linha_cadm=mysqli_fetch_array($result_cadm);

  $id_tcomp = $linha_cadm['id'];

  $codigo = $linha_cadm['codigo'];

  $id_inf = $linha_cadm['id_informativo'];

  $intervalo = $linha_cadm['intervalo'];

  

 //horário normal Brasil

 $timestamp = mktime(date("H")-3, date("i"), date("s"), date("m"), date("d"), date("Y"), 0);

 $data_hora = gmdate("d/m/Y H:i:s", $timestamp);

 //horário verão Brasil

 $timestamp2 = mktime(date("H")-2, date("i"), date("s"), date("m"), date("d"), date("Y"), 0);

 $data_hora2 = gmdate("d/m/Y H:i:s", $timestamp2);

 



  $data_atual = substr($data_hora,0,10);

  $hora_atual = substr($data_hora,11,8);

  

  //$hora_atual_s = date("H:i:s");  

  //$hora_atual = status_codigo($hora_atual_s,5);

  //$data_atual = date("Y-m-d");

//==================================

  $result = mysqli_query($conexao,"UPDATE informativo_hora SET

  hr_cron='".$hora_atual."',

  dt_cron='".datapadrao_date($data_atual)."'   

  where id='".$id_tcomp."'") or die(mysqli_error($conexao));

//==================================     

  if($tr==1){

  

  //==================================================================================

  $result = mysqli_query($conexao,"UPDATE informativo_hora SET

  rodou='s', 

  hr_execucao='".$hora_atual."',

  dt_execucao='".datapadrao_date($data_atual)."'   

  where id='".$id_tcomp."'") or die(mysqli_error($conexao));

 //==================================================

  $sql_inf="SELECT * FROM informativo_fila where id='$id_inf'";

  $result_inf=mysqli_query($conexao,$sql_inf) or die (mysqli_error($conexao));		  

  $linha_inf=mysqli_fetch_array($result_inf);  

  

// Recupera os dados do formulÃ¡rio

$tipo      = $linha_inf["tipo"];

$horainf   = $linha_inf["hr_cad"];

$datainf   = $linha_inf["dt_cad"];



//=================================================

  } // atalho do teste

//=================================================  

/* if($tipo=="msoftx"){ 

//$sql_cad="SELECT DISTINCT(email) FROM base_email WHERE dominio!='maringa.pr.gov.br' AND situacao='a' ORDER BY id ASC";

$sql_grava = array("",

"SELECT DISTINCT(email),nome FROM base_email WHERE email='marcosaplopes@gmail.com' AND situacao='a' ORDER BY id ASC LIMIT 0,300");

} */

  

/* if($tipo=="todos"){

//$sql_cad="SELECT DISTINCT(email) FROM base_email WHERE situacao='a' ORDER BY id ASC";

$sql_grava = array("",

"SELECT DISTINCT(email),nome FROM base_email WHERE situacao='a' ORDER BY id ASC LIMIT 0,300", 

"SELECT DISTINCT(email),nome FROM base_email WHERE situacao='a' ORDER BY id ASC LIMIT 301,300",

"SELECT DISTINCT(email),nome FROM base_email WHERE situacao='a' ORDER BY id ASC LIMIT 601,300",

"SELECT DISTINCT(email),nome FROM base_email WHERE situacao='a' ORDER BY id ASC LIMIT 901,300",

"SELECT DISTINCT(email),nome FROM base_email WHERE situacao='a' ORDER BY id ASC LIMIT 1201,300",

"SELECT DISTINCT(email),nome FROM base_email WHERE situacao='a' ORDER BY id ASC LIMIT 1501,300"); 

}   */

//==================================================

 /* $sql_cad = $sql_grava[$codigo];

 $result_cad=mysqli_query($conexao,$sql_cad) or die (mysqli_error($conexao));		  



 $cont = 0;

 //$conts = 0;

 //$vazio = " ";

 while ($linha_cad = mysqli_fetch_array($result_cad)){



  $cont++;

  /* 

  $conts++;

  if($conts==8){

  $quebra = "<br>";

  $conts = 0;

  }

  echo "[ ".$linha_cad['nome']." ] ".$linha_cad["email"].";".$quebra;

  //echo $linha_cad['email'].";".$quebra;

  $quebra = ""; */

  

//===========================

/*   $result = mysqli_query($conexao,"insert into informativo_lote SET

  id_informativo='".$id_inf."', 

  dt_informativo='".$datainf."',

  hr_informativo='".$horainf."',

  codigo='".$codigo."',

  tipo='".$tipo."',

  intervalo='".$intervalo."',

  email='".$linha_cad['email']."', 

  nome='".$linha_cad['nome']."'

  ") or die (mysqli_error($conexao));  */

//===========================

  

//}//fim while

 

 /* $result = mysqli_query($conexao,"UPDATE informativo_hora SET

  enviou='".$cont."'  

  where id='".$id_tcomp."'") or die(mysqli_error($conexao)); */

  

//}//fim if





 exit();

?> 