|
![Picture of Javier Navarrete Picture of Javier Navarrete](https://files.phpclasses.org/graphics/unknown.gif) Javier Navarrete - 2008-03-16 00:52:53
Hi, i found your class very useful, but i need to save the attached file in a directory. How can i do that?
![Picture of Javier Navarrete Picture of Javier Navarrete](https://files.phpclasses.org/graphics/unknown.gif) Javier Navarrete - 2008-03-16 01:09:01 - In reply to message 1 from Javier Navarrete
....With the original file name attached. I getting the attachment file as 2 with:
$parameters=array(
'File'=>$message_file,
'SaveBody'=>'tmp',
//'SkipBody'=>1,
);
Thanks in advance.
![Picture of Manuel Lemos Picture of Manuel Lemos](https://files.phpclasses.org/picture/user/1.jpg) Manuel Lemos - 2008-03-16 02:57:03 - In reply to message 2 from Javier Navarrete
That is right. 2 is the name of the file that the parser saves. The class does not save with the original file names for security reasons. You can however check the FileName attribute of the respective decoded part.
![Picture of Javier Navarrete Picture of Javier Navarrete](https://files.phpclasses.org/graphics/unknown.gif) Javier Navarrete - 2008-03-16 04:56:33 - In reply to message 3 from Manuel Lemos
Thanks,
I´v placed these little modifications in mime_parser.php file and i´v got the original files exported from then eml file.
case 'BodyData':
if(IsSet($parameters['SaveBody']))
{
if(!IsSet($decoded['BodyFile']))
{
$directory_separator=(defined('DIRECTORY_SEPARATOR') ? DIRECTORY_SEPARATOR : '/');
if ($this->body_part_number == 2) {
$filename=$header_parameters[$filename];
$path = (strlen($parameters['SaveBody']) ? ($parameters['SaveBody'].(strcmp($parameters['SaveBody'][strlen($parameters['SaveBody'])-1], $directory_separator) ? $directory_separator : '')) : '').$filename; } else { $path = (strlen($parameters['SaveBody']) ? ($parameters['SaveBody'].(strcmp($parameters['SaveBody'][strlen($parameters['SaveBody'])-1], $directory_separator) ? $directory_separator : '')) : '').strval($this->body_part_number);
}
.
.
.
JN
![Picture of Manuel Lemos Picture of Manuel Lemos](https://files.phpclasses.org/picture/user/1.jpg) Manuel Lemos - 2008-03-16 17:32:55 - In reply to message 4 from Javier Navarrete
I think you misunderstood what I explained.
The class already saves the message body parts to files. It just does not use the original file names for security reasons.
If you change the class to use the original file names you may risk you server security by overwriting important files. That may be used to abuse from your server.
Think for instance if somebody sends you an harmful message with an attachment named /etc/passwd or for instance the path of your site /index.php . Next think he can do is to access to login in your server and cause damage to your sites.
![Picture of Javier Navarrete Picture of Javier Navarrete](https://files.phpclasses.org/graphics/unknown.gif) Javier Navarrete - 2008-03-16 19:35:16 - In reply to message 5 from Manuel Lemos
Yes, i´m sending the attached files to a particular directory (only with the name, im extracting the path). Program folders have only rx attributes for security.
Iv reached im looking for.
My next question is how to read only new incoming mails. I'll appreciate your assist.
Thanks.
JN
|