]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Number of email record according select value
authorJean-Marc Pigeon <jmp@safe.c>
Tue, 9 Sep 2025 11:46:04 +0000 (07:46 -0400)
committerJean-Marc Pigeon <jmp@safe.c>
Tue, 9 Sep 2025 11:46:04 +0000 (07:46 -0400)
tools/genpsdusr.sh
www/devsql.php
www/gessql.php
www/lvlusr.php

index 9e7ad416fb1ac430c3b587a3ed1dcf192ad21a2a..3c2a936559550c0ac889784b02ebb6c7448402be 100755 (executable)
@@ -11,6 +11,6 @@ for (( num=0; num<$max; num++ ))
  do
  (
  fnum=$(printf "%05d\n" "$num")
- echo "INSERT INTO emails (email) values ('z-popusr$fnum');";
+ echo "INSERT INTO emails (email) values ('z-popusr$fnum@example.com');";
  )
  done
index 5e88526d3eea5f9a393818aa307d9c7b2d1ce3d4..94e2bee681d41f420dce4fd063b144d237f52a71 100644 (file)
@@ -130,14 +130,14 @@ $dbtype=getenv("DB_TYPE");
 //      database table.
 //
 //==============================================================
-function sql_getnumrec($dbsql,$table)
+function sql_getnumrec($dbsql,$select,$table)
 
 {
 $OPEP="gessql.php:sql_getnumrec";
 
 $recnum=NULL;
 if ($dbsql!=NULL) {
-  $stmt=$dbsql->Select("Select count(*) from $table");
+  $stmt=$dbsql->Select("Select count(*) from $table $select");
   $recnum=$stmt->fetchColumn(); 
   }
 return $recnum;
index 502e257908f08d24add381d78523dfe9e7653cbf..9d4b26ee145edca23ca960dfa9fbcf686a4e7ee1 100644 (file)
@@ -184,4 +184,20 @@ $stmt=$dbsql->Select("$strsel $strlim $strskip");
 return $stmt->fetchAll();
 }
 
+//==============================================================
+//
+//      Function to return the number of record within email
+//      table according a select.
+//
+//==============================================================
+function sql_getnumemail($dbsql,$username)
+
+{
+$OPEP="gessql.php:sql_getnumemail";
+
+$select=NULL;
+if ($username!=NULL) 
+  $select="where email like '%$username%'";
+return sql_getnumrec($dbsql,$select,"emails");
+}
 ?>
index 4cdb33d9e444fbbaa75ace503f736503d4286cd8..cd2870f4c27d0c49304ee72aeab119f230257e8d 100644 (file)
@@ -80,6 +80,8 @@ return $STR;
 function body($logname)
 
 {
+$OPEP="lvlusr.php:body";
+
 global $isadmin;
 global $logname;
 
@@ -87,14 +89,13 @@ $limit=20;
 $offset=0;
 $username="";
 $dbsql=sql_connect();
-$numrec=sql_getnumrec($dbsql,"emails");
 if (isset($_POST['username']))
-  $username=($_POST['username']);
-rou_alert(0,"Post jmpdbg=<$username>");
+  $username=trim(($_POST['username']));
 if (isset($_POST['limit']))
   $limit=intval($_POST['limit']);
 if (isset($_POST['offset']))
   $offset=intval($_POST['offset']);
+$numrec=sql_getnumemail($dbsql,$username);
 if (isset($_POST['scanner'])) {
   $scanner=$_POST['scanner'];
   switch ($scanner) {
@@ -102,6 +103,7 @@ if (isset($_POST['scanner'])) {
       $offset=$numrec-$limit;
       break;
     case "gonext"       :
+
       $offset+=$limit;
       if ($offset>($numrec-$limit))
         $offset=$numrec-$limit;
@@ -118,8 +120,8 @@ if (isset($_POST['scanner'])) {
       break;
     }
   }
-$line="";
 $emails=sql_getemaillist($dbsql,$username,$limit,$offset);
+$line="";
 $count=$offset;
 foreach($emails as $email) {
   $bgcolor="white";