From: Jean-Marc Pigeon Date: Tue, 9 Sep 2025 11:46:04 +0000 (-0400) Subject: Number of email record according select value X-Git-Tag: end-0.15~1 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=08c1b32a41295b2fae2a7f53cca744b912efd43f;p=jmp%2Fmailleur Number of email record according select value --- diff --git a/tools/genpsdusr.sh b/tools/genpsdusr.sh index 9e7ad41..3c2a936 100755 --- a/tools/genpsdusr.sh +++ b/tools/genpsdusr.sh @@ -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 diff --git a/www/devsql.php b/www/devsql.php index 5e88526..94e2bee 100644 --- a/www/devsql.php +++ b/www/devsql.php @@ -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; diff --git a/www/gessql.php b/www/gessql.php index 502e257..9d4b26e 100644 --- a/www/gessql.php +++ b/www/gessql.php @@ -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"); +} ?> diff --git a/www/lvlusr.php b/www/lvlusr.php index 4cdb33d..cd2870f 100644 --- a/www/lvlusr.php +++ b/www/lvlusr.php @@ -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";