| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::MonM::Channel::File; |
|
2
|
1
|
|
|
1
|
|
340
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf-8 |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
App::MonM::Channel::File - MonM file channel |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.00 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Type File |
|
20
|
|
|
|
|
|
|
Enable on |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Real To Email address |
|
23
|
|
|
|
|
|
|
To testuser@localhost |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Schedule |
|
26
|
|
|
|
|
|
|
#At Sun-Sat[00:00-23:59] |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# MIME options |
|
29
|
|
|
|
|
|
|
#Encoding 8bit |
|
30
|
|
|
|
|
|
|
# 8bit, quoted-printable, 7bit, base64 |
|
31
|
|
|
|
|
|
|
#ContentType text/plain |
|
32
|
|
|
|
|
|
|
#Charset utf-8 |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Output File Options |
|
35
|
|
|
|
|
|
|
#Dir /path/to/my/messages |
|
36
|
|
|
|
|
|
|
#File [DATETIME]-[ID].[EXT] |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This module provides a method that writes the content |
|
43
|
|
|
|
|
|
|
of the message to an external file |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over 4 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item B |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
For internal use only! |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 CONFIGURATION DIRECTIVES |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The basic Channel configuration options (directives) detailed describes in L |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item B, B |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Dir /tmp |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Defines path to save the message files |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Default: your temp directory |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item B, B |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
File [DATETIME]-[ID].[EXT] |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Defines special mask of the message's filename |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Default: "[DATETIME]-[ID].[EXT]" |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Available variables: |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
[ID] -- Internal ID of the message |
|
78
|
|
|
|
|
|
|
[TO] -- The real "to" field of message |
|
79
|
|
|
|
|
|
|
[RCPT], [RECIPIENT] -- Recipient (name, account, id, number and etc.) |
|
80
|
|
|
|
|
|
|
[EXT] -- file extension (default: msg) |
|
81
|
|
|
|
|
|
|
[TIME] -- Current time (in unix time format) |
|
82
|
|
|
|
|
|
|
[DATETIME] -- date and time in short-format (YYYMMDDHHMMSS) |
|
83
|
|
|
|
|
|
|
[DATE] -- Date in short-format (YYYMMDD) |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item B |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Sender address (Email) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item B |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Recipient address (Email) or name |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item B |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Type File |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Required directive! |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Defines type of channel. MUST BE set to "File" value |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
About common directives see L |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 HISTORY |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
See C file |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 TO DO |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
See C file |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 LICENSE |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
|
132
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
See C file and L |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
|
|
138
|
1
|
|
|
1
|
|
33
|
use vars qw/$VERSION/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
31
|
|
|
139
|
|
|
|
|
|
|
$VERSION = '1.00'; |
|
140
|
|
|
|
|
|
|
|
|
141
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
1
|
|
|
1
|
|
4
|
use CTK::ConfGenUtil; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
59
|
|
|
144
|
1
|
|
|
1
|
|
5
|
use CTK::Util qw/ dformat date_time2dig date2dig /; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
39
|
|
|
145
|
1
|
|
|
1
|
|
4
|
use App::MonM::Util qw/ set2attr /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
use constant { |
|
148
|
1
|
|
|
|
|
282
|
FILEEXT => "msg", |
|
149
|
|
|
|
|
|
|
FILEMASK => "[DATETIME]-[ID].[EXT]", |
|
150
|
1
|
|
|
1
|
|
5
|
}; |
|
|
1
|
|
|
|
|
2
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub sendmsg { |
|
153
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
154
|
0
|
0
|
|
|
|
|
return $self->maybe::next::method() unless $self->type eq 'file'; |
|
155
|
0
|
|
|
|
|
|
my $message = $self->message; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Options |
|
158
|
0
|
|
0
|
|
|
|
my $options = set2attr($self->chconf) || {}; |
|
159
|
|
|
|
|
|
|
#print App::MonM::Util::explain($options); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# File |
|
162
|
0
|
|
0
|
|
|
|
my $filemask = value($self->chconf, "filemask") || value($self->chconf, "file") || FILEMASK; |
|
163
|
0
|
|
|
|
|
|
my $filename = dformat($filemask, { |
|
164
|
|
|
|
|
|
|
ID => $self->message->msgid, |
|
165
|
|
|
|
|
|
|
TO => $self->message->to, |
|
166
|
|
|
|
|
|
|
RCPT => $self->message->recipient, RECIPIENT => $self->message->recipient, |
|
167
|
|
|
|
|
|
|
EXT => FILEEXT, |
|
168
|
|
|
|
|
|
|
TIME => time(), DATETIME=> date_time2dig(), DATE => date2dig(), |
|
169
|
|
|
|
|
|
|
}); |
|
170
|
0
|
|
0
|
|
|
|
my $dir = value($self->chconf, "directory") || value($self->chconf, "dir") || File::Spec->tmpdir; |
|
171
|
0
|
|
|
|
|
|
my $file; |
|
172
|
0
|
0
|
|
|
|
|
if (File::Spec->file_name_is_absolute($filename)) { |
|
173
|
0
|
|
|
|
|
|
$file = $filename; |
|
174
|
|
|
|
|
|
|
} else { |
|
175
|
0
|
0
|
0
|
|
|
|
unless (-e $dir and -w $dir) { |
|
176
|
0
|
|
|
|
|
|
$self->error(sprintf("Can't use directory: %s", $dir)); |
|
177
|
0
|
|
|
|
|
|
return 0; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
0
|
|
|
|
|
|
$file = File::Spec->catfile($dir, $filename); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# Save |
|
183
|
0
|
0
|
|
|
|
|
$message->save($file) or do { |
|
184
|
0
|
|
|
|
|
|
$self->error($message->error); |
|
185
|
0
|
|
|
|
|
|
return 0; |
|
186
|
|
|
|
|
|
|
}; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
#printf "Send message %s to %s (%s) via %s\n", $self->message->msgid, $self->message->to, $self->message->recipient, $self->type; |
|
189
|
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
return 1; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
1; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
__END__ |