-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbusca.php
More file actions
123 lines (115 loc) · 3.88 KB
/
busca.php
File metadata and controls
123 lines (115 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php include "config.php"; ?>
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" type="image/png" href="http://<?php echo $url; ?>/favicon.png">
<title>Serviço SPFBL</title>
<link rel="stylesheet" href="http://<?php echo $url; ?>/style.css">
<link rel="stylesheet" href="/notify.css">
</head>
<body>
<div id="container">
<div id="divlogo">
<img src="http://<?php echo $url; ?>/logo.png" alt="Logo">
<hr>
</div>
<div id="divmsg">
<p id="titulo">Procurar um relatório de erro.</p>
<div class='warn'> Atenção: A busca só opera para a data atual.</div>
</div>
<hr>
<?php
// Nossas variáveis
$remetente = filter_var(urldecode($_GET['rem']),FILTER_VALIDATE_EMAIL,FILTER_SANITIZE_EMAIL);
$destinatario = filter_var(urldecode($_GET['dest']),FILTER_VALIDATE_EMAIL,FILTER_SANITIZE_EMAIL);
if( !empty($remetente) && !empty($destinatario)){
iniciar($remetente, $destinatario);
}else{
echo "<div class='warn'> Sem informações para processar. </div>";
}
function iniciar($remetente, $destinatario){
echo "<div class='info'> Buscando logs que contenham
<br> Remetente: ".$remetente."
<br> Destinatario: ".$destinatario."
</div>\n";
// Lê um arquivo em um array.
// /var/log/spfbl/spfbl.2017-07-08.log
$log = "/var/log/spfbl/spfbl.".date('Y-m-d').".log";
$lines = file($log);
$existLog = false; $printline=false; $printBlock=false; $printOk = false;
$thisLine = "";$i=0;
$searchd = "/".$destinatario."/";
$searchr = "/".$remetente."/";
if ($lines) {
foreach ($lines as $line) {
if(preg_match('/(SPFTCP)([0-9]{3})( SPFBL)/', $line)){
$itens = explode(" ", trim($line));
$x=0;
foreach($itens as $item) {
$item = str_replace(array('\'', '"'), '',$item); // Limpa quotes
$item = str_replace(array('\n', ''), '',$item); // Limpa \n
if($x==0 | $x==8 | $x==9 | $x==10 | $x==13){
$thisLine = $thisLine.$item."<br>\n";
if($x==8){
$ip=$item;
}
if($x==10){
$helo=$item;
}
if($x==14){ // Define a URL do SPFBL
$urlSPFBL=$item;
}
}
if($item==$remetente){
//$thisLine = $thisLine.$item." ";
}elseif(preg_match($searchd, $item) && preg_match($searchr, $thisLine)){
//$thisLine = $thisLine.$item." ";
$existLog=true;
$printline=true;
}elseif($item=="PASS" | $item=="WHITE" ){
$printOk = true;
}elseif($item=="BLOCKED" | $item=="FAIL" | $item=="SOFTFAIL"){
$printBlock = true;
}
$x++;
}
if($printline==true){
if($printOk==true){
echo "<div class='sucess'>Linha #<b>".$i."</b> : " . $thisLine . "
<br> <a target='_blank' href='/consulta.php?ip=".$ip."&rem=".$remetente."&helo=".$helo."&dest=".$destinatario."'> Consultar configuração </a>
</div>\n";
}elseif($printBlock==true){
echo "<div class='error'>Linha #<b>".$i."</b> : " . $thisLine . "
<br> <a target='_blank' href='/consulta.php?ip=".$ip."&rem=".$remetente."&helo=".$helo."&dest=".$destinatario."'> Consultar configuração </a>
</div>\n";
}else{
echo "<div class='warn'>Linha #<b>".$i."</b> : " . $thisLine . "
<br> <a target='_blank' href='/consulta.php?ip=".$ip."&rem=".$remetente."&helo=".$helo."&dest=".$destinatario."'> Consultar configuração </a>
</div>\n";
}
}
$thisLine="";
$printline=false; $printBlock=false; $printOk=false;
$ip = ""; $helo = "";
}
$i++;
}
if($existLog==false){
echo "<div class='warn'> Sem Logs para a busca. </div>";
}
}
}
?>
<hr>
<div id="divfooter">
<div id="divanuncio">
Anuncie aqui pelo <a target='_blank' href='http://a-ads.com?partner=455818'>Anonymous Ads</a>
</div>
<div id="divpowered">
Powered by <a target='_blank' href="http://spfbl.net/">SPFBL.net</a>
</div>
</div>
</div>
</body>
</html>