]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to implement user log display within web "main screen"
authorJean-Marc Pigeon <jmp@safe.c>
Sat, 13 Sep 2025 11:05:34 +0000 (07:05 -0400)
committerJean-Marc Pigeon <jmp@safe.c>
Sat, 13 Sep 2025 11:05:34 +0000 (07:05 -0400)
lib/geseml.c
www/gessql.php
www/lvllog.php
www/lvlmai.php

index fb19cc9cc316965cfe762adbfaa78bd37dd55eef..df161acd467aa407942bfdc0c562be1848a31d65 100644 (file)
@@ -194,14 +194,14 @@ if (tra!=(TRATYP *)0) {
   status=true;
   (void) strftime(temps,sizeof(temps),"#%Y-%m-%d %H:%M:%S",
                                       localtime(&(tra->date)));
-  (void) snprintf(line,sizeof(line),"%c\t%lu\t%05u%*s %*s %*s \"%*s\" %s",
+  (void) snprintf(line,sizeof(line),"%c\t%lu\t%05u %*s %*s %*s \"%*s\" %s",
                                     tra->code,
                                     tra->date,
                                     tra->delay,
-                                    32,tra->sessid,
-                                    30,tra->rcptto,
-                                    30,tra->sfrom,
-                                    30,tra->hfrom,
+                                    -32,tra->sessid,
+                                    -30,tra->rcptto,
+                                    -30,tra->sfrom,
+                                    -30,tra->hfrom,
                                     tra->hsubject
                                     );
   (void) print_tra(qfile,line,temps);
@@ -243,12 +243,12 @@ if (tra!=(TRATYP **)0) {
     (void) fprintf(qfile,"#'C', completed email task\n");
     (void) fprintf(qfile,"#'L', Local email\n");
     (void) fprintf(qfile,"#'R', Remote email\n");
-    (void) fprintf(qfile,"#code\tdate\t\tdelay"
-                         "%*s %*s %*s %*s\n",
-                          32,"session-id",
-                          30,"recipient",
-                          30,"sfrom",
-                          30,"efrom");
+    (void) fprintf(qfile,"#code\tdate\t\tdelay "
+                         "%*s %*s %*s %*s subject\n",
+                          -32,"session-id",
+                          -30,"recipient",
+                          -30,"sfrom",
+                          -30,"efrom");
     }
   while (*tra!=(TRATYP *)0) {
     (void) eml_dump_one_tra(qfile,*tra);
@@ -304,6 +304,7 @@ if (tra!=(TRATYP *)0) {
   dup->delay=tra->delay;
   dup->sfrom=strdup(tra->sfrom);
   dup->hfrom=strdup(tra->hfrom);
+  dup->hsubject=strdup(tra->hsubject);
   dup->rcptto=strdup(tra->rcptto);
   dup->sessid=strdup(tra->sessid);
   if (tra->resp!=(char **)0) {
index 9d4b26ee145edca23ca960dfa9fbcf686a4e7ee1..7f456e908b5d68f23615adbcee31e0f205e112d0 100644 (file)
@@ -162,7 +162,7 @@ rou_alert(0,"$OPEP, now logname=<$logname>");
 
 //==============================================================
 //
-//      Function to retreive a some email record
+//      Function to retreive user email list
 //
 //==============================================================
 function sql_getemaillist($dbsql,$username,$limit,$skip)
@@ -200,4 +200,29 @@ if ($username!=NULL)
   $select="where email like '%$username%'";
 return sql_getnumrec($dbsql,$select,"emails");
 }
+//==============================================================
+//
+//      Function to retreive user actions list
+//
+//
+//==============================================================
+function sql_getactionslist($dbsql,$username,$limit,$skip)
+
+{
+$OPEP="gessql.php:sql_getactions";
+
+$strlim="";
+$strskip="";
+$select="";
+if ($username!=NULL) 
+  $select="where (smtpfrom like '%$username%') or (rcptto like '%username')";
+$strsel="Select * from actions $select order by creation asc";
+if ($limit!=NULL) 
+  $strlim="limit $limit";
+if ($skip!=NULL) 
+  $strskip="offset $skip";
+$stmt=$dbsql->Select("$strsel $strlim $strskip");
+return $stmt->fetchAll();
+}
+
 ?>
index cc08d9577af4b1910bf04037ea3f7835fbbce1aa..cf86ae5ada8308dd5ddf3f826f11a46b10c1c548 100644 (file)
@@ -42,7 +42,7 @@ $STR  = <<<EOT
                 <tr>
                   <td align="left" nowrap="nowrap"><span class="translatable" trkey="Email">Email</span><span>:</span></td>
                   <td>
-                  <input type="text" name="email" size="20" onchange="" />
+                  <input type="text" name="email" size="40" onchange="" />
                   <select id="first-choice" onchange="updateTranslations()">
                     <option value="en">English</option>
                     <option value="fr">Francais</option>
@@ -53,7 +53,7 @@ $STR  = <<<EOT
                 <tr>
                   <td align="left" nowrap="nowrap"><span class="translatable" trkey="Password">Password</span><span>:</span></td>
                   <td>
-                 <input type="password" name="passwd" size="20" id="myInput" />
+                 <input type="password" name="passwd" size="40" id="myInput" />
                   <input type="checkbox" onclick="showpass()">
                     <span class="translatable" trkey="Show" >Show</span>
                  </td>
index 1c01adc54cb983706bb5fbf218b67865923c87f9..fd36102f4b03167c05ee4b1d43a56d1c5ac7b1ab 100644 (file)
@@ -20,24 +20,75 @@ $start=starthtml(NULL);
 $stop=endhtml();
 $top=topper($isadmin,$logname,"lvlmai");
 $footer=footer("lvlmai");
-$cook="???";
-if (isset($_COOKIE[getenv("APPNAME")])==true)
-  $cook=$_COOKIE[getenv("APPNAME")];
+
+$limit=20;
+$offset=0;
+$username="";
+$dbsql=sql_connect();
+if (isset($_POST['username']))
+  $username=trim(($_POST['username']));
+if (isset($_POST['limit']))
+  $limit=intval($_POST['limit']);
+if (isset($_POST['offset']))
+  $offset=intval($_POST['offset']);
+
+$actions=sql_getactionslist($dbsql,$username,$limit,$offset);
+$line="";
+$count=$offset;
+foreach($actions as $action) {
+  $bgcolor="white";
+  if ($count & 1 ) {
+    $bgcolor="green";
+    }
+  $date=$action['creation'];
+  $smtpfrom=$action['smtpfrom'];
+  $emailfrom=$action['emailfrom'];
+  $emailfrom=str_replace("<","&lt;",$emailfrom);
+  $emailfrom=str_replace(">","&gt;",$emailfrom);
+  rou_alert(0,"JMPDBG <$emailfrom>");
+  $recipient=$action['rcptto'];
+  $line=$line."<TR>\r\n";
+  $line=$line."<TD><FONT SIZE=-1>$count&nbsp</FONT>\r\n";
+  $line=$line."<TD align=left>$date</TD>\r\n";
+  $line=$line."<TD align=left>$smtpfrom</TD>\r\n";
+  $line=$line."<TD align=left>$emailfrom</TD>\r\n";
+  $line=$line."<TD align=left>$recipient</TD>\r\n";
+  $line=$line."</TR>";
+  $count++;
+  }
+sql_close($dbsql);
 
 $STR  = <<<EOT
 
 $start
 $top
-<CENTER><FONT SIZE=+2 color=red>
-Within mailleur
-<BR>
-LOGNAME=$logname
-<BR>
-ADMIN=$isadmin
-<BR>
-The cookies=$cook
-<BR>
-</FONT></STRONG></CENTER>
+  <style type="text/css">
+.table-userlist tr:nth-child(odd)
+  {
+  background-color: #66ff99;    /*light green   */
+  color: black ;
+  }
+
+.table-userlist tr:nth-child(even)
+  {
+  background-color: white;
+  color: black ;
+  }
+</style>
+<CENTER>
+<table WIDTH="100%" BORDER="0" CellSpacing="0">
+<table class="table-userlist" WIDTH="100%" BORDER="1" CellSpacing="0">
+<TR>
+<TH align=center></TH>
+<TH align=center>Date</TH>
+<TH align=center>SMTP Originator</TH>
+<TH align=center>Email From</TH>
+<TH align=center>Recipient</TH>
+</TR>
+$line
+</Table>
+</Table>
+</CENTER>
 <BR>
 $footer
 $stop