Mercurial > hgrepos > hgweb.cgi > after5
annotate after5.rb @ 81:abf46a970b21 draft
typo
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 05 Mar 2013 15:28:02 +0900 |
parents | 5381d9b4adb5 |
children | 0ca2c48f8387 |
rev | line source |
---|---|
17 | 1 #!/usr/local/bin/ruby19 |
16 | 2 # -*- coding: euc-jp -*- |
0 | 3 # |
4 # Associative Scheduling Table - after5 | |
80
5381d9b4adb5
Correct date format for SMTP.
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
5 # (C)2003, 2004, 2006, 2008, 2012, 2013 by HIROSE Yuuji [yuuji<at>gentei.org] |
76
53e747495502
Bug-fix: Regexp matching should be done in euc-jp.
HIROSE Yuuji <yuuji@gentei.org>
parents:
75
diff
changeset
|
6 # $Id: after5.rb,v 1.20 2012/12/03 15:54:20 yuuji Exp $ |
81 | 7 # Last modified Tue Mar 5 15:27:29 2013 on firestorm |
0 | 8 # See http://www.gentei.org/~yuuji/software/after5/ |
9 # このスクリプトはEUCで保存してください。 | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
10 $hgid = <<_HGID_.split[1..-2].join(" ") |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
11 $HGid$ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
12 _HGID_ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
13 $myurl = "http://www.gentei.org/~yuuji/software/after5/" |
0 | 14 |
15 require 'kconv' | |
17 | 16 require 'nkf' |
0 | 17 |
18 $charset = 'EUC-JP' | |
19 | |
20 class HTMLout | |
21 def contenttype(type = "text/html", charset = $charset) | |
22 sprintf "Content-type: %s; charset=%s\n\n", type, charset | |
23 end | |
24 def initialize(title = "Document") | |
25 @title = title | |
26 @eltstack = [] | |
27 end | |
28 def resetstack() | |
29 @eltstack = [] | |
30 end | |
31 def head(title = @title, css = "style.css") | |
32 sprintf <<__EOS__, title, css | |
33 <html> | |
34 <head> | |
35 <title>%s</title> | |
36 <link rel="stylesheet" type="text/css" href="%s"> | |
37 </head> | |
38 __EOS__ | |
39 end | |
40 | |
41 def startelement(elt, attrs = {}, nl = true) | |
42 attr = "" | |
43 if attrs.is_a?(Hash) | |
44 for k in attrs.keys | |
45 attr += " %s=\"%s\"" % [k, attrs[k]] | |
46 end | |
47 end | |
48 @eltstack.push(elt) | |
49 sprintf "<%s%s>%s", elt, attr, nl ? "\n" : "" | |
50 end | |
51 def endelement(elt = nil, nl = true) | |
52 if elt | |
53 x = elt | |
54 @eltstack.pop | |
55 else | |
56 x = @eltstack.pop | |
57 end | |
58 sprintf "</%s>%s", x, nl ? "\n" : "" | |
59 end | |
60 def element(elt, attrs = nil, nl = nil) | |
61 attr = "" | |
62 lf = nl ? "\n" : "" | |
63 if attrs.is_a?(Hash) | |
64 for k in attrs.keys | |
65 attr += " %s=\"%s\"" % [k, attrs[k]] | |
66 end | |
67 end | |
68 body = yield | |
69 sprintf "<%s%s>%s%s%s</%s>%s", elt, attr, lf, body, lf, elt, lf | |
70 end | |
71 def elementln(elt, attr=nil) | |
72 body = yield | |
73 element(elt, attr, true){body} | |
74 end | |
75 def a(href, anchor = nil, attrs = {}) | |
76 attr = attrs | |
77 attr['href'] = href | |
78 element("a", attr){ | |
79 anchor or href | |
80 } | |
81 end | |
82 def p(msg, attrs=nil) | |
83 element("p", attrs){msg} | |
84 end | |
85 def text(name, value='', size=nil, maxlength=nil) | |
86 sprintf "<input type=\"text\" name=\"%s\" value=\"%s\"%s%s>", | |
87 name, value, | |
88 size ? " size=\"%s\""%size.to_s : '', | |
89 maxlength ? " maxlength=\"%s\""%maxlength.to_s : '' | |
90 end | |
91 def hidden(name, value='') | |
92 sprintf "<input type=\"hidden\" name=\"%s\" value=\"%s\">", name, value | |
93 end | |
94 def radio(name, value, text='', checked=nil) | |
95 sprintf "<input type=\"radio\" name=\"%s\" value=\"%s\"%s>%s", | |
96 name, value, checked ? " checked" : "", text | |
97 end | |
98 def checkbox(name, value, text='', checked=nil) | |
99 sprintf "<input type=\"checkbox\" name=\"%s\" value=\"%s\"%s>%s", | |
100 name, value, checked ? " checked" : "", text | |
101 end | |
102 def submit(name, value, text='') | |
103 sprintf "<input type=\"submit\" name=\"%s\" value=\"%s\">%s\n", | |
104 name, value, text | |
105 end | |
106 def reset(name, value, text='') | |
107 sprintf "<input type=\"reset\" name=\"%s\" value=\"%s\">\n", | |
108 name, value, text | |
109 end | |
110 def submit_reset(name) | |
111 submit(name, "GO")+reset(name, "Reset") | |
112 end | |
113 | |
2 | 114 def select(name, range, selected=nil) |
115 #start = (b<e ? b : e) | |
116 #last = (b>e ? b : e) | |
117 c=0 | |
0 | 118 "<select name=\"#{name}\">\n" + \ |
2 | 119 range.collect{|i| |
3 | 120 value = (i.is_a?(Array) ? i[1] : i).to_s |
121 sprintf "<option%s%s>%s%s</option>", | |
122 (selected.to_s==value.to_s) ? " selected" : "", | |
123 i.is_a?(Array) ? " value=\"%s\"" % value : '', | |
124 i.is_a?(Array) ? i[0] : i.to_s, | |
2 | 125 (c+=1)%6==0 ? "\n" : '' |
0 | 126 }.join + \ |
127 "\n</select>\n" | |
128 end | |
129 end | |
14 | 130 class TEXTout |
131 def isBlock(elt) | |
132 /\b(tr|[udo]l|p|div)\b/i =~ elt | |
133 end | |
134 def isEOC(elt) | |
135 /\bt[dh]\b/i =~ elt | |
136 end | |
137 def eoelem(elt) | |
138 r = "" | |
139 r << "\n" if isBlock(elt) | |
140 r << " " if isEOC(elt) | |
141 r | |
142 end | |
143 def contenttype(type = "text/plain", charset = $charset) | |
144 ### sprintf "Content-type: %s; charset=%s\n\n", type, charset | |
145 "" | |
146 end | |
147 def initialize(title = "Document") | |
148 @title = title | |
149 @eltstack = [] | |
150 end | |
151 def resetstack() | |
152 @eltstack = [] | |
153 end | |
154 def head(title = @title, css = "style.css") | |
155 sprintf <<__EOS__, title, css | |
156 ===== [[[ %s ]]] ===== | |
157 __EOS__ | |
158 end | |
159 | |
160 def startelement(elt, attrs = {}, nl = true) | |
161 attr = "" | |
162 x = sprintf "%s", " "*@eltstack.length | |
163 @eltstack.push(elt) | |
164 x | |
165 end | |
166 def endelement(elt = nil, nl = true) | |
167 if elt | |
168 x = elt | |
169 @eltstack.pop | |
170 else | |
171 x = @eltstack.pop | |
172 end | |
173 eoelem(x) | |
174 end | |
175 def element(elt, attrs = nil, nl = nil) | |
176 attr = "" | |
177 lf = nl ? "\n" : "" | |
178 body = yield | |
179 #sprintf "<%s%s>%s%s%s</%s>%s", elt, attr, lf, body, lf, elt, lf | |
180 sprintf "%s%s", body, eoelem(elt) | |
181 end | |
182 def elementln(elt, attr=nil) | |
183 body = yield | |
184 sprintf "%s\n", body | |
185 end | |
186 def a(href, anchor = nil, attrs = {}) | |
187 attr = attrs | |
188 attr['href'] = href | |
189 # sprintf "%s\n", href | |
190 anchor | |
191 end | |
192 def p(msg, attrs=nil) | |
193 element("p", attrs){msg} | |
194 end | |
195 def text(name, value='', size=nil, maxlength=nil) | |
196 "" | |
197 end | |
198 def hidden(name, value='') | |
199 "" | |
200 end | |
201 def radio(name, value, text='', checked=nil) | |
202 "" | |
203 end | |
204 def checkbox(name, value, text='', checked=nil) | |
205 "" | |
206 end | |
207 def submit(name, value, text='') | |
208 "" | |
209 end | |
210 def reset(name, value, text='') | |
211 "" | |
212 end | |
213 def submit_reset(name) | |
214 "" | |
215 end | |
216 def select(name, range, selected=nil) | |
217 "" | |
218 end | |
219 end | |
0 | 220 |
221 class PasswdMgr | |
222 def initialize(name, mode=0640) | |
223 require 'dbm' | |
224 @pdb = DBM.open(name, mode) | |
225 end | |
226 def checkpasswd(user, passwd) | |
227 if @pdb[user] then | |
228 @pdb[user] == passwd.crypt(@pdb[user]) | |
229 end | |
230 end | |
231 def setpasswd(user, passwd) | |
232 salt = [rand(64),rand(64)].pack("C*").tr("\x00-\x3f","A-Za-z0-9./") | |
233 @pdb[user] = passwd.crypt(salt) | |
234 end | |
235 def userexist?(user) | |
236 @pdb[user] ? true : false | |
237 end | |
238 def getpasswd(user) | |
239 @pdb[user] | |
240 end | |
241 def delete(user) | |
242 @pdb.delete(user) | |
243 end | |
244 def close() | |
245 @pdb.close() | |
246 end | |
247 def newpasswd(length) | |
61
502103680ea2
Call srand() without parameter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
60
diff
changeset
|
248 srand() |
0 | 249 left = "qazxswedcvfrtgb12345" |
250 right = "yhnmjuik.lop;/67890-" | |
251 array = [left, right] | |
252 (1..length).collect{|i| | |
253 a = array[i%array.length] | |
254 a[rand(a.length), 1] | |
255 }.join('') | |
256 end | |
257 def users() | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
258 @pdb.keys.collect{|u| u.toeuc} # toeuc is for 1.9 :( |
0 | 259 end |
260 private :newpasswd | |
261 def setnewpasswd(user, length=8) | |
262 newp = newpasswd(length) | |
263 setpasswd(user, newp) | |
264 newp | |
265 end | |
266 end | |
267 | |
268 class ScheduleDir | |
269 def initialize(dir = "s") | |
270 @dir = dir | |
271 @schedulefile = "sched" | |
272 @usermapdir = File.join(@dir, "usermap") | |
273 @usermap = mkusermap() | |
274 @groupmapdir = File.join(@dir, "groupmap") | |
275 @groupmap = mkgroupmap() | |
276 @crondir = File.join(@dir, "crondir") | |
277 | |
278 end | |
279 def mkusermap() | |
280 map = {} | |
281 unless test(?d, @usermapdir) | |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
282 mkdir_p(@usermapdir, 0750) |
0 | 283 end |
284 Dir.foreach(@usermapdir){|u| | |
285 next if /^\./ =~ u | |
286 newu = '' | |
287 u.split('').each{|c| # for security wrapping | |
12 | 288 newu << c[0].chr if %r,[-A-Z0-9/+_.@],i =~ c |
0 | 289 } |
290 u = newu | |
291 map[u] = {} | |
17 | 292 d = File.join(@usermapdir, u).untaint |
0 | 293 next unless test(?d, d) |
294 Dir.foreach(d){|attr| | |
295 next if /^\./ =~ attr | |
12 | 296 attr.untaint if /^[A-Z_][-A-Z_0-9]*$/i =~ attr |
17 | 297 file = File.join(@usermapdir, u, attr).untaint |
0 | 298 next unless test(?s, file) && test(?r, file) |
17 | 299 map[u][attr] = IO.readlines(file).join.toeuc.strip |
0 | 300 } |
301 } | |
302 map | |
303 end | |
69
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
304 def ismembersemail(email) |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
305 @usermap.keys.each {|u| |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
306 return u if u==email |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
307 return u if mailaddress(u).split(/,\s*|\s+/).grep(email)[0] |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
308 } |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
309 nil |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
310 end |
0 | 311 def putuserattr(user, attr, text) |
312 # if text==nil, remove it | |
313 d = File.join(@usermapdir, user) | |
314 Dir.mkdir(d) unless test(?d, d) | |
315 file = File.join(d, attr) | |
316 begin | |
2 | 317 unless @usermap[user] |
318 @usermap[user] = {} | |
319 mkdir_p(d) unless test(?d, d) | |
320 end | |
0 | 321 @usermap[user][attr] = text |
322 if text==nil | |
323 File.unlink(file) | |
324 else | |
325 open(file, "w"){|w| w.puts @usermap[user][attr]} | |
326 end | |
327 rescue | |
328 return nil | |
329 end | |
330 return {attr => text} | |
331 end | |
332 def getuserattr(user, attr) | |
333 # Should we distinguish between attribute is nil and "" ? | |
334 if @usermap.has_key?(user) && @usermap[user][attr].is_a?(String) && | |
335 @usermap[user][attr] > '' | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
336 return @usermap[user][attr].untaint |
0 | 337 else |
338 return nil | |
339 end | |
340 end | |
341 | |
342 def nickname(user) | |
343 if @usermap.has_key?(user) && @usermap[user]['name'].is_a?(String) && | |
344 @usermap[user]['name'] > '' | |
345 return @usermap[user]['name'] | |
346 else | |
347 return user.sub(/@.*/, '') | |
348 end | |
349 end | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
350 def mailaddress(user, grp = nil) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
351 grp ? mail4grp(user, grp) : \ |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
352 (getuserattr(user, 'email') || user) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
353 end |
0 | 354 def setnickname(user, nickname) |
355 putuserattr(user, 'name', nickname) | |
356 end | |
357 | |
358 # | |
359 # make group map | |
360 def collectmembers(gname) | |
361 @visitedgroup=[] unless @visitedgroup | |
362 return [] unless @visitedgroup.grep(gname).empty? | |
363 @visitedgroup.push(gname) | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
364 mdir = File.join(@groupmapdir, gname, 'members').untaint |
0 | 365 return [] unless test(?d, mdir) |
366 members = [] | |
367 Dir.foreach(mdir){|item| | |
368 next if /^\./ =~ item | |
369 item.untaint | |
370 next unless test(?f, File.join(mdir, item)) | |
371 if /.+@.+/ =~ item | |
372 members << item | |
373 else | |
374 members += collectmembers(item) | |
375 end | |
376 } | |
377 @visitedgroup.pop | |
378 members | |
379 end | |
380 def mkgroupmap() | |
381 map = {} | |
382 return map unless test(?d, @groupmapdir) | |
383 @visitedgroup = [] | |
384 Dir.foreach(@groupmapdir){|g| | |
385 next if /^\./ =~ g | |
386 newg = '' | |
387 next unless /^[-a-z0-9_.]+$/i =~ g | |
388 #g.untaint ## untaintじゃだめだ。map{g} のkeyがtaintedになっちゃうよ | |
389 gg = '' # for security wrapping | |
390 g.split('').each{|c| gg << c[0].chr if c != '`'} | |
391 g = gg | |
392 map[gg] = {} | |
17 | 393 d = File.join(@groupmapdir, g).untaint |
0 | 394 next unless test(?d, d) |
395 # get group name | |
17 | 396 gnf = File.join(d, 'name').untaint |
0 | 397 if test(?r, gnf) && test(?s, gnf) |
17 | 398 n = IO.readlines(gnf)[0].to_s.toeuc.strip |
0 | 399 map[g]['name'] = if n > '' then n else g end |
400 else | |
401 map[g]['name'] = g | |
402 end | |
403 # get administrators | |
404 # | |
17 | 405 gad = File.join(d, 'admin').untaint |
0 | 406 map[g]['admin'] = [] |
407 if test(?d, gad) | |
408 Dir.foreach(gad){|a| | |
409 # administrator should be a person (not group) | |
410 next unless /@/ =~ a | |
411 map[g]['admin'] << a | |
412 } | |
413 end | |
414 # collect members | |
415 #map[g]['members'] = collectmembers(g) | |
17 | 416 memd = File.join(d, 'members').untaint |
0 | 417 map[g]['members'] = [] |
418 if test(?d, memd) | |
419 Dir.foreach(memd){|a| | |
420 next if /^\./ =~ a | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
421 map[g]['members'] << a.untaint |
0 | 422 } |
423 end | |
47 | 424 # get other attributes |
425 Dir.foreach(d) {|attr| | |
426 next if /^\./ =~ attr | |
427 next unless /^[-_a-z]+$/i =~ attr | |
428 next if attr == "name" # already collected | |
429 attr.untaint | |
430 file = File.join(d, attr) #.untaint | |
431 next if test(?d, file) | |
432 next unless test(?s, file) && test(?r, file) | |
433 map[g][attr] = IO.readlines(file).join.toeuc.strip | |
434 } | |
0 | 435 } |
436 map | |
437 end | |
47 | 438 def putgroupattr(group, attr, value) |
439 d = File.join(@groupmapdir, group).untaint | |
440 Dir.mkdir(d) unless test(?d, d) | |
441 file = File.join(d, attr) | |
442 begin | |
443 unless @groupmap[group] | |
444 @groupmap[group] = {} | |
445 end | |
446 @groupmap[group][attr] = value | |
447 if value == nil | |
448 File.unlink(file) | |
449 else | |
450 open(file, "w"){|w| w.puts @groupmap[group][attr]} | |
451 end | |
452 rescue | |
453 return nil | |
454 end | |
455 return {attr => value} | |
456 end | |
457 def getgroupattr(group, attr) | |
458 if @groupmap.has_key?(group) && @groupmap[group][attr].is_a?(String) && | |
459 @groupmap[group][attr] > '' | |
460 return @groupmap[group][attr].untaint | |
461 else | |
462 return nil | |
463 end | |
464 end | |
0 | 465 def groupmap() |
466 @groupmap | |
467 end | |
468 def groups() | |
469 @groupmap.keys | |
470 end | |
2 | 471 def addgroup(group, users, remove=nil, role='members') |
472 grp = groups.grep(group)[0] # group may be tainted, using kept name | |
473 return nil unless grp | |
0 | 474 for u in users |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
475 m = nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
476 u, m = u if u.is_a?(Array) # ["user", "mailto"] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
477 m = nil if mailaddress(u)==m || /@/ !~ m |
0 | 478 next unless account_exists(u) |
17 | 479 mdir = File.join(@groupmapdir, grp, role).untaint |
480 file = File.join(mdir, u).untaint | |
0 | 481 if remove |
482 @groupmap[grp][role].delete(u) | |
483 File.unlink(file) if test(?e, file) | |
484 else | |
485 @groupmap[grp][role] << u | |
486 @groupmap[grp][role].uniq | |
487 Dir.mkdir(file) unless test(?d, mdir) | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
488 open(file, "w"){|x|x.puts m if m} |
0 | 489 end |
490 end | |
491 grp | |
492 end | |
493 def setgroupname(grp, name) | |
494 return nil unless @groupmap[grp] | |
17 | 495 mdir = File.join(@groupmapdir, grp).untaint |
496 nfile = File.join(mdir, 'name').untaint | |
0 | 497 @groupmap[grp]['name'] = name |
498 if grp == name | |
499 # remove the name file because it is default name | |
500 File.unlink(nfile) if test(?e, nfile) | |
501 else | |
502 Dir.mkdir(mdir) unless test(?d, mdir) | |
503 open(nfile, "w"){|n| n.puts name.to_s.strip} | |
504 end | |
505 name | |
506 end | |
507 def creategroup(grp, grpname="", admin=[]) | |
2 | 508 grpptnOK = /^[-A-Z0-9._:!$%,]+$/i |
509 return nil unless grpptnOK =~ grp | |
510 gg = '' | |
511 grp.split('').each{|c| gg << c[0].chr if c =~ grpptnOK} | |
512 grp = gg | |
0 | 513 gdir = File.join(@groupmapdir, grp) |
514 mkdir_p(gdir) # Should not care errors here | |
515 Dir.mkdir(File.join(gdir, "admin")) | |
516 Dir.mkdir(File.join(gdir, "members")) | |
517 @groupmap[grp] = {} | |
518 if grpname == '' | |
519 @groupmap[grp]['name'] = grp | |
520 else | |
521 setgroupname(grp, grpname) | |
522 end | |
523 @groupmap[grp]['members'] = [] | |
524 @groupmap[grp]['admin'] = [] | |
525 addgroup(grp, admin) | |
526 addgroup(grp, admin, nil, 'admin') | |
527 return @groupmap[grp] | |
528 end | |
529 def createuser(user, email = nil) | |
530 return nil unless /@/ =~ user | |
531 return nil if %r@[\/()\;|,$\%^!\#&\'\"]@ =~ user | |
532 email = email || user | |
533 @usermap[user] = {} | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
534 dir = File.join(@usermapdir, user).untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
535 test(?d, dir) || Dir.mkdir(dir) |
0 | 536 putuserattr(user, 'email', email) |
537 end | |
538 def deleteuser(user) | |
539 return nil unless @usermap[user] | |
540 begin | |
541 @usermap[user] # return value | |
542 ensure | |
543 @usermap.delete(user) | |
544 rm_rf(File.join(@usermapdir, user)) | |
545 rm_rf(File.join(@groupmapdir, "*/members/#{user}")) | |
546 rm_rf(File.join(@crondir, "[1-9]*-*-*/#{user}")) | |
547 rm_rf(File.join(@dir, "[1-9]*/[0-9][0-9]/[0-9][0-9]/[0-9]???/#{user}")) | |
548 end | |
549 end | |
550 def destroygroup(grp) | |
551 return nil unless @groupmap[grp] | |
552 begin | |
553 @groupmap[grp] # return value | |
554 ensure | |
555 @groupmap.delete(grp) | |
556 rm_rf(File.join(@groupmapdir, grp)) | |
557 rm_rf(File.join(@groupmapdir, "*/members/#{grp}")) | |
558 rm_rf(File.join(@crondir, "[1-9]*-*-*/#{grp}")) | |
559 rm_rf(File.join(@dir, "[1-9]*/[0-9][0-9]/[0-9][0-9]/[0-9]???/#{grp}")) | |
560 end | |
561 end | |
562 def rm_rf(path) | |
6 | 563 path.untaint |
0 | 564 if (list = Dir.glob(path))[0] |
565 for p in list | |
2 | 566 p.untaint |
0 | 567 system "/bin/rm -rf \"#{p}\"" |
568 end | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
569 cleanup_files(list) |
0 | 570 end |
571 end | |
572 def account_exists(instance) | |
573 if /@/ =~ instance | |
574 true | |
575 else | |
576 ! @groupmap.select{|k, v| k==instance}.empty? | |
577 end | |
578 end | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
579 def mail4grp(usr, group) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
580 file = File.expand_path((group+"/members/"+usr).untaint, @groupmapdir) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
581 if test(?s, file.untaint) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
582 open(file, "r"){|f|f.gets.chomp}.untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
583 else |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
584 mailaddress(usr) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
585 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
586 end |
0 | 587 def ismember(user, grouporuser) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
588 return user if user==grouporuser |
0 | 589 if @groupmap[grouporuser] |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
590 @groupmap[grouporuser]['members'].grep(user)[0] && |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
591 mail4grp(user, grouporuser) |
0 | 592 end |
593 end | |
2 | 594 def isuser(user) |
595 @usermap[user] && @usermap.keys.grep(user)[0] | |
596 end | |
0 | 597 def isgroup(grp) |
598 @groupmap[grp] | |
599 end | |
600 def isadmin(user, group) | |
601 @groupmap[group] and @groupmap[group]['admin'].grep(user)[0] | |
602 end | |
603 def members(grp) | |
604 @groupmap[grp] and ####################@groupmap[grp]['members'] | |
605 collectmembers(grp) | |
606 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
607 def membernames(grp) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
608 members(grp).collect{|u| nickname(u)} |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
609 end |
0 | 610 def admins(grp) |
611 @groupmap[grp] and @groupmap[grp]['admin'] | |
612 end | |
613 def groupname(grp) | |
614 @groupmap[grp] && @groupmap[grp]['name'] | |
615 end | |
2 | 616 def name2group(name) |
617 @groupmap.find{|g, v| v.is_a?(Hash) && v['name']==name} | |
618 end | |
619 def day_all(d, user=nil, personalonly = nil) | |
0 | 620 y, m, d = d.scan(%r,(\d\d\d\d+)/(\d+)/(\d+),)[0] |
621 #daydir = File.join(@dir, "%04d"%y.to_i, "%02d"%m.to_i, "%02d"%d.to_i) | |
622 daydir = File.join("s", "%04d"%y.to_i, "%02d"%m.to_i, "%02d"%d.to_i) | |
623 sched = {} | |
624 return sched unless test(?d, daydir) | |
625 Dir.foreach(daydir) {|time| | |
626 next if /^\./ =~ time | |
627 next unless /^\d\d\d\d$/ =~ time | |
628 time.untaint | |
629 t = File.join(daydir, time) | |
630 next unless test(?d, t) | |
631 sched[time] = {} | |
632 Dir.foreach(t){|who| | |
633 next if /^\./ =~ who | |
634 | |
635 visible = false | |
636 #next unless /@/ =~ who # user must be as user@do.ma.in | |
637 next unless account_exists(who) | |
7 | 638 ## next if personalonly && who != user #2004/1/16 |
0 | 639 who.untaint |
640 dir = File.join(t, who) | |
641 next unless test(?d, dir) && test(?x, dir) | |
642 pub = File.join(dir, 'pub') | |
7 | 643 if test(?f, pub) && test(?r, pub) && test(?s, pub) && |
644 !personalonly # unneccessary if personal mode | |
0 | 645 if IO.readlines(pub)[0].to_i > 0 |
646 visible = true | |
647 end | |
648 end | |
649 | |
650 | |
651 if ismember(user, who) || visible | |
652 sched[time][who] = {} | |
653 file = File.join(dir, @schedulefile) | |
654 if test(?s, file) && test(?r, file) && test(?s, file) | |
17 | 655 sched[time][who]['sched'] = IO.readlines(file).join.toeuc.chomp! |
6 | 656 sched[time][who]['regtime'] = File.stat(file).mtime |
0 | 657 end |
658 sched[time][who]['pub'] = visible | |
659 end | |
660 } #|who| | |
661 sched.delete(time) if sched[time].empty? | |
662 } | |
663 sched | |
664 end | |
665 | |
666 def scheduledir(user, y, m, d, time) | |
667 sprintf("%s/%04d/%02d/%02d/%04d/%s", | |
44 | 668 @dir, y.to_i, m.to_i, d.to_i, time.to_i, user).untaint |
0 | 669 end |
670 def schedulefile(user, y, m, d, time) | |
671 File.join(scheduledir(user, y, m, d, time), @schedulefile) | |
672 end | |
673 def mkdir_p(path, mode=0777) | |
674 # Do not mkdir `path' for | |
675 # absolute paths | |
676 # those paths which contains `../' | |
677 # for the sake of security reason | |
678 return false if %r,\.\./|^/, =~ path | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
679 path = path.untaint |
0 | 680 p = 0 |
681 i=0 | |
682 while p=path.index("/", p) | |
683 dir = path[0..p].chop | |
684 p += 1 | |
685 break if i > 10 # overprotecting | |
686 next if test(?d, dir) | |
687 Dir.mkdir(dir, mode) | |
688 i += 1 | |
689 end | |
690 Dir.mkdir(path, mode) unless test(?d, path) | |
691 end | |
692 | |
693 # | |
694 # register schedule for user | |
695 # | |
696 def register(user, year, month, day, time, text, replace=nil) | |
697 # return code: 0 = succesfull new registration | |
698 # 1 = succesfull appending registration | |
699 dir = scheduledir(user, year, month, day, time) | |
700 file = schedulefile(user, year, month, day, time) | |
701 ret = 0 | |
702 um = File.umask(027) | |
703 begin | |
704 if !replace && test(?s, file) | |
705 ret = 1 | |
706 else | |
707 mkdir_p(dir, 0777) | |
708 end | |
709 ensure | |
710 File.umask(um) | |
711 end | |
712 open(file, replace ? "w" : "a"){|out|out.print text} | |
713 return ret | |
714 end | |
715 def getschedule(user, year, month, day, time) | |
716 file = schedulefile(user, year, month, day, time) | |
717 if test(?r, file) && test(?s, file) | |
17 | 718 return IO.readlines(file).join.toeuc |
0 | 719 end |
720 return nil | |
721 end | |
722 def remove(user, year, month, day, time) | |
723 file = schedulefile(user, year, month, day, time) | |
724 dir = File.dirname(file) | |
725 if test(?r, file) && test(?s, file) | |
726 File.unlink(file) | |
727 end | |
728 for f in Dir.glob(File.join(dir, "*")) | |
729 f.untaint | |
730 File.unlink(f) | |
731 end | |
732 Dir.rmdir(dir) if test(?d, dir) | |
733 begin | |
734 Dir.rmdir(File.dirname(dir)) | |
735 rescue | |
736 end | |
737 end | |
738 # | |
739 # register file | |
740 # | |
741 def putfile(user, year, month, day, time, file, contents) | |
742 scback = @schedulefile | |
743 begin | |
744 @schedulefile = File.basename(file) | |
745 register(user, year, month, day, time, contents, true) | |
746 ensure | |
747 @schedulefile = scback | |
748 end | |
749 end | |
750 def getfile(user, year, month, day, time, file) | |
751 scback = @schedulefile | |
752 begin | |
753 @schedulefile = File.basename(file) | |
754 getschedule(user, year, month, day, time) | |
755 ensure | |
756 @schedulefile = scback | |
757 end | |
758 end | |
759 def removefile(user, year, month, day, time, file) | |
760 dir = scheduledir(user, year, month, day, time) | |
761 file = File.join(dir, file) | |
762 if test(?e, file) | |
763 File.unlink(file) | |
764 end | |
765 end | |
766 # | |
767 # registration to crondir | |
768 # | |
769 def cronlink_file(nt_time, user, y, m, d, time) | |
770 subdir = nt_time.strftime("%Y-%m-%d-%H%M/#{user}") | |
771 cdir = File.join(@crondir, subdir) | |
772 File.join(cdir, sprintf("%04d-%02d-%02d-%04d", y, m, d, time)) | |
773 end | |
774 def register_crondir(nt_time, user, y, m, d, time) | |
775 linkfile = cronlink_file(nt_time, user, y, m, d, time) | |
776 mkdir_p(File.dirname(linkfile)) | |
777 scfile = schedulefile(user, y, m, d, time) | |
778 if test(?s, scfile) | |
779 sclink = File.join("../../..", scfile.sub!(Regexp.quote(@dir+'/'), '')) | |
780 File.symlink(sclink, linkfile) unless test(?e, linkfile) | |
781 return linkfile | |
782 end | |
783 return false | |
784 end | |
785 def remove_crondir(nt_time, user, y, m, d, time) | |
786 linkfile = cronlink_file(nt_time, user, y, m, d, time) | |
787 scfile = schedulefile(user, y, m, d, time) | |
788 if test(?e, linkfile) | |
789 File.unlink(linkfile) | |
790 begin | |
791 dir = linkfile | |
792 2.times {|x| | |
793 dir = File.dirname(dir) | |
794 if Dir.open(dir).collect.length <= 2 # is empty dir | |
795 Dir.rmdir(dir) | |
796 else | |
797 break | |
798 end | |
799 } | |
800 rescue | |
801 end | |
802 return linkfile | |
803 end | |
804 return false | |
805 end | |
806 | |
807 # | |
808 # return the Hash of crondir {user => files} | |
809 def notify_list(asof) | |
810 slack = 5*60 | |
811 gomifiles = [] | |
812 ntl = {} | |
813 return ntl unless test(?d, @crondir) | |
814 Dir.foreach(@crondir){|datedir| | |
2 | 815 next unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ datedir |
10 | 816 ##datedir = sprintf("%04d-%02d-%02d-%04d", |
817 ## $1.to_i, $2.to_i, $3.to_i, $4.to_i) | |
818 datedir.untaint | |
0 | 819 dd = File.join(@crondir, datedir) |
820 next unless test(?d, dd) | |
821 y, m, d, hm = $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
822 hh = hm/100 % 60 | |
823 mm = (hm%100) % 60 | |
824 t = Time.mktime(y, m, d, hh, mm) | |
825 next if t-slack > asof | |
826 # | |
827 # collect them | |
828 Dir.foreach(dd){|user| | |
2 | 829 # next unless /@/ =~ user || isgroup(user) |
830 next if /^\./ =~ user | |
831 if isgroup(user) | |
832 user = @groupmap.keys.grep(user)[0] | |
833 else | |
834 user = @usermap.keys.grep(user)[0] | |
835 end | |
836 next unless user | |
72
6a0c2f85faa3
Canonicalize arguments for isHoliday(), which will be sent to Time.mktime().
HIROSE Yuuji <yuuji@gentei.org>
parents:
71
diff
changeset
|
837 ud = File.join(dd, user).untaint |
0 | 838 next unless test(?d, ud) |
78 | 839 ntl[user] = {} unless ntl.has_key?(user) |
0 | 840 Dir.foreach(ud){|date| |
841 next if /^\./ =~ date | |
842 unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ date | |
843 gomifiles << File.join(ud, date) | |
844 next | |
845 end | |
13 | 846 #date = sprintf("%04d-%02d-%02d-%04d", |
847 # $1.to_i, $2.to_i, $3.to_i, $4.to_i) | |
848 date.untaint | |
0 | 849 f = File.join(ud, date) |
850 if test(?s, f) | |
851 ntl[user][date] = {} | |
852 ntl[user][date]['file'] = f | |
33 | 853 ntl[user][date]['text'] = |
854 IO.readlines(f).collect{|l| l.toeuc} # ...why? :-( | |
0 | 855 else |
856 File.unlink(f) # symlink points to nonexistent file | |
857 end | |
858 } | |
859 if ntl[user].empty? | |
860 # if ud does not contain valid cron symlinks, | |
861 # ud had been left badly. Remove it. | |
862 ntl.delete(user) | |
863 cleanup_files(gomifiles) | |
864 end | |
865 } | |
866 } | |
867 ntl | |
868 end | |
869 # | |
870 # cleanup file and directories | |
871 def cleanup_crondir(time) | |
872 Dir.foreach(@crnondir){|datedir| | |
873 dd = File.join(@crondir, datedir) | |
874 next unless test(?d, dd) | |
875 next unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ dd | |
876 y, m, d, hm = $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
877 hh = hm/100 % 60 | |
878 mm = (hm%100) % 60 | |
879 t = Time.mktime(y, m, d, hh, mm) | |
880 if t < time | |
881 system "rm -rf #{dd}" | |
882 end | |
883 } | |
884 end | |
885 # | |
886 # remove files in FILES, and remove parent directory if possible | |
887 def cleanup_files(files) | |
888 sentinel = File.stat(@dir).ino | |
16 | 889 me = $0.dup.untaint |
890 scriptsuid = File.stat(me).uid | |
0 | 891 for f in files |
2 | 892 if $SAFE > 0 |
893 f.untaint | |
894 if test(?e, f) && File.stat(f).uid != scriptsuid | |
895 f.taint | |
896 end | |
897 end | |
898 printf "Removing %s\n", f if $DEBUG | |
0 | 899 File.unlink(f) if test(?e, f) |
900 d = f | |
901 loop { | |
902 d = File.dirname(d) | |
903 break if d.length < 2 | |
904 break if File.stat(d).ino == sentinel | |
905 begin | |
906 puts "rmdir #{d}" if $DEBUG | |
907 Dir.rmdir(d) | |
908 rescue | |
909 break | |
910 end | |
911 } | |
912 end | |
913 end | |
914 end | |
915 | |
916 class StringIO<IO | |
917 def initialize() | |
918 @str="" | |
919 end | |
920 def foo=(str) | |
921 @str = str | |
922 end | |
2 | 923 def append(str) |
924 @str = str+@str | |
925 end | |
0 | 926 def print(str) |
927 @str << str | |
928 end | |
929 def puts(str) | |
930 @str << str+"\n" | |
931 end | |
932 def printf(*args) | |
933 @str << sprintf(*args) | |
934 end | |
935 def write(bytes) | |
936 print(bytes) | |
937 end | |
938 def gets() | |
939 return nil if @str == '' | |
940 p = @str.index(?\n) | |
941 if p | |
942 r = @str[0..p] | |
943 @str=@str[p+1..-1] | |
944 else | |
945 r = @str | |
946 end | |
947 return r | |
948 end | |
949 def readline() | |
950 this.gets() | |
951 end | |
952 def readlines() | |
953 r = @str | |
954 @str='' | |
955 r | |
956 end | |
957 | |
958 def p(*obj) | |
959 STDOUT.p(*obj) | |
960 end | |
961 end | |
962 | |
963 class CMDTimeout < Exception | |
964 def initialize() | |
965 @pw = IO.pipe | |
966 @pr = IO.pipe | |
967 @pe = IO.pipe | |
968 @timeout = false | |
969 end | |
970 def start(cmd, timeout, mixstderr=false) | |
971 if @pid=fork | |
972 @pw[0].close | |
973 @pr[1].close | |
974 @pe[1].close | |
975 # puts "parent!" | |
976 if @tk=fork | |
977 # main | |
978 else | |
979 @pw[1].close | |
980 @pr[0].close | |
981 @pe[0].close | |
982 trap(:INT){exit 0} | |
983 sleep timeout | |
984 begin | |
985 @timeout = true | |
986 STDERR.puts "TIMEOUT" | |
987 Process.kill :INT, @pid | |
988 rescue | |
989 #puts "Already done" | |
990 end | |
991 exit 0 | |
992 end | |
993 else | |
994 # Running this block with pid=@pid | |
995 trap(:INT){@timeout = true; exit 0} | |
996 @pw[1].close | |
997 STDIN.reopen(@pw[0]) | |
998 @pw[0].close | |
999 | |
1000 @pr[0].close | |
1001 STDOUT.reopen(@pr[1]) | |
1002 if mixstderr | |
1003 STDERR.reopen(@pr[1]) | |
1004 else | |
1005 STDERR.reopen(@pe[1]) | |
1006 end | |
1007 @pr[1].close | |
1008 @pe[0].close | |
1009 @pe[1].close | |
1010 | |
15 | 1011 exec(*cmd) |
0 | 1012 exit 0 |
1013 end | |
1014 return [@pw[1], @pr[0], @pe[0]] | |
1015 end | |
1016 def wait() | |
1017 Process.waitpid(@pid, nil) | |
1018 end | |
1019 def close() | |
1020 @pr.each{|p| p.close unless p.closed?} | |
1021 @pw.each{|p| p.close unless p.closed?} | |
1022 @pe.each{|p| p.close unless p.closed?} | |
1023 begin | |
1024 Process.kill :INT, @tk | |
1025 rescue | |
1026 end | |
1027 end | |
1028 def timeout() | |
1029 @timeout | |
1030 end | |
1031 end | |
1032 | |
1033 class Holiday | |
1034 def initialize(dir = ".") | |
1035 @@dir = dir | |
1036 defined?(@@holiday) || setupHoliday | |
1037 end | |
1038 def setupHoliday(file = "holiday") | |
1039 @@holiday = {} | |
1040 return unless test(?f, file) && test(?s, file) | |
1041 IO.foreach(file){|line| | |
17 | 1042 line = line.toeuc.strip |
0 | 1043 next if /^#/ =~ line |
1044 date, what = line.scan(/(\S+)\s+(.*)/)[0] | |
1045 if %r,(\d+)/(\d+)/(\d+), =~ date | |
1046 cdate = sprintf("%d/%d/%d", $1.to_i, $2.to_i, $3.to_i) | |
1047 @@holiday[cdate] || @@holiday[cdate] = [] | |
1048 @@holiday[cdate] << what | |
1049 elsif %r,(\d+)/(\d+), =~ date | |
1050 cdate = sprintf("%d/%d", $1.to_i, $2.to_i) | |
1051 @@holiday[cdate] || @@holiday[cdate] = [] | |
1052 @@holiday[cdate] << what | |
1053 elsif %r,(\d+)/(\w+), =~ date | |
1054 cdate = sprintf("%d/%s", $1.to_i, $2.downcase) | |
1055 @@holiday[cdate] || @@holiday[cdate] = [] | |
1056 @@holiday[cdate] << what | |
1057 end | |
1058 } | |
1059 end | |
1060 def isHoliday(y, m, d, wday=nil) | |
1061 y, m, d = y.to_i, m.to_i, d.to_i | |
1062 wname = %w[sun mon tue wed thu fri sat] | |
35 | 1063 wday = wname[wday || Time.mktime(y, m, d).wday] |
0 | 1064 holiday = @@holiday[sprintf("%d/%d/%d", y, m, d)] || |
1065 @@holiday[sprintf("%d/%d", m, d)] | |
1066 unless holiday | |
1067 nthweek = (d-1)/7+1 | |
1068 holiday = @@holiday[sprintf("%d/w%d%s", m, nthweek, wday)] | |
1069 end | |
35 | 1070 if !holiday && wday == "mon" && d > 0 # d<1 when column is before 1th |
1071 # holiday in lieu | |
1072 yesterday = Time.mktime(y, m, d)-3600*24 | |
1073 holiday = ["振替休日"] if | |
1074 isHoliday(yesterday.year, yesterday.mon, yesterday.day) | |
1075 end | |
0 | 1076 holiday |
1077 end | |
1078 def holidays() | |
1079 @@holiday | |
1080 end | |
1081 end | |
1082 | |
1083 class After5 | |
1084 def initialize() | |
1085 @me = File.expand_path($0) | |
1086 @mydir, @myname = File.dirname(@me), File.basename(@me) | |
1 | 1087 @mybase = @myname.sub(/\.\w+$/, '') |
0 | 1088 @mydir.untaint |
1 | 1089 @mybase.untaint |
0 | 1090 Dir.chdir @mydir |
1 | 1091 @myname='a5.cgi' if test(?f, "a5.cgi") |
0 | 1092 @conf = nil |
1093 @schedulearea = {'rows'=>'4', 'cols'=>'60', 'name'=>'schedule'} | |
1094 @oldagent = (%r,Mozilla/4, =~ ENV['HTTP_USER_AGENT']) | |
2 | 1095 @lang = 0 |
14 | 1096 @mailmode = nil |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1097 @mailadmdelimiter = "/" |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1098 @mailadmsuffix = @mailadmdelimiter + "adm" |
7 | 1099 @saveprefsregexp = /^(display(mode|days)$|nt|headline)/ |
0 | 1100 @opt = { |
1101 'conf' => @mybase+".cf", | |
1102 'css' => @mybase+".css", | |
13 | 1103 'logfile' => 's/'+@mybase+".log", |
0 | 1104 "sendmail" => "/usr/sbin/sendmail", |
1105 'hostcmd' => '/usr/bin/host', | |
1106 'nslookup' => '/usr/sbin/nsookup', | |
1107 'bg' => 'ivory', | |
8 | 1108 'name' => nil, |
0 | 1109 'at_bsd' => '%H:%M %b %d %Y', |
1110 'at_solaris' => '%H:%M %b %d,%Y', | |
1111 'schedir' => 's', | |
1112 'tdskip' => '<br>', | |
1113 'forgot' => 'wasureta', | |
1114 'size' => @oldagent ? '15' : '40', | |
1115 'morning' => '6', | |
1116 'night' => '22', | |
1117 'alldaydir' => '3000', | |
1118 'pswdlen' => 4, | |
6 | 1119 'pswddb' => 's/a5pswd', |
2 | 1120 'lang' => 'j', |
6 | 1121 'notifymail' => true, |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1122 'mailbracket' => '[%n-ML]', |
0 | 1123 } |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1124 @subjtags = [['[GroupID:#]', "[%i:%c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1125 ['[GroupID:#####]', "[%i:%5c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1126 ['[GroupName:#]', "[%n:%c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1127 ['[GroupName:#####]', "[%n:%5c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1128 ['(GroupID:#)', "(%i:%c)"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1129 ['(GroupID:#####)', "(%i:%5c)"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1130 ['(GroupName:#)', "(%n:%c)"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1131 ['(GroupName:#####)', "(%n:%5c)"]] |
0 | 1132 ##@job = "today" |
3 | 1133 @wnames = %w[sun mon tue wed thu fri sat] |
0 | 1134 @job = "login" |
1135 @sc = ScheduleDir.new | |
1136 @O = StringIO.new | |
1137 @H = HTMLout.new() | |
1138 @umback = File.umask | |
1139 @author = 'yuuji@gentei.org' | |
1140 @after5url = 'http://www.gentei.org/~yuuji/software/after5/' | |
1141 File.umask(007) | |
1142 end | |
1143 def doit() | |
1144 @params = getarg() | |
1145 @cookie = getcookie() | |
3 | 1146 importcookie() |
2 | 1147 @lang = (/^j/i =~ @opt['lang'] ? 0 : 1) |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1148 @ntlist = [ # this shoud be set after @lang |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1149 ['nt10m', "10"+msg('minutes', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1150 ['nt30m', "30"+msg('minutes', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1151 ['nt60m', "60"+msg('minutes', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1152 ['nttoday', msg('theday')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1153 ['nt1d', "1"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1154 ['nt2d', "2"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1155 ['nt3d', "3"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1156 ['nt7d', "7"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1157 ['nt30d', "30"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1158 ] |
0 | 1159 p @cookie if $DEBUG |
1160 p @params if $DEBUG | |
1161 | |
3 | 1162 ### @params['displaymode'] = @params['displaymode'] || @cookie['displaymode'] |
2 | 1163 personal = /personal/i =~ @params['displaymode'] |
1164 bodyclass = if personal then {'class'=>'personal'} end | |
0 | 1165 |
1166 ## x = {"align"=>'center'} | |
1167 ## @H.element("p", x, "hoge", nil) | |
1168 ## @H.element("p", nil, "buha", nil) | |
1169 | |
3 | 1170 if nil |
0 | 1171 if !@params['passwd'] && @cookie['passwd'] |
1172 @params['passwd'] = @cookie['passwd'] | |
1173 end | |
1174 if !@params['user'] && @cookie['user'] | |
1175 @params['user'] = @cookie['user'] | |
1176 end | |
3 | 1177 end |
0 | 1178 @params['user'] = safecopy(@params['user']) |
2 | 1179 |
15 | 1180 ######eval @job |
8 | 1181 a5name = if @opt['name'] && @opt['name'] > '' |
1182 sprintf("(%s)", @opt['name']) | |
1183 else | |
1184 "" | |
1185 end | |
2 | 1186 @O.append(@H.contenttype() + |
8 | 1187 @H.head(a5name+"After 5"+@job.sub(/\s*/, ' '), @opt['css'])) |
2 | 1188 @O.print @H.startelement("body", bodyclass, true) |
15 | 1189 # @job should be here because its output shoud go after <body>. |
1190 eval @job | |
0 | 1191 @O.print @H.endelement(nil, true) # body |
14 | 1192 @O.print @H.endelement("html", true) # html |
0 | 1193 setcookie() |
1194 | |
1195 print @O.readlines | |
1196 end | |
1197 def msg(*keyword) | |
1198 unless defined?(@msg) | |
1199 @msg = { | |
3 | 1200 'title' => ['みんなの予定表 <img src="after5.png" alt="「アフター5」">', 'Schedule table for us all <img src="after5.png" alt="After 5">'], |
0 | 1201 'login' => ['ログイン', 'Login'], |
1202 'loginfirst' => ['最初にログインすべし', 'Login first'], | |
1203 'autherror' => ['認証エラーがあったと管理者に伝えてくれっす', | |
1204 'Unexpected authentication error. Please tell this to the administrator'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1205 'yourmail' => ['あなたのメイルアドレス', 'Your email address'], |
0 | 1206 'passwd' => ['パスワード<br>(初回時は空欄)', |
1207 'Passowrd<br>Left blank, first time'], | |
1208 'error' => ['エラー:', 'Error: '], | |
1209 'mailerror' => ['メイルアドレスが違います', 'Invalid email address'], | |
1210 'pswderror' => ['パスワードが違います', 'Password incorrect'], | |
22
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
1211 'forgotguide' => ['忘れた場合は %s と入力するよろし', |
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
1212 "Put \`%s' when you forgot password."], |
8 | 1213 'fmtdaysschedule'=> ['%s〜の予定', 'Schedule from %s'], |
18 | 1214 'schedtable' => ['予定表', 'Schedule Table'], |
0 | 1215 'noplan' => ['登録されている予定はありません', 'No plans'], |
1216 'allday' => ['全日', 'whole day'], | |
1217 'addsched' => ['新規予定項目の登録', 'Register new schedule'], | |
1218 'defthisday' => ['デフォルトの日付はこの日になってま', ''], | |
1219 '24hour' => ['24時間制4桁でね<br>(0000〜2359)<br>%sは時刻指定なし', 'in 24-hour<br>(0000-2359)<br>%s for whole day'], | |
14 | 1220 '24hourtxt' => ['24時間制4桁でね(0000〜2359), %sは時刻指定なし', 'in 24-hour(0000-2359), %s for whole day'], |
0 | 1221 'reqnotify' => ['通知メイルいるけ?', 'Previous notification'], |
1222 'rightnow' => ['登録時にすぐ', 'Right now on registration'], | |
1223 'immediatenote' => ['に以下の予定を登録しました', | |
1224 ", Your schedule has been registered as follows;"], | |
1225 'registerer_is' => ['登録名義: ', 'Register as '], | |
1226 'registerer' => ['登録者: ', 'registerer: '], | |
1227 'about' => ['約', 'about'], | |
1228 'minutes' => ['分', 'minutes'], | |
1229 'hours' => ['時間', 'hour(s)'], | |
1230 'days' => ['日', 'day(s)'], | |
2 | 1231 'daystodisplay' => ['日分表示', 'days to display'], |
0 | 1232 'before' => ['前', 'before'], |
2 | 1233 'precedingday' => ['前日', 'Preceding day'], |
0 | 1234 'theday' => ['当日朝', "the day's morning"], |
1235 'night' => ['(夜)', '(night)'], | |
63
e2aa6180c2c6
Show the number of group member in groupman().
HIROSE Yuuji <yuuji@gentei.org>
parents:
62
diff
changeset
|
1236 'publicok' => ['アカウント保持者全員<br>に見せてもええね?', |
e2aa6180c2c6
Show the number of group member in groupman().
HIROSE Yuuji <yuuji@gentei.org>
parents:
62
diff
changeset
|
1237 'visible to anyone who has account of this board?'], |
0 | 1238 'public' => ['公', 'pub'], |
1239 'nonpublic' => ['非', 'sec'], | |
2 | 1240 'through' => ['〜', '=>'], |
0 | 1241 'yes' => ['はいな', 'yes'], |
29
e7a01e561e28
Message 'no' should contain only 'no'.
HIROSE Yuuji <yuuji@gentei.org>
parents:
28
diff
changeset
|
1242 'no' => ['やだ', 'nope'], |
2 | 1243 'wnames' => [%w[日 月 火 水 木 金 土], |
1244 %w[sun mon tue wed thu fri sat]], | |
1245 'whichday' => ['<small>(まとめ登録の場合)</small><br>期間中のどの日に?', | |
1246 '<small>(On multiple registration)</small><br>Which days in the term?'], | |
1247 'singleday' => ['一日分だけ登録', '1day regist'], | |
1248 'everyday' => ['毎日', 'everyday'], | |
0 | 1249 'invaliddate' => ['日付指定が変みたい', 'Invalid time string'], |
1250 'past' => ['それはもう過去の話ね', 'It had Pasted'], | |
1251 'putsomething' => ['何か書こうや', 'Write some message please'], | |
1252 'appended' => ['既存の予定に追加しました', 'Appended'], | |
1253 'append' => ['追加', 'append'], | |
1254 'join' => ['参加', 'join'], | |
1255 'regist' => ['登録', 'register'], | |
1256 'remove' => ['削除', 'remove'], | |
14 | 1257 'move' => ['移動', 'move'], |
1258 'newdate' => ['移動先時刻', 'New date'], | |
0 | 1259 'deletion' => ['完全消去', 'deletion'], |
1260 'deletionwarn' => ['OK押したら即消去。確認とらないぞ', | |
1261 'Hitting OK immediately delets this group, be carefully!'], | |
1262 'deluser' => ['%s ユーザ消してええかの?', "Delete the user `%s'"], | |
1263 'delgroup' => ['%s グループ消してええかの?', "Delete the group `%s'"], | |
1264 'really?' => ['ほんまにええけ?', 'Really?'], | |
1265 'chicken' => ['ふっ、腰抜けめ', 'Hey, chicken boy'], | |
1266 'modify' => ['修正', 'modify'], | |
1267 'done' => ['完了', 'done'], | |
1268 'success' => ['成功', 'success'], | |
1269 'failure' => ['失敗', 'failure'], | |
1270 'tomonthlist' => ['%s の一覧', 'all %s table'], | |
1271 'notifysubj' => @mybase+"'s reminder for your plan", | |
1272 'introduce' => ['はいこんにちは、'+@mybase+'ですよ〜。', | |
1273 "Hi, this is #{@mybase}'s notification."], | |
1274 'notifymail' => ['こんな予定がありまっせ。', | |
1275 "You have some eschedule below;"], | |
1276 'notification' => ['の通知', 'notification'], | |
1277 'newaccount' => ["新しいアカウントを作りました。\n"+ | |
1278 "パスワードは %s さん宛に送信しておきました。\n", | |
1279 "You got new account for #{@mybase}\n" + | |
1280 "Password was sent to %s.\nThank you.\n"], | |
1281 'accessfrom' => ["%s からのアクセスによる送信\n", | |
1282 "This mail was sent by the access from %s\n"], | |
1283 'newpassword' => ["%s さんのパスワードは %s です。\n", | |
1284 "The password of %s is %s\n"], | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1285 'mischief' => ["身に覚えのない場合はMLへの代理登録の可能性があります。 |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1286 上記URLが見慣れたものならばアクセスしてみるか、 |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1287 このURLの管理人(%s さん)に問い合わせてみて下さい。 |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1288 それらも心当たりのない場合はいたずらです。対処しますので管理人まで御連絡下さい。", |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1289 'If you have no idea of the reason for getting this message, '+ |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1290 'it may be a invitation of mailing list from your friend. |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1291 Please try to access URL above if it is familiar one or |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1292 contact to the administrator of the site(is %s). |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1293 If you have completely no clue for this invitation, |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1294 it might be a mischief by someone else. Please notice the fact |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1295 to the administrator. Thank you.'], |
0 | 1296 'user' => ['ユーザ', 'user'], |
1297 'group' => ['グループ', 'group'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1298 'mladdress' => ['公開MLアドレス(%s以外にしたい場合設定する)', |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1299 "Public ML address(if you set to diffrent address than `%s')"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1300 'fromhack' => ['ML配送時のFrom:を常にMLのアドレスにする |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1301 (From:にしか返さないケータイ参加者が多いときにオススメ)', |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1302 'Set From: address of all ML messages to ML address, which is convenient |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1303 to keep responses from cellular phones surely to ML address. Most cellular |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1304 phones tend to return only from: address.'], |
66 | 1305 'inviteonly' => ['管理者のみ加入操作可能', |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1306 'Only administrators can add new members.'], |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1307 'invite-error' => ['%s への加入はグループ管理者のみが操作できます。', |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1308 "Only administrator of this group(`%s') can add you."], |
69
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
1309 'limitsender' => ['アカウント保持者のみ送信可能', |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
1310 'Allow only account holders to post to ML'], |
0 | 1311 'personal' => ['個人で', 'personal'], |
17 | 1312 'registas' => ['グループ予定として登録?', 'Register as group?'], |
1313 'headsched' => ['下の枠内に予定を記入: 1行以内で短めに。 | |
1314 長くなるときは2行目以降に詳細を。', | |
1315 'Put shortest sentence as possible within 1 line. | |
1316 Or, put short subject in the first line, details in latter lines.'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1317 'joinquit' => ['入退会', 'joining/quiting'], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1318 'operation' => ['操作', 'operation'], |
0 | 1319 'of' => ['の', "'s"], |
47 | 1320 'id' => ['ID(英単語かローマ字の分かりやすい1単語半角空白なしで)', 'ID(without spaces)'], |
0 | 1321 'name' => ['名前', 'name'], |
1322 'anystring' => ['(日本語OK)', '(any length, any characters)'], | |
1323 'setto' => ['を設定 → ', 'set to '], | |
2 | 1324 'dupname' => ['あー、%sってグループ名は既にあるん素。別のにして.', |
1325 "Group name `%s' already exists, choose another name."], | |
0 | 1326 'management' => ['管理', 'management'], |
1327 'administrator' => ['管理者', 'Administrator'], | |
1328 'newgroup' => ['新規グループ作成', 'Create new group'], | |
1329 'adminop' => ['管理<br>操作', "Administrative<br>operation"], | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1330 'sendall' => ['一斉送信', "write to members"], |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1331 'sendall_err' => ["%s ファイルで mailprefix と maildomain を定義しとかないと送れまへん。 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1332 例: mailprefix=yuuji-after5 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1333 maildomain=gentei.org |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1334 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1335 さらに、.qmail-$mailprefix-default も以下のように用意しておこね。 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1336 | ./#{@myname} -list", |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1337 "You should define `mailprefix' and `maildomain' in %s file before |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1338 sending message to all. |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1339 (ex.) mailprefix=yuuji-after5 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1340 maildomain=gentei.org |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1341 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1342 And then prepare .qmail-$mailprefix-default file as below. |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1343 | ./#{@myname} -list"], |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1344 'sendall_head' => ['「%s」宛のメイル送信', "Send message to `%s'"], |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1345 'sendall_note' => ['メンバーへの連絡だけでなく、グループ非加入者がこれから加入する旨の通知などにも有用。', |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1346 "Send this message to all of group."], |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1347 'sendall_done' => ['送信完了', "sending message done"], |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1348 'body' => ['本文', 'Body'], |
0 | 1349 'member' => ['メンバー', 'Member'], |
2 | 1350 'personalmode' => ['自分のだけ表示モード', 'Display Personal Only'], |
1351 'normalmode' => ['全員分表示モード', "Display Everyone's"], | |
3 | 1352 'display' => ['予定表示行: ', 'Display schedule of: '], |
1353 'nameonly' => ['名前のみ', 'Name Only'], | |
1354 'head5char' => ['先頭5文字', 'Head 5 chars'], | |
1355 'headline' => ['先頭1行', 'Headline only'], | |
1356 'whole' => ['長くても全部', 'Whole text'], | |
6 | 1357 'hldays' => ['最新X日分強調', 'Hilight Recent X-days'], |
0 | 1358 'addedtogroup' => ['をグループに追加 →', 'added to the group:'], |
1359 'removedfromgp' => ['をグループから削除:', 'removed from the group:'], | |
1360 'soleadmin' => ['%s は %s の唯一の管理者なのでやめられないのだ', | |
1361 "%s is sole administrator of %s. Cannot retire."], | |
1362 'recursewarn' => ['個人では加入してないが、別の加入グループがこのグループに入っているので実質参加していることになっている。', | |
1363 'Though this member does not join to this group, it is assumed to be joining this group because other group where one joins is joined to this group.'], | |
1364 'regaddress' => ['登録アカウント名', 'Account id'], | |
1365 'existent' => ['既にあるんすよ → ', 'Already exists: '], | |
1366 'mailaddress' => ['通知送付先アドレス', 'Notification email address'], | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1367 'multipleok' => ['<br>(スペースで区切って複数指定可)', |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1368 '<br>(Two or more addresses are OK by delimiting with space.)'], |
0 | 1369 'weburl' => ['ゲストブックとかURL<br><small>(予定への反応を書いて欲しい場所)</small>', 'Your guest book URL'], |
1370 'usermodwarn' => ['いちいち yes/no とか確認取らないから押したら最後、気いつけて。', | |
1371 'This is the final decision. Make sure and sure.'], | |
1372 'joinmyself' => ['自分自身が既存のグループに対して入る(IN)か出る(OUT)かを決めるのがここ。自分管理のグループに誰かを足すなら「管理操作」、新たにグループを作るなら', | |
1373 'In this page, you can decide put yourself IN or OUT of the existing groups. If you want to manage the member of your own group, go to'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1374 'aboutgroup' => ['グループ %s の操作', "Operations on group `%s'"], |
0 | 1375 'groupwarn' => ['自分が参加してないグループAに、自分が参加しているグループBが含まれている場合、グループAにも加入していると見なされるので気をつけよう。管理者はグループのニックネームを変えられるよ。', |
1376 'Though you are not member of group A, you are treated as a member of A, if you join to the group B, which is a member of A. Think the nesting of groups carefully, please. Group administrator can change the group nickname.'], | |
1377 'wholemembers' => ['グループ内グループを考慮した上で、現在グループ %s への通知は以下のメンバーに送られる。', | |
1378 "Consiering the groups registered in another group, notification to the group `%s' is send to members as follows."], | |
1379 'noadmingroup' => ['管理できるグループはないっす', | |
1380 "'There's no groups under your administration."], | |
1381 'nickname' => ['ニックネーム', 'nickname'], | |
1382 'shortnameplz' => ['表が崩れるほど長すぎるニックネームは嫌われるよ。短めにね。', | |
1383 'Because nickname is displayed many times in table, shorter name is prefered.'], | |
1384 'nicknamenote' => ['ニックネームを消去するとデフォルト名になりんす.', | |
1385 'Default name is displayed if you remove nickname.'], | |
1386 'nothingtodo' => ['って何もやることあらへんかったで', | |
14 | 1387 'Nothing to do for this transaction.'], |
1388 'schedlist' => [' and %d days Schedule list', | |
1389 'から%d日間の予定一覧'], | |
1390 'nothing' => ['なんもないす', 'Nothing'], | |
1391 'sessionpswd' => ['セッションパスワード(これはいじらないでね)', | |
1392 'Session Password(Do not modify this)'], | |
1393 'date' => ['日付', 'Date'], | |
1394 'time' => ['時刻指定', 'Time'], | |
1395 'publicp' => ['公開=yes、非公開=no', 'Public?'], | |
1396 'neednotify' => ['通知メイル(要らないのは消してね)', | |
1397 'Leave lines for notification timing'], | |
1398 'schedulehere' => ['以下登録内容', 'Your Schedule below'] | |
0 | 1399 } |
1400 end | |
1401 keyword.collect{|k| | |
1402 if @msg[k].is_a?(Array) | |
2 | 1403 @msg[k][@lang] |
0 | 1404 elsif @msg[k].is_a?(String) |
1405 @msg[k] | |
1406 else | |
1407 '' | |
1408 end | |
2 | 1409 }.join(['', ' '][@lang]) |
0 | 1410 end |
1411 | |
3 | 1412 def importcookie() |
7 | 1413 @cookie.keys.grep(@saveprefsregexp){|v| |
3 | 1414 @params[v] = @params[v] || @cookie[v] |
1415 } | |
7 | 1416 for v in %w[user passwd] |
1417 @params[v] = @params[v] || @cookie[v] | |
1418 end | |
3 | 1419 end |
0 | 1420 def setcookie() |
7 | 1421 a = {} |
1422 a['user'] = @params['user'] if @params['user'] | |
1423 a['passwd'] = @params['passwd'] if @params['passwd'] | |
1424 ac = gencookie("value", a, 3600*6*1) | |
1425 printf "Set-Cookie: %s\n", ac if ac | |
0 | 1426 p = {} |
7 | 1427 @params.keys.grep(@saveprefsregexp){|v| |
6 | 1428 p[v] = @params[v].to_s.strip if @params[v] && @params[v] > '' |
0 | 1429 } |
7 | 1430 c = gencookie("prefs", p, 3600*24*7) |
1431 str = [ac, c].select{|x|x}.join("; ") | |
1432 # printf "Set-Cookie: %s\n", str if str>'' | |
0 | 1433 printf "Set-Cookie: %s\n", c if c |
1434 end | |
1435 | |
1436 def encode(string) # borrowed from cgi.rb | |
1437 string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do | |
1438 '%' + $1.unpack('H2' * $1.size).join('%').upcase | |
1439 end.tr(' ', '+') | |
1440 end | |
14 | 1441 def purify(string) |
1442 string.gsub(/[\040-\177]/) {encode($&)} | |
1443 end | |
0 | 1444 def decode!(string) |
1445 string.gsub!(/\+/, ' ') | |
1446 string.gsub!(/%(..)/){[$1.hex].pack("c")} | |
1447 end | |
14 | 1448 def decode(string) |
17 | 1449 string.gsub(/\+/, ' ').gsub(/%(..)/){[$1.hex].pack("c")} |
14 | 1450 end |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1451 def escape(string) |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1452 string.gsub(/&/n, '&').gsub(/\"/n, '"'). |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1453 gsub(/>/n, '>').gsub(/</n, '<') |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1454 end |
0 | 1455 |
7 | 1456 def gencookie(name, a, expire) |
0 | 1457 x = a.collect{|k, v| |
1458 sprintf("%s=%s", k, encode(v)) if v | |
1459 } | |
1460 x.delete(nil) | |
1461 return nil if x.empty? | |
1462 str = x.join('&') | |
1463 ex = (Time.new+expire).to_s | |
7 | 1464 sprintf "%s=%s; expires=%s", name, encode(str), ex |
0 | 1465 end |
1466 | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1467 def login(altaction = nil) |
0 | 1468 @O.print @H.elementln("h1", nil){msg('title')} |
1469 @O.print @H.elementln("h2", nil){msg('login')} | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1470 format = {'method'=>'POST', |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1471 'action'=> @myname+"?" +(altaction || "-today")} |
0 | 1472 @O.print @H.elementln("form", format){ |
1473 @H.elementln("table", nil){ | |
1474 @H.elementln("tr", nil){ | |
1475 @H.element("td", nil){msg('yourmail')} + \ | |
1476 @H.element("td", nil){ | |
1477 sprintf '<input type="text" size="%s" name="user">', @opt['size'] | |
1478 } | |
1479 } + \ | |
1480 @H.elementln("tr", nil){ | |
1481 @H.element("td", nil){msg('passwd')} + \ | |
1482 @H.element("td", nil){ | |
1483 sprintf '<input type="password" size="%s" name="passwd">', @opt['size'] | |
1484 } | |
1485 } | |
1486 } + '<input type="submit" value="LOGIN">' | |
1487 } | |
1488 @O.print footer2() | |
1489 end | |
1490 def open_pm() | |
1491 begin | |
1492 PasswdMgr.new(@opt['pswddb']) | |
1493 rescue | |
1494 STDERR.printf "Cannot open pswd file [%s]\n", @opt['pswddb'] | |
1495 STDERR.printf "euid=#{Process.euid}, uid=#{Process.uid}\n", @opt['pswddb'] | |
1496 nil | |
1497 end | |
1498 end | |
1499 def outputError(*msg) | |
1500 @O.print @H.p(msg('error')+sprintf(*msg)) | |
1501 end | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1502 def mailaddress(user, grp=nil) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1503 @sc.mailaddress(user, grp) |
0 | 1504 end |
1505 def webpage(user) | |
1506 @sc.getuserattr(user, "webpage") | |
1507 end | |
14 | 1508 def checkauth_mail() |
1509 return true # temporary | |
1510 end | |
0 | 1511 def checkauth() |
14 | 1512 if @mailmode && @params['sessionpw'] |
1513 return checkauth_mail | |
1514 end | |
1515 auth = catch(:auth) { | |
0 | 1516 unless @params['user'] |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1517 #outputError(@H.a(@myname, msg('loginfirst'))) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1518 login(@oldargv.join('+')) |
0 | 1519 throw :auth, nil |
1520 end | |
1521 unless pm=open_pm() | |
1522 outputError(msg('autherror')) | |
1523 throw :auth, nil | |
1524 end | |
1525 user, passwd = @params['user'], @params['passwd'] | |
1526 email = mailaddress(user) | |
1527 if !checkmail(user) | |
1528 outputError(msg('mailerror')) | |
1529 throw :auth, nil | |
1530 end | |
1531 if pm.userexist?(user) | |
1532 if pm.checkpasswd(user, passwd) | |
1533 throw :auth, true | |
1534 elsif passwd == @opt['forgot'] | |
1535 newp = pm.setnewpasswd(user, @opt['pswdlen']) | |
1536 sendMail(email, "#{@mybase} password", | |
1537 "(#{ENV['REMOTE_ADDR']} からのアクセスによる送信)\n" + | |
7 | 1538 @opt['url'] + "\n" + |
0 | 1539 "#{@mybase} 用の #{user} さんのパスワードは\n" + |
1540 (newp || "未定義") + "\nです。\n") | |
1541 @O.print @H.p("#{email} 宛に送信しておきました") | |
1542 throw :auth, nil | |
1543 else | |
1544 outputError(msg('pswderror')) | |
22
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
1545 @O.print @H.p(sprintf(msg('forgotguide'), @opt['forgot'])) |
0 | 1546 throw :auth, nil |
1547 end | |
7 | 1548 elsif passwd == '' |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1549 # Create new user from Web-UI |
0 | 1550 newp = pm.setnewpasswd(user, @opt['pswdlen']) |
1551 @sc.createuser(user, user) | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1552 putLog("New user [#{user}] created\n") |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1553 sendMail(@opt['maintainer'], "After5 New User", |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1554 sprintf("URL=%s\nREMOTE_ADDR=%s\nuser=%s", |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1555 @opt['url'], ENV['REMOTE_ADDR'], user)) |
0 | 1556 sendMail(email, "#{@mybase} new account", |
1557 sprintf(msg('accessfrom'), ENV['REMOTE_ADDR']) + | |
7 | 1558 sprintf(@opt['url']) + "\n" + |
0 | 1559 sprintf(msg('newpassword'), user, newp) + |
1560 sprintf(msg('mischief'))) | |
1561 @O.print @H.p(sprintf(msg('newaccount'), user)) | |
1562 @O.print @H.p(@H.a(@myname, msg('login'))) | |
1563 throw :auth, nil | |
7 | 1564 else |
1565 outputError(msg('pswderror')) | |
1566 throw :auth, nil | |
0 | 1567 end |
1568 } | |
1569 if auth | |
1570 return true | |
1571 else | |
1572 return false | |
1573 end | |
1574 end | |
1575 def safecopy(string) | |
1576 return nil unless string | |
1577 if $SAFE > 0 | |
1578 cpy='' | |
1579 string.split('').each{|c| | |
1580 cpy << c[0].chr if c[0] != ?` # ` | |
1581 } | |
28 | 1582 cpy.untaint |
0 | 1583 else |
1584 string | |
28 | 1585 end |
0 | 1586 end |
1587 def checkmail(mail) | |
1588 account, domain = mail.scan(/(.*)@(.*)/)[0] | |
1589 return false unless account != nil && domain != nil | |
17 | 1590 return false unless /^[-0-9a-z_.]+$/oi =~ domain.toeuc |
0 | 1591 domain = safecopy(domain) |
1592 require 'socket' | |
1593 begin | |
1594 TCPSocket.gethostbyname(domain) | |
1595 return true | |
1596 rescue | |
1597 if test(?x, @opt["hostcmd"]) | |
1598 open("| #{@opt['hostcmd']} -t mx #{domain}.", "r") {|ns| | |
1599 #p ns.readlines.grep(/\d,\s*mail exchanger/) | |
1600 return ! ns.readlines.grep(/is handled .*(by |=)\d+/).empty? | |
1601 } | |
1602 elsif test(?x, @opt["nslookup"]) | |
1603 open("| #{@opt['nslookup']} -type=mx #{domain}.", "r") {|ns| | |
1604 #p ns.readlines.grep(/\d,\s*mail exchanger/) | |
1605 return ! ns.readlines.grep(/\d,\s*mail exchanger/).empty? | |
1606 } | |
1607 end | |
1608 return false | |
1609 end | |
1610 end # checkmail | |
1611 | |
1612 # Logging | |
1613 # | |
1614 def putLog(msg) | |
1615 msg += "\n" unless /\n/ =~ msg | |
1616 open(@opt["logfile"], "a+") {|lp| | |
1617 lp.print Time.now.to_s + " " + msg | |
1618 } | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1619 msg |
0 | 1620 end |
1621 | |
1622 def sendnotify(whom, subj, body) | |
1623 users = users() | |
1624 if grepgroup(whom) | |
1625 recipients = @sc.members(whom) | |
1626 else | |
1627 recipients=[whom] | |
1628 end | |
1629 for u in recipients | |
1630 if users.grep(u)[0] | |
1631 sendMail(mailaddress(u), subj, body) | |
1632 end | |
1633 end | |
1634 end | |
1635 | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1636 def dospool(dir, outhandle) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1637 seq=1 |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1638 seqfile=File.expand_path("seq", dir).untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1639 spooldir=File.expand_path("spool", dir).untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1640 test(?d, spooldir) or Dir.mkdir(spooldir) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1641 if test(?s, seqfile) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1642 seq=open(seqfile, "r"){|s|s.gets.to_i} |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1643 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1644 seq+=1 while test(?s, (newfile=sprintf("%s/%d", spooldir, seq))) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1645 open(newfile, "w") do |spoolfile| |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1646 countdone = nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1647 while line=STDIN.gets |
76
53e747495502
Bug-fix: Regexp matching should be done in euc-jp.
HIROSE Yuuji <yuuji@gentei.org>
parents:
75
diff
changeset
|
1648 if !countdone && /^X-ML-Name: / =~ line.toeuc |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1649 line += sprintf("X-Mail-Count: %d\n", seq) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1650 coutndone=true |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1651 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1652 spoolfile.print line |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1653 outhandle.print line |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1654 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1655 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1656 open(seqfile, "w"){|s| s.puts seq.to_s} # update `seq' file |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1657 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1658 def mlseq(dir) |
65
3e91dd66deb6
Return 1 if /seq file is not there.
HIROSE Yuuji <yuuji@gentei.org>
parents:
64
diff
changeset
|
1659 test(?s, (seqfile = dir+"/seq")) ? |
3e91dd66deb6
Return 1 if /seq file is not there.
HIROSE Yuuji <yuuji@gentei.org>
parents:
64
diff
changeset
|
1660 open(seqfile, "r"){|s|s.gets.to_i+1} |
3e91dd66deb6
Return 1 if /seq file is not there.
HIROSE Yuuji <yuuji@gentei.org>
parents:
64
diff
changeset
|
1661 : 1 |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1662 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1663 def sendMail(to, subject, body, from=nil, rcptto=nil, header={}, |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1664 thru=nil, spoolto=false) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1665 body = NKF.nkf("-j", body) unless thru |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1666 subject = NKF.nkf("-jM", subject.strip) |
0 | 1667 to = safecopy(to) # cleanup tainted address |
1668 subject.gsub!(/\n/, '') | |
1669 begin | |
1670 if (m=open("|-", "w")) | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1671 header.each do |h, v| |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1672 m.printf("%s: %s\n", h.strip, v.strip) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1673 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1674 unless thru |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1675 m.print "To: #{to}\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1676 from and m.print "From: #{from}\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1677 m.print "Subject: #{subject}\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1678 m.puts "Mime-Version: 1.0 |
0 | 1679 Content-Transfer-Encoding: 7bit |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1680 Content-Type: Text/Plain; charset=iso-2022-jp" |
81 | 1681 m.puts "Date: #{Time.now.strftime("%a, %d %b %Y %T %z")}" |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1682 m.print "\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1683 end |
0 | 1684 m.print body, "\n" |
1685 m.close | |
1686 else | |
1687 # exec(@attr['mail'], "-s", subject, to) | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1688 recipient = rcptto || to.split(/,\s*|\s+/) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1689 #p recipient |
56 | 1690 File.umask(027) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1691 if spoolto && spoolto.is_a?(String) && |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1692 proc { |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1693 require 'fileutils' |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1694 begin |
67
a421c2fefc32
Fix the argument for FileUtils.mkdir_p()
HIROSE Yuuji <yuuji@gentei.org>
parents:
66
diff
changeset
|
1695 test(?d, spoolto) or FileUtils.mkdir_p(spoolto, :mode => 0750) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1696 test(?w, spoolto) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1697 rescue |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1698 nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1699 end}.call && |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1700 (tee=open("|-", "w")) # popen should be done in if-condition |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1701 dospool(spoolto, tee) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1702 else |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1703 if ENV['MAILCMD'] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1704 #exec("qmail-inject", "yuuji@gentei.org", "yuuji@koeki-u.ac.jp") |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1705 open("/tmp/body", "w") {|w| w.print STDIN.readlines.join |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1706 w.puts "---" |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1707 w.puts recipient.join(",\n") |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1708 } |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1709 exit 0 |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1710 else |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1711 #recipient.unshift "-f"+header['return-path'] if header['return-path'] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1712 exec(ENV['MAILCMD'] || @opt['sendmail'], *recipient) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1713 end |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1714 end |
0 | 1715 exit 0; |
1716 end | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1717 putLog("Sent '#{subject.toeuc}' to #{to}\n") |
0 | 1718 return true |
1719 rescue | |
1720 putLog("FAILED! - Sent '#{subject}' to #{to}\n") | |
1721 return nil | |
1722 end | |
1723 end # sendMail | |
1724 | |
1725 def today() | |
1726 today = Time.now | |
1727 showtable(today) | |
1728 end | |
1729 def isleap?(y) | |
1730 if y%400 == 0 | |
1731 true | |
1732 elsif y%100 == 0 || y%4 != 0 | |
1733 false | |
1734 else | |
1735 true | |
1736 end | |
1737 end | |
1738 def daysofmonth(year, month) | |
1739 dl = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
1740 if month != 2 || !isleap?(year) | |
1741 dl[month-1] | |
1742 else | |
1743 29 | |
1744 end | |
1745 end | |
1746 # | |
1747 # Return the Time object at the last day of last month | |
1748 def lastmonth(today) | |
1749 Time.at(Time.mktime(today.year, today.month)-3600*24) | |
1750 end | |
1751 # | |
1752 # Return the Time object at the first day of next month | |
1753 def nextmonth(today) | |
1754 y, m = today.year, today.month | |
1755 Time.at(Time.mktime(y, m, daysofmonth(y, m))+3600*24) | |
1756 end | |
1757 | |
1758 def month(month) | |
1759 y, m = month.scan(%r,(\d\d\d\d+)/(\d+),)[0] | |
1760 if y && m | |
1761 showtable(Time.mktime(y, m, 1)) | |
1762 else | |
1763 outputError "%s %s", msg('invaliddate'), month | |
1764 return nil | |
1765 end | |
1766 end | |
1767 def footer1() | |
1768 "<br>" + \ | |
1769 @H.element("p"){ | |
1770 me = @myname+"?-"; delim = " / " | |
1771 @H.a(me+'userman', msg('user', 'management')) + delim + \ | |
2 | 1772 @H.a(me+'groupman', msg('group', 'management')) + delim + \ |
1773 if /personal/i =~ @params['displaymode'] | |
1774 @H.a(me+'today_n', msg('normalmode')) | |
1775 else | |
1776 @H.a(me+'today_p', msg('personalmode')) | |
1777 end | |
0 | 1778 } |
1779 end | |
1780 | |
1781 def footer2() | |
1782 "<hr>" + \ | |
1783 @H.element("code") { | |
1784 "This " + \ | |
1785 @H.a(@after5url, "After5") + \ | |
1786 " board is maintained by " + \ | |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1787 @opt['maintainer'].gsub(".", "<span>.</span>"). |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1788 sub('@', "@") + \ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1789 '<span style="display: none;">.cut.here</span>' + \ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1790 "." |
0 | 1791 } |
1792 end | |
1793 def footer() | |
1794 footer1+footer2 | |
1795 end | |
1796 def nickname(userORgroup) | |
1797 if grepgroup(userORgroup) | |
1798 @sc.groupname(userORgroup) | |
1799 else | |
1800 @sc.nickname(userORgroup) | |
1801 end | |
1802 end | |
1803 # | |
1804 # show specified month's calendar | |
1805 def showtable(day) | |
1806 if !checkauth | |
1807 return nil | |
1808 end | |
17 | 1809 |
0 | 1810 month = day.month.to_s |
1811 first = Time.mktime(day.year, day.month, 1) | |
1812 last = daysofmonth(day.year, day.month) | |
1813 wday1 = first.wday | |
1814 start = 1-wday1 | |
3 | 1815 wname = @wnames |
0 | 1816 today = Time.now |
8 | 1817 todayy = today.year |
0 | 1818 todaym = today.month |
1819 todayd = today.day | |
1820 tdclass = {} | |
1821 tdclass["width"] = "64px" if @oldagent # workaround for NN4 | |
2 | 1822 personal = /personal/ =~ @params['displaymode'] |
3 | 1823 headline = @params['headline'] |
6 | 1824 headlinehl = @params['headlinehl'] |
1825 hldays = headlinehl.to_i * 3600*24 | |
1826 recent = {'class'=>'recent'} | |
3 | 1827 monthstr = sprintf "%d/%d", day.year, day.month |
1828 | |
0 | 1829 holiday = Holiday.new |
1830 # create dayofweek header | |
3 | 1831 @O.print @H.elementln("h1", nil){monthstr} |
2 | 1832 # which mode? |
1833 @O.print @H.p(msg(personal ? 'personalmode' : 'normalmode')) | |
1834 # | |
1835 # display table | |
0 | 1836 @O.print @H.startelement("table", {'border'=>"1", 'class'=>'main'}) |
1837 | |
1838 # day of week | |
1839 @O.print @H.startelement("tr") | |
1840 for w in wname | |
1841 @O.print @H.element("th", {'class'=>w}){w.capitalize} | |
1842 end | |
1843 @O.print "\n"+@H.endelement(nil, true) | |
1844 | |
1845 # create day table | |
1846 column = start | |
1847 ## p day, last | |
1848 while column <= last | |
1849 @O.print @H.elementln("tr", nil){ | |
1850 (column..column+6).collect{|d| | |
8 | 1851 todayp = (day.year==todayy && day.month==todaym && d==todayd) |
0 | 1852 wd=d-column |
75 | 1853 thisday = first+(d-1)*3600*24 |
72
6a0c2f85faa3
Canonicalize arguments for isHoliday(), which will be sent to Time.mktime().
HIROSE Yuuji <yuuji@gentei.org>
parents:
71
diff
changeset
|
1854 hd = holiday.isHoliday(thisday.year, thisday.month, thisday.day, wd) |
0 | 1855 tdclass['class'] = (hd ? 'holiday' : wname[wd]) |
1856 @H.element("td", tdclass){ | |
13 | 1857 if d>0 |
1858 #date = "%d/%d/%d"%[day.year, day.month, d] | |
1859 date = "%d/%d/%d"%[thisday.year, thisday.month, thisday.day] | |
0 | 1860 @H.element("p", {'class'=>todayp ? 'todayline' : 'dayline'}){ |
13 | 1861 ##@H.a(@myname+"?-show+"+date, "%4d"%d) |
1862 @H.a(@myname+"?-show+"+date, "%4d"%thisday.day) | |
0 | 1863 } + \ |
1864 # isHoliday? | |
1865 if hd | |
1866 @H.element("small"){hd.join("<br>")} | |
1867 end.to_s + \ | |
1868 @H.element("p", {'class'=>'topic'}){ | |
2 | 1869 s = @sc.day_all(date, @params['user'], personal) |
0 | 1870 if !s.empty? |
1871 s.keys.sort.collect{|time| | |
1872 s[time].keys.sort.collect{|who| | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1873 text = escape(s[time][who]['sched']) |
6 | 1874 topic = sprintf "%s%s", |
3 | 1875 time == @opt['alldaydir'] ? '' : time+":", |
2 | 1876 if personal |
9 | 1877 (@params['user'] == who ? "" : nickname(who)+"=") + |
7 | 1878 text ## .split("\n") ##[0] |
2 | 1879 else |
5 | 1880 nickname(who) + \ |
3 | 1881 if headline == 'whole' |
5 | 1882 '=' + text |
3 | 1883 elsif headline == 'head5char' |
5 | 1884 '=' + text.gsub(/\n/, '').sub(/(.{5}).*/, '\1') |
3 | 1885 elsif headline == 'headline' |
5 | 1886 '=' + text.split("\n")[0] |
3 | 1887 end.to_s |
2 | 1888 end |
6 | 1889 if hldays > 0 && |
1890 (today - s[time][who]['regtime']) < hldays | |
1891 topic = @H.element("span", recent){topic} | |
1892 end | |
1893 topic | |
3 | 1894 }.join("<br>") |
1895 }.join("<br>\n") | |
0 | 1896 else |
1897 @opt['tdskip'] | |
1898 end | |
1899 } | |
1900 else | |
1901 @opt['tdskip'] | |
1902 end | |
1903 } | |
1904 }.join | |
1905 } | |
1906 column += 7 | |
1907 end | |
1908 | |
1909 # month-link | |
1910 @O.print @H.elementln("tr", {'class'=>'monthlink'}){ | |
1911 lm1 = lastmonth(day) | |
1912 lm2 = lastmonth(lm1) | |
1913 lm3 = lastmonth(lm2) | |
1914 nm1 = nextmonth(day) | |
1915 nm2 = nextmonth(nm1) | |
1916 nm3 = nextmonth(nm2) | |
1917 [lm3, lm2, lm1, nil, nm1, nm2, nm3].collect{|t| | |
1918 @H.element("td"){ | |
1919 if t.is_a?(Time) | |
1920 ym = sprintf("%d/%d", t.year, t.month) | |
1921 @H.a(sprintf("%s?-month+%s", @myname, ym), ym) | |
1922 else | |
1923 sprintf "%d/%d", day.year, day.month | |
1924 end | |
1925 } | |
1926 }.join("\n") | |
1927 } | |
1928 @O.print "\n"+@H.endelement(nil, true) | |
1929 | |
1930 @O.print "showtable" if @params['user'] == @author | |
3 | 1931 @O.print @H.elementln("form", {'action'=>@myname+"?-month+#{monthstr}", 'method'=>'POST'}){ |
1932 choice = [ | |
1933 [msg('nameonly'), 'name'], | |
1934 [msg('head5char'), 'head5char'], | |
1935 [msg('headline'), 'headline'], | |
1936 [msg('whole'), 'whole']] | |
1937 msg('display') + \ | |
6 | 1938 @H.select('headline', choice, headline) + "/" + \ |
1939 msg('hldays') + \ | |
1940 @H.select('headlinehl', 0..30, headlinehl) + \ | |
3 | 1941 @H.submit("GO", "GO") |
1942 } | |
0 | 1943 @O.print footer |
1944 ##schedule.day_all("2003/12/22") | |
1945 # @O.print @H.endelement() | |
1946 end | |
1947 | |
1948 # | |
1949 # Put carrying values | |
1950 def hiddenvalues() | |
2 | 1951 h = %w[user displaymode].collect{|v| |
0 | 1952 if @params[v] |
1953 sprintf "<input type=\"hidden\" name=\"%s\" value=\"%s\">\n", | |
1954 v, @params[v] | |
1955 end | |
1956 } | |
1957 h.delete(nil) | |
1958 h.join | |
1959 end | |
2 | 1960 def date2ymd(date) |
1961 %r,(\d\d\d\d+)/(\d\d?)/(\d\d?), =~ date and | |
1962 [$1.to_i, $2.to_i, $3.to_i] | |
1963 end | |
0 | 1964 # |
1965 # Return the string of table | |
2 | 1966 def dayTableString(user, datestr, range, personal = nil) |
1967 #s = @sc.day_all(date, user, personal) | |
1968 #return '' if s.empty? | |
0 | 1969 r = '' |
2 | 1970 header = @H.startelement("table", {'border'=>'1'}, true) |
1971 | |
1972 day = Time.mktime(*date2ymd(datestr)) | |
1973 i = -1 | |
1974 while (i+=1) < range | |
1975 d = Time.at(day+i*3600*24) | |
1976 date = sprintf("%04d/%02d/%02d", d.year, d.month, d.day) | |
3 | 1977 datewn = @H.element("span", {'class'=>@wnames[d.wday]}){ |
1978 sprintf("%s(%s)", date, @msg['wnames'][@lang][d.wday]) | |
1979 } | |
2 | 1980 s = @sc.day_all(date, user, personal) |
1981 next if s.empty? | |
1982 | |
1983 r << @H.element("tr", nil){ | |
1984 @H.element("th", {'class'=>'time'}){'TIME'} + \ | |
3 | 1985 @H.element("th", nil){'Who - '+datewn+' - What'} |
2 | 1986 } |
6 | 1987 for time in s.keys.sort |
2 | 1988 tstr = case time |
1989 when @opt['alldaydir'] | |
1990 msg('allday') | |
1991 else | |
1992 sprintf "%02d:%02d", time.to_i/100, time.to_i%100 | |
1993 end | |
1994 r << @H.startelement("tr", nil, true) | |
1995 r << @H.element("th", {'class'=>'time'}){tstr} | |
1996 r << @H.element("td"){ | |
1997 @H.elementln("table"){ | |
1998 s[time].keys.collect{|who| | |
1999 editable = (user==who || @sc.ismember(user, who)) | |
2000 groupp = grepgroup(who) | |
2001 @H.element("tr"){ | |
2002 @H.element("td", {'class'=>groupp ? 'group' : 'who'}){ | |
2003 if !groupp && webpage(who) | |
2004 @H.a(webpage(who), nickname(who)) | |
2005 else | |
2006 nickname(who) | |
2007 end | |
2008 } + \ | |
2009 @H.element("td"){ | |
2010 if editable | |
2011 s[time][who]['pub'] ? msg('public') : | |
2012 msg('nonpublic') | |
2013 else | |
2014 @opt['tdskip'] | |
2015 end | |
2016 } + \ | |
2017 @H.element("td"){ | |
2018 if editable | |
2019 @H.a(@myname+"?-modify+#{date}/#{time}/#{who}", | |
2020 msg('modify')) | |
2021 else | |
2022 @opt['tdskip'] | |
2023 end | |
2024 } + \ | |
2025 @H.element("td"){ | |
2026 if editable | |
2027 @H.a(@myname+"?-remove+#{date}/#{time}/#{who}", | |
2028 msg('remove')) | |
2029 else | |
2030 @opt['tdskip'] | |
2031 end | |
2032 } + \ | |
14 | 2033 @H.element("td"){ |
2034 if editable | |
2035 @H.a(@myname+"?-move+#{date}/#{time}/#{who}", | |
2036 msg('move')) | |
2037 else | |
2038 @opt['tdskip'] | |
2039 end | |
2040 } + \ | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2041 @H.element("td"){escape(s[time][who]['sched'])} |
2 | 2042 } |
2043 }.join("\n") | |
2044 } | |
0 | 2045 } |
2 | 2046 r << @H.endelement() |
2047 end | |
0 | 2048 end |
2 | 2049 footer = @H.endelement() |
2050 if r > '' | |
2051 header + r + footer | |
2052 else | |
2053 '' | |
2054 end | |
0 | 2055 end |
14 | 2056 def dayTextString(user, datestr, range, personal = nil) |
2057 r = '' | |
2058 cols = 20 | |
2059 header = "-" * cols + "\n" | |
2060 | |
2061 day = Time.mktime(*date2ymd(datestr)) | |
2062 i = -1 | |
2063 while (i+=1) < range | |
2064 d = Time.at(day+i*3600*24) | |
2065 date = sprintf("%04d/%02d/%02d", d.year, d.month, d.day) | |
2066 datewn = sprintf("%s(%s)", date, @msg['wnames'][@lang][d.wday]) | |
2067 s = @sc.day_all(date, user, personal) | |
2068 next if s.empty? | |
2069 | |
2070 r << sprintf("TIME Who %s - What\n", datewn) | |
2071 | |
2072 for time in s.keys.sort | |
2073 tstr = case time | |
2074 when @opt['alldaydir'] | |
2075 msg('allday') | |
2076 else | |
2077 sprintf "%02d:%02d", time.to_i/100, time.to_i%100 | |
2078 end | |
2079 r << s[time].keys.collect{|who| | |
2080 editable = (user==who || @sc.ismember(user, who)) | |
2081 groupp = grepgroup(who) | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2082 sprintf("%-5s %-10s %s", |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2083 tstr, nickname(who), escape(s[time][who]['sched'])) |
14 | 2084 }.join("\n") + "\n" |
2085 end | |
2086 r << "-" * cols + "\n" | |
2087 end | |
2088 footer = "That's all\n" | |
2089 if r > '' | |
2090 header + r + footer | |
2091 else | |
2092 '' | |
2093 end | |
2094 | |
2095 end | |
0 | 2096 # |
2 | 2097 # new form |
2098 def displayRegistForm(date, multiple = true) | |
0 | 2099 # |
2100 # Link button to add new plan | |
2101 #now = Time.now+3600*24 | |
2 | 2102 thisyear, thismonth, thisday = date.scan(%r,(\d\d\d\d+)/(\d+)/(\d+),)[0] |
2103 user = @params['user'] | |
0 | 2104 now = Time.mktime(thisyear, thismonth, thisday.to_i, Time.now.hour) |
2105 y, m, d, h, min = now.year, now.month, now.day, now.hour, now.min | |
2 | 2106 nextweek = Time.at(now+3600*24*7) |
2107 ey, em, ed = nextweek.year, nextweek.month, nextweek.day | |
2108 rcsp = (multiple ? {'colspan'=>'2'} : nil) | |
2109 wnames = @msg['wnames'][@lang] | |
2110 wnames << @msg['everyday'][@lang] | |
2111 | |
0 | 2112 @O.print @H.element('h2', nil, true){msg('addsched')} |
2113 @O.print @H.element('p', nil){msg('defthisday')} | |
2 | 2114 |
0 | 2115 @O.print @H.element("form", {'action'=>@myname+"?-addsched", 'method'=>'POST'}){ |
2 | 2116 border1 = {'border'=>'1'} |
2117 border1c = {'border'=>'1', 'class'=>'c'} | |
2118 mygroup = @sc.groups().select{|g|@sc.ismember(user, g)} | |
0 | 2119 @H.elementln('table', border1){ |
2120 @H.elementln('tr'){ | |
2121 @H.element('th'){'Name'} + \ | |
2 | 2122 @H.element('td', rcsp){ |
0 | 2123 hiddenvalues() + @sc.nickname(user) |
2124 } | |
2125 } + \ | |
2126 @H.elementln('tr'){ | |
2127 @H.element('th'){'Year'} + \ | |
2 | 2128 @H.element('td'){@H.select("year", y..y+5, y)} + \ |
2129 if multiple | |
2130 @H.element('td'){ | |
2131 d1 = msg('singleday') | |
2132 msg('through')+@H.select("endyear", [d1]+(y..y+5).to_a, d1) | |
2133 } | |
2134 end | |
0 | 2135 } + \ |
2136 @H.elementln('tr'){ | |
2137 @H.element('th'){'Month'} + \ | |
2 | 2138 @H.element('td'){@H.select("month", 1..12, m)} + \ |
2139 if multiple | |
2140 @H.element('td'){ | |
2141 msg('through')+@H.select("endmonth", 1..12, em) | |
2142 } | |
2143 end | |
0 | 2144 } + \ |
2145 @H.elementln('tr'){ | |
2146 @H.element('th'){'Day'} + \ | |
2 | 2147 @H.element('td'){@H.select("day", 1..31, d)} + \ |
2148 if multiple | |
2149 @H.element('td'){ | |
2150 msg('through')+@H.select("endday", 1..31, ed) | |
2151 } | |
2152 end | |
0 | 2153 } + \ |
2 | 2154 if multiple |
2155 @H.elementln('tr'){ | |
2156 @H.element('th'){ | |
2157 msg('whichday') | |
2158 } + \ | |
2159 @H.element('td', rcsp){ | |
2160 @H.elementln('table', border1c){ | |
2161 @H.element('tr'){ | |
2162 i=-1 | |
2163 wnames.collect{|w| | |
2164 @H.element('td'){ | |
2165 i+=1 | |
2166 @H.radio('whichday', i.to_s, '', i==wnames.length-1) | |
2167 } | |
2168 }.join("\n") | |
2169 } + \ | |
2170 @H.element('tr'){ | |
2171 i=-1 | |
2172 wnames.collect{|w| | |
2173 @H.element('td'){w} | |
2174 }.join | |
2175 } | |
2176 } | |
2177 } | |
2178 } | |
2179 end + \ | |
0 | 2180 @H.elementln('tr'){ |
2181 @H.element('th'){'Time<br>'+ \ | |
2182 sprintf(msg('24hour'), @opt['alldaydir'])} + \ | |
2 | 2183 @H.element('td', rcsp){ |
0 | 2184 '<input type=text name="time" value="3000" size=8 maxlength="4">' |
2185 } | |
2186 } + \ | |
2187 @H.elementln('tr'){ | |
2188 @H.element('th'){msg('publicok')} + \ | |
2 | 2189 @H.element('td', rcsp){ |
0 | 2190 @H.radio('pub', 'yes', msg('yes')+'<br>', true) + \ |
2191 @H.radio('pub', 'no', msg('no')) | |
2192 } | |
2193 } | |
2194 ## table | |
2195 } + \ | |
2196 @H.elementln("p"){ # put notify mail checkbox | |
2197 msg('reqnotify') + '<br>' + \ | |
2198 @ntlist.collect{|n, v| | |
8 | 2199 # Actual variables of notifylist for submitting is "sub_"+n |
2200 @H.checkbox("sub_"+n, 'yes', v, @params[n]) | |
0 | 2201 }.join("\n") + \ |
2202 " " + @H.checkbox('rightnow', 'yes', msg('rightnow'), true) + \ | |
2203 "\n" | |
2204 } + \ | |
2205 if mygroup[0] | |
2206 @H.elementln("p"){ # put "register as" | |
2207 msg('registas') + "<br>\n" + \ | |
2208 mygroup.collect{|g| | |
2209 @H.radio('registas', g, @sc.groupname(g)) | |
2210 }.join(' ') + "\n/ " + \ | |
2211 @H.radio('registas', 'no', msg('personal')) | |
2212 } | |
2213 end.to_s + "\n" + \ | |
2 | 2214 @H.radio('editmode', 'remove', 'Delete?') + " / " + \ |
2215 @H.radio('editmode', 'modify', 'Overwrite?') + " / " + \ | |
2216 @H.radio('editmode', 'append', 'Append?', true) + "<br>\n" + \ | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2217 @H.element("p"){msg('headsched') + "<br>\n" + \ |
17 | 2218 @H.element("textarea", @schedulearea){}} + # textarea |
0 | 2219 @H.submit_reset("GO") |
2220 } #form | |
2 | 2221 end |
2222 # | |
2223 # show the schedule list of specified date | |
2224 # | |
2225 def show(date) | |
2226 if !checkauth | |
2227 return nil | |
2228 end | |
2229 user = safecopy(@params['user']) | |
2230 personal = (/personal/i =~ @params['displaymode']) | |
2231 @params['displaydays'] = @params['displaydays'] || @cookie['displaydays'] | |
3 | 2232 days = @params['displaydays'].to_i |
18 | 2233 days = (days > 0 ? days : 3) |
2 | 2234 |
2235 # str = @sc.day_all(date, user, personal) | |
2236 outstr = dayTableString(user, date, days, personal) | |
2237 | |
2238 @O.print @H.element("h1", nil){ | |
2239 sprintf msg('fmtdaysschedule'), date | |
2240 } | |
18 | 2241 @O.print @H.element("h2"){msg('schedtable')} |
2 | 2242 ## @O.print @H.p() |
2243 @O.print @H.elementln("form", {'action'=>@myname+"?-show+#{date}", 'method'=>'POST'}){ | |
2244 @H.elementln("p"){ | |
6 | 2245 msg(personal ? 'personalmode' : 'normalmode') + "<br>" + \ |
2 | 2246 @H.select("displaydays", 1..30, days) + msg('daystodisplay') + \ |
2247 @H.submit("GO", "GO") | |
2248 } | |
2249 } | |
2250 if outstr > '' | |
2251 @O.print outstr | |
2252 else | |
2253 @O.print @H.p(msg('noplan')) | |
2254 end #is_empty? | |
2255 thisyear, thismonth, thisday = date.scan(%r,(\d\d\d\d+)/(\d+)/(\d+),)[0] | |
2256 mstr = sprintf "%04d/%02d", thisyear.to_i, thismonth.to_i | |
2257 @O.print @H.a(@myname+"?-month+"+mstr, | |
2258 sprintf(msg('tomonthlist'), mstr)) | |
2259 | |
2260 | |
2261 # | |
2262 # Display registration form | |
2263 displayRegistForm(date) | |
0 | 2264 @O.print "show" if user == @author |
2265 end | |
2266 | |
2267 # | |
2268 # call process | |
2269 def call_process(cmd, input=nil, timeout=10) | |
2270 prc = CMDTimeout.new | |
2271 fds = prc.start(cmd, timeout, true) | |
2272 if input | |
2273 Thread.start { | |
2274 fds[0].sync = true | |
2275 fds[0].print.input | |
2276 fds[0] | |
2277 } | |
2278 end | |
2279 begin | |
2280 fds[1].readlines | |
2281 ensure | |
2282 prc.close() | |
2283 end | |
2284 end | |
2285 # | |
2286 # notification registerer | |
2287 def notify_time(year, month, day, time, symbol) | |
2288 if (t = time.to_i) > 2359 | |
2289 hh = mm = 0 | |
2290 else | |
2291 hh, mm = t/100, t%100 | |
2292 end | |
2293 base = Time.mktime(year.to_i, month.to_i, day.to_i, hh, mm) | |
2294 if /nt(\d+)([mh])$/ =~ symbol | |
2295 return nil if t > 2359 | |
2296 num, unit = $1.to_i, $2.downcase | |
2297 rate = {'h'=>3600, 'm'=>60}[unit] || 3600 | |
2298 return Time.at(base-rate*num) | |
2299 elsif /nt(\d+)d/ =~ symbol | |
2300 seconds = $1.to_i*3600*24 | |
14 | 2301 tday= Time.at(base-seconds) |
2302 target = [tday.year, tday.month, tday.day, @opt['night'].to_i] | |
2303 targetnight = Time.mktime(*target) | |
0 | 2304 elsif "nttoday" == symbol |
2305 Time.mktime(year.to_i, month.to_i, day.to_i, @opt['morning']) | |
2306 end | |
2307 end | |
2308 def reg_notify(user, year, month, day, time, text, cancelall = nil) | |
6 | 2309 return nil unless @opt['notifymail'] |
0 | 2310 threshold = 5*60 # Omit notifycation within 30min future |
2311 | |
2312 y, m, d, t, = year.to_i, month.to_i, day.to_i, time.to_i | |
2313 if t > 2359 | |
2314 hh = mm = 0 | |
2315 else | |
2316 hh = t/100 | |
2317 mm = t%100 | |
2318 end | |
2319 now = Time.now | |
2320 | |
2321 filearg = [user, year, month, day, t] | |
2322 @ntlist.each{|k, v| | |
8 | 2323 # @params[k]s are always defined in cookies, so we use @params["sub_"+k] |
2324 @params[k] = @params["sub_"+k] | |
0 | 2325 nt_time = notify_time(year, month, day, t, k) |
2326 if !nt_time | |
2327 # do nothing for allday schedule's notification before some minutes | |
2328 elsif cancelall || nt_time < now+threshold || | |
2329 /yes|on|true|1/ !~ @params[k] || !@params[k] | |
2330 # cancel | |
2331 uf = @sc.remove_crondir(nt_time, user, year, month, day, t) | |
2332 @sc.removefile(*(filearg+[k])) | |
2333 else | |
2334 # register | |
2335 lf = @sc.register_crondir(nt_time, user, year, month, day, t) | |
2336 @sc.putfile(*(filearg+[k, lf])) | |
2337 end | |
2338 } | |
2339 end | |
2340 def cancel_notify(user, year, month, day, time) | |
2341 reg_notify(user, year, month, day, time, 'dummy', true) | |
2342 end | |
2 | 2343 |
2344 def commit_schedule(who, y, m, d, timedir, text, repl, pub) | |
2345 | |
2346 end | |
2347 | |
14 | 2348 def regulate_time(y, m, d, tm) |
2349 if tm > 2399 | |
2350 sh, smin = 23, 59 | |
2351 timedir=@opt['alldaydir'] | |
2352 tmstr = msg('allday') | |
2353 else | |
2354 sh = (tm/100).to_i | |
2355 smin = (tm%100).to_i | |
2356 timedir = sprintf("%04d", tm) | |
2357 tmstr = sprintf("%d:%02d", sh, smin) | |
2358 end | |
2359 time = nil | |
2360 begin | |
2361 time = Time.mktime(y, m, d, sh, smin) | |
2362 rescue | |
2363 outputError "%s<br>\nyear=%s<br>month=%s<br>day=%s<br>time=%s\n", | |
2364 msg('invaliddate'), | |
2365 @params['year'], @params['month'], @params['day'], @params['time'] | |
2366 return nil | |
2367 end | |
2368 [time, timedir, tmstr] | |
2369 end | |
2370 | |
0 | 2371 # |
2372 # add or remove a schedule | |
2373 # | |
2374 def add_remove(remove = nil) | |
2375 if !checkauth | |
2376 return nil | |
2377 end | |
2378 user = registerer = @params['user'] | |
2379 as = @params['registas'] | |
2380 if as && as > '' && /^no$/ !~ as && @sc.ismember(user, as) | |
3 | 2381 if (gr=grepgroup(as)) |
2382 registerer = gr | |
2383 end | |
0 | 2384 end |
2385 now = Time.now | |
2 | 2386 #y, m, d, h, min = now.year, now.month, now.day, now.hour, now.min |
0 | 2387 |
2388 $KCODE='e' if $DEBUG | |
2389 @O.print @params.inspect if $DEBUG | |
2390 # | |
2391 # Check the validity of specified time | |
2392 sy = @params['year'].to_i | |
2393 sm = @params['month'].to_i | |
2394 sd = @params['day'].to_i | |
2395 tm = @params['time'].to_i | |
14 | 2396 |
2397 time, timedir, tmstr = regulate_time(sy, sm, sd, tm) | |
2 | 2398 |
2399 # | |
2400 # Check continuous schedule registration | |
2401 wwday = @params['whichday'].to_i | |
2402 if @params['endyear'] && @params['endmonth'] && @params['endday'] && | |
2403 (ey=@params['endyear'].to_i) > 0 && | |
2404 (em=@params['endmonth'].to_i) > 0 && | |
2405 (ed=@params['endday'].to_i) > 0 | |
2406 daylist = [] | |
2407 endtime = Time.mktime(ey, em, ed, 23, 59) | |
2408 ti = time | |
2409 begin | |
2410 if wwday==7 || wwday==ti.wday | |
2411 daylist << [ti.year, ti.month, ti.day] | |
2412 end | |
9 | 2413 end while (ti=Time.at(ti+3600*24)) <= endtime |
2 | 2414 else |
2415 daylist = [[sy, sm, sd]] | |
2416 end | |
2417 | |
2418 if !remove && !(@params['schedule'] && @params['schedule'].strip > '') | |
0 | 2419 outputError msg('putsomething') |
2420 return nil | |
2421 end | |
2422 | |
2 | 2423 |
2424 for y, m, d in daylist | |
2425 # do remove or addition | |
2426 if remove | |
2427 cancel_notify(registerer, y, m, d, timedir) | |
2428 begin | |
2429 @sc.remove(registerer, y, m, d, timedir) | |
2430 #########@O.print @H.p(msg('remove')+msg('done')) | |
2431 rescue | |
2432 outputError("Failed"+$!) | |
2433 end | |
2434 else | |
2435 if time < now | |
2436 outputError(msg('past')) | |
2437 return nil | |
2438 end | |
2439 begin | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2440 |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2441 (text = @params['schedule'].toeuc.strip.gsub(/\r+\n/, $/)) << "\n" |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2442 # text = purify(text) |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2443 STDERR.print text |
2 | 2444 replace = (/modify/i =~ @params['editmode']) |
2445 rc = @sc.register(registerer, y, m, d, timedir, text, replace) | |
2446 if @params['pub'] && /yes/ =~ @params['pub'] | |
2447 @sc.putfile(registerer, y, m, d, timedir, 'pub', "1\n") | |
2448 else | |
2449 @sc.removefile(registerer, y, m, d, timedir, 'pub') | |
2450 end | |
2451 ######## @O.print @H.p(msg('appended')) if rc == 1 | |
2452 rescue | |
2453 outputError("Failed"+$!) | |
2454 end | |
17 | 2455 text = @sc.getschedule(registerer, y, m, d, timedir) |
2 | 2456 reg_notify(registerer, y, m, d, timedir, text) |
2457 | |
0 | 2458 end |
2 | 2459 |
2460 end | |
2461 | |
2462 if !remove && @params['rightnow'] && /yes/i =~ @params['rightnow'] | |
2463 header = sprintf("%s\n%s/%s/%s%s %s %s\n%s%s%s\n%s\n", | |
2464 @opt['url'], | |
2465 sy, sm, sd, | |
2466 if daylist.length > 1 | |
2467 "-%s/%s/%s" % daylist[-1] | |
2468 end, | |
2469 tmstr, msg('immediatenote'), | |
2470 msg('registerer_is'), nickname(registerer), | |
2471 if user!=registerer | |
2472 sprintf(" (%s%s)", | |
2473 msg('registerer'), nickname(user)) | |
2474 else | |
2475 "" | |
2476 end, | |
2477 "-"*70) | |
2478 sendnotify(registerer, "Registration completed", header+text) | |
0 | 2479 end |
14 | 2480 unless @mailmode |
2481 show(sprintf("%04d/%02d/%02d", sy, sm, sd)) | |
2482 @O.print "add_remove" if user == @author | |
2483 end | |
0 | 2484 end |
2485 | |
2486 # add | |
2487 def addsched() | |
14 | 2488 if "move" == @params['editmode'] |
2489 add_remove(:remove) | |
2490 for p in %w(year month day time) do | |
2491 @params[p] = @params["new"+p] | |
2492 end | |
2493 end | |
2494 add_remove(/^remove/i =~ @params['editmode']) | |
0 | 2495 end |
2496 | |
2497 # | |
2498 # Display remove or modify screen | |
14 | 2499 def remove_modify(datetime, editmode) |
0 | 2500 if !checkauth |
2501 return nil | |
2502 end | |
2503 | |
2504 user = @params['user'] | |
2505 y, m, d, time, dummy, as = | |
2506 datetime.scan(%r,(\d\d\d\d+)/(\d+)/(\d+)/(\d+)(/(.+))?,)[0] | |
2507 # datetime always contains trailing slash generated by parsedate | |
2508 # but if the trailing part is a user(not a group), it is removed | |
2509 # because it filtered out by grepgroup() function | |
2510 if ! (y && m && d && time) | |
2511 outputError "Invalid time specification" | |
2512 return nil | |
2513 elsif as && as > '' | |
2514 unless @sc.ismember(user, as) | |
2515 outputError "You have no permission to edit group %s's schedule", as | |
2516 return nil | |
2517 end | |
2518 user = as | |
2519 end | |
2520 unless text=@sc.getschedule(user, y, m, d, time) | |
2521 outputError "%s %s", datetime, msg('noplan') | |
2522 return nil | |
2523 end | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2524 ## text = decode(text) |
0 | 2525 @O.print @H.elementln("h1"){ |
14 | 2526 sprintf "%s %s", datetime, msg(editmode) |
0 | 2527 } |
2528 @O.print @H.elementln("form", {'action'=>@myname+"?-addsched", 'method'=>'POST'}){ | |
2529 pubp=(@sc.getfile(user, y, m, d, time, 'pub').to_i > 0) | |
2530 if as | |
2531 @H.hidden("registas", as) | |
2532 end.to_s + \ | |
2533 "<input type=\"hidden\" name=\"year\" value=\"%04d\">\n" % y.to_i + \ | |
2534 "<input type=\"hidden\" name=\"month\" value=\"%02d\">\n" % m.to_i + \ | |
2535 "<input type=\"hidden\" name=\"day\" value=\"%02d\">\n" % d.to_i + \ | |
2536 "<input type=\"hidden\" name=\"time\" value=\"%04d\">\n" % time.to_i + \ | |
14 | 2537 if editmode=="move" |
2538 @H.elementln("table") { | |
2539 @H.elementln("tr", {"colspan" => "2"}) {msg('newdate')} + \ | |
2540 @H.elementln("tr") { | |
2541 @H.element("th"){"Year"} + \ | |
2542 @H.element("td"){@H.select("newyear", y.to_i..y.to_i+5, y)} | |
2543 } + \ | |
2544 @H.elementln("tr") { | |
2545 @H.element("th"){"Month"} + \ | |
2546 @H.element("td"){@H.select("newmonth", 1..12, m)} | |
2547 } + \ | |
2548 @H.elementln("tr") { | |
2549 @H.element("th"){"Day"} + \ | |
2550 @H.element("td"){@H.select("newday", 1..31, d)} | |
2551 } + \ | |
2552 @H.elementln("tr") { | |
2553 @H.element("th"){"Time"} + \ | |
2554 @H.element("td"){ | |
2555 "<input type=text name=\"newtime\" value=\"#{time}\" " + \ | |
2556 "size=\"8\" maxlength=\"4\">" | |
2557 } | |
2558 } | |
2559 } | |
2560 end.to_s + \ | |
2561 @H.elementln("div", {"style" => | |
2562 "visibility: " + | |
2563 (editmode=="move" ? "hidden" : "show") + "\""}) { | |
2564 msg('reqnotify') + "<br>\n" + \ | |
2565 @ntlist.collect{|nt, v| | |
2566 cronp = @sc.getfile(user, y, m, d, time, nt) | |
2567 sprintf "<input type=\"checkbox\" name=\"%s\"%s>%s \n", | |
2568 nt, (cronp ? " checked" : ""), v | |
2569 }.join + "<br>" | |
2570 } + \ | |
0 | 2571 @H.element("textarea", @schedulearea) {text} + "<br>" + \ |
2572 @H.radio("editmode", "append", msg('append')) + ' / ' + \ | |
14 | 2573 @H.radio("editmode", "modify", msg('modify'), editmode=="modify")+' / '+\ |
2574 @H.radio("editmode", "remove", msg('remove'), editmode=="remove")+' / '+\ | |
2575 @H.radio("editmode", "move", msg('move'), editmode=="move") + ' / ' + \ | |
0 | 2576 "<br>\n" + \ |
2577 msg('publicok') + \ | |
2578 @H.radio("pub", "yes", msg('yes'), pubp) + \ | |
2579 @H.radio("pub", "no", msg('no'), !pubp) + \ | |
2580 '<br>' + \ | |
2581 @H.submit_reset("GO") | |
2582 } | |
2583 @O.print "remove_modify" if user == @author | |
2584 end | |
2585 def remove(datetime) | |
14 | 2586 remove_modify(datetime, "remove") |
0 | 2587 end |
2588 def modify(datetime) | |
14 | 2589 remove_modify(datetime, "modify") |
2590 end | |
2591 def move(datetime) | |
2592 remove_modify(datetime, "move") | |
0 | 2593 end |
2594 | |
2595 def prohibitviahttp() | |
2596 %w[REMOTE_ADDR REMOTE_HOST SERVER_NAME].each{|v| | |
2597 if ENV[v] | |
2598 print "Content-type: text/plain\n\n" | |
2599 print "Do not call this via CGI" | |
2600 exit 0 | |
2601 end | |
2602 } | |
2603 end | |
2604 # | |
2605 # notify: call via cron | |
2606 def notify() | |
2607 prohibitviahttp() | |
2608 unless @opt['maintainer'] | |
2609 STDERR.printf "Set maintainer(email-address) in %s\n", @opt['conf'] | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2610 STDERR.print "(ex.) maintainer=yuuji@gentei.org\n" |
0 | 2611 exit 0 |
2612 end | |
2613 Dir.chdir @mydir | |
2614 line = "-"*25 | |
2615 indent = " " | |
2616 now = Time.now | |
78 | 2617 ntlist = @sc.notify_list(now) |
2618 p "notifylist", ntlist if $DEBUG | |
2619 ntlist.each{|u, datehash| | |
0 | 2620 dellist = [] |
2621 content = datehash.sort.collect{|date, filehash| | |
2622 next unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ date | |
2623 y, m, d, t = $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
11 | 2624 ddiff=(Time.mktime(y, m, d) \ |
2625 - Time.mktime(now.year, now.month, now.day))/3600/24 | |
0 | 2626 if t > 2359 |
2627 hhmm = msg('allday') | |
11 | 2628 if ddiff > 1 |
2629 comment = "%d%s" % [ddiff, msg('days', 'before')] | |
2630 else | |
2631 comment = msg(now.hour > 18 ? 'precedingday' : 'theday') | |
2632 end | |
0 | 2633 else |
2634 hhmm = sprintf "%02d:%02d", t/100, t%100 | |
2 | 2635 diff = Time.mktime(y, m, d, t/100, t%100) - now |
0 | 2636 if diff < 7200 |
2637 comment = "%d%s" % [diff/60, msg('minutes', 'before')] | |
11 | 2638 elsif (ddiff == 0) |
0 | 2639 comment = "%s%d%s" % |
2640 [msg('about'), diff/3600, msg('hours', 'before')] | |
2641 else | |
2642 comment = "%d%s" % [ddiff, msg('days', 'before')] | |
2643 end | |
2644 end | |
2645 dellist << filehash['file'] | |
2646 sprintf("%s[[[%d/%d/%d %s]]]%s\n", line, y, m, d, hhmm, line) + \ | |
2647 sprintf("(%s %s)\n", comment, msg('notification')) + \ | |
31
aceb533dfa32
Schedule file is already decoded. No need to decode again.
HIROSE Yuuji <yuuji@gentei.org>
parents:
30
diff
changeset
|
2648 indent+filehash['text'].join(indent) + "\n\n" |
0 | 2649 } |
2650 # content.delete(nil) | |
2651 if content | |
2652 if $DEBUG | |
2653 print content | |
2654 else | |
2655 content.unshift(msg('introduce')+"\n"+msg('notifymail')+"\n") | |
2656 content.unshift(@opt['url'].to_s+"\n") | |
2657 if sendnotify(u, msg('notifysubj'), content.join) | |
2658 # send mail completed | |
2659 begin | |
2660 @sc.cleanup_files(dellist) | |
2661 rescue | |
2662 end | |
2663 end | |
2664 end | |
2665 end | |
2666 } | |
79 | 2667 if !(list = @sc.notify_list(now)).empty? |
0 | 2668 subj = @mybase+": Undeleted old cron files detected" |
79 | 2669 files = list.collect{|who, whash| |
0 | 2670 whash.sort.collect{|date, fhash| fhash['file']}.join("\n") |
2671 }.join("\n") | |
2672 sendMail(@opt['maintainer'], subj, | |
2673 "This is `#{@mybase}' in #{@mydir}\n" + | |
2674 "You'd better check and remove these files.\n\n"+files) | |
2675 end | |
2676 | |
2677 exit 0 | |
2678 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2679 # ML functions |
47 | 2680 def parseaddress(spec) # from catchup.rb |
2681 # Return [email, comment] | |
2682 # nil if comment does not exitst. | |
2683 if /(.*)\s*<(.*)>/ =~ spec then | |
2684 [$2, $1.strip] | |
2685 elsif /(.*)\s*\((.*)\)/ =~ spec then | |
2686 [$1.strip, $2] | |
2687 else | |
2688 [spec.strip, nil] | |
2689 end | |
2690 end | |
2691 def rewritefrom(email, comment, newseed) # from catchup.rb | |
2692 # no need to setcomment here because if comment set, it's enough | |
2693 comment.sub!(/(\"?)(.*)\1/, '\2') | |
2694 comment += "/" if comment>"" | |
2695 return comment.gsub(/([^\x00-\x7f]+)/){NKF.nkf('-jM', $1)} + | |
2696 email.sub("@", "=")+" <"+newseed+">" | |
2697 # end | |
2698 end | |
2699 | |
2700 def tagify_subj(body, tag, removeregexp, fromhack = nil) | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2701 # This method should be generic for other headers than `Subject'? |
40 | 2702 hold = [] |
2703 ret = [] | |
2704 skip = false | |
2705 while line = body.shift | |
2706 case line.toeuc | |
2707 when /^$/ | |
2708 hold << "\n" | |
2709 break | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2710 ## when /^(subject|from): /i |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2711 when /^(\S+): /i # if new header comes |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2712 if /^subject:/i =~ hold[0] # check previous header in hold space |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2713 sj = hold.join.toeuc.sub("Subject: ", "").gsub(tag, "").strip |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2714 sj.gsub!(removeregexp, "") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2715 sj = sj.sub(/^(re: *)+/i, "Re: ").gsub("\n", "") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2716 hold = ["Subject: "+NKF.nkf('-jM', tag+" "+sj).strip+"\n"] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2717 elsif /^from/i =~ hold[0] && fromhack.is_a?(String) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2718 from = hold.join.toeuc.sub(/From: */i, "").strip |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2719 email, comment = parseaddress(from) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2720 hold = ["From: "+rewritefrom(email, comment, fromhack)+"\n"] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2721 end |
40 | 2722 ret += hold |
2723 hold = [line] | |
2724 when /^\s/ # continued line | |
2725 hold << line | |
2726 end | |
2727 end | |
2728 ret + hold + body | |
2729 end | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2730 def defaultmladdress(name) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2731 prefix = (@opt['mailprefix'] || "") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2732 dash = prefix > '' ? "-" : "" |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2733 sprintf("%s%s%s@%s", prefix, dash, name, @opt['maildomain']) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2734 end |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2735 def list() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2736 # For debug: |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2737 # LOCAL=1 DEFAULT=name ./after5.rb -list |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2738 # $DEFAULT is ML name |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2739 viamail = ENV['LOCAL'] && ENV['DEFAULT'] # called via mail |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2740 from = toadmin = nil |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2741 unless @opt['mailprefix'] && @opt['maildomain'] |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2742 if viamail |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2743 STDERR.print msg('sendall_err') % [@opt['conf']] |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2744 exit 0 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2745 else |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2746 @O.print @H.elementln("pre"){msg('sendall_err') % [@opt['conf']]} |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2747 return true |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2748 end |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2749 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2750 if viamail then |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2751 prohibitviahttp() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2752 name = ENV['DEFAULT'] |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
2753 if Regexp.new("(.*)("+Regexp.quote(@mailadmsuffix)+")") =~ name |
58 | 2754 # To: GROUP/adm*@domain |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2755 # -> Forward to group administrator(s) |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2756 name, toadmin = $1, $2 |
58 | 2757 sendMail("dummy", 'dummy', # Original To: and Subject: go through |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2758 STDIN.readlines.join, nil, @sc.admins(name), |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2759 {"Return-path" => @opt['maintainer']}, :thru) |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2760 exit 0 |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2761 end |
56 | 2762 unless grepgroup(name) |
2763 sendMail(@opt['maintainer'], "no group", | |
2764 sprintf("Invalid group address: %s(%s@%s)\nSent by %s\n" + | |
2765 "URL: %s\n------------\n", | |
2766 name, ENV['LOCAL'], ENV['HOST'], ENV['SENDER'], | |
2767 @opt['url']) + | |
2768 "> "+STDIN.readlines.join("> ")) | |
2769 exit 0 # should exit 0 in mail mode | |
2770 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2771 else # via http |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2772 return nil unless checkauth |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2773 name = @params['name'].untaint |
56 | 2774 unless grepgroup(name) |
2775 @O.print @H.p("No such group: #{name}") | |
2776 return true | |
2777 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2778 nick = @sc.nickname(@params['user']) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2779 from = sprintf("%s <%s>", nick, @params['user']) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2780 body = @params['body'].gsub("\r", "").untaint |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2781 end |
71
156f315f52b8
Default mailbracket should be taken from @opt.
HIROSE Yuuji <yuuji@gentei.org>
parents:
70
diff
changeset
|
2782 bracket = @sc.getgroupattr(name, 'subjtag') || @opt['mailbracket'] |
47 | 2783 fromhack = @sc.getgroupattr(name, 'fromhack') |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2784 mldir = "ml/"+name |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2785 to = @sc.getgroupattr(name, 'mladdress') || defaultmladdress(name) |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
2786 returnpath = to.sub("@", @mailadmsuffix+"-@") |
69
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2787 adminaddr = to.sub("@", @mailadmsuffix+"@") |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2788 subj = @params['subject'] || "Message from "+@myname |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2789 sjtag = bracket.gsub("%n", nickname(name)). |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2790 gsub("%i", name). |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2791 gsub(/%(\d*)c/){("%0"+$1+"d") % [mlseq(mldir)]} |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2792 tagpt = Regexp.quote(bracket). # compute bracket pattern |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2793 gsub("%n", Regexp.quote(nickname(name))). |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2794 gsub("%i", Regexp.quote(name)). |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2795 gsub(/%(\d*)c/, '\d+') |
47 | 2796 tagre = Regexp.new(tagpt) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2797 subj = sjtag.strip+" "+subj.gsub(Regexp.new(tagpt), "") |
40 | 2798 if viamail then |
47 | 2799 body = tagify_subj(STDIN.readlines, sjtag, tagre, |
2800 fromhack ? to : nil).join | |
2801 elsif fromhack | |
2802 from = rewritefrom(@params['user'], nick, to) | |
40 | 2803 end |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2804 header = { |
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2805 "Reply-to" => to, |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2806 "X-ML-Driver" => ($hgid || @myname), |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2807 "X-ML-Driver-URI" => $myurl, |
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2808 "X-ML-Name" => name, |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2809 "X-ML-URI" => sprintf("%s?-groupman+%s", @opt['url'], name), |
58 | 2810 "Return-path" => returnpath} |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2811 Dir.chdir @mydir |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2812 rcpts = if grepgroup(name) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2813 @sc.members(name) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2814 else |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2815 [name] |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2816 end.collect {|u| mailaddress(u, name).split(/,\s*|\s+/)}.flatten |
69
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2817 ENV["QMAILINJECT"] = "r" # for ML mode, use verp |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2818 # |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2819 # On mail mode, check if sender can send message to list. |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2820 if viamail && @sc.getgroupattr(name, 'limitsender') |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2821 s = ENV['SENDER'] |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2822 if !catch(:senderok) { |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2823 throw :senderok, true if rcpts.grep(s)[0] |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2824 throw :senderok, true if @sc.ismembersemail(s) |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2825 } |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2826 # sender is not allowed to send to ML |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2827 sendMail(s, "You are not allowed to send to this ML", |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2828 ("Before posting to this list(%s),\n"+ |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2829 "subscribe to %s") % [to, @opt['url']], |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2830 adminaddr, nil, {"Return-path" => returnpath}) |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2831 exit 0 |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2832 end |
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
2833 end |
70
2e293d4d8db4
Not using proc.call for the sake of displaying document title.
HIROSE Yuuji <yuuji@gentei.org>
parents:
69
diff
changeset
|
2834 # |
2e293d4d8db4
Not using proc.call for the sake of displaying document title.
HIROSE Yuuji <yuuji@gentei.org>
parents:
69
diff
changeset
|
2835 # OK to send, go ahead |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2836 sendMail(to, subj, body, from, rcpts, |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2837 header, |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2838 ENV['SENDER'], |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2839 @opt['mlspooling'] ? mldir : nil) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2840 if !viamail then |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2841 @O.print @H.elementln("h1"){msg('sendall_done')} |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2842 @O.print @H.p(sprintf(msg('sendall_head'), |
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2843 nickname(name))+" "+msg('done')) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2844 link2home() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2845 @O.print footer() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2846 return true |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2847 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2848 exit 0 |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2849 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2850 def listdraft(name) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2851 return nil unless checkauth |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2852 return nil unless name |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2853 unless @opt['mailprefix'] && @opt['maildomain'] |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2854 @O.print @H.elementln("pre"){msg('sendall_err') % [@opt['conf']]} |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2855 return true |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2856 end |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2857 |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2858 user=@params['user'] |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2859 nickname = @sc.nickname(user) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2860 @O.print @H.elementln("h1") { |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2861 @mybase+' '+msg('sendall').sub("<br>", " ") |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2862 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2863 @O.print @H.elementln("h2") { |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2864 sprintf(msg('sendall_head'), nickname(name)) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2865 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2866 @O.print @H.p(sprintf("(%s: %s)", msg('member'), |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2867 @sc.membernames(name).join(", "))) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2868 @O.print \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2869 @H.elementln("form", {'action' => @myname+'?-list', 'method'=>"POST"}) { |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2870 @H.elementln("table"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2871 @H.elementln("tr"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2872 @H.element("td"){"Subject"} + \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2873 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2874 @H.text("subject", "", 40, 128) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2875 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2876 } + \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2877 @H.elementln("tr"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2878 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2879 msg('body') |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2880 } + \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2881 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2882 @H.element("textarea", @schedulearea.merge({"name"=>"body"})){} |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2883 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2884 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2885 } + # </table> |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2886 @H.hidden("name", name) + |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2887 @H.submit("send", "SEND") + |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2888 @H.reset("clear", "Clear") |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2889 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2890 @O.print @H.p(msg('sendall_note')) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2891 end |
0 | 2892 |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2893 # put Link to home |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2894 def link2home() |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2895 @O.print @H.p("-> " + @H.a(@myname+"?-today", "Home")) |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2896 end |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2897 |
0 | 2898 # |
2899 # user management | |
2900 def userman() | |
2901 if !checkauth | |
2902 return nil | |
2903 end | |
2904 user=@params['user'] | |
2905 nickname = @sc.nickname(user) | |
2906 tdclass = {} | |
2907 tdclass["width"] = "80px" if @oldagent # workaround for NN4 | |
2908 | |
2909 @O.print @H.elementln("h1"){ | |
2910 @mybase+' '+msg('user', 'management') | |
2911 } | |
2912 @O.print @H.p(@sc.mkusermap.inspect) if $DEBUG | |
2913 @O.print @H.p(msg('usermodwarn')) | |
2914 @O.print \ | |
2915 @H.elementln("form", {'action'=>@myname+"?-usermod", 'method'=>'POST'}){ | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2916 @H.elementln("table", {"class" => "border"}){ |
0 | 2917 @H.elementln("tr"){ |
2918 @H.element("td", tdclass) {msg('regaddress')} + \ | |
2919 @H.element("td") { | |
2920 @H.element("code"){user} | |
2921 } | |
2922 } + \ | |
2923 @H.elementln("tr"){ | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2924 @H.element("td", tdclass) {msg('mailaddress', 'multipleok')} + \ |
0 | 2925 @H.element("td") { |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
2926 @H.text("newmail", mailaddress(user), @opt['size'], 180) |
0 | 2927 } |
2928 } + \ | |
2929 @H.elementln("tr"){ | |
2930 @H.element("td", tdclass) {msg('weburl')} + \ | |
2931 @H.element("td") { | |
2932 @H.text("webpage", webpage(user), @opt['size'], 80) | |
2933 } | |
2934 } + \ | |
2935 @H.elementln("tr"){ | |
2936 @H.element("td") {msg('nickname')} + \ | |
2937 @H.element("td") { | |
2938 @H.text("nickname", nickname, @opt['size'], 10) | |
2939 } | |
2940 } | |
2941 } + \ | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2942 @H.elementln("p"){msg('shortnameplz')} + \ |
0 | 2943 '<br>' + \ |
2944 @H.submit_reset("GO") | |
2945 } # form | |
2946 | |
2947 # | |
2948 # Next section, REMOVE USER! | |
2949 @O.print @H.elementln("h2"){ | |
2950 sprintf "%s %s %s", msg('user'), user, msg('deletion') | |
2951 } | |
2952 @O.print @H.p(msg('deletionwarn'))+"\n" | |
2953 @O.print @H.elementln("form", {'action'=>@myname+"?-delusersub+#{user}", 'method'=>'POST'}){ | |
2954 @H.hidden("user", user) + "\n" + \ | |
2955 @H.elementln("table"){ | |
2956 @H.elementln("tr"){ | |
2957 @H.elementln("td"){ | |
2958 sprintf msg('deluser'), user | |
2959 } + \ | |
2960 @H.elementln("td"){ | |
2961 @H.radio("delete", "yes", msg('yes')) + ' ' + \ | |
2962 @H.radio("delete", "no", msg('no'), true) | |
2963 } | |
2964 } + \ | |
2965 @H.elementln("tr"){ | |
2966 @H.elementln("td"){ | |
2967 sprintf msg('really?'), user | |
2968 } + \ | |
2969 @H.elementln("td"){ | |
2970 @H.radio("delete2", "yes", msg('yes')) + ' ' + \ | |
2971 @H.radio("delete2", "no", msg('no'), true) | |
2972 } | |
2973 } | |
2974 } + \ | |
2975 "<br>\n" + @H.submit_reset("GO") | |
2976 } | |
2977 | |
2978 | |
2979 end | |
2980 def usermod() | |
2981 if !checkauth | |
2982 return nil | |
2983 end | |
2984 @O.print @H.elementln("h1"){ | |
2985 msg('user', 'management')+" "+msg('done') | |
2986 } | |
2987 user=@params['user'] | |
2988 email = mailaddress(user) | |
2989 newmail = @params['newmail'] | |
2990 nickname = @sc.nickname(user) | |
2991 newnn = @params['nickname'].to_s.strip | |
2992 webpage = webpage(user) | |
2993 newweb = @params['webpage'] | |
2994 if email != newmail | |
2995 # change user's address | |
2996 if newmail == user | |
2997 newvalue = nil | |
2998 elsif checkmail(newmail) | |
2999 newvalue = newmail | |
3000 else | |
3001 @O.print @H.elementln("pre"){"Invalid mail address"} | |
3002 end | |
3003 @O.print @H.elementln("pre"){ | |
3004 if @sc.putuserattr(user, 'email', newvalue) | |
3005 sprintf "new mail address=\"%s\"", mailaddress(user) | |
3006 else | |
3007 sprintf "Setting new mail address to \"%s\" failed", newvalue | |
3008 end | |
3009 } | |
3010 end | |
3011 if nickname != newnn | |
3012 if @sc.setnickname(user, newnn) | |
3013 @O.print @H.p(msg('success')) | |
3014 @O.print @H.elementln("pre"){ | |
3015 sprintf "user=\"%s\"\nnickname=\"%s\"", user, @sc.nickname(user) | |
3016 } | |
3017 @O.print @H.p(msg('nicknamenote')) if newnn == '' | |
3018 else | |
3019 @O.print @H.p(msg('failure')) | |
3020 end | |
3021 end | |
3022 if newweb > '' && webpage != newweb | |
3023 if @sc.putuserattr(user, "webpage", newweb) | |
3024 @O.print @H.p(msg('success')) | |
3025 @O.print @H.elementln("pre"){ | |
3026 sprintf "user=\"%s\"\nwebpage=\"%s\"", user, webpage(user) | |
3027 } | |
3028 else | |
3029 @O.print @H.p("Update webpage"+msg('failure')) | |
3030 end | |
3031 end | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3032 link2home |
0 | 3033 end |
3034 # | |
3035 # Display form of group management | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3036 def groupman(grp = nil) |
0 | 3037 if !checkauth |
3038 return nil | |
3039 end | |
3040 user=@params['user'] | |
3041 nickname = @sc.nickname(user) | |
3042 tdclass = {} | |
3043 tdclass["width"] = "80px" if @oldagent # workaround for NN4 | |
3044 admclass = {'class'=>'admin'} | |
3045 grmap = @sc.groupmap | |
3046 | |
3047 @O.print @H.elementln("h1"){ | |
3048 @mybase+' '+msg('group', 'management') | |
3049 } | |
3050 $KCODE='e' if $DEBUG | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3051 if grp && group = grepgroup(grp) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3052 @O.print @H.elementln("h2"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3053 sprintf(msg('aboutgroup'), group) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3054 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3055 grmap = {group => grmap[group]} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3056 end |
0 | 3057 @O.print grmap.inspect if $DEBUG |
3058 @O.print @H.p(msg('joinmyself')+ | |
3059 @H.a(@myname+"?-newgroup", msg('newgroup'))) | |
3060 @O.print @H.p(msg('usermodwarn')) | |
3061 @O.print \ | |
3062 @H.elementln("form", {'action'=>@myname+"?-groupmod", 'method'=>'POST'}){ | |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3063 @H.elementln("table", {'class'=>'border'}){ |
47 | 3064 grmap.sort.collect{|g, ghash| |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3065 memberp = @sc.ismember(user, g) |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3066 adminp = @sc.isadmin(user, g) |
0 | 3067 @H.elementln("tr"){ |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3068 @H.element("td", adminp ? admclass : nil){ |
63
e2aa6180c2c6
Show the number of group member in groupman().
HIROSE Yuuji <yuuji@gentei.org>
parents:
62
diff
changeset
|
3069 g + "<br>("+@sc.members(g).length.to_s+")" |
0 | 3070 } + \ |
3071 @H.element("td"){ | |
3072 @H.element("div", {'class'=>'c'}) { | |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3073 if adminp |
0 | 3074 @H.a(@myname+"?-admgroup+#{g}", msg('adminop')) |
3075 else | |
3076 '--' | |
3077 end | |
3078 } | |
3079 } + \ | |
3080 @H.element("td"){ | |
3081 if ghash['admin'].grep(user)[0] | |
67
a421c2fefc32
Fix the argument for FileUtils.mkdir_p()
HIROSE Yuuji <yuuji@gentei.org>
parents:
66
diff
changeset
|
3082 @H.text("groupname-#{g}", ghash['name'], nil, 12) |
0 | 3083 else |
3084 ghash['name'] | |
3085 end + '<br>' + \ | |
66 | 3086 # If this group is inviteonly and the user is not a member, |
67
a421c2fefc32
Fix the argument for FileUtils.mkdir_p()
HIROSE Yuuji <yuuji@gentei.org>
parents:
66
diff
changeset
|
3087 # one cannot join. |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3088 if memberp && adminp || !@sc.getgroupattr(g, 'inviteonly') |
66 | 3089 @H.radio("groupadd-#{g}", "yes", "IN", memberp) + " / " + \ |
3090 @H.radio("groupadd-#{g}", "no", "OUT", !memberp) | |
3091 else | |
3092 @H.element("small"){"("+msg('inviteonly')+")"} | |
3093 end | |
0 | 3094 } + \ |
3095 @H.element("td"){ | |
47 | 3096 @H.element("div", {'class'=>'memlist5'}){ |
3097 memlist = ghash['members'] | |
3098 if memberp # move this user to the beginning of list | |
3099 memlist.delete(user) | |
3100 memlist.unshift(user) | |
3101 end | |
3102 memlist.collect{|u| | |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3103 (adminp \ |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3104 ? @H.element("abbr", "title"=>mailaddress(u)) { |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3105 @sc.nickname(u) |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3106 } |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3107 : @sc.nickname(u)) + \ |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3108 ((u == user) ? ("("+@H.text("mail4-#{g}", memberp, 30, 180)+")") : "") |
47 | 3109 }.join(", ") |
3110 } | |
3111 } + \ | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3112 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3113 @H.a(@myname+"?-listdraft+#{g}", msg('sendall')) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3114 } |
0 | 3115 } |
27 | 3116 }.join("\n") |
0 | 3117 } + \ |
3118 '' + \ | |
3119 @H.p(msg('groupwarn', 'shortnameplz')) + \ | |
3120 @H.submit_reset("GO") | |
3121 } # form | |
3122 end | |
2 | 3123 def groupnamesString() |
3124 @H.elementln("p", {'class'=>'listup'}){ | |
3125 @sc.groups().collect{|g|@sc.groupname(g)}.join(", ") | |
3126 } | |
3127 end | |
0 | 3128 def groupmod() |
3129 if !checkauth | |
3130 return nil | |
3131 end | |
3132 @O.print @H.elementln("h1"){ | |
3133 msg('group', 'management')+" "+msg('done') | |
3134 } | |
3135 user=@params['user'] | |
3136 @O.print @params.inspect if $DEBUG | |
3137 | |
3138 for grp in @sc.groups() | |
3139 # | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3140 # As a member, participate or retire |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3141 |
0 | 3142 key = "groupadd-#{grp}" |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3143 memberp = @sc.ismember(user, grp) |
0 | 3144 removep = (/no/i =~ @params[key]) |
3145 if @params[key] | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3146 # |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3147 # Check the group is invitation-only mode. |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3148 if !removep && !memberp && !@sc.isadmin(user, grp) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3149 @O.print @H.elementln("p") { |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3150 sprintf(msg('invite-error'), grp) + "<br>\n" + \ |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3151 @sc.admins(grp).join(", ") |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3152 } |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3153 sendMail(defaultmladdress(grp).sub("@", @mailadmsuffix+"@"), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3154 "Group paticipation attempt to #{grp}", |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3155 putLog("User `%s' tried to join `%s' from %s" % |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3156 [user, grp, ENV['REMOTE_ADDR']]), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3157 nil, |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3158 @sc.admins(grp)) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3159 next |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3160 end |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3161 # |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3162 # OK to join/retire |
0 | 3163 if (!removep) ^ memberp |
3164 @sc.addgroup(grp, [user], removep) | |
3165 @O.print @H.elementln("p"){ | |
3166 sprintf "%s [%s] %s %s", msg('user'), user, | |
3167 removep ? msg('removedfromgp') : msg('addedtogroup'), grp | |
3168 } | |
3169 end | |
3170 end | |
3171 # | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3172 # As a member, change group-specific mailto address. |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3173 key = "mail4-#{grp}" |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3174 if memberp && @params[key] && memberp != @params[key] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3175 @sc.addgroup(grp, [[user, @params[key]]]) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3176 newmemp = @sc.ismember(user, grp) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3177 @O.print @H.elementln("p") { |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3178 sprintf("%s `%s' %s => %s%s", |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3179 msg('group'), grp, msg('mailaddress'), @params[key], |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3180 @params[key]==mailaddress(user) ? "(same)" : "") |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3181 } |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3182 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3183 # |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3184 # as an owner, change the name of group |
0 | 3185 if @sc.isadmin(user, grp) && |
3186 (newname = @params["groupname-#{grp}"]) && | |
3187 @sc.groupname(grp) != newname | |
2 | 3188 @O.printf "@sc.name2group=%s<br>\n", @sc.name2group(newname) |
3189 if dupl=@sc.name2group(newname) | |
3190 @O.print @H.p(sprintf(msg('dupname'), newname)) | |
3191 @O.print groupnamesString() | |
3192 | |
3193 else | |
3194 @sc.setgroupname(grp, newname) | |
3195 @O.print @H.elementln("p"){ | |
3196 sprintf "%s %s%s %s", | |
3197 msg('group'), grp, msg('of', 'name', 'setto'), newname | |
3198 } | |
3199 end | |
0 | 3200 end |
3201 end | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3202 link2home |
0 | 3203 end |
3204 def users() | |
3205 unless pm=open_pm() | |
3206 outputError(msg('autherror')) | |
3207 return nil | |
3208 end | |
3209 pm.users | |
3210 end | |
3211 def grepgroup(gname) | |
3212 gr = @sc.groups.grep(gname)[0] | |
3213 end | |
3214 def admgroup(group = nil) | |
3215 # if group==nil, create new | |
3216 if !checkauth | |
3217 return nil | |
3218 end | |
3219 @O.print @H.elementln("h1"){ | |
3220 msg('group', 'management') | |
3221 } | |
3222 user=@params['user'] | |
3223 | |
3224 # Check the existent group's validity | |
3225 if group | |
3226 unless (gr=grepgroup(group)) | |
3227 @O.print @H.p("No such group #{group}") | |
3228 return nil | |
3229 end | |
3230 group = gr | |
3231 unless @sc.isadmin(user, group) | |
3232 @O.print @H.p("You are not administrator of #{group}.") | |
3233 return nil | |
3234 end | |
3235 @O.print @H.elementln("h2"){ | |
3236 msg('group')+" #{group}" + | |
3237 if group != @sc.groupname(group) | |
3238 " (#{@sc.groupname(group)})" | |
3239 end.to_s | |
3240 } | |
3241 actionmethod={'action'=>@myname+"?-admgroupsub", 'method'=>'POST'} | |
3242 else | |
3243 # New group creation | |
3244 @O.print @H.elementln("h2"){ | |
3245 msg('newgroup') | |
3246 } | |
3247 actionmethod={'action'=>@myname+"?-newgroupsub", 'method'=>'POST'} | |
3248 end | |
3249 | |
43 | 3250 userlist = ([user] + users()).uniq.sort |
0 | 3251 myselfclass = {'class'=>'admin'} |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3252 yesclass = {'class' => 'yes'} |
0 | 3253 colspan2 = {'colspan'=>'2'} |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3254 colspan3 = {'colspan'=>'3'} |
0 | 3255 warnclass = {'class'=>'warn'} |
3256 warnp = nil | |
3257 | |
3258 @O.print @H.elementln("form", actionmethod){ | |
3259 @H.hidden('group', group) + "\n" + \ | |
3260 if group | |
64
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3261 # Non symmetric job: Move the current users above. |
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3262 gmemlist = userlist.select{|u| @sc.ismember(u, group)} |
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3263 userlist = (gmemlist + userlist).uniq |
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3264 # In this context, should return simply "". |
0 | 3265 "" |
3266 else | |
3267 # new group creation | |
3268 grps = @sc.groups() | |
3269 i=1 | |
3270 defname = "group%03d"%i | |
3271 while grps.grep(defname)[0] | |
3272 defname = "group%03d"%(i+=1) | |
3273 end | |
3274 @H.element("pre"){ | |
3275 msg('group', 'of', 'id')+"\n"+@H.text("group", defname) + "\n" + \ | |
3276 msg('group', 'of', 'name', 'anystring')+"\n"+ \ | |
3277 @H.text("gname", '') + "\n" | |
3278 } | |
3279 end + \ | |
47 | 3280 @H.elementln("div", {'class'=>'memlist'}){ |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3281 @H.elementln("table", {'border'=>'1'}){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3282 @H.elementln("tr") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3283 @H.elementln("th", colspan3) { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3284 msg('member', 'of', 'joinquit', 'operation')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3285 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3286 @H.elementln("tr"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3287 @H.element("th"){msg('join')} + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3288 @H.element("th"){msg('administrator')} + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3289 @H.element("th"){msg('member')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3290 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3291 userlist.collect{|u| |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3292 recursememp = nil |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3293 if group |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3294 memberp = (@sc.ismember(u, group) && true) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3295 adminp = (@sc.isadmin(u, group) && true) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3296 if !memberp && @sc.members(group).grep(u)[0] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3297 recursememp = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3298 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3299 else |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3300 memberp = adminp = (u == user) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3301 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3302 @H.elementln("tr", (u==user ? myselfclass : nil)){ |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3303 @H.element("td", memberp && yesclass){ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3304 yes = memberp ? 'YES' : 'yes' |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3305 @H.radio('mem-'+u, 'yes', yes+' / ', memberp) + \ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3306 @H.radio('mem-'+u, 'no', 'no', !memberp) |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3307 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3308 @H.element("td"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3309 @H.radio('adm-'+u, 'yes', 'Admin / ', adminp) + \ |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3310 @H.radio('adm-'+u, 'no', 'no', !adminp) |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3311 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3312 @H.element("td"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3313 @H.element("abbr", "title"=>mailaddress(u)) { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3314 @sc.nickname(u) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3315 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3316 if recursememp |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3317 warnp = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3318 @H.element("span", warnclass){"(*)"} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3319 end.to_s |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3320 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3321 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3322 }.join + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3323 # group names |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3324 @H.elementln("tr") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3325 @H.elementln("th", colspan3) { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3326 msg('group', 'of', 'joinquit', 'operation')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3327 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3328 @H.elementln("tr"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3329 @H.element("th", colspan2){msg('join')} + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3330 @H.element("th"){msg('group')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3331 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3332 @sc.groups().sort.collect{|g| |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3333 next if group == g |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3334 memberp = @sc.ismember(g, group) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3335 @H.element("tr"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3336 @H.element("td", colspan2){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3337 @H.radio('mem-'+g, 'yes', 'YES / ', memberp) + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3338 @H.radio('mem-'+g, 'no', 'NO', !memberp) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3339 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3340 @H.element("td"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3341 if @sc.isadmin(user, g) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3342 @H.a(@myname+"?-admgroup+#{g}", @sc.groupname(g)) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3343 else |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3344 @sc.groupname(g) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3345 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3346 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3347 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3348 }.join |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3349 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3350 } + \ |
69
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
3351 ["fromhack", "inviteonly", "limitsender"].collect do |param| |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3352 @H.checkbox(param, "yes", msg(param), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3353 @sc.getgroupattr(group, param)) + "<br>\n" |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3354 end.join + \ |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3355 (group ? @H.elementln("p") { |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3356 sprintf(msg('mladdress'), defaultmladdress(group)) + \ |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3357 @H.text("mladdress", @sc.getgroupattr(group, 'mladdress'), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3358 @opt['size'], 80) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3359 } : "") + \ |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3360 @H.elementln('p') { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3361 n = -1 |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3362 curtag = @sc.getgroupattr(group, 'subjtag') |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3363 values = @subjtags.collect {|x| |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3364 sprintf(' <option value="%d"%s>%s</option>', n+=1, |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3365 curtag==@subjtags[n][1] ? ' selected' : "", |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3366 x[0]) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3367 }.join("\n") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3368 "Subject tag: " + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3369 <<-_EOF_ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3370 <select name="subjtag"> |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3371 <option value="">DEFAULT</option> |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3372 #{values} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3373 </select> |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3374 _EOF_ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3375 } + \ |
0 | 3376 @H.submit_reset("GO") |
3377 } # form | |
3378 @O.print @H.p(@H.element("span", warnclass){"(*)"}+ | |
3379 msg('recursewarn')) if warnp | |
2 | 3380 if group && (members = @sc.members(group))[0] |
0 | 3381 @O.print @H.p(sprintf(msg('wholemembers'), group)) |
3382 @O.print @H.elementln("p", {'class'=>'listup'}){ | |
2 | 3383 members.collect{|u|@sc.nickname(u)}.join(", ")} |
0 | 3384 end |
3385 | |
3386 # | |
3387 # Next section, REMOVE GROUP! | |
3388 return nil unless group | |
3389 @O.print @H.elementln("h2"){ | |
3390 sprintf "%s %s %s", msg('group'), group, msg('deletion') | |
3391 } | |
3392 @O.print @H.p(msg('deletionwarn'))+"\n" | |
3393 @O.print @H.elementln("form", {'action'=>@myname+"?-delgroupsub+#{group}", 'method'=>'POST'}){ | |
3394 @H.hidden("group", group) + "\n" + \ | |
3395 @H.elementln("table"){ | |
3396 @H.elementln("tr"){ | |
3397 @H.elementln("td"){ | |
3398 sprintf msg('delgroup'), group | |
3399 } + \ | |
3400 @H.elementln("td"){ | |
3401 @H.radio("delete", "yes", msg('yes')) + ' ' + \ | |
3402 @H.radio("delete", "no", msg('no'), true) | |
3403 } | |
3404 } + \ | |
3405 @H.elementln("tr"){ | |
3406 @H.elementln("td"){ | |
3407 sprintf msg('really?'), group | |
3408 } + \ | |
3409 @H.elementln("td"){ | |
3410 @H.radio("delete2", "yes", msg('yes')) + ' ' + \ | |
3411 @H.radio("delete2", "no", msg('no'), true) | |
3412 } | |
3413 } | |
3414 } + \ | |
3415 "<br>\n" + @H.submit_reset("GO") | |
3416 } | |
3417 | |
3418 @O.print footer() | |
3419 end | |
3420 def newgroup() | |
3421 admgroup(nil) | |
3422 end | |
3423 | |
3424 def delgroupsub(group) | |
3425 if !checkauth | |
3426 return nil | |
3427 end | |
3428 user = @params['user'] | |
3429 if group != @params['group'] | |
3430 @O.print @H.p("Group mismatch") | |
3431 return nil | |
3432 end | |
3433 unless (gr=grepgroup(group)) | |
3434 @O.print @H.p("No such group #{group}") | |
3435 return nil | |
3436 end | |
3437 group = gr | |
3438 unless @sc.isadmin(user, group) | |
3439 @O.print @H.p("You are not administrator of #{group}.") | |
3440 return nil | |
3441 end | |
3442 unless @params['delete'] && /yes/i =~ @params['delete'] \ | |
3443 && @params['delete2'] && /yes/i =~ @params['delete2'] | |
3444 @O.print @H.p(msg('chicken')) | |
3445 return nil | |
3446 end | |
3447 @O.print @H.elementln("h1"){ | |
3448 msg('group')+" #{group} "+msg('deletion') | |
3449 } | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3450 resmsg = @sc.destroygroup(group) ? msg("done") : msg("failure") |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3451 @O.print @H.p(resmsg) |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3452 putLog("Delete group '#{group}' #{resmsg}\n") |
0 | 3453 |
3454 @O.print footer() | |
3455 end | |
3456 | |
3457 def deleteuser(user) | |
3458 @sc.deleteuser(user) && | |
3459 begin | |
3460 pm = open_pm | |
3461 pm.delete(user) | |
3462 pm.close() | |
3463 true | |
3464 rescue | |
3465 nil | |
3466 end | |
3467 end | |
3468 def delusersub(user) | |
3469 if !checkauth | |
3470 return nil | |
3471 end | |
3472 user = @params['user'] | |
3473 if user != @params['user'] | |
3474 @O.print @H.p("User mismatch") | |
3475 return nil | |
3476 end | |
3477 unless (us=users().grep(user)[0]) | |
3478 @O.print @H.p("No such user #{user}") | |
3479 return nil | |
3480 end | |
3481 user = us | |
3482 unless @params['delete'] && /yes/i =~ @params['delete'] \ | |
3483 && @params['delete2'] && /yes/i =~ @params['delete2'] | |
3484 @O.print @H.p(msg('chicken')) | |
3485 return nil | |
3486 end | |
3487 @O.print @H.elementln("h1"){ | |
3488 msg('user')+" #{user} "+msg('deletion') | |
3489 } | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3490 resmsg = deleteuser(user) ? msg("done") : msg("failure") |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3491 @O.print @H.p(resmsg) |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3492 putLog("Delete user '#{user}' #{resmsg}\n") |
0 | 3493 |
7 | 3494 @O.print @H.p(@H.a(@myname, msg('login'))) |
0 | 3495 end |
3496 | |
3497 def admgroupsub() | |
3498 if !checkauth | |
3499 return nil | |
3500 end | |
3501 user = @params['user'] | |
3502 group = @params['group'] | |
3503 unless (gr=grepgroup(group)) | |
3504 @O.print @H.element("pre"){"No such group #{group.inspect}"} | |
3505 return nil | |
3506 end | |
3507 unless @sc.isadmin(user, group) | |
3508 @O.print @H.p("You are not administrator of #{group}.") | |
3509 return nil | |
3510 end | |
3511 gorup = gr | |
3512 @O.print @H.elementln("h1"){ | |
3513 msg('group', 'management', 'done') | |
3514 } | |
3515 @O.print @H.elementln("h2"){ | |
3516 msg('group')+" #{group}" + | |
3517 if group != @sc.groupname(group) | |
3518 " (#{@sc.groupname(group)})" | |
3519 end.to_s | |
3520 } | |
3521 somethingdone = nil | |
3522 for u in users() | |
2 | 3523 u = @sc.isuser(u) # users() value is considered tainted. |
3524 next unless u # Use registered value in @sc. | |
0 | 3525 for var, kind in { |
3526 "mem"=>['members', 'member'], 'adm'=>['admin', 'administrator']} | |
3527 memv = "#{var}-#{u}" | |
3528 if @params[memv] | |
3529 joinp = ((/^yes/i =~ @params[memv]) && true) | |
3530 membp = if var=='mem' | |
3531 @sc.ismember(u, group) | |
3532 else # admin | |
3533 @sc.isadmin(u, group) | |
3534 end && true | |
3535 if var=='adm' && @sc.admins(group).length == 1 && membp && !joinp | |
3536 @O.print @H.p(sprintf(msg('soleadmin'), u, group)) | |
3537 elsif joinp ^ membp | |
3538 somethingdone = true | |
3539 @sc.addgroup(group, [u], !joinp, kind[0]) | |
3540 @O.print @H.elementln("p"){ | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3541 putLog(sprintf "%s [%s](%s) %s %s", msg('user'), u, |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3542 msg(kind[1]), |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3543 joinp ? msg('addedtogroup'): msg('removedfromgp'), group) |
0 | 3544 } |
3545 end | |
3546 end | |
3547 end | |
3548 end # users() | |
3549 | |
3550 # add or remove for group in groups | |
3551 for g in @sc.groups() | |
3552 next if g == group | |
3553 memv = "mem-#{g}" | |
3554 if @params[memv] | |
3555 joinp = ((/^yes/i =~ @params[memv]) && true) | |
3556 membp = (@sc.ismember(g, group) && true) | |
3557 if joinp ^ membp | |
3558 somethingdone = true | |
3559 @sc.addgroup(group, [g], !joinp) | |
3560 @O.print @H.elementln("p"){ | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3561 putLog(sprintf("%s [%s] %s %s", |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3562 msg('group'), g, |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3563 joinp ? |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3564 msg('addedtogroup') |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3565 : msg('removedfromgp'), group)) |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3566 } |
0 | 3567 end |
3568 end | |
3569 end # groups | |
47 | 3570 # Change parameter(s) |
3571 # To be more generic... | |
69
bdb7e40c2d4f
`limitsender' option to prohibit anonymous user to send to ML
HIROSE Yuuji <yuuji@gentei.org>
parents:
68
diff
changeset
|
3572 ["fromhack", "inviteonly", "limitsender"].each {|param| |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3573 parsetp = (@params[param] && /^yes/i =~ @params[param]) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3574 cursetp = (@sc.getgroupattr(group, param)!=nil) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3575 if cursetp ^ parsetp |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3576 @sc.putgroupattr(group, param, @params[param]) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3577 @O.print @H.elementln("p") { |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3578 putLog(sprintf("group: %s[%s] -> %s", |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3579 group, param, @params[param].inspect)) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3580 } |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3581 somethingdone = true |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3582 end |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3583 } |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3584 # mladdress |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3585 newmladdress = @params['mladdress'] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3586 newmladdress = nil if newmladdress == "" |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3587 curmladdress = @sc.getgroupattr(group, 'mladdress') |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3588 if newmladdress != curmladdress |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3589 defmladdress = defaultmladdress(group) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3590 @sc.putgroupattr(group, 'mladdress', newmladdress) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3591 @O.print @H.elementln("p") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3592 putLog(sprintf("group: %s[mladdress] <%s> -> <%s>", |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3593 group, |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3594 curmladdress || defmladdress, |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3595 newmladdress || defmladdress)) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3596 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3597 somethingdone = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3598 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3599 # Subject tag bracket |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3600 newtag = @params['subjtag'] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3601 if newtag == '' |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3602 newtag = nil |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3603 else |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3604 newtag = @subjtags[newtag.to_i % @subjtags.length][1] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3605 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3606 @sc.putgroupattr(group, 'subjtag', newtag) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3607 if newtag && newtag > "" |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3608 @O.print @H.elementln("p") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3609 putLog(sprintf("group: %s[subjtag] set to '%s'", group, newtag)) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3610 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3611 somethingdone = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3612 end |
0 | 3613 unless somethingdone |
3614 # @O.print @H.p(msg('nothingtodo')) | |
3615 end | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3616 # @O.print footer() |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3617 link2home |
0 | 3618 end |
3619 def newgroupsub() | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3620 return nil unless checkauth |
0 | 3621 user = @params['user'] |
3622 newgroup = @params['group'] | |
3623 newgname = @params['gname'] | |
3624 | |
3625 | |
3626 if @sc.groups.grep(newgroup)[0] | |
3627 @O.print @H.p(msg('existent')+newgroup) | |
3628 return nil | |
3629 end | |
2 | 3630 if dupl=@sc.name2group(newgname) |
3631 @O.print @H.p(sprintf(msg('dupname'), newgname)) | |
3632 @O.print groupnamesString() | |
3633 return nil | |
3634 end | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3635 @sc.creategroup(newgroup, newgname, [user]) && |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3636 putLog("New group '#{newgroup}'(#{newgname}) created\n") |
47 | 3637 admgroupsub() |
0 | 3638 end |
3639 | |
14 | 3640 # |
3641 # Methods Related to viaMail functions | |
3642 def gen_sessionpswd() | |
3643 | |
3644 end | |
3645 def viamail_registform() | |
3646 c = "# " | |
3647 nl = "\n" | |
3648 user = @params['user'] | |
3649 msg('addsched') + "-" * 20 + nl*2 + \ | |
3650 c + msg('user') + nl + \ | |
3651 "user=" + user + nl*2 + \ | |
3652 c + msg('sessionpswd') + nl + \ | |
3653 "sp=hoge" + nl*2 + \ | |
3654 c + msg('date') + nl + \ | |
3655 "date="+Time.now.strftime("%Y/%m/%d") + nl*2 + \ | |
3656 c + msg('time') + sprintf(msg('24hourtxt'), @opt['alldaydir']) + nl + \ | |
3657 "time=3000"+nl*2 + \ | |
3658 c + msg('publicp') + nl + \ | |
3659 "public=yes" + nl*2 + \ | |
3660 c + msg('neednotify') + nl + \ | |
3661 "nt10m=yes (%s) | |
3662 nttoday=yes (%s) | |
3663 nt1d=yes (%s) | |
3664 nt7d=yes (%s)" % ["10"+msg('minutes')+msg('before'), | |
3665 msg('theday'), msg('precedingday'), | |
3666 "7"+msg('days')+msg('before')] + nl*2 + \ | |
3667 | |
3668 c + msg('schedulehere') | |
3669 end | |
3670 def viamail_footer() | |
3671 viamail_registform() | |
3672 end | |
3673 def show_by_text(date, days) | |
3674 user = @params['user'] | |
3675 personal = true | |
3676 sched = dayTextString(user, date, days, personal) | |
3677 # @O.print outstr | |
3678 | |
3679 sendMail(mailaddress(user), | |
3680 "After5 Schedule", | |
3681 @opt['url'] + "\n" + \ | |
3682 Time.now.strftime("%Y/%m/%d") + \ | |
3683 sprintf(msg('schedlist'), days) + "\n\n" + \ | |
3684 if sched > '' | |
3685 sched | |
3686 else | |
3687 msg('noplan')+"\n" | |
3688 end + \ | |
3689 viamail_footer | |
3690 ) | |
3691 | |
3692 end | |
3693 def parseHeader | |
3694 contline=nil | |
3695 header=Hash.new | |
3696 text=Array.new | |
3697 | |
3698 field=nil | |
3699 # header | |
3700 while line=STDIN.gets | |
3701 text << line | |
3702 break if /^$/ =~ line | |
3703 | |
3704 if /^\s+/ =~ line | |
3705 if field | |
3706 header[field][-1] << line | |
3707 end | |
3708 else | |
3709 if /^([^:]+):\s*(.*)/ =~ line | |
3710 field=$1.downcase | |
3711 header[field] or header[field] = [] | |
3712 header[field] << $2 | |
3713 end | |
3714 end | |
3715 end | |
3716 header | |
3717 end | |
3718 def mail_regsched() | |
3719 @params = Hash.new # Reset | |
3720 | |
3721 reqparams = %w[user sp date time public] | |
3722 otherparams = %w[nt10m nttoday nt1d nt7d] | |
3723 setall = lambda{ | |
3724 reqparams.each{|key| return false unless @params.has_key?(key)} | |
3725 return true | |
3726 } | |
3727 stack = "" | |
3728 while line=gets # !setall.call && line=gets | |
3729 if /^(\S+)=(.*)/ =~ line | |
3730 next unless reqparams.index($1) || otherparams.index($1) | |
3731 @params[$1] = $2 | |
3732 #if reqparams.index($1) | |
3733 STDERR.print "Set #{$1} to #{$2}\n" | |
3734 #end | |
3735 buf = "" | |
3736 elsif /^\s*\#|^$/ =~ line | |
3737 # skip comments | |
3738 else | |
3739 buf += line | |
3740 end | |
3741 end | |
3742 unless setall.call | |
3743 STDERR.print "Insufficient variables\n" | |
3744 exit 1 | |
3745 end | |
3746 p buf | |
3747 | |
3748 y, m, d = date2ymd(@params["date"]) | |
3749 @params["year"] = y | |
3750 @params["month"] = m | |
3751 @params["day"] = d | |
3752 @params["schedule"] = buf | |
3753 @params["editmode"] = "modify" | |
3754 @params["sessionpw"] = @params["sp"] | |
3755 p @params | |
3756 add_remove() | |
3757 end | |
3758 def mail_getsched() | |
3759 user = nil | |
3760 while bline=gets | |
3761 if /(\S+@\S+)/ =~ bline | |
3762 break if user=@sc.isuser($1) | |
3763 end | |
3764 end | |
3765 unless user | |
3766 sendMail(@opt['maintainer'], "viaMail Request Error", | |
3767 "This is `#{@mybase}' in #{@mydir}\n" + | |
3768 "Invalid schedule request from #{ENV['SENDER']}.\n\n") | |
3769 exit 1 | |
3770 end | |
3771 today = Time.now.strftime("%Y/%m/%d") | |
3772 days = 7 | |
3773 if bline=gets | |
3774 if /\d+/ =~ bline | |
3775 days = bline.to_i | |
3776 end | |
3777 end | |
3778 # Send user to schedules of today and near future | |
3779 @params['user'] = user | |
3780 show_by_text(today, days) | |
3781 end | |
3782 def doMail() | |
3783 days = 7 | |
3784 # Confirm `via Mail' | |
3785 prohibitviahttp() | |
3786 @H = TEXTout.new | |
3787 unless ENV['RECIPIENT'] && ENV['SENDER'] | |
3788 STDERR.print "Call me via qmail\n" | |
3789 exit 1 | |
3790 end | |
3791 @mailmode = true | |
3792 header = parseHeader # is this necessary? | |
3793 if /regist/ =~ ENV["EXT"] | |
3794 mail_regsched() | |
3795 else | |
3796 mail_getsched() | |
3797 end | |
3798 end | |
3799 | |
3800 # | |
3801 # Password related Methos | |
0 | 3802 def setpasswd(user) |
3803 prohibitviahttp() | |
3804 pm = open_pm() | |
3805 exit 1 unless pm | |
3806 if pm.userexist?(user) then | |
3807 begin | |
3808 system "stty -echo" | |
3809 STDERR.print "New passwd: " | |
3810 p1 = STDIN.gets | |
3811 STDERR.print "\nAgain: " | |
3812 p2 = STDIN.gets | |
3813 ensure | |
3814 system "stty echo" | |
3815 end | |
3816 if (p1 == p2) then | |
3817 pm.setpasswd(user, p1.chop!) | |
3818 end | |
3819 STDERR.print "New password for #{user} set successfully\n" | |
3820 else | |
3821 STDERR.print "User #{user} not found\n" | |
3822 end | |
3823 pm.close() | |
3824 exit 0 | |
3825 end | |
3826 def adduser(user) | |
3827 prohibitviahttp() | |
3828 pm = open_pm() | |
3829 exit 1 unless pm | |
60 | 3830 if pm.userexist?(user) && !ENV['PWRESET'] |
59
595ff0134cd9
Skip creation of user which is already registered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
58
diff
changeset
|
3831 printf("User %s already exists. Skip.\n", user) |
60 | 3832 printf("If you reset passwd to new one, PWRESET=1 #{$0} ...\n") |
59
595ff0134cd9
Skip creation of user which is already registered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
58
diff
changeset
|
3833 exit 1 |
595ff0134cd9
Skip creation of user which is already registered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
58
diff
changeset
|
3834 end |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3835 email = nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3836 if /(.*@.*)=(.*@.*)/ =~ user |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3837 user, email = $1, $2 |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3838 end |
0 | 3839 newpwd = pm.setnewpasswd(user, 4) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3840 @sc.createuser(user, email) |
0 | 3841 print "#{user}'s password is #{newpwd}\n" |
3842 pm.close() | |
3843 exit 0 | |
3844 end | |
3845 def deluser(user) | |
3846 prohibitviahttp() | |
3847 pm = open_pm() | |
3848 exit 1 unless pm | |
3849 pm.delete(user) | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3850 @sc.deleteuser(user) |
0 | 3851 pm.close() |
3852 exit 0 | |
3853 end | |
3854 | |
3855 # read configuratoin file | |
3856 def readconf(conf) | |
3857 cf = "after5.cf" #conf # || @opt['conf'] | |
3858 cf = File.join(@mydir, cf) unless test(?s, cf) | |
3859 cf = File.join(ENV["HOME"], cf) unless test(?s, cf) | |
3860 return unless test(?s, cf) | |
3861 begin | |
3862 IO.foreach(cf){|line| | |
26 | 3863 line = line.toeuc |
0 | 3864 next if /^\s *#/ =~ line |
3865 line.chop! | |
3866 line.sub!(/^\s*#.*/, '') | |
3867 next if /^$/ =~ line | |
3868 case line | |
3869 # title, type = line.split(/\t+/) | |
3870 when /^([a-z]+)=(.*)/oi | |
3871 key, value = $1, $2 | |
3872 case value | |
6 | 3873 when /^(no|none|null|nil|false|0|off)$/io |
0 | 3874 @opt[key] = nil |
3875 else | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3876 @opt[key] = value.untaint |
0 | 3877 end |
3878 print "#{key} set to #{value}\n" if $DEBUG | |
3879 end | |
3880 } | |
3881 rescue | |
26 | 3882 STDERR.printf("Configuration file %s not readable\n", cf) |
0 | 3883 end |
3884 end | |
3885 | |
3886 def parsedate(string) | |
3887 if %r,^(\d\d\d\d+)/(\d+)/(\d+)/(\d+)/([^/]+)$, =~ string | |
3888 sprintf "%04d/%02d/%02d/%04d/%s", $1.to_i, $2.to_i, $3.to_i, $4.to_i, | |
3889 grepgroup($5) | |
3890 elsif %r,^(\d\d\d\d+)/(\d+)/(\d+)/(\d+), =~ string | |
3891 sprintf "%04d/%02d/%02d/%04d", $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
3892 elsif %r,^(\d\d\d\d+)/(\d+)/(\d+), =~ string | |
3893 sprintf "%04d/%02d/%02d", $1.to_i, $2.to_i, $3.to_i | |
3894 elsif %r,^(\d\d\d\d+)/(\d+), =~ string | |
3895 sprintf "%04d/%02d", $1.to_i, $2.to_i | |
3896 elsif %r,^(\d\d\d\d+)/(\d+), =~ string | |
3897 sprintf "%04d", $1.to_i | |
3898 end | |
3899 end | |
3900 | |
3901 def getarg() | |
3902 argument = {} | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3903 @oldargv = ARGV.dup |
0 | 3904 |
3905 while /^-/ =~ ARGV[0] | |
3906 case ARGV[0] | |
3907 when '-f' | |
3908 conf = ARGV[1] | |
3909 ARGV.shift | |
3910 when "-d" | |
3911 $DEBUG = true | |
3912 when "-install" | |
14 | 3913 when "-stream" |
3914 # ARGV.shift | |
3915 # @job = 'show_by_text "2005/1/18"' | |
3916 @job = 'doMail' | |
0 | 3917 when "-addsched" |
3918 @job = "addsched" | |
3919 when "-today" | |
3920 @job = "today" | |
2 | 3921 when "-today_p" |
3922 argument['displaymode'] = 'personal' | |
3923 @job = "today" | |
3924 when "-today_n" | |
3925 argument['displaymode'] = 'normal' | |
3926 @job = "today" | |
0 | 3927 when "-remove" |
3928 ARGV.shift | |
3929 @job = 'remove "'+parsedate(ARGV[0])+'"' | |
14 | 3930 when "-move" |
3931 ARGV.shift | |
3932 @job = 'move "'+parsedate(ARGV[0])+'"' | |
0 | 3933 when "-modify" |
3934 ARGV.shift | |
3935 @job = 'modify "'+parsedate(ARGV[0])+'"' | |
3936 when "-month" | |
3937 ARGV.shift | |
3938 @job = 'month "'+parsedate(ARGV[0])+'"' | |
3939 when "-show" | |
3940 ARGV.shift | |
3941 # @job = "show '"+ARGV[0]+"'" | |
3942 @job = "show '"+parsedate(ARGV[0])+"'" | |
3943 when "-login" | |
3944 @job = "login" | |
3945 when "-userman" | |
3946 @job = "userman" | |
3947 when "-usermod" | |
3948 @job = "usermod" | |
3949 when "-groupinout" | |
3950 @job = "groupinout" | |
3951 when "-groupsubmit" | |
3952 @job = "groupsubmit" | |
3953 when "-groupman" | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3954 ARGV.shift |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3955 x=ARGV[0] |
70
2e293d4d8db4
Not using proc.call for the sake of displaying document title.
HIROSE Yuuji <yuuji@gentei.org>
parents:
69
diff
changeset
|
3956 @job = "groupman("+(x ? "'#{x.dup.untaint}'" : "") + ")" |
0 | 3957 when "-groupmod" |
3958 @job = "groupmod" | |
3959 when "-notify" | |
3960 @job = 'notify' # + exit | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3961 when "-list" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3962 @job = 'list' # + exit |
0 | 3963 when "-newgroup" |
3964 @job = 'newgroup' | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3965 when /^-(admgroup|listdraft)$/ |
0 | 3966 ARGV.shift |
3967 gr = safecopy(grepgroup(ARGV[0])) | |
3968 ##gr.untaint | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3969 @job = safecopy($1)+' "'+gr+'"' |
0 | 3970 when "-admgroupsub" |
3971 @job = 'admgroupsub' | |
3972 when "-newgroupsub" | |
3973 @job = 'newgroupsub' | |
3974 when "-delusersub" | |
3975 ARGV.shift | |
6 | 3976 usr = safecopy(users().grep(ARGV[0])[0]) |
0 | 3977 @job = 'delusersub "'+usr+'"' |
3978 when "-delgroupsub" | |
3979 ARGV.shift | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3980 gr = safecopy(grepgroup(ARGV[0])) |
0 | 3981 @job = 'delgroupsub "'+gr+'"' |
3982 when /-(setpasswd|deluser|adduser)$/ | |
3983 ARGV.shift | |
3984 @job = $1+ " '#{ARGV[0]}'" # + exit | |
3985 when "" | |
3986 end | |
3987 ARGV.shift | |
3988 end | |
3989 | |
3990 readconf(@conf) | |
3991 | |
3992 query = '' | |
3993 method = ENV["REQUEST_METHOD"] | |
3994 if /POST/i =~ method then | |
3995 length = ENV["CONTENT_LENGTH"].to_i | |
3996 query = STDIN.read(length) | |
3997 elsif /GET/i =~ method then | |
3998 query = ENV["QUERY_STRING"] | |
3999 else # executed from command line | |
4000 query = ARGV.join("&") | |
4001 end | |
4002 | |
4003 for unit in query.split(/\&/) | |
4004 if /^([a-z][-_0-9@%a-z.]*)=(.*)/i =~ unit | |
4005 key, value = $1, $2 | |
4006 #value.gsub!(/%(..)/){[$1.hex].pack("c")} # これでURLデコードが一発 | |
4007 decode!(value) | |
4008 decode!(key) | |
4009 value = Kconv::toeuc(value) # EUCに変換 | |
4010 printf "[%s] = %s\n", key, value if $DEBUG | |
4011 argument[key] = value | |
4012 end | |
4013 end | |
4014 argument | |
4015 end | |
4016 def getcookie() | |
4017 cookie = {} | |
7 | 4018 return cookie unless ENV['HTTP_COOKIE'] |
4019 #if /value=(.*)/ =~ ENV['HTTP_COOKIE'] | |
4020 for cv in ENV['HTTP_COOKIE'].split(/[\; ]+/).grep(/(value|prefs)=(.*)/) | |
0 | 4021 # value=$1.gsub!(/%(..)/){[$1.hex].pack("c")} |
7 | 4022 next unless /\w+=(.*)/ =~ cv |
0 | 4023 value=decode!($1) |
7 | 4024 next unless value |
0 | 4025 for line in value.split("&") |
4026 if /(\w+)=(.*)/ =~ line | |
4027 key, value = $1, $2 | |
4028 #value.gsub!(/%(..)/){[$1.hex].pack("c")} # これでURLデコードが一発 | |
4029 decode!(value) | |
4030 value = Kconv::toeuc(value) # EUCに変換 | |
4031 printf "cookie[%s] = %s\n", key, value if $DEBUG | |
4032 cookie[key] = value | |
4033 end | |
4034 end | |
4035 end | |
4036 cookie | |
4037 end | |
4038 end | |
4039 | |
17 | 4040 $KCODE='e' if RUBY_VERSION < "1.9" |
0 | 4041 After5.new.doit |
4042 | |
4043 if __FILE__ == $0 | |
4044 end | |
4045 | |
4046 | |
4047 # Local variables: | |
4048 # buffer-file-coding-system: euc-jp | |
4049 # End: |