[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 04/39: Fix bug in recover password Include se
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 04/39: Fix bug in recover password Include sendmail.class.php fix bug sending email with file (compatibility PHP7) |
Date: |
Sat, 11 Jul 2020 13:20:35 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 92bd3eb5063805e97d236f61f58208a82bac26a5
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Mon May 11 00:03:41 2020 +0200
Fix bug in recover password
Include sendmail.class.php
fix bug sending email with file (compatibility PHP7)
---
include/lib/sendmail_core.class.php | 37 ++++++++++++++++++++-----------------
include/recover.php | 23 +++++++++++++++++------
2 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/include/lib/sendmail_core.class.php
b/include/lib/sendmail_core.class.php
index 11a5180..b62061d 100644
--- a/include/lib/sendmail_core.class.php
+++ b/include/lib/sendmail_core.class.php
@@ -78,7 +78,8 @@ class Sendmail_Core
*/
function set_message($p_message)
{
- $this->message = $p_message;
+ // $this->message =wordwrap($p_message,70,"\r\n");
+ $this->message =$p_message;
}
/**
@@ -134,24 +135,26 @@ class Sendmail_Core
$this->content .= "Content-Type: text/plain; charset=\"utf-8\"" . $eol;
$this->content .= "Content-Transfer-Encoding: 7bit" . $eol.$eol ;
$this->content .= $this->message . $eol ;
-
- // attachment
- for ($i = 0; $i < count($this->afile); $i++)
+ if ( ! empty($this->afile ) )
{
- $file = $this->afile[$i];
- $file_size = filesize($file->full_name);
- $handle = fopen($file->full_name, "r");
- $content = fread($handle, $file_size);
- fclose($handle);
- $content = chunk_split(base64_encode($content));
- $this->content .= "--" . $separator . $eol;
- $this->content .= "Content-Type: " . $file->type . "; name=\"" .
$file->filename . "\"" . $eol;
- $this->content .= "Content-Disposition: attachment; filename=\"" .
$file->filename . "\"" . $eol;
- $this->content .= "Content-Transfer-Encoding: base64" . $eol;
- $this->content.=$eol;
- $this->content .= $content . $eol ;
+ // attachment
+ for ($i = 0; $i < count($this->afile); $i++)
+ {
+ $file = $this->afile[$i];
+ $file_size = filesize($file->full_name);
+ $handle = fopen($file->full_name, "r");
+ $content = fread($handle, $file_size);
+ fclose($handle);
+ $content = chunk_split(base64_encode($content));
+ $this->content .= "--" . $separator . $eol;
+ $this->content .= "Content-Type: " . $file->type . "; name=\""
. $file->filename . "\"" . $eol;
+ $this->content .= "Content-Disposition: attachment;
filename=\"" . $file->filename . "\"" . $eol;
+ $this->content .= "Content-Transfer-Encoding: base64" . $eol;
+ $this->content.=$eol;
+ $this->content .= $content . $eol ;
+ }
}
- if ( count ($this->afile) == 0 ) $this->content.=$eol;
+ if ( empty ($this->afile) ) $this->content.=$eol;
$this->content .= "--" . $separator . "--";
}
diff --git a/include/recover.php b/include/recover.php
index ec082d1..cf9dac8 100644
--- a/include/recover.php
+++ b/include/recover.php
@@ -25,6 +25,7 @@ define('SIZE_REQUEST', 70);
require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
+require_once NOALYSS_INCLUDE.'/class/sendmail.class.php';
/**
* @brief generate a random string of char
* @param $car int length of the string
@@ -95,12 +96,22 @@ elseif ($action=="send_email") :
if ($valid==true):
$request_id=generate_random(SIZE_REQUEST);
$user_password=generate_random(10);
- /*
- * save the request into
- */
- $cn->exec_sql("insert into
recover_pass(use_id,request,password,created_on,created_host) "
- ." values ($1,$2,$3,now(),$4)", array($user_id, $request_id,
$user_password, $_SERVER['REMOTE_ADDR']));
-
+ // exist a valid request for this user ?
+ $exist_request= $cn->get_array("select request , password from
recover_pass
+ where use_id=$1 and created_on > now() - interval '12
hours'",[$user_id]);
+ if ( empty($exist_request ) ) {
+ /* save the request into */
+ $cn->exec_sql("insert into
recover_pass(use_id,request,password,created_on,created_host) "
+ ." values ($1,$2,$3,now(),$4)", array($user_id,
$request_id, $user_password, $_SERVER['REMOTE_ADDR']));
+ } else {
+ $request_id=$exist_request[0]["request"];
+ $user_password=$exist_request[0]['password'];
+ /* if too many request , there is a bug somewhere , so record an
warning */
+ if ( count($exist_request)> 1 ){
+ error_log("WRE109 Trop de request pour
".var_export($exist_request,true));
+ }
+
+ }
/*
* send an email
*/
- [Noalyss-commit] [noalyss] branch master updated (aa78d59 -> 3450d5f), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 01/39: Pierre-François P. Ajout des parenthèses dans le calcul des champs numériques, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 05/39: Code : add connection by DSN, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 07/39: Remove DB connect with DSN, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 04/39: Fix bug in recover password Include sendmail.class.php fix bug sending email with file (compatibility PHP7),
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 10/39: Task #1532 : detail payment, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 11/39: #1583: [Cosmétique] Liste de catégories de fiches, espace avant les (), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 08/39: #1798 French calendar, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 09/39: Compatility PHP7.4, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 02/39: Bug Database:lo_unlink unknown variable, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 06/39: Compatibility postgresql 12, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 03/39: Fix problem with redirect, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 12/39: CSS : new background-selected for a row in table, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 16/39: task #0001413: Duplication d'opération 2 - le retour, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 18/39: Task #1803 : export detail of an operation in PDF, Dany De Bontridder, 2020/07/11