Fix bug in recover password
Include sendmail.class.php
fix bug sending email with file (compatibility PHP7)
This commit is contained in:
parent
39617e77e4
commit
92bd3eb506
2 changed files with 37 additions and 23 deletions
|
|
@ -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 . "--";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue