<?
require('conexion.php');



if(ini_set("max_execution_time", "0"))
echo "Parámetro cambiado.<br><br>";
else
echo "Error al cambiar el parámetro.<br><br>";




$archivo = file("prueba_2.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++){ 
	$correo = $archivo[$i];
$correo = str_replace("\r", "", $correo);
$correo = str_replace("\n", "", $correo);
$correo = eregi_replace("@","#",$correo);

echo '<br><b>'.$correo.'</b><br />';

$rsql = "SELECT EMAIL,NOBOLETIN FROM POTENCIALES WHERE (EMAIL like '$correo')";
$results=odbc_exec($cid,$rsql)or die(exit("Error en odbc_exec"));
$num_results = odbc_fetch_row($results);
if ($num_results>=1) {
	
	//existe, modificamos sus datos
	$fecha_pre1 = 2009-05-10;
	$motivo = 'No quiero recibir spam';
	$tsql =  "UPDATE POTENCIALES SET NOBOLETIN='1', USU_NOBOLETIN='WB', MOTI_NOBOLETIN='$motivo' WHERE EMAIL='$correo'";
$results=odbc_exec($cid,$tsql)or die(exit("Error en odbc_exec"));
	

//print odbc_result_all($result,"border=1");
}


$sql="Select EMAIL,NOBOLETIN from potenciales WHERE EMAIL like'$correo'";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

}







//comprobamos si existe en potenciales
/*
$rsql = "SELECT EMAIL,NOBOLETIN FROM POTENCIALES WHERE (EMAIL like '$correo')";
$results=odbc_exec($cid,$rsql)or die(exit("Error en odbc_exec"));
$num_results = odbc_fetch_row($results);
if ($num_results>=1) {
	/*
	//existe, modificamos sus datos
	$fecha_pre1 = 2009-05-10;
	$motivo = 'No quiero recibir spam';
	$tsql =  "UPDATE POTENCIALES SET NOBOLETIN='1', USU_NOBOLETIN='WB', MOTI_NOBOLETIN='$motivo' WHERE EMAIL='$correo'";
$results=odbc_exec($cid,$tsql)or die(exit("Error en odbc_exec"));
	*/
/*
print odbc_result_all($result,"border=1");
}

/*
$sql="Select * from potenciales WHERE EMAIL like'$correo'";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/

/*
$sql="Select top 100 * from potenciales WHERE numero like '00%' order by chofer DESC ";
//$sql="Select top 20 * from potenciales";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select top 20 * from MSN ORDER BY CODIGO DESC";
//$sql="Select top 20 * from potenciales";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select * from CHOFERES WHERE COD_CHOF like '00%' ORDER BY COD_CHOF DESC";
//$sql="Select top 20 * from potenciales";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/

/*
$sql="Select * from CONFI_EMP";
//$sql="Select top 20 * from PRESUP1 WHERE NUMERO_PRE like '00%' ORDER BY NUMERO_PRE DESC";
//$sql="Select * from PERSONAL WHERE COD_PERS like '07%'";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

*/
/*
$sql="Select * from CONCEP_FACTUR";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/


/*

$sql = "SELECT * FROM TARIFAS_PRECIOS";

$sql = "SELECT * FROM TARIFAS_PRECIOS WHERE (TARIFA = 'TARIDISPO8') AND (GRUPO = 'M') AND (CONCEPTO = '5')";
*/
/*
$sql="Select * from TARIFAS_PRECIOS";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/

/*
$sql="Select top 20 * from PRESUP1 WHERE  NUMERO_PRE like '00%' ORDER BY NUMERO_PRE DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");


$sql="Select top 20 * from PRESUP2 WHERE NUMERO_PRE like '00%' ORDER BY NUMERO_PRE DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");


$sql="Select top 20 * from LIPRESUP WHERE NUMERO like '00%' ORDER BY NUMERO DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

/*
$sql="Select * from POBLACIONES";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

$sql="Select * from PROVINCIA";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select * from POTENCIALES WHERE NUMERO LIKE'0001%' ORDER BY NUMERO DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

/*
$sql="Select top 100 * from PERSONAL WHERE COD_PERS like'07%' ORDER BY COD_PERS DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select TOP 30 * from COMISIO";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
/*
$sql="Select top 100 * from CHOFERES WHERE COD_CHOF like'07%' ORDER BY COD_CHOF DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

$sql="Select top 100 * from CHOFER_IDIOMAS WHERE CHOFER LIKE '07%' ORDER BY CHOFER DESC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/


/*
$email = 'jdavid#agenciacreativa.net';
$nif = '23264467J';

$sql="Select top 1 count(EMAIL) AS num_mail, count(NIF) AS num_nif from POTENCIALES WHERE EMAIL='$email' AND NIF='$nif'";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
while ($row = odbc_fetch_array($result)) {
	echo $row['num_mail'];
	echo '<br>';
	echo $row['num_nif'];
}


$sql="Select * from ntari WHERE NOPUBLICARWEB='0' ORDER BY ORDENWEB ASC";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
/*
while ($row = odbc_fetch_array($result)) {
	
	echo $row['CODIGO'].' - '.$row['NOMBRE'].'<br />';
	
}
*/


/*
$sql="Select * from ntari";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select * from CONCEP_FACTUR";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");



$sql="Select * from vehiculo1";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");


$sql="Select * from vehiculo2";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
/*
$sql="Select * from CONDICIONES";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select * from TARI_COND";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/
/*
$sql="Select * from IDIOMA_TRADUCCION";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");

/*
$sql = "SELECT * FROM TARIFAS_PRECIOS";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
/*
$sql="Select * from COMISIO";
$result=odbc_exec($cid,$sql)or die(exit("Error en odbc_exec"));
print odbc_result_all($result,"border=1");
*/

?>