From: Jean-Marc Pigeon Date: Mon, 1 Dec 2025 17:51:15 +0000 (-0500) Subject: Ajout de champs select pour lvlmai.php X-Git-Tag: tag-0.19~16 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=761f199601d5c1e40a869e75a464138f72c9fc4a;p=jmp%2Fmailleur Ajout de champs select pour lvlmai.php --- diff --git a/www/lvlmai.php b/www/lvlmai.php index 50c2b64..6dabe19 100644 --- a/www/lvlmai.php +++ b/www/lvlmai.php @@ -5,27 +5,28 @@ // 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 = << @@ -61,6 +62,11 @@ $STR = << $email: + @@ -83,119 +89,125 @@ $email: 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 .= "\r\n"; + $line .= "$count\r\n"; + $line .= "$status\r\n"; + $line .= "$date\r\n"; + $line .= "$remoteip\r\n"; + $line .= "$reverse\r\n"; + $line .= "$smtpfrom
$emailfrom\r\n"; + $line .= "$recipient\r\n"; + $line .= "$subject\r\n"; + $line .= "\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."\r\n"; - $line=$line."$count\r\n"; - $line=$line."$status\r\n"; - $line=$line."$date\r\n"; - $line=$line."$remoteip\r\n"; - $line=$line."$reverse\r\n"; - $line=$line.""; - $line=$line."$smtpfrom
"; - $line=$line."$emailfrom"; - $line=$line."\r\n"; - $line=$line."$recipient\r\n"; - $line=$line."$subject\r\n"; - $line=$line.""; - //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 = <<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 = <<Reverse Address Originator Recipient -subject +Subject $line @@ -221,9 +233,12 @@ $footer $stop EOT; -return $STR; + return $STR; } +//============================================================== +// Script execution +//============================================================== global $logname; $dbsql=sql_connect(); @@ -232,12 +247,9 @@ sql_close($dbsql); rou_closelog(); if ($logname!=NULL) { - echo body($logname); - } -else { - header('Location: lvllog.php'); - } + echo body($logname); +} else { + header('Location: lvllog.php'); +} ?> - -