<?php
-// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab :
//==============================================================
//
// Main screen management
// Table header generation
//==============================================================
function tblheader(string $dsearch,int $numrec,int $offset,int $limit, string $selectedField)
+
{
- global $userlang;
- global $myfilename;
+global $userlang;
+global $myfilename;
- $debut=$offset+1;
- $search=gettranslate($userlang,"Search");
+$debut=$offset+1;
+$search=gettranslate($userlang,"Search");
+$originator=gettranslate($userlang,"Originator");
+$recipient=gettranslate($userlang,"Recipient");
+$date=gettranslate($userlang,"Date");
- $STR = <<<EOT
+$STR = <<<EOT
<TABLE WIDTH="100%" BORDER="0" CellSpacing="0">
<TR>
<TD align=left>
$search:
<input type="text" value="$dsearch" name="dsearch" size=20 style="font-size: 100%;">
<select name="filterfield" style="font-size:100%;">
- <option value="smtpfrom" EOT . (($selectedField==='smtpfrom')?'selected':'') . EOT>Originator</option>
- <option value="rcptto" EOT . (($selectedField==='rcptto')?'selected':'') . EOT>Recipient</option>
- <option value="creation" EOT . (($selectedField==='creation')?'selected':'') . EOT>Date</option>
+ <option value="smtpfrom" EOT . (($selectedField==='smtpfrom')?'selected':'') . EOT>$originator</option>
+ <option value="rcptto" EOT . (($selectedField==='rcptto')?'selected':'') . EOT>$recipient</option>
+ <option value="creation" EOT . (($selectedField==='creation')?'selected':'') . EOT>$date</option>
</select>
<input type="submit" style="display:none"/>
</FONT>
</TABLE>
EOT;
- return $STR;
+return $STR;
}
//==============================================================
// Main screen body generation
//==============================================================
function body($logname)
+
{
- global $isadmin;
- global $myfilename;
+global $userlang;
+global $isadmin;
+global $myfilename;
- $limit=20;
- $offset=0;
- $dsearch="";
- $selectedField = 'rcptto';
+$limit=20;
+$offset=0;
+$dsearch="";
+$selectedField = 'rcptto';
- if (isset($_POST['limit']))
- $limit=intval($_POST['limit']);
- if (isset($_POST['offset']))
- $offset=intval($_POST['offset']);
- if (isset($_POST['filterfield']))
- $selectedField = $_POST['filterfield'];
+if (isset($_POST['limit']))
+ $limit=intval($_POST['limit']);
+if (isset($_POST['offset']))
+ $offset=intval($_POST['offset']);
+if (isset($_POST['filterfield']))
+ $selectedField = $_POST['filterfield'];
- $rqst = new probe("actions",$limit,$offset);
+$rqst = new probe("actions",$limit,$offset);
- if (isset($_POST['dsearch'])) {
- $dsearch=trim($_POST['dsearch']);
- if (strlen($dsearch)>0) {
- // sécuriser le champ sélectionné
- $allowedFields = ['smtpfrom','rcptto','creation'];
- if (!in_array($selectedField,$allowedFields))
- $selectedField = 'rcptto';
+if (isset($_POST['dsearch'])) {
+ $dsearch=trim($_POST['dsearch']);
+ if (strlen($dsearch)>0) {
+ // sécuriser le champ sélectionné
+ $allowedFields = ['smtpfrom','rcptto','creation'];
+ if (!in_array($selectedField,$allowedFields))
+ $selectedField = 'rcptto';
- // filtrage selon le champ choisi
- if ($selectedField === 'creation') {
- // pour la date, on peut filtrer par LIKE
- $rqst->where("$selectedField::text LIKE '%$dsearch%'");
- } else {
- $rqst->where("$selectedField LIKE '%$dsearch%'");
- }
- }
+ // filtrage selon le champ choisi
+ if ($selectedField === 'creation') {
+ // pour la date, on peut filtrer par LIKE
+ $rqst->where("$selectedField::text LIKE '%$dsearch%'");
}
+ else {
+ $rqst->where("$selectedField LIKE '%$dsearch%'");
+ }
+ }
+}
- $numrec=$rqst->getnumrec();
+$numrec=$rqst->getnumrec();
- if (isset($_POST['scanner'])) {
- $scanner=$_POST['scanner'];
- switch ($scanner) {
- case "golast" :
- $offset=$rqst->goLast();
- break;
- case "gonext" :
- $offset=$rqst->goNext();
- break;
- case "goprevious" :
- $offset=$rqst->goPrevious();
- break;
- case "gofirst" :
- $offset=$rqst->goFirst();
- break;
- default :
- break;
- }
+if (isset($_POST['scanner'])) {
+ $scanner=$_POST['scanner'];
+ switch ($scanner) {
+ case "golast" :
+ $offset=$rqst->goLast();
+ break;
+ case "gonext" :
+ $offset=$rqst->goNext();
+ break;
+ case "goprevious" :
+ $offset=$rqst->goPrevious();
+ break;
+ case "gofirst" :
+ $offset=$rqst->goFirst();
+ break;
+ default :
+ break;
}
+ }
- $actions=$rqst->order("creation desc")
- ->limit($limit)
- ->GET();
-
- $line="";
- $count=$offset+1;
- foreach($actions as $action) {
- $info=substr($action['info'],3,1);
- $status=$action['status'];
- $subject=htmlspecialchars($action['subject'],ENT_QUOTES);
- if (($subject==NULL) || (strlen($subject)==0))
- $subject=htmlspecialchars($action['info'],ENT_QUOTES);
+$actions=$rqst->order("creation desc")
+ ->limit($limit)
+ ->GET();
- switch ($status) {
- case 250: $bgcolor="#90EE90"; break; // light green
- case 460: $bgcolor="#ff6666"; $subject=htmlspecialchars($action['info'],ENT_QUOTES); break; // light red
- case 551: $bgcolor="#FF7F50"; break; // coral
- case 555: $bgcolor="#D3D3D3"; break; // light gray
- default: $bgcolor="yellow"; break;
- }
+$line="";
+$count=$offset+1;
+foreach($actions as $action) {
+ $info=substr($action['info'],3,1);
+ $status=$action['status'];
+ $subject=htmlspecialchars($action['subject'],ENT_QUOTES);
+ if (($subject==NULL) || (strlen($subject)==0))
+ $subject=htmlspecialchars($action['info'],ENT_QUOTES);
+ switch ($status) {
+ case 250:
+ $bgcolor="#90EE90";
+ break; // light green
+ case 460:
+ $bgcolor="#ff6666";
+ $subject=htmlspecialchars($action['info'],ENT_QUOTES);
+ break; // light red
+ case 551:
+ $bgcolor="#FF7F50";
+ break; // coral
+ case 555:
+ $bgcolor="#D3D3D3";
+ break; // light gray
+ default:
+ $bgcolor="yellow";
+ break;
+ }
+ $date=$action['creation'];
+ $reverse=$action['reverse'];
+ $remoteip=$action['remoteip'];
+ $smtpfrom=$action['smtpfrom'];
+ $recipient=$action['rcptto'];
+ $emailfrom=htmlspecialchars($action['emailfrom'],ENT_QUOTES);
- $date=$action['creation'];
- $reverse=$action['reverse'];
- $remoteip=$action['remoteip'];
- $smtpfrom=$action['smtpfrom'];
- $recipient=$action['rcptto'];
- $emailfrom=htmlspecialchars($action['emailfrom'],ENT_QUOTES);
+ // Generating the table contents
+ $line .= "<TR bgcolor=\"$bgcolor\">\r\n";
+ $line .= "<TD align=center>$count</TD>\r\n";
+ $line .= "<TD align=center>$status</TD>\r\n";
+ $line .= "<TD align=left>$date</TD>\r\n";
+ $line .= "<TD align=left>$remoteip</TD>\r\n";
+ $line .= "<TD align=left>$reverse</TD>\r\n";
+ $line .= "<TD align=left>$smtpfrom<BR><FONT SIZE=-1>$emailfrom</FONT></TD>\r\n";
+ $line .= "<TD align=left>$recipient</TD>\r\n";
+ $line .= "<TD align=left>$subject</TD>\r\n";
+ $line .= "</TR>\r\n";
- // Generating the table contents
- $line .= "<TR bgcolor=\"$bgcolor\">\r\n";
- $line .= "<TD align=center>$count</TD>\r\n";
- $line .= "<TD align=center>$status</TD>\r\n";
- $line .= "<TD align=left>$date</TD>\r\n";
- $line .= "<TD align=left>$remoteip</TD>\r\n";
- $line .= "<TD align=left>$reverse</TD>\r\n";
- $line .= "<TD align=left>$smtpfrom<BR><FONT SIZE=-1>$emailfrom</FONT></TD>\r\n";
- $line .= "<TD align=left>$recipient</TD>\r\n";
- $line .= "<TD align=left>$subject</TD>\r\n";
- $line .= "</TR>\r\n";
+ $count++;
+ }
- $count++;
- }
+$rqst->close();
- $rqst->close();
+$start=starthtml(NULL);
+$stop=endhtml();
+$top=topper($isadmin,$logname,"$myfilename");
+$footer=footer("$myfilename");
+$tblheader=tblheader($dsearch,$numrec,$offset,$limit,$selectedField);
+$tblfooter="";
+if ($limit>30)
+ $tblfooter=$tblheader;
- $start=starthtml(NULL);
- $stop=endhtml();
- $top=topper($isadmin,$logname,"$myfilename");
- $footer=footer("$myfilename");
- $tblheader=tblheader($dsearch,$numrec,$offset,$limit,$selectedField);
- $tblfooter="";
- if ($limit>30)
- $tblfooter=$tblheader;
+$originator=gettranslate($userlang,"Originator");
+$recipient=gettranslate($userlang,"Recipient");
+$date=gettranslate($userlang,"Date");
- $STR = <<<EOT
+$STR = <<<EOT
$start
$top
<TR>
<TH align=center>Num</TH>
<TH align=center>Status</TH>
-<TH align=center>Date</TH>
+<TH align=center>$date</TH>
<TH align=center>IP</TH>
<TH align=center>Reverse Address</TH>
-<TH align=center>Originator</TH>
-<TH align=center>Recipient</TH>
+<TH align=center>$originator</TH>
+<TH align=center>$recipient</TH>
<TH align=center>Subject</TH>
</TR>
$line
$stop
EOT;
- return $STR;
+return $STR;
}
//==============================================================
rou_closelog();
if ($logname!=NULL) {
- echo body($logname);
-} else {
- header('Location: lvllog.php');
-}
+ echo body($logname);
+ }
+else {
+ header('Location: lvllog.php');
+ }
?>