// Main screen management
//
//==============================================================
+
include_once "subrou.php";
include_once "unienv.php";
include_once "gesdis.php";
include_once "gessql.php";
-
-//Defining the application name
+// Defining the application name
global $myfilename;
$myfilename="lvlmai";
-
-function tblheader(string $username,int $numrec,int $offset,int $limit)
-
+//==============================================================
+// Table header generation
+//==============================================================
+function tblheader(string $username,int $numrec,int $offset,int $limit, string $selectedField)
{
-global $userlang;
-global $myfilename;
+ global $userlang;
+ global $myfilename;
-$debut=$offset+1;
-$email=gettranslate($userlang,"Received email");
+ $debut=$offset+1;
+ $email=gettranslate($userlang,"Received email");
-$STR = <<<EOT
+ $STR = <<<EOT
<TABLE WIDTH="100%" BORDER="0" CellSpacing="0">
<TR>
<TD align=left>
<FONT SIZE=+1>
$email:
<input type="text" value="$username" name="username" 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>
+</select>
<input type="submit" style="display:none"/>
</FONT>
</FORM>
</TABLE>
EOT;
-return $STR;
+ return $STR;
}
//==============================================================
-//
-// section to generate the main screen body
-//
+// Main screen body generation
//==============================================================
function body($logname)
-
{
-global $isadmin;
-global $myfilename;
+ global $isadmin;
+ global $myfilename;
+
+ $limit=20;
+ $offset=0;
+ $username="";
+ $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'];
+
+ $rqst = new probe("actions",$limit,$offset);
+
+ if (isset($_POST['username'])) {
+ $username=trim($_POST['username']);
+ if (strlen($username)>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 LIKE '%$username%'");
+ } else {
+ $rqst->where("$selectedField LIKE '%$username%'");
+ }
+ }
+ }
-$limit=20;
-$offset=0;
-$username="";
-if (isset($_POST['limit']))
- $limit=intval($_POST['limit']);
-if (isset($_POST['offset']))
- $offset=intval($_POST['offset']);
-$rqst=NEW probe("actions",$limit,$offset);
-if (isset($_POST['username'])) {
- $username=trim(($_POST['username']));
- if (strlen($username)>0)
- $rqst->where("(smtpfrom like '%$username%') OR (rcptto like '%$username%')");
- }
-$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;
+ $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;
+ }
}
- }
-$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);
- switch ($status) {
- case 250 :
- $bgcolor="#90EE90"; //light green
- break;
- case 460 :
- $bgcolor="#ff6666"; //light red
- $subject=htmlspecialchars($action['info'],ENT_QUOTES);
- break;
- case 551 :
- $bgcolor="#FF7F50"; //coral (orange red)
- break;
- case 555 :
- $bgcolor="#D3D3D3"; //light gray
- break;
- default :
- $bgcolor="yellow";
- 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);
+
+ 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);
+
+ // 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++;
}
- $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=$line."<TR bgcolor=\"$bgcolor\">\r\n";
- $line=$line."<TD align=center>$count</TD>\r\n";
- $line=$line."<TD align=center>$status</TD>\r\n";
- $line=$line."<TD align=left>$date</TD>\r\n";
- $line=$line."<TD align=left>$remoteip</TD>\r\n";
- $line=$line."<TD align=left>$reverse</TD>\r\n";
- $line=$line."<TD align=left>";
- $line=$line."$smtpfrom<BR>";
- $line=$line."<FONT SIZE=-1>$emailfrom</FONT>";
- $line=$line."</TD>\r\n";
- $line=$line."<TD align=left>$recipient</TD>\r\n";
- $line=$line."<TD align=left>$subject</TD>\r\n";
- $line=$line."</TR>";
- //end of generation
- $count++;
- }
-$rqst->close();
-
-$start=starthtml(NULL);
-$stop=endhtml();
-$top=topper($isadmin,$logname,"$myfilename");
-$footer=footer("$myfilename");
-$tblheader=tblheader($username,$numrec,$offset,$limit);
-$tblfooter="";
-if ($limit>30)
- $tblfooter=$tblheader;
-
-$rqst->close();
-
-$STR = <<<EOT
+
+ $rqst->close();
+
+ $start=starthtml(NULL);
+ $stop=endhtml();
+ $top=topper($isadmin,$logname,"$myfilename");
+ $footer=footer("$myfilename");
+ $tblheader=tblheader($username,$numrec,$offset,$limit,$selectedField);
+ $tblfooter="";
+ if ($limit>30)
+ $tblfooter=$tblheader;
+
+ $STR = <<<EOT
$start
$top
<TH align=center>Reverse Address</TH>
<TH align=center>Originator</TH>
<TH align=center>Recipient</TH>
-<TH align=center>subject</TH>
+<TH align=center>Subject</TH>
</TR>
$line
</Table>
$stop
EOT;
-return $STR;
+ return $STR;
}
+//==============================================================
+// Script execution
+//==============================================================
global $logname;
$dbsql=sql_connect();
rou_closelog();
if ($logname!=NULL) {
- echo body($logname);
- }
-else {
- header('Location: lvllog.php');
- }
+ echo body($logname);
+} else {
+ header('Location: lvllog.php');
+}
?>
-
-