나는 내 일을 돕기 위해 작은 시스템을 만들려고 노력하고 있습니다. 테스트 및 실패, 여기에서 몇 가지 기사를 읽고,이 코드 작업을했다 :file_get_contents 마지막 레코드
error_reporting(error_reporting() & ~E_NOTICE);
header("Content-Type: text/html; charset=ISO-8859-1", true);
$opts = array('http'=>array('method'=>"GET",
'header'=>"Accept-Language: pt-BR\r\n" .
"Cookie: ASPSESSIONIDSCSSRCRA=MHFGEDNDPHHBJDHGCMJKPDKN; ASPSESSIONIDQCSTTDRB=EKJNDDNDGGFMAHBFJABMJNAM".session_name()."=".session_id()."\r\n"));
$context = stream_context_create($opts);
session_write_close(); // unlock the file
$url = "http://www.comprasnet.gov.br/pregao/fornec/mensagens_acomp.asp?prgcod=622924";
$contents = file_get_contents($url, false, $context);
session_start(); // Lock the file
echo ($contents);
// Função para procura várias palavras em uma string
function procpalavras01 ($contents, $palavras, $resultado = 0) {
foreach ($palavras as $key => $value) {
$pos = stripos($contents, $value);
if ($pos !== false) {
$palavras_encontradas[] = $value; }
}
if (is_array($palavras_encontradas)) {
$palavras_encontradas = implode(",",$palavras_encontradas);
}
return $palavras_encontradas;
}
$palavras = array ("Ilma Chaves Pereira","19.026.964/0001-37","origina","correio","@");
$resultado = procpalavras01($contents, $palavras);
//Variáveis
$nome = ('ACLicita');
$mensagem = ('Pregoeiro chama no pregão');
$pregao = ('72016');
$uasg = ('160019');
$data_envio = date('d/m/Y');
$hora_envio = date('H:i:s');
// Compo E-mail
$arquivo = "
<style type='text/css'>
body {
margin:0px;
font-family:Verdane;
font-size:12px;
color: #666666;
}
a{
color: #666666;
text-decoration: none;
}
a:hover {
color: #FF0000;
text-decoration: none;
}
</style>
<html>
<table width='510' border='1' cellpadding='1' cellspacing='1' bgcolor='#CCCCCC'>
<tr>
<td>
<tr>
<td width='500'>Nome:$nome</td>
</tr>
<tr>
<td width='320'>Mensagem:$mensagem</td>
</tr>
<tr>
<td width='320'>Pregão:$pregao</td>
</tr>
<tr>
<td width='320'>Uasg:$uasg</td>
</tr>
<tr>
<td width='320'>Palavra Encontrada:$resultado</td>
</tr>
</td>
</tr>
<tr>
<td>Este e-mail foi enviado em <b>$data_envio</b> às <b>$hora_envio</b></td>
</tr>
</table>
</html>
";
//enviar
// emails para quem será enviado o formulário
$emailenviar = "[email protected]";
$destino = $emailenviar;
$assunto = "Atenção ao Pregão: " . $pregao . " Uasg: " . $uasg;
// É necessário indicar que o formato do e-mail é html
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ACLicita';
//$headers .= "Bcc: $EmailPadrao\r\n";
if ($resultado === null) {
} else {
$enviaremail = mail($destino, $assunto, $arquivo, $headers);
}
그것은 잘 작동하지만 난이 (날짜와 시간에 의해) 링크 마지막 메시지를 확인하려면, 그리고 경우 이미 보냈는데 다시 보내지 마십시오. 웹 사이트는 새로 고침 시스템을 가지고 있기 때문에 웹 사이트가 새로 고침 될 때마다 코드가 갱신되어 $ palavras에있는 단어가 발견되면 다른 메일을 보냅니다. 도와 주거나 저에게 길을 보여 주시겠습니까, 약간의 빛이 어떻게이를 바로 잡을 수 있습니까? 내가 나 자신을 분명히했는지 나는 모른다.
편집 1 : 코드 테이블에 inserto하려고 :
if ($resultado === null) {
} else {
$enviaremail = mail($destino, $assunto, $arquivo, $headers);
$sql = "INSERT INTO Licita (date, assunto, arquivo, email)
VALUES ('$date', '$assunto', '$arquivo', '$emailenviar')";
}
우리가 어떻게 그것을 보내거나하지 있었는지 알 수 있습니까? –
그게 내가 알고 싶은 지적이다. 전에 나는 PHP에 대해 아무것도 모릅니다. 내가 아는 전부는 어떤 단어가 링크에서 발견되면 메일이 도착한다는 것입니다. –
당신은 "링크의 마지막 메시지 (날짜와 시간 기준) 만 확인하고, 이미 보낸 경우 다시 메일을 보내지 마십시오"라고 말했습니까? 보낸 편지에 td의 특정 단어가 있습니까? –