Initial commit

This commit is contained in:
Charlie Root 2025-03-01 00:58:18 +01:00
commit 529efd53a1
140 changed files with 10310 additions and 0 deletions

196
sendmail-mailq.php Normal file
View file

@ -0,0 +1,196 @@
<?php
include_once("./include/cfg-petar.php");
include_once("./include/layout.php");
include_once("./include/users.php");
include_once("./include/cfg-sendmail.php");
# per rimandare un msg: sendmail -v -qQ -qIq4V6hwnJ079224
?>
<!-- ------------------------------------------------------------------------ -->
<?php require 'include/inc-header.php';?>
<!-- ------------------------------------------------------------------------ -->
<?php require 'include/inc-top.php';?>
<!-- ------------------------------------------------------------------------ -->
<tr bgcolor=navy align=center>
<td colspan=7><font color=yellow><b>analisi queue</b></font></td>
<tr><td width=100% colspan=7><FORM NAME=search ACTION=<?php echo $_SERVER["PHP_SELF"] ?> METHOD=POST>
tipo di coda: <select name=sendmail_type_queue>
<option value=quarantine>quarantine</option>
<option value=queued>deferred</option>
</select>
&nbsp;&nbsp;
campo di ricerca <select name=key1>
<option value=key1_rcp>destinatario</option>
<option value=key1_sndr>mittente</option>
<option value=key1_uid>uid msg</option>
<option value=key1_qua>tipo quarantena</option>
</select>
&nbsp;&nbsp;
chiave : <INPUT TYPE=TEXT NAME=key2 SIZE=50 MAXLENGTH=50 >
&nbsp; [ <a href='javascript:document.search.submit();'>Inizia ricerca </a> ]
&nbsp; [ <a href=<?php echo $_SERVER["PHP_SELF"] ?>>Restart</a> ]
</form>
<?php
### cancellazione singolo queue_id ##############################################################
if (isset($_REQUEST["kill_queue_uid"])){
$cmdstr1 = "sudo /bin/rm /var/spool/mqueue/*".$_REQUEST["kill_queue_uid"];
echo "<tr bgcolor=navy align=center>".
"<td colspan=7><font color=yellow><b>messaggio: ".$_REQUEST["kill_queue_uid"].
" cancellato !!!</b></font></td>";
$result = shell_exec($cmdstr1);
}
### analisi singolo queue_id ####################################################################
if (isset($_REQUEST["queue_uid"])){
$cmdstr1 = "sudo /bin/cat /var/spool/mqueue/hf".$_REQUEST["queue_uid"];
$cmdstr2 = "sudo /bin/cat /var/spool/mqueue/df".$_REQUEST["queue_uid"];
echo "<tr bgcolor=navy align=center>".
"<td colspan=7><font color=red><b>messaggio: ".$_REQUEST["queue_uid"]."</b></font>".
"&nbsp;&nbsp;&nbsp;".
"<a href='".$_SERVER["PHP_SELF"]."?kill_queue_uid=".$_REQUEST["queue_uid"]."'>delete from disk</a>".
"&nbsp;&nbsp;&nbsp;".
"<a href='".$_SERVER["PHP_SELF"]."?resend_queue_uid=".$_REQUEST["queue_uid"]."'>resend from queue</a>".
"</td>";
echo "<tr>".
"<td width=100% colspan=7><font color=red>Analisi RAW headers</font><p><pre>".
shell_exec($cmdstr1).
"<tr>".
"<td width=100% colspan=7><font color=red>Analisi RAW Body</font><p><pre>".
shell_exec($cmdstr2).
"</pre></td></tr></table>";
}
### creazione lista queue ########################################################################
if (isset($_REQUEST["sendmail_type_queue"])){
$match1 = "|^(\S+)\s+(\d*)\s*(.+)<(.*)>$|i";
$match3 = "|^\s+<(.*)>$|i";
if ($_REQUEST["sendmail_type_queue"] == "quarantine"){
$cmdstr = "sudo /usr/bin/mailq -qQ ";
$match2 = "|^\s+(QUARANTINE.*)$|i";
$color = "red";
} else {
$cmdstr = "sudo /usr/bin/mailq -q -vv ";
$match2 = "|^\s+\((.*)\)$|i";
$color = "green";
}
if ($_REQUEST["key2"]){
switch ($_REQUEST["key1"]) {
case "key1_uid":
$cmdstr .= "-qI".$_REQUEST["key2"];
break;
case "key1_sndr":
$cmdstr .= "-qS".$_REQUEST["key2"];
break;
case "key1_rcp":
$cmdstr .= "-qR".$_REQUEST["key2"];
break;
case "key1_qua":
$cmdstr .= "-qQ".$_REQUEST["key2"];
break;
}
}
$index=0;
$fp = popen($cmdstr, 'r');
while ($line = fgets($fp, 4096)){
if (preg_match($match1,$line,$out)){
$index += 1;
$id[$index] = $out[1];
$size[$index] = $out[2];
$date[$index] = $out[3];
$from[$index] = $out[4];
$rcp[$index] = "";
$msg[$index] = "undefined";
}
if (preg_match($match2,$line,$out)){
$msg[$index] = $out[1];
}
if (preg_match($match3,$line,$out)){
$rcp[$index] .= $out[1]." ";
}
}
echo "<tr bgcolor=navy>".
"<td ><font color=yellow>-</font></td>".
"<td ><font color=yellow>id</font></td>".
"<td ><font color=yellow>mittente</font></td>".
"<td ><font color=yellow>dim.</font></td>".
"<td ><font color=yellow>data</font></td>".
"<td ><font color=yellow>destinatari</font></td>".
"<td ><font color=yellow>messaggio</font></td>";
for ($i = 1; $i <= $index; $i++) {
echo "<tr>".
"<td>".$i."</td>".
"<td><a href=".$_SERVER["PHP_SELF"]."?queue_uid=".$id[$i].">".$id[$i]."</a></td>".
"<td>".$from[$i]."</td>".
"<td>".$size[$i]."</td>".
"<td>".$date[$i]."</td>".
"<td>".$rcp[$i]."</td>".
"<td><font color=red>".substr($msg[$i],0,60)."</font></td>".
"</tr>";
}
}
?>
<!-- ------------------------------------------------------------------------ -->
<?php require 'include/inc-footer.php';?>
<!-- ------------------------------------------------------------------------ -->