PHP Classes

How to prevent my script

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  How to prevent my script  >  (Un) Subscribe thread alerts  
Subject:How to prevent my script
Summary:how to check file format
Messages:4
Author:nitin sharma
Date:2009-07-25 11:51:22
Update:2009-07-27 07:19:56
 

  1. How to prevent my script   Reply   Report abuse  
Picture of nitin sharma nitin sharma - 2009-07-25 11:51:22
Hi

i using this class to read the image attachment and this is working well

now but i facing the problem if some one send a attachment as a video file
i have a question that can i check the content before the message decode if yes what will be be syntex for this please help me about this.


code:

.......
.....
...
if(($error=$pop3->Open())=="")
{
echo "<PRE>Connected to the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "<PRE>User &quot;$user&quot; logged in.</PRE>\n";
if(($error=$pop3->Statistics($messages,$size))=="")
{
echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";

$result=$pop3->ListMessages("",0);
if(GetType($result)=="array")
{
for(Reset($result),$message=1;$message<=count($result);Next($result),$message++)
{
if($messages>0)
{
echo $message;

$pop3->GetConnectionName($connection_name);
//$message=1;
$message_file='pop3://'.$connection_name.'/'.$message;
$mime=new mime_parser_class;

/*
* Set to 0 for not decoding the message bodies
*/
$mime->decode_bodies = 1;

$parameters=array(
'File'=>$message_file,

/* Read a message from a string instead of a file */
/* 'Data'=>'My message data string', */

/* Save the message body parts to a directory */
/* 'SaveBody'=>'/tmp', */

/* Do not retrieve or save message body parts */
'SkipBody'=>0,
);
$success=$mime->Decode($parameters, $decoded);



if($mime->Analyze($decoded[0], $results))
{

......

}

....
..


Thank
Nitin

  2. Re: How to prevent my script   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-07-25 20:13:10 - In reply to message 1 from nitin sharma
I am afraid there is no way of checking the message attached files without decoding the message because the attachments are in the message body and the headers do not contain any information about the contents.

What you can do is to use the SkipBody option to make the class parse the message without wasting memory or disk space to store the attached files.

  3. Re: How to prevent my script   Reply   Report abuse  
Picture of nitin sharma nitin sharma - 2009-07-27 06:38:54 - In reply to message 2 from Manuel Lemos
no i can't skip the body there is anyway we check attachment file name extension before the decode the attachment message so that's also help me for prevent my script.

  4. Re: How to prevent my script   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-07-27 07:19:56 - In reply to message 3 from nitin sharma
SkipBody means that the message body is parsed but the data in the body parts (including attachments) are not extracted. The class just parses the message and keeps the values of the headers, including those with the attachment file names.