[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Attachment Remover

Attachment Remover

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Attachment Remover

Postby cssutto » Tue Mar 07, 2006 12:17 pm

Pete:

I have butchered your script up in order to accomplish a goal.

I hope you do not mind.

Let me say first that I can not write script, but I have learned a little about how to plagiarize.

I left lots of white space above and below so it wll make it easy for you to see what I did.

I also had to comment out several lines to get the script to continue when no attachment was found.

I get one error in debug, but the error correction fixes it and it keeps going and I am not smart enough to know why or how to fix it.

If you think it is a good idea and would clean it up, I would much appreciate it.

Here is the logic behind what I have done.

I am fed up with spam and I have not seen a really good way to fight it.

This script is one of my essential steps in removing spam.

In a few days, I plan to post my complete system in the spam group, but for right now I d want to get this where you can see it.

My purpose in this particular script is to be able to remove attachments hidden in spam that could be harmful. As you well know, it drives one nuts to look in the attachment folder and see all of those .txt, .gif, attch.....etc., and try to determine which you want to keep because they go with a desirable email and which to delete.

You script does a super job of deleting the attachment.

But what I wanted is a script that will delete the attachment with spam and at the same time send the spam address to the banned words folder in the junk mail folder.

I wanted to be able to execute the bad file with a button from either my "In" file or "junk Mail file" .

I have filters to send suspected spam to junk mail and filters that send known banned senders straight to the trash file.

I use Rachel Heath's "Empty Trash and Delete Attachment" which works very well except it leaves the headers and does not refresh the screen to empty.

So senders who are already banned get that treatment.

So far, I am leaving the "Preoceed" window active to be certain I am not missing anything.

I plan to comment this out within the next few days so banning 10 0r 12 spams will take less time.

I think this is an essential step to any serious attempt to get rid of spam and avoid damage from hidden attachments, and it is surprising to me how many are hidden.
cssutto
Drop-in Visitor
 
Posts: 7
Joined: Tue Mar 07, 2006 4:25 am

Postby cssutto » Tue Mar 07, 2006 3:42 pm

I forgot to enclose the script.
Here it is as I modified it.

Set $OnErrorMessage ""
AddStrings $OnErrorMessage "Error in " $pocoScriptName
Set $OnErrorGoTo "POCO_ERROR"

{ Do not run if currently in a "Special" mailbox. }
StringPos #index "System.pocosys" $currentMailbox
If #index ! 0 Then SPECIAL_MAILBOX_ERROR

{ Get list of attachments for message }
ReadAttached $attachmentList %message
LineCount #attachmentListSize $attachmentList
if #attachmentListSize = 0 Then Ban

{ Determine whether user leaves attachments encoded
Set &isEncoded True
ReadHeader $tmp "X-Poco-Attachment:" %message
If $tmp = "" Then ENCODED
Set &isEncoded False

:ENCODED
ReadHeader $subject "Subject:" %message
ChopString $subject 41 999
Set $wasMessageChanged "False"
Set #i -1

{ For each attachment in the message... }
:MAIN_LOOP
Inc #i
If #i = #attachmentListSize Then SAVE
GetLine $attachmentName #i $attachmentList
Call DELETE_ROUTINE
Goto MAIN_LOOP

{ Now save the resulting message if necessary }
:SAVE
If $wasMessageChanged = "False" Then DONE
{If #pocoScriptMode ! 5 Then DONE
{SaveMessage %message $currentMailbox
DeleteMessage %message







:Ban
Set $OnErrorGoTo ErrorHandler

{ Initialize user settings: }
External $userfile1 "Junk Senders..." junksender.txt
set $file $userfile1
{set $mailbox "Junk Mail.mbx"}
ImportSettings

{ Fetch the header content }
ReadHeader $header From %message
ExtractEmail $header

{AddStrings $msg "Do you want to add " $header " to the Junk Sender list, and then send the message to the Junk Mail folder?%var%"
{InputBox $answer $msg "Yes|No"
{LowerCase $answer
{If $answer ! "yes" Then Leave

{ Convert header to lowercase }
Lowercase $header
{ Open list of banned sender's e-mails }
OpenBody $m $file
set $new $m
Lowercase $m
TrimLines $m
LinePos #a $header $m

if #a > -1 then JustDelete

{ If not found, add the sender }
AppendToFile False
AppendBody $new $header
SaveBody $new $file

:JustDelete
{ Make sure message is appended to mailbox }
{AppendToFile True}
{ Trash the message }
{SaveMessage %message $mailbox}
{ Finally, delete message }
DeleteMessage %message

:Leave
{Exit


:ErrorHandler
{Exit






















:DONE
Exit

:SPECIAL_MAILBOX_ERROR
Set $tmp ""
AddStrings $tmp "Cannot remove attachments from messages in \"Special\" mailboxes.\n"
AddStrings $tmp "Please run the script from the actual mailbox (e.g. \"In\")"
MessageBox $tmp
Exit

:POCO_ERROR
Exit


{*******************************************************************************
{* Delete Routine
{*******************************************************************************
{* This subroutine deletes the current attachment, but only if all of the
{* criteria are met.
{*
{* This routine uses the global variables (unlike Filename Filter).
{*******************************************************************************
:DELETE_ROUTINE

Set $FF_filename $attachmentName
Call FILENAME_FILTER
If $FF_doDelete = "False" Then Return
If #pocoScriptMode ! 5 Then DELETE_IT
Set $prompt ""
AddStrings $prompt "MESSAGE: " $subject "\n"
AddStrings $prompt "ATTACHMENT: \"" $attachmentName "\"\n"
AddStrings $prompt "Do you want to delete this attachment? %var%"
InputBox $response $prompt "Yes|No"
If $response = "Yes" Then DELETE_IT
Return

:DELETE_IT
Set $wasMessageChanged "True"
DeleteAttached %message $attachmentName
If &isEncoded Then Return
FileExists &doesFileExist $attachmentName
If &doesFileExist Then DELETE_DISK_FILE
Return

:DELETE_DISK_FILE
DeleteFile $attachmentName
Return


{*******************************************************************************
{* Filename Filter
{*******************************************************************************
{* This subroutine determines whether the passed filename meets the criteria
{* for deletion of the attachment.
{*
{* $FF_filename (in/out) This variable should contain the filename (including
{* the path and extension) of the current attachment in
{* the message. This subroutine removes the path from
{* this variable and converts the remainder to lowercase.
{* $FF_doDelete (out) This variable will be set to "True" if the current
{* attachment should be deleted.
{*******************************************************************************
:FILENAME_FILTER

{ When running the script in manual mode, comment the next line if you want to
{ delete attachments based on filename and extension.
{ (In manual mode, you will be prompted for confirmation
{ regardless of this setting.)
If #pocoScriptMode = 5 Then FF_DELETE

{ First, remove the path to the filename }
StringPos #FF_index \ $FF_filename
If #FF_index = 0 Then FF_PARSE_EXTENSION
ChopString $FF_filename 1 #FF_index
Goto FILENAME_FILTER

{ Second, parse the extension }
:FF_PARSE_EXTENSION
Set $FF_extension ""
Lowercase $FF_filename
Set $FF_tmp $FF_filename

:FF_EXTENSION_LOOP
StringPos #FF_index "." $FF_tmp
If #FF_index = 0 Then FF_MAIN
ChopString $FF_tmp 1 #FF_index
Set $FF_extension $FF_tmp
Goto FF_EXTENSION_LOOP

{ Finally, decide whether or not to remove this attachment. }

:FF_MAIN

{ Uncomment any of the following lines or add your own. }
{ Here are examples that check the extension:
{ If $FF_extension = "jpg" Then FF_KEEP
{ If $FF_extension = "pdf" Then FF_KEEP
{ If $FF_extension = "" Then FF_DELETE
{ If $FF_extension = "bat" Then FF_DELETE
{ If $FF_extension = "exe" Then FF_DELETE
{ If $FF_extension = "scr" Then FF_DELETE
{ Here are examples that check the filename (and extension):
{ If "phrase one" ^ $FF_filename Then FF_DELETE
{ If "phrase two" ^ $FF_filename Then FF_KEEP
{ If no matches were found so far, then use the following default action:
Goto FF_DELETE
{Goto FF_KEEP

:FF_DELETE
Set $FF_doDelete "True"
Return

:FF_KEEP
Set $FF_doDelete "False"
Return
cssutto
Drop-in Visitor
 
Posts: 7
Joined: Tue Mar 07, 2006 4:25 am


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron