Mercurial > hg > mlmmj
annotate contrib/web/perl-admin/htdocs/subscribers.cgi @ 787:284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Streibelt, Bitmand)
author | Ben Schmidt |
---|---|
date | Sun, 21 Nov 2010 00:31:09 +1100 |
parents | 7fefd9a9fad5 |
children |
rev | line source |
---|---|
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
1 #!/usr/bin/perl -w |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
2 |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
3 # Copyright (C) 2004, 2005, 2006, 2007 Christian Laursen <christian@pil.dk> |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
4 # Copyright (C) 2007 Franky Van Liedekerke <liedekef@telenet.be> |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
5 # |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
6 # $Id$ |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
7 # |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
8 # Permission is hereby granted, free of charge, to any person obtaining a copy |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
9 # of this software and associated documentation files (the "Software"), to |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
10 # deal in the Software without restriction, including without limitation the |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
11 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
12 # sell copies of the Software, and to permit persons to whom the Software is |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
13 # furnished to do so, subject to the following conditions: |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
14 # |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
15 # The above copyright notice and this permission notice shall be included in |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
16 # all copies or substantial portions of the Software. |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
17 # |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
21 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
23 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
24 # IN THE SOFTWARE. |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
25 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
26 use strict; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
27 use URI::Escape; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
28 use HTML::Entities; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
29 use CGI; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
30 use CGI::FastTemplate; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
31 use Digest::MD5; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
32 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
33 use vars qw($topdir $templatedir $list); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
34 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
35 if (exists $ENV{CONFIG_PATH}) { |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
36 require $ENV{CONFIG_PATH}; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
37 } else { |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
38 require "../conf/config.pl"; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
39 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
40 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
41 my $mlmmjsub = "/usr/local/bin/mlmmj-sub"; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
42 my $mlmmjunsub = "/usr/local/bin/mlmmj-unsub"; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
43 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
44 my $tpl = new CGI::FastTemplate($templatedir); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
45 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
46 my $q = new CGI; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
47 $list = $q->param("list"); |
388 | 48 my $update = $q->param("update"); |
546 | 49 my $search = $q->param("search"); |
50 my $email = $q->param("email"); | |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
51 my $file = $q->param("file"); |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
52 my $removeall = $q->param("removeall"); |
546 | 53 |
54 # Everything is submitted from the same form so a little hackery is needed | |
55 # to pick the right action to perform. When doing subscribe and search we | |
56 # don't depend on the submit buttons since hitting enter in either of the | |
57 # text fields will pick the "Subscribe" button. | |
58 # | |
59 # If an email has been entered for subscription, clear the search field. | |
60 | |
61 if (defined $email && $email !~ /^$/) { | |
62 $search = undef; | |
63 } else { | |
64 $email = undef; | |
65 } | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
66 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
67 die "no list specified" unless $list; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
68 die "non-existent list" unless -d("$topdir/$list"); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
69 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
70 $tpl->define(main => "subscribers.html", |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
71 row => "subscribers_row.html"); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
72 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
73 my $action = ''; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
74 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
75 my $subscribers; |
552
fee753d23b25
Show list name on configure and subscriber pages as well as the number of
xi
parents:
551
diff
changeset
|
76 my $subcount; |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
77 |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
78 if (defined $removeall) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
79 my $removeall_check = $q->param("removeall_check"); |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
80 if ($removeall_check) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
81 unlink <$topdir/$list/subscribers.d/*>; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
82 unlink <$topdir/$list/nomailsubs.d/*>; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
83 unlink <$topdir/$list/digesters.d/*>; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
84 $action = "All subscribers have been removed."; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
85 } else { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
86 $action = "Safety check not clicked, nothing done."; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
87 } |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
88 } elsif (defined $file) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
89 my $subscriber = $q->param("subscriber"); |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
90 my $digester = $q->param("digester"); |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
91 my $nomailsub = $q->param("nomailsub"); |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
92 my $upload_handle = $q->upload("file"); |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
93 binmode $upload_handle; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
94 while (<$upload_handle>) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
95 s/\r?\n$//; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
96 my $email=$_; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
97 if ($email =~ /^[a-z0-9\.\-_\@]+$/i) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
98 if ($subscriber) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
99 system "$mlmmjsub -L $topdir/$list -a $email -U -s"; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
100 } |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
101 if ($digester) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
102 system "$mlmmjsub -L $topdir/$list -a $email -Ud -s"; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
103 } |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
104 if ($nomailsub) { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
105 system "$mlmmjsub -L $topdir/$list -a $email -Un -s"; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
106 } |
787
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
107 if ($? == 0) { |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
108 $action .= "$email has been subscribed.<br>\n"; |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
109 } else { |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
110 $action .= "error subscribing $email (code $?)<br>\n"; |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
111 } |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
112 } else { |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
113 $action .= '"'.encode_entities($email).'" is not a valid email address.<br>'; |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
114 } |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
115 } |
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
116 } elsif (defined $email) { |
388 | 117 my $subscriber = $q->param("subscriber"); |
118 my $digester = $q->param("digester"); | |
119 my $nomailsub = $q->param("nomailsub"); | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
120 if ($email =~ /^[a-z0-9\.\-_\@]+$/i) { |
388 | 121 if ($subscriber) { |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
122 system "$mlmmjsub -L $topdir/$list -a $email -U -s"; |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
123 } |
388 | 124 if ($digester) { |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
125 system "$mlmmjsub -L $topdir/$list -a $email -Ud -s"; |
388 | 126 } |
127 if ($nomailsub) { | |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
128 system "$mlmmjsub -L $topdir/$list -a $email -Un -s"; |
388 | 129 } |
787
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
130 if ($? == 0) { |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
131 $action = "$email has been added"; |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
132 } else { |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
133 $action = "error adding $email (code $?)"; |
284c640f1b3f
Check return status in mlmmj-perl-admin when adding subscribers (Florian
Ben Schmidt
parents:
657
diff
changeset
|
134 } |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
135 } else { |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
136 $action = '"'.encode_entities($email).'" is not a valid email address.'; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
137 } |
388 | 138 } elsif (defined $update) { |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
139 my $maxid = $q->param("maxid"); |
388 | 140 $subscribers = get_subscribers(); |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
141 for (my $i = 0; $i < $maxid; ++$i) { |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
142 my $email = $q->param("email$i"); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
143 if (defined $email) { |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
144 if ($email =~ /^[a-z0-9\.\-_\@]+$/i) { |
388 | 145 my $updated = 0; |
146 | |
147 my @actions = (); | |
148 | |
149 push @actions, {oldstatus => exists $subscribers->{$email}->{subscriber}, | |
150 newstatus => defined $q->param("subscriber$i"), | |
151 action => ''}; | |
152 push @actions, {oldstatus => exists $subscribers->{$email}->{digester}, | |
153 newstatus => defined $q->param("digester$i"), | |
154 action => '-d'}; | |
155 push @actions, {oldstatus => exists $subscribers->{$email}->{nomailsub}, | |
156 newstatus => defined $q->param("nomailsub$i"), | |
157 action => '-n'}; | |
158 | |
159 for my $action (@actions) { | |
160 if ($action->{oldstatus} && !$action->{newstatus}) { | |
161 system "$mlmmjunsub -L $topdir/$list -a $email $action->{action}"; | |
162 $updated = 1; | |
163 } elsif (!$action->{oldstatus} && $action->{newstatus}) { | |
164 system "$mlmmjsub -L $topdir/$list -a $email $action->{action}"; | |
165 $updated = 1; | |
166 } | |
167 } | |
168 | |
169 if ($updated) { | |
170 $action .= "Subscription for $email has been updated.<br>\n"; | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
171 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
172 } else { |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
173 $action .= '"'.encode_entities($email).'" is not a valid email address.'."<br>\n"; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
174 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
175 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
176 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
177 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
178 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
179 $tpl->assign(ACTION => $action); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
180 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
181 $subscribers = get_subscribers(); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
182 |
547 | 183 my $paginator = ''; |
184 my $page = $q->param('page'); | |
657
7fefd9a9fad5
Merged changes from Franky Van Liedekerke <liedekef@telenet.be>:
xi
parents:
552
diff
changeset
|
185 $page = 0 unless defined $page && $page =~ /^\d+$/; |
547 | 186 if (keys %$subscribers > 50) { |
187 $paginator = 'Pages: '; | |
188 my $pages = (keys %$subscribers) / 50; | |
189 $page = 0 unless ($page >= 0 && $page < $pages); | |
551 | 190 my $searchstr = (defined $search && $search ne '') ? '&search='.uri_escape($search) : ''; |
547 | 191 |
192 for (my $i = 0; $ i < $pages; ++$i) { | |
193 if ($page == $i) { | |
194 $paginator .= ($i + 1)." "; | |
195 } else { | |
196 $paginator .= "<a href=\"?list=".uri_escape($list)."&page=$i$searchstr\">".($i + 1)."</a> "; | |
197 } | |
198 } | |
199 } | |
200 | |
388 | 201 my $i = 0; |
547 | 202 my @addresses = sort {lc $a cmp lc $b} keys %$subscribers; |
203 if ($paginator ne '') { | |
204 @addresses = @addresses[$page * 50 .. ($page + 1) * 50 - 1]; | |
205 pop @addresses until defined $addresses[@addresses - 1]; | |
206 } | |
207 | |
208 for my $address (@addresses) { | |
388 | 209 $tpl->assign(EMAIL => $address, |
210 ID => $i++, | |
211 SCHECKED => $subscribers->{$address}->{subscriber} ? 'checked' : '', | |
212 DCHECKED => $subscribers->{$address}->{digester} ? 'checked' : '', | |
213 NCHECKED => $subscribers->{$address}->{nomailsub} ? 'checked' : ''); | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
214 $tpl->parse(ROWS => '.row'); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
215 } |
388 | 216 if (keys %$subscribers == 0) { |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
217 $tpl->assign(ROWS => ''); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
218 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
219 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
220 $tpl->assign(LIST => encode_entities($list), |
547 | 221 MAXID => scalar(@addresses), |
222 SEARCH => defined $search ? $search : '', | |
223 PAGINATOR => $paginator, | |
552
fee753d23b25
Show list name on configure and subscriber pages as well as the number of
xi
parents:
551
diff
changeset
|
224 PAGE => $page, |
fee753d23b25
Show list name on configure and subscriber pages as well as the number of
xi
parents:
551
diff
changeset
|
225 SUBCOUNT => $subcount); |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
226 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
227 print "Content-type: text/html\n\n"; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
228 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
229 $tpl->parse(CONTENT => "main"); |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
230 $tpl->print; |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
231 |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
232 sub get_subscribers { |
388 | 233 my %subscribers = (); |
234 | |
235 my @subscribers = `/usr/local/bin/mlmmj-list -L $topdir/$list`; | |
236 my @digesters = `/usr/local/bin/mlmmj-list -L $topdir/$list -d`; | |
237 my @nomailsubs = `/usr/local/bin/mlmmj-list -L $topdir/$list -n`; | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
238 |
388 | 239 chomp @subscribers; |
240 chomp @digesters; | |
241 chomp @nomailsubs; | |
242 | |
546 | 243 if (defined $search) { |
548 | 244 $search = lc $search; |
245 @subscribers = grep {index(lc $_, $search) != -1} @subscribers; | |
246 @digesters = grep {index(lc $_, $search) != -1} @digesters; | |
247 @nomailsubs = grep {index(lc $_, $search) != -1} @nomailsubs; | |
546 | 248 } |
249 | |
388 | 250 for my $address (@subscribers) { |
251 $subscribers{$address}->{subscriber} = 1; | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
252 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
253 |
388 | 254 for my $address (@digesters) { |
255 $subscribers{$address}->{digester} = 1; | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
256 } |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
257 |
388 | 258 for my $address (@nomailsubs) { |
259 $subscribers{$address}->{nomailsub} = 1; | |
260 } | |
261 | |
552
fee753d23b25
Show list name on configure and subscriber pages as well as the number of
xi
parents:
551
diff
changeset
|
262 $subcount = scalar(keys %subscribers); |
fee753d23b25
Show list name on configure and subscriber pages as well as the number of
xi
parents:
551
diff
changeset
|
263 |
388 | 264 return \%subscribers; |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
diff
changeset
|
265 } |