annotate s4-funcs.sh @ 554:0c6e28f7a7a8

s/BBS/SNS/
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 12 Apr 2019 01:31:54 +0900
parents fb9d684a93d9
children 7e7b3b2822f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1 #!/bin/sh
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2 # Here's global variable table. Do not use this names.
1
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
3 # $HGid$
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
4
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
5 [ -f s4-config.sh ] && . ./s4-config.sh
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
6
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
7 myname=`basename ${SCRIPT_NAME:-$0}`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
8 mydir=`dirname ${SCRIPT_FILENAME:-$0}`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
9 myargs="$@"
531
01b9e2b16d7a Redirect stderr to file only if being called via CGI
HIROSE Yuuji <yuuji@gentei.org>
parents: 517
diff changeset
10 test -n "$HTTP_HOST" && isCGI=true
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
11 PATH=/usr/local/sqlite3/bin:/usr/local/vim7/bin:/usr/iekei/ImageMagick/bin:/usr/local/ImageMagick/bin:$PATH
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
12 tmpdir=${TMPDIR:-tmp}
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
13 dbdir=${DBDIR:-db}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
14 tmpfiles=""
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
15 db=${DB:-$dbdir/cgi.sq3}
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
16 admin=${ADMIN:-hostmaster@example.org}
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
17 templ=${TEMPL:-templ}
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
18 layout=${LAYOUT:-$templ/default}
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
19 formdir=${FORMDIR:-$templ/form}
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
20 imgdir=${IMGDIR:-img}
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
21 url=${URL:-"${REQUEST_SCHEME:-http${HTTPS:+s}}://$HTTP_HOST$REQUEST_URI"}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
22 urlbase=${url%%\?*}
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
23 msgdir=$templ/msg
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
24 timeout="+2 days"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
25 memoplimitdays="7"
252
75dfaceac01f Link to newest article of the blog in the recent writing place
HIROSE Yuuji <yuuji@gentei.org>
parents: 251
diff changeset
26 dumpcollen=22
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
27 #thumbxy=120x120
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
28 thumbxy=96x96
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
29 iconxy_S=80x80
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
30 iconxy_M=400x400
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
31 maximagexy=1600x1600
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
32 ### maximagexy=400x400
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
33 filesize_max=$((5*1024*1024))
513
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
34 filesize_max_MB="$((filesize_max/1024/1024))MB"
209
70fa878fe3ea "accept" attribute modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 208
diff changeset
35 file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*"'
512
24a5010a131b Allow video/
HIROSE Yuuji <yuuji@gentei.org>
parents: 511
diff changeset
36 file_accept_egrep='^(text/|message/|image/|audio/|video/|application/(vnd.oasis|pdf|epub|xml|zip||[xz]-))'
513
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
37 file_accept_help="添付可能ファイル: テキスト、画像、音声、動画、ODT、PDF、
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
38 圧縮ファイル、データベースファイル
513
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
39 (いずれも ${filesize_max_MB} 以内)
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
40 "
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
41 file_warn="$file_accept_help
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
42 [編集]リンクから修正してください。"
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
43 blogreadflagrowid=0
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
44 blogcutoffflagrowid=-1
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
45 querylog=$tmpdir/query.log
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
46 searchlog=$tmpdir/search.log
207
355fcbdc3b49 Add 'file_accept'
HIROSE Yuuji <yuuji@gentei.org>
parents: 203
diff changeset
47
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
48 tconfs=""
231
332092fa437e Separate cachedir
HIROSE Yuuji <yuuji@gentei.org>
parents: 230
diff changeset
49 imgcached=cache/img.`date +%Y/%m`
4
6822f4362bf9 New system name declared as yas4
HIROSE Yuuji <yuuji@gentei.org>
parents: 3
diff changeset
50 conftbl=_tblconf
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
51 nl="
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
52 "
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
53 likeesc=`printf '\037'` # ESCAPE char of LIKE operator
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
54 iconcachekey="profimgcache_S"
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
55 case "$HTTP_USER_AGENT" in
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
56 *i[Pp]hone*|*[Aa]ndroid*) touchpanel=1 ;;
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
57 *) touchpanel="" ;;
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
58 esac
515
0b47ddf9c8de Load s4-cgi if necessary
HIROSE Yuuji <yuuji@gentei.org>
parents: 514
diff changeset
59 [ -f ./s4-cgi.sh ] && . ./s4-cgi.sh
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
60
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
61 : <<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
62
249
6bb5513efb8e Add caution comment to the beginning of description
HIROSE Yuuji <yuuji@gentei.org>
parents: 248
diff changeset
63 !! 検索等でblogテーブル参照時は sql4readableblogs() で定義される
6bb5513efb8e Add caution comment to the beginning of description
HIROSE Yuuji <yuuji@gentei.org>
parents: 248
diff changeset
64 !! readableblogs テーブルを使うこと
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
65 資料配布、グループ管理・ML、ファイル交換、クリッカー、アンケート
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
66 レポート提出管理
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
67 ひとつのarticleをheadingにして新規ツリーを作成、あるといいかも。
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
68
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
69 [2016]
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
70 7/12 根本への反省
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
71 * cgi自身の $1, $2 での切り替えでなく、CGI変数での受け渡しにすべき。
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
72 arg1/arg2/arg3 的に $1 に / 区切りでつけた方がよかったかな。
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
73
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
74 [以下2015]
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
75 8/4 ○グループに承認加入モードを追加
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
76 ○グループに参加していない場合は grpaction できない
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
77 Web
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
78 締切設定
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
79
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
80 8/2 ○s4.cgi生成系 → index.cgi生成
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
81 ○自分の提出物リスト
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
82
52
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
83 7/19 ○設置
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
84 ○一斉送信
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
85 ○getparfilename の tmpd の扱い
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
86 ○やっぱりs4にしようかな
4
6822f4362bf9 New system name declared as yas4
HIROSE Yuuji <yuuji@gentei.org>
parents: 3
diff changeset
87 7/18 ○書込著者からホームへのリンク
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
88 7/17 ○個人blogに「レポート提出用」がついたときの挙動
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
89 ○添付ファイル回収
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
90 ○imgcacheは別ディレクトリにしないと + .htaccess
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
91 7/15 ○レポート提出モードの表示を付ける
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
92 管理者権限での削除? → まだいいか
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
93
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
94 7/13 ○前回アクセス基準の新着数は欲しいなあ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
95 ○レポート提出はどうしよう
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
96 → ○blogにモードを追加:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
97 ○レポート提出モード
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
98 添付ファイル (誰が見たかログ)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
99 クリッカーは別立てメニューにしないと(管理者がON/OFF)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
100 ○添付ファイルの読み出し権(6/22から) ← モードで対処
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
101
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
102
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
103 7/9 ○管理者の追加
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
104 △グループメンバの操作 → 要不要を吟味
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
105 ○グループ情報編集の行先はそのグループがいい?
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
106 ○新規グループの作成はどこから入るか
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
107 △グループホームとユーザホームを揃える
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
108
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
109 7/8 ○グループ一覧をユーザ一覧と揃える。
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
110
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
111 7/6の次 ○グループのconf編集の入口
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
112 ○グループ検索
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
113
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
114 6/22の次 ○ホーム画面、○招待状、親記事追跡、○編集ボタン、削除ボタン、
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
115
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
116
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
117 6/7の次 ○blogを作ってみる || userconfig || _mのまとめ編集(削除)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
118 6/7の次の次 ○userconfigの画面だけ作ってみる。
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
119
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
120 ○ 5/28の次 edittableに「削除」ボタンを足す
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
121 ○6/1 par2tableを triplex 対応に
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
122 select "yuuji@gentei.org",var,"text",NULL,val from par where var in (select col from _tblconf where tbl="/user" and keytype in ('p', 's'));
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
123 →とすると 一気に
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
124
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
125 ## form.def を考えなおそう:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
126 ## userのように必須カラムを決まった位置に付ける?
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
127 ## 必須カラム、owner(foreign key passwd(name)), update datetime
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
128 ## ユーザ管理とグループ管理はデフォルトで持たせてしまえ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
129
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
130 ## 縦持ちデータの入力/編集を供給する関数 single + multi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
131 ## 持てるテーブル構造はシステム標準5種 + ユーザ定義2種類
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
132 ## 1. passwd
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
133 ## 2. grp
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
134 ## 3. grp_mem
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
135 ## 4. topic 記事のIDとなる
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
136 ## 5. topic_cont 特定IDの記事の内容物
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
137 ## 6. list 繰り返し登場あり
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
138 ## 7. hash 繰り返し登場なし
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
139
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
140 ## ● listの定義:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
141 ## create table list(id unique, parentID, type, value);
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
142 ## ● hashの定義:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
143 ## create table hash(parentID, type, value, primary key(parentID, type));
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
144
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
145 ## グループ属性: community, friend
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
146 ## ○ blob使えるのかな。streamで行けるのか? xxdで行けた。ありがたい。
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
147 ## form-defとtableは1対1対応でいいか
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
148 ## csv2sq3 で .csv.sq3 の Makefile
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
149
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
150 ## 書き込みオブジェクトとは何か?
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
151 ## topic : id, belongto, title, owner, mode
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
152 ## type := root | comment
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
153 ## topic_cont : id, topicid(F), ppath, contenttype, filename, content,
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
154 ## unique(id, filename)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
155 ## type := body(single) | attachment(multi)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
156
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
157 ## group := name(P), tag, gecos, owner(F), mode
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
158 ## tag := personal | friend | ... any string
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
159 ## group_member := gname(F), type, name(F), UNIQUE(gname, type, name)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
160 ## type := "u" | "g"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
161 ## できたー!
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
162 ## with recursive allmem as (select * from grp_mem where gname='bar' union all select grp_mem.* from grp_mem,allmem where allmem.name=grp_mem.gname) select * from allmem where type='u';
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
163
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
164 ↓以下に変更
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
165 with recursive allmem as
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
166 (select gname,val from grp_m where gname='foo'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
167 union all select grp_m.gname,grp_m.val from
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
168 grp_m,allmem where allmem.val=grp_m.gname)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
169 select val from allmem where val in (select name from user);
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
170
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
171
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
172 with recursive allmem as
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
173 (select gname,val from grp_m where gname='foo'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
174 union all select grp_m.gname,grp_m.val from grp_m,allmem
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
175 where allmem.val=grp_m.gname)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
176 select a.*, coalesce(b.val,a.val) from allmem a left join grp_mem_s b
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
177 on a.gname=b.gname and a.val=b.user and b.key='email'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
178 where a.val in (select name from user);
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
179
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
180
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
181 ## triggerもできた。
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
182 ## 5/22から:グループ作成画面
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
183 ## 埋め込み画像 data:CONTENT-TYPE;base64,.....
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
184
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
185 ## 考え得るノードタイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
186 ## 日報 - 個人所属かグループ所属か
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
187 ## 課題提出 - 個人所属かグループ所属か
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
188 ## グループ管理
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
189 ## 個人情報管理
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
190 ##
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
191
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
192 ## 例: group:sip - topic:1:sip:Aperture:yuuji:rw
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
193 ## - topic:2:sip:ISO:yuuji:rw
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
194 ## topic_cont 1:1:/:body:text...Aperture
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
195 ## 2:1:/1:body:text..Aperture
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
196 ## 3:1:/1:attachment:binary..Aperture
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
197 ## 4:1:/2:body:text..Aperture
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
198 ## 5:1:/2:attachment:binary..Aperture
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
199 ## 6:2:/:body:text..ISO
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
200 ## 7:2:/6:body:text..ISO
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
201 ## 8:2:/6:attachment:binary..
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
202
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
203 ## ログテーブル
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
204 ## time, who, action, tbl, id idなんか取れるかな
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
205
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
206
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
207
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
208 ■表設計
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
209 * 3つの表に分散管理
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
210 id格納表 + hash表 + list表
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
211 * *_s *_m
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
212
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
213
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
214
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
215 user, user_map, user_col
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
216
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
217 ■抽象エントリタイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
218 * user
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
219 idとして機能 → table中の owner に自動挿入(?)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
220 * group
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
221 権限判定に利用
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
222 * serial
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
223 自動idとして機能
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
224 * password
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
225 入力 type=passwordで入力
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
226 変更 oldpasswd, password×2 で確認後修正
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
227 * session
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
228 password認証後のセッションキーとして機能
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
229 * text
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
230 入力 type=text
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
231 * textarea
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
232 入力 textarea
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
233 * image|document
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
234 入力 type=fileで入力し、mime-typeを確認
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
235 * owner
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
236 入力時の $user で、外部キー制約が付く
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
237 * gowner
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
238 グループとしての所有者で、外部キー制約が付く
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
239 * timestamp
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
240 datetime()
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
241 * parent
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
242 木構造の場合の親の位置
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
243 * path
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
244 木構造の場合の自分の位置
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
245
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
246 格納タイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
247 * list
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
248 表 parentID, key, val でUNIQUE(parentID, key, val)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
249 * hash
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
250 表 parentID, key, val でUNIQUE(parentID, key)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
251
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
252 オブジェクトタイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
253 * entry
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
254 id, title, owner
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
255 * textpart
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
256 id, parentID, text
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
257 * binarypart
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
258 id, parentID, contenttype, filename, content
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
259 * content
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
260 hash(textpart), list(binarypart)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
261 * topic
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
262 id, hash(content), list(reply)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
263 * reply
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
264 id, parentID, content
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
265 * blog
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
266 list(entry)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
267 blog = [topic, list(reply)]
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
268
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
269
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
270 blog = [ {"title" => "hoge", "owner" => "yuuji", "date" => "2015-04-27",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
271 "text" => "hogehoge ..",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
272 "reply" => [ {"serial" => 1,
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
273 "author" => "taro",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
274 "date" => "2015-04-28",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
275 "parent" => "/",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
276 "path" => "/1",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
277 "text" => "blah, blah, ....",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
278 "image" => ["a.jpg", "b.jpg"] },
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
279 {"serial" => 2,
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
280 "author" => "hanako",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
281 "date" => "2015-04-29",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
282 "parent" => "/",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
283 "path" => "/2",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
284 "text" => "blah, blah, ....",
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
285 "image" => [] }]},
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
286 {"title" => "buha", ...} ]
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
287
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
288
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
289 user:=
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
290 ユーザ名(英数字):name:p:text:length="20" maxlength="40"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
291 パスワード:pswd:s:password:length="20" maxlength="40"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
292 説明(日本語OK):gecos:s:text:length="20" maxlength="40"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
293 セッションキー:skey:s:session
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
294 メイルアドレス:email:m:text:length="20" maxlength="40"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
295 住所:address:m:textarea:maxlength="400"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
296 プロフィール画像:profimg:m:image:maxlength="400K"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
297 履歴書:profpdf:m:document:maxlength="4M"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
298
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
299 変換表
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
300 /user/email=m
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
301
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
302 blog:=
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
303 シリアル:id:p:serial
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
304 タイトル:title:s:text:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
305 所有者:owner:s:owner:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
306 時刻:ctime:s:stamp:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
307 リード文:heading:s:textarea:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
308 リプライ:reply:m:*article:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
309
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
310 article:=
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
311 シリアル:id:p:serial
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
312 筆者:author:s:owner
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
313 時刻:ctime:s:stamp:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
314 参照元:parent:s:parent:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
315 パス:path:s:path:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
316 本文:text:s:textarea:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
317 画像:image:m:image:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
318
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
319 履歴書:profpdf:m:document:maxlength="4M"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
320
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
321
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
322 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
323
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
324 logstart() {
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
325 echo "`date '+%F %T'`:[${user:-NULL}] <<<" >> ${1:-$querylog}
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
326 }
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
327 logend() {
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
328 echo ">>>" >> ${1:-$querylog}
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
329 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
330 sq() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
331 # ./args.rb -cmd ".timeout 3000" "$@"
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
332 logstart
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
333 if [ -z "$1" ]; then
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
334 tee -a $querylog|sqlite3 -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000"
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
335 else
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
336 echo "$@" >> $querylog
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
337 sqlite3 -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000" "$@"
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
338 fi
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
339 logend
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
340 }
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
341 dbsetup() {
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
342 [ -d $tmpdir ] || mkdir -m 1777 $tmpdir
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
343 [ -d $dbdir ] || mkdir -m 1775 $dbdir
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
344 sqi=$tmpdir/sqi.$$
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
345 sqo=$tmpdir/sqo.$$
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
346 mkfifo $sqi $sqo
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
347 #tail -f $sqi | sq $db & # "tail -f" is too heavy. DO NOT USE!!
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
348 sq $db < $sqi &
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
349 sq3pid="`jobs -p` $!"
533
52cf1ec90cfa isCGI reversed
HIROSE Yuuji <yuuji@gentei.org>
parents: 532
diff changeset
350 if [ -n "$isCGI" ]; then
531
01b9e2b16d7a Redirect stderr to file only if being called via CGI
HIROSE Yuuji <yuuji@gentei.org>
parents: 517
diff changeset
351 exec 2>> $tmpdir/error.out
01b9e2b16d7a Redirect stderr to file only if being called via CGI
HIROSE Yuuji <yuuji@gentei.org>
parents: 517
diff changeset
352 fi
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
353 exec 3>> $tmpdir/debug.out
531
01b9e2b16d7a Redirect stderr to file only if being called via CGI
HIROSE Yuuji <yuuji@gentei.org>
parents: 517
diff changeset
354 exec 5> $sqi # Turning $sqi access through fd5 for continuous open state
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
355 rm $sqi
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
356 }
396
cacd961d3405 Dirty workaround for produced zombie processes
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
357 cleanup2() { # Dirty workaround for produced zombie processes
517
6cdd032070e3 $TTY not set on sh-script
HIROSE Yuuji <yuuji@gentei.org>
parents: 516
diff changeset
358 if [ -n "$HTTP_USER_AGENT" ]; then # When called from httpd
516
575e321179c3 Do not call pkill cleanup on terminal
HIROSE Yuuji <yuuji@gentei.org>
parents: 515
diff changeset
359 pkill -9 -u `id -u` -P 1
575e321179c3 Do not call pkill cleanup on terminal
HIROSE Yuuji <yuuji@gentei.org>
parents: 515
diff changeset
360 fi
396
cacd961d3405 Dirty workaround for produced zombie processes
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
361 }
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
362 cleanup() {
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 332
diff changeset
363 trap '' INT HUP EXIT TERM PIPE
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
364 echo .quit >&5
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
365 kill $sq3pid
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
366 kill $sq3pid
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
367 rm -f $sqo $sqi
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
368 rm -rf $tmpfiles
396
cacd961d3405 Dirty workaround for produced zombie processes
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
369 cleanup2
118
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
370 }
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
371 # We want to use piped function to put querylog, but we use
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
372 # simple redirection for the sake of speed.
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
373 query() {
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
374 echo ".once $sqo" >&5
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
375 logstart
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
376 if [ -z "$1" ]; then
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
377 tee -a $querylog
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
378 else
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
379 echo "$@" >> $querylog
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
380 echo "$@"
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
381 fi >&5
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
382 cat $sqo
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
383 logend
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
384 }
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
385 _m4() {
549
2a48690b8cbc Put $S4NAME in title
HIROSE Yuuji <yuuji@gentei.org>
parents: 543
diff changeset
386 #S4NAME=f,f,f
550
fb9d684a93d9 $S4NAME handling fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 549
diff changeset
387 m4 ${S4NAME:+"-D_S4NAME_=${S4NAME}"} ${S4CSS:+-D_S4CSS_="$S4CSS"} "$@"
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
388 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
389 ismember() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
390 # $1=user, $2=group
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
391 err ismem: "select user from grp_mem where gname=$(sqlquote $2) and user='$1';"
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
392 test -n "`query \"select user from grp_mem where gname=$(sqlquote \"$2\") and user='$1';\"`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
393 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
394 isuser() { # Check if $1 is a valid user
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
395 test -n "`query \"select name from user where name='$1';\"`"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
396 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
397 isgroup() { # Check if $1 is a valid group
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
398 err isgroup: "select gname from grp where gname=$(sqlquote $1);"
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
399 test -n "`query \"select gname from grp where gname=$(sqlquote \"$1\");\"`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
400 }
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
401 isgrpowner() (
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
402 # $1=user, $2=group
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
403 gn=`sqlquote "$2"`
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
404 sql="select user from grp_adm where gname=$gn and user='$1';"
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
405 err isgrpowner: $sql
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
406 test -n "`query $sql`"
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
407 )
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
408 getgroupadminmails() {
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
409 # $1=group
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
410 for i in $(getgroupadmins $1); do
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
411 email4group "$1" "$i" ;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
412 done
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
413 }
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
414 getgroupadmins() { # $1=group
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
415 # This function is called in a backquote, so needn't to be subshellized
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
416 qgrp=`sqlquote "$1"`
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
417 query "select user from grp_adm where gname=$qgrp;"
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
418 }
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
419 getgroupattr() { # $1=group $2=attr
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
420 # This function is called in a backquote, so needn't to be subshellized
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
421 getvalbyid grp $2 \
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
422 $(query "select rowid from grp where gname=`sqlquote \"$1\"`;")
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
423 }
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
424 getgroupbyid() {
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
425 # $1=id|gname
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
426 sql="select coalesce((select gname from grp where gname=$(sqlquote \"$1\")),
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
427 (select gname from grp where rowid=$(sqlquote $1)));"
71
3a157da0801d cache name fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 69
diff changeset
428 # err ggbyid: `echo $sql`
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
429 query $sql
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
430 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
431 isfilereadable() { # $1=user $2=tbl $3=rowid
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
432 # Return true if user($1) can read attachment files in tbl($2):rowid($3)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
433 [ -z "$1" -o -z "$2" -o -z "$3" ] && return 1 # invalid argument
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
434
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
435 # Return true when anonymous mode
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
436 [ "$anonymousmode" ] && return 0
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
437 # case `getvalbyid blog mode $2` in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
438 # normal|*open*|"") return 0 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
439 # *closed*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
440 # owner=`getvalbyid blog owner $2`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
441 # if isgrp $owner; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
442 # isgrpowner $1 $owner && return 0 || return 1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
443 # elif isuser $owner; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
444 # [ x"$1" = x"$owner" ] && return 0 || return 1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
445 # fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
446 # esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
447 # ↑ 要はこういう処理を↓で一気にやっている
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
448 sql="with getblog as (\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
449 select key,val from blog_s where id=(\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
450 select blogid from article where id in\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
451 (select id from $2 where rowid=$3))),\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
452 getowner as (select val from getblog where key='owner'),\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
453 getmode as (select val from getblog where key='mode')\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
454 select case\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
455 when (select author from article where\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
456 id=(select id from $2 where rowid=$3))='$1' \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
457 then 'author'\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
458 when (select val from getmode) in ('report-open', 'normal')\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
459 then 'open'\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
460 when (select val from getmode) is null \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
461 then 'open'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
462 when (select val from getowner) in (select gname from grp)\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
463 then (select user from grp_adm where \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
464 gname=(select val from getowner) and \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
465 user='$1')\
39
5ed3caba8dd1 report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents: 33
diff changeset
466 when (select author from article where\
5ed3caba8dd1 report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents: 33
diff changeset
467 id=(select id from $2 where rowid=$3))='$1'
5ed3caba8dd1 report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents: 33
diff changeset
468 then 'user+author'
5ed3caba8dd1 report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents: 33
diff changeset
469 else '' end;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
470 ## err isfilereadable: sql="`echo $sql`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
471 # caseのネストで内側のcaseがスカラーtrueを返しても外側はtrue扱いにならない
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
472 result=`query "$sql"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
473 [ -n "$result" ] && return 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
474 return 2
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
475 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
476 linkhome() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
477 # $1=UserOrGroup
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
478 echo -n '<a href="?'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
479 if isuser $1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
480 err "select 'home+'||rowid from user where name='$1';"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
481 query "select 'home+'||rowid from user where name='$1';"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
482 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
483 echo -n "grp+$1"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
484 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
485 echo "\">`gecos $1`</a>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
486 }
208
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
487 hreflink() {
284
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
488 # s4 specific notation:
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
489 # ^href=URL
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
490 # ^iframe=URL
496
18f7f10566bf Add link notation: "video=URL"
HIROSE Yuuji <yuuji@gentei.org>
parents: 495
diff changeset
491 # ^video=URL
478
926f61977175 Add experimental search keyword link like hash-tags
HIROSE Yuuji <yuuji@gentei.org>
parents: 475
diff changeset
492 # [[#NUM]] - Jump to article ID NUM
926f61977175 Add experimental search keyword link like hash-tags
HIROSE Yuuji <yuuji@gentei.org>
parents: 475
diff changeset
493 # [[#Keyword] - Jump to keywrod search for "Keyword"
284
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
494 # OSM umap Wikistyle Notation:
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
495 # [[URL]] - Simle Link
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
496 # [[URL|Word]] - Link with anchor word
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
497 # {{URL}} - <img src="URL">
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
498 # {{URL|width}} - <img src="URL" width="width">
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
499 # {{{URL}} } - <iframe src="URL"></iframe>
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
500 # {{{URL|height}} - <iframe src="URL" height="height"></iframe>
485
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
501 # Other Style
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
502 # ---- - <hr> (In the beginning of line)
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
503 # *Word* - <em>Word</em>
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
504 # _Word_ - <em>Word</em>
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
505 # **Word** - <strong>Word</strong>
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
506 # __Word__ - <strong>Word</strong>
495
59cd8278a5b5 Trailing 2 consecutive SPC will be translated to <br>
HIROSE Yuuji <yuuji@gentei.org>
parents: 494
diff changeset
507 # SPC+SPC+$ - <br>
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
508 cb='<input type="checkbox" class="s4-checkbox" disabled'
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
509 checkboxON="${cb} checked>"
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
510 checkboxOFF="${cb}>"
267
9bfa9bda1289 Add `!' to href pattern.
HIROSE Yuuji <yuuji@gentei.org>
parents: 266
diff changeset
511 _hrefptn="[-A-Za-z0-9,.:;/~_%#&+?=@!]*"
482
3dc012eb1ad0 URL pattern fixed to exclude URL example which starts with multibyte
HIROSE Yuuji <yuuji@gentei.org>
parents: 479
diff changeset
512 _hrefptn="[A-Za-z0-9/~%+?=@!.][^][()<> ]*" # URL should start with ASCII
451
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 448
diff changeset
513 sed -e "s|\[\[\#\([0-9][0-9]*\)\]\]|<a href=\"?aid\1\">#\1</a>|g" \
479
077dc1763239 Inhibit escaping required chars from hash-tag search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 478
diff changeset
514 -e "s|\[\[#\([^]&]*\)\]\]|<a href=\"?kwd=\1\&stage=searchart\">\#\1</a>|g" \
451
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 448
diff changeset
515 -e "s|\[\[\($_hrefptn\)\|\([^]]*\)\]\]|<a href=\"\1\">\2</a>|g" \
284
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
516 -e "s|\[\[\($_hrefptn\)\]\]|<a href=\"\1\">\1</a>|" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
517 -e "s|{{{\($_hrefptn\)\|\(.*\)}}}|<iframe src=\"\1\" height=\"\2\"></iframe>|g" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
518 -e "s|{{{\($_hrefptn\)}}}|<iframe src=\"\1\"></iframe>|g" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
519 -e "s|{{\($_hrefptn\)\|\(.*\)}}|<img src=\"\1\" width=\"\2\">|g" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
520 -e "s|{{\($_hrefptn\)}}|<img src=\"\1\">|g"\
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
521 -e "s|^href=\($_hrefptn\)|<a &>\1</a>|" \
425
961173fdc904 # at the beginning of the line turns to <h2>...</h2>
HIROSE Yuuji <yuuji@gentei.org>
parents: 424
diff changeset
522 -e "s|^iframe=\($_hrefptn\)|<iframe src=\"\1\"></iframe>|" \
496
18f7f10566bf Add link notation: "video=URL"
HIROSE Yuuji <yuuji@gentei.org>
parents: 495
diff changeset
523 -e "s|^video=\($_hrefptn\)|<video controls><source height=\"320\" src=\"\1\"></video>|" \
426
b3b33923638c ## at the beginning of the line turns to <h2>...</h2>
HIROSE Yuuji <yuuji@gentei.org>
parents: 425
diff changeset
524 -e "s,^#### *\(.*\),<h4>\1</h4>," \
b3b33923638c ## at the beginning of the line turns to <h2>...</h2>
HIROSE Yuuji <yuuji@gentei.org>
parents: 425
diff changeset
525 -e "s,^### *\(.*\),<h3>\1</h3>," \
483
be821d63848c Consecutive 3 or more hyphens become <hr>
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
526 -e "s,^## *\(.*\),<h2>\1</h2>," \
485
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
527 -e 's,^----*$,<hr>,' \
486
44b4a45e2617 Emphasizing pattherns like *word* should have surrounding spaces.
HIROSE Yuuji <yuuji@gentei.org>
parents: 485
diff changeset
528 -e 's, \*\*\([^* |][^*|]*[^ |]\)\*\* ,<strong>\1</strong>,g' \
44b4a45e2617 Emphasizing pattherns like *word* should have surrounding spaces.
HIROSE Yuuji <yuuji@gentei.org>
parents: 485
diff changeset
529 -e 's, __\([^_ |][^_]*[^ ]\)__ ,<strong>\1</strong>,g' \
44b4a45e2617 Emphasizing pattherns like *word* should have surrounding spaces.
HIROSE Yuuji <yuuji@gentei.org>
parents: 485
diff changeset
530 -e 's, \*\([^* |][^*|]*[^ |]\)\* ,<em>\1</em>,g' \
495
59cd8278a5b5 Trailing 2 consecutive SPC will be translated to <br>
HIROSE Yuuji <yuuji@gentei.org>
parents: 494
diff changeset
531 -e 's, _\([^_ ][^_]*[^ ]\)_ ,<em>\1</em>,g' \
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
532 -e 's, $,<br>,' \
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
533 -e "s,- \[ *\]\([^|-]*\),${checkboxOFF}<label>\\1</label>,g" \
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
534 -e "s,- \[[^ ]\]\([^|-]*\),${checkboxON}<label>\\1</label>,g" \
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
535
208
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
536 }
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
537 minitbl() {
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
538 sed -n '
295
56c2d2df5b7b minitbl() detection rule modified from /^|[^|]/ to /^|.*|/
HIROSE Yuuji <yuuji@gentei.org>
parents: 292
diff changeset
539 /^|.*|/ {; # If the line begin with "|" and has 2 or more "|"
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
540 s,|$,,; # Remove trailing "|" first
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
541 s,|\* *\([^|]*\) *,<th>\1</th>,g; # "|*..." to "<th>...</th>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
542 s,| *\([^|]*\) *,<td>\1</td>,g; # "|..." to "<td>...</td>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
543 s,^,<tr>,; s,$,</tr>,; # Enclose with "<tr>" and "</tr>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
544 H; # Concat this line to HoldSpace
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
545 s/.*//; # Delete PatternSpace for finalization
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
546 $ b cont
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
547 d; # If in final line, output the rest, else jump to next turn
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
548 }
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
549 :cont
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
550 x; # For non-"|" lines, check HoldSpace
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
551 /^./ {; # If HoldSpace has "|" table elements
398
f50d4df067b5 Workaround regexp fix for FreeBSD sed
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
552 s|^.|<table class="mini">|; # Enclose whole elements like this:
f50d4df067b5 Workaround regexp fix for FreeBSD sed
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
553 # . of ^. is workaround for FreeBSD sed
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
554 # s|$|</table>|; # <table class="mini">..\n..</table>
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
555 p; # Print whole "table" element
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
556 s/.*//; # Erase all when done.
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
557 x; s|^|</table>|; x; # Preppend /table to the next line
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
558 }
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
559 x; # Back to the newest line
489
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
560 p; # Print rest' | miniul
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
561 }
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
562 miniul() {
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
563 sed -e '
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
564 /^\* / {; # 行頭 "* "
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
565 x; s,^,<ul>,; x; # 1週目: ホールドスペース先頭に <ul> を
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
566 :top
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
567 s/\n//;
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
568 s/^ *//; # 2周目以降: 行頭空白削除
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
569 s,\* ,,; # まず行頭の "* " を消しておく
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
570 H; # 置き換え結果をホールドスペースに追加
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
571 s/.*//; # パターンスペースは消しておく
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
572 # ↓最終行なら残ったホールドスペース処理のため :cont へ
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
573 $ b cont
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
574 N; # 次の行を読む
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
575 s/\n//; # 空白始まりは継続行
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
576 /^ /b top
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
577 x; s/\n/<li>/; s,$,</li>,; # 継続行でなければ <li></li> で囲む
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
578 p; s/.*//;
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
579 x; # 次も "* " ならループを抜けない
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
580 /^\* /b top
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
581 s,^,</ul>,; # 次が一般行なら箇条書終わり
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
582 }
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
583
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
584 :cont
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
585 x; # 行頭| 以外の行:
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
586 /./ {; # ホールドスペースに文字列があれば
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
587 s/^\n/<li>/; s,$,</li></ul>,; # 箇条書を書き切って終わり
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
588 H; x
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
589 }
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
590 x'
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
591 }
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
592 acclog() (
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
593 # $1=table, $2=rowid
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
594 n=${2%%[!-0-9]*} # Remove non-digit chars from $2(should be rowid)
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
595 if [ -n "$n" ]; then
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
596 now=`date +"%F %T"`
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
597 #query "replace into acclog values('$user', '$1', '$n', '$now');"
278
2f1607d8b56b New access log schema started
HIROSE Yuuji <yuuji@gentei.org>
parents: 276
diff changeset
598 #query "replace into acclog values('$user', '$1', $n, '$now');"
2f1607d8b56b New access log schema started
HIROSE Yuuji <yuuji@gentei.org>
parents: 276
diff changeset
599 query "replace into tblaccesses values('$user', '$1', $n, '$now');"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
600 fi
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
601 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
602 gecos() (
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
603 u=`sqlquote "${1:-$user}"`
173
31e63d173d38 gecos() uses gecoses table
HIROSE Yuuji <yuuji@gentei.org>
parents: 171
diff changeset
604 query "select gecos from gecoses where name=$u;"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
605 )
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
606 setpar() {
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
607 query "replace into par values('$session', '$1', '$2', \"$3\");"
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
608 }
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
609 replpar() {
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
610 query "update par set val=\"$3\" where sessid='$session' and var='$1' and type='$2';"
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
611 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
612 getpar() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
613 val=`query "select val from par where var='$1' and sessid='$session' $2;"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
614 ## err getpar/val1: "val=[$val]"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
615 if [ -z "$val" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
616 val=`query "select val from cookie where var='$1' and sessid='$session' $2;"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
617 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
618 ## err getpar/val2: "val=[$val]"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
619 case "$var" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
620 owner)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
621 if [ x"$user" = x"$val" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
622 echo $user; return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
623 elif ismember $user $val; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
624 echo $val; return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
625 fi ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
626 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
627 ## err getpar/ret: "val=[$val]"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
628 echo "$val"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
629 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
630
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
631 getpartype() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
632 query "select type from par where var='$1' and sessid='$session' $2;"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
633 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
634 getparcount() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
635 query "select count(*) from par where var='$1' and sessid='$session' $2;"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
636 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
637 getparfilename() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
638 # null if type of $1 is not file
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
639 (f=`query "select val from par where var='$1' and sessid='$session' and type='file' $2;"`
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
640 [ -n "$f" ] && echo $f)
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
641 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
642 sqlquote() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
643 (v="$1"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
644 case "$v" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
645 "") return ;; # null
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
646 "X'"*) # quoted hex string
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
647 echo $1 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
648 *\"*) # string including dbl-quote"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
649 v=`echo "$v"|sed -e 's/\"/\"\"/g'`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
650 echo "\"$v\""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
651 return ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
652 *.*.*|*-*-*|*[Ee]*[Ee]*|[Ee]*|*[\ -,:-df-~]*) # string
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
653 echo "\"$v\""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
654 return ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
655 *)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
656 if expr "$v" : '[-0-9.Ee][-0-9.Ee]*$' >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
657 echo $v # MAYBE numeric, maybe...
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
658 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
659 echo "\"$v\""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
660 fi ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
661 esac)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
662 }
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
663 sqlquotestr() (
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
664 case "$1" in
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
665 *\'*) v=`echo "$1"| sed "s/'/''/g"`
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
666 echo "'$v'" ;;
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
667 *) echo "'$1'" ;;
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
668 esac
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
669 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
670 mktempd() {
11
3565d93c2fb1 add mpsplit.pl
HIROSE Yuuji <yuuji@gentei.org>
parents: 8
diff changeset
671 TMPDIR=$tmpd mktemp -d -t $session
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
672 }
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
673 getcachedir() { # $1=maintable
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
674 if [ -n "$imgcached" ]; then
231
332092fa437e Separate cachedir
HIROSE Yuuji <yuuji@gentei.org>
parents: 230
diff changeset
675 echo $imgcached/$(echo ${1:-hoge}|md5)/$thumbxy
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
676 else
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
677 echo $tmpd/$thumbxy
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
678 fi
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
679 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
680 getval() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
681 # $1=table $2=col $3(optional)=condition
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
682 case `gettbl_coltype "/$1/$2"` in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
683 user|author) # author added 2015-06-18 for article(author)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
684 echo "$user" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
685 stamp|datetime)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
686 date "+%F %T" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
687 serial)
218
849e6dee3485 Rewind it to use $2 instead of "serial" (getval())
HIROSE Yuuji <yuuji@gentei.org>
parents: 217
diff changeset
688 (s=`getpar $2`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
689 if [ -n "$s" ]; then echo $s; else echo "`date +%s`x$$"; fi) ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
690 *)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
691 getpar "$2" "$3";;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
692 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
693 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
694
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
695 getvalquote() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
696 # $1=table $2=col $3(optional)=condition
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
697 (v=`getval "$@"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
698 case "$v" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
699 "") echo NULL ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
700 *) sqlquote "$v" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
701 esac)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
702 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
703 getparquote() {
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
704 sqlquote "`getpar $1`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
705 }
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
706 getbinbyid() {
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
707 # $1=tbl $2=col $3=rowid $4=tmpdirForBinary
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
708
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
709 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
710 getvalbyid() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
711 # $1=tbl $2=col $3=rowid $4=tmpdirForBinary
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
712 # If two or more values found, save them to $tmpd/${column}.$N and
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
713 # store the number of files into $tmpd/${column}.count and
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
714 # their each rowid stored into $tmpd/${column}.$N.rowid.
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
715 ## err gtb-$1=`gettblcols $1`, tbl=$1, col=$2, '$3'=$3
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
716
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
717 (for c in `gettblcols $1`; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
718 if [ x"$2" = x"$c" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
719 ###sq $db "select $2 from $1 where rowid=$3"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
720 query "select $2 from $1 where rowid=$3;"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
721 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
722 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
723 done
231
332092fa437e Separate cachedir
HIROSE Yuuji <yuuji@gentei.org>
parents: 230
diff changeset
724 rowid=$3
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
725 pk=`gettblpkey $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
726 key=`query "select $pk from $1 where rowid=$3;"`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
727 getkey="(select $pk from $1 where rowid=$3)"
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
728 td=${4:-$tmpd}
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
729 [ -d $td ] || mkdir -p $td
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
730 ### err "select $pk from $1 where rowid=$3" - key=$key '$4(tmp)'=$4
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
731 for kt in s m; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
732 t=${1}_$kt
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
733 for c in `gettbl_${kt}_cols $1`; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
734 vcount=1 # count(val)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
735 if [ x"$2" = x"$c" ]; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
736 #### cond="$t where $pk=\"$key\" and key=\"$c\"" #2015-07-22
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
737 cond="$t where $pk=$getkey and key=\"$c\""
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
738 val=`query "select val from $cond limit 1;"`
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
739 type=`query "select type from $cond limit 1;"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
740 if [ $kt = m ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
741 ###vcount=`sq $db "select count(val) from $cond"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
742 # Reset val to store filenames if type is string
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
743 val=`query "select val from $cond and type like 'file:%' order by rowid;"`
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
744 err gvb1-sql: "select count(val) from $cond;"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
745 vcount=`query "select count(val) from $cond;"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
746 echo $vcount > $td/$c.count
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
747 i=0
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
748 ## err gvbid: i=$i vcount=$vcount
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
749 while [ $i -lt $vcount ]; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
750 slice="order by rowid limit 1 offset $i"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
751 i=$((i+1))
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
752 fn=$c.$i
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
753 err td=$td, fn=$fn, type=$type, val="[$val]"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
754 case $type in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
755 file:*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
756 #file=$td/$val
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
757 r_f=`query "select rowid||'//'||val from $cond $slice;"`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
758 f_rid=${r_f%%//*}
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
759 file=$td/${r_f##*//}
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
760 # FOR SPEED: Skip file generation if imgcache exists
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
761 [ -s "$file" -a -s "$td/$fn.rowid" -a -s "$file.rowid" ] \
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
762 && [ x"$f_rid" = x"`cat $td/$fn.rowid`" ] \
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
763 && continue
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
764 # err gvbid-get="select quote(bin) from $cond $slice;"
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
765 ## err output: "fn=[$fn] file=[$file]"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
766 sq $db<<EOF | unhexize > "$file"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
767 .output '$td/$fn.rowid'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
768 select rowid from $cond $slice;
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
769 .output '$td/$fn'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
770 select val from $cond $slice;
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
771 .output '$td/${fn}.content-type'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
772 select substr(type, 6) from $cond $slice;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
773 .output stdout
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
774 select quote(bin) from $cond $slice;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
775 EOF
131
9782a978d53c Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 128
diff changeset
776 ## err gvbid-get2: "`ls -lF $file`"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
777 ## err i=$i - file=$file rowid=`cat $td/$fn.rowid`
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
778 cp "$td/$fn.rowid" "$file.rowid" 2>&3 # for convenience
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
779 cp "$file" "$file.orig" 2>&3
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
780 ls -lh "$file" |
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
781 awk '{print $5"B"}'|sed 's/BB/B/' > "$file.size"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
782 case "$type" in
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
783 *:[Ii]mage*) mogrify -geometry $thumbxy "$file" ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
784 ### ここのアイコンを増やしたい
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
785 *|*:[Aa]pplication*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
786 convert -geometry $thumbxy $imgdir/file-icon.png \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
787 png:- > "$file"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
788 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
789 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
790 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
791 *)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
792 sq $db<<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
793 .output $td/$fn.rowid
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
794 select rowid from $cond $slice;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
795 .output $td/$fn
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
796 select val from $cond $slice;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
797 EOF
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
798 val=$val${val:+$nl}"`echo $fn`" # should be delimited by newline
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
799 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
800 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
801 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
802 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
803 rm -f $td/$c.count
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
804 case $type in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
805 file:*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
806 echo "$val" \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
807 | while read fn; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
808 file=$td/$fn
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
809 if [ ! -s "$file" ]; then
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
810 ## sq $db "select quote(bin) from $cond and val=\"$fn\"" \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
811 query "select quote(bin) from $cond and val=\"$fn\";" \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
812 | unhexize > "$file"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
813 ##@@## -- echo ${type#file:} > "$file.content-type"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
814 case $type in
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
815 *:[Ii]mage*) mogrify -geometry $thumbxy "$file" ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
816 *:[Aa]pplication*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
817 convert -geometry $thumbxy $imgdir/file-icon.png \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
818 png:- > $file ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
819 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
820 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
821 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
822 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
823 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
824 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
825 echo "$val" # Keep newlines by ""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
826 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
827 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
828 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
829 done)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
830 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
831 getvalbypkey() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
832 # $1=tbl $2=col $3=pkey $4=tmpdirForBinary
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
833 pk=`gettblpkey $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
834 rowid=`query "select rowid from $1 where $pk='$3';"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
835 getvalbyid "$1" "$2" $rowid $4
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
836 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
837 getvalbycond() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
838 # $1=tbl $2=col $3=SQL-Condition
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
839 ###rowid=`sq $db "select rowid from $1 where $3"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
840 rowid=`query "select rowid from $1 where $3;"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
841 if [ -n "$rowid" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
842 getvalbyid "$1" "$2" $rowid "$4"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
843 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
844 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
845 getpwfield() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
846 # getpwfield user column
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
847 # val=`sqlite3 $db "select $2 from passwd where name='$1' $3"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
848 val=`getvalbycond user $2 "name='$1'"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
849 if [ -n "$val" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
850 echo "$val"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
851 return 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
852 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
853 return 1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
854 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
855 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
856 encode() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
857 if [ -z "$sha1" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
858 if type sha1 >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
859 sha1=sha1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
860 elif type sha1sum >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
861 sha1=sha1sum
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
862 elif type gsha1sum >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
863 sha1=gsha1sum
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
864 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
865 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
866 $sha1 "$@" | cut -d' ' -f1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
867 }
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
868 enjpeg() {
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
869 if [ -z "$cjpeg" ]; then
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
870 if type cjpeg >/dev/null 2>&1; then
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
871 cjpeg="cjpeg"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
872 else
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
873 cjpeg="convert - jpeg:-"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
874 fi
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
875 fi
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
876 $cjpeg "$@"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
877 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
878 mycrypt() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
879 key=$1 salt=$2
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
880 err \$2=$2
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
881 case $2 in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
882 '$'*'$'*) salt=${salt#\$4\$}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
883 salt=${salt%\$*} ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
884 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
885 echo -n '$4$'"$salt"'$'
144
f9e8504bb8f2 Abort if encode fails
HIROSE Yuuji <yuuji@gentei.org>
parents: 143
diff changeset
886 echo "$salt$key" | encode || exit 1 # Abort if fail to call encode
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
887 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
888 hexize() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
889 if [ -z "$hexize" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
890 if type xxd >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
891 hexize="xxd -p"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
892 else
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
893 hexize_hd() {
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
894 hexdump -ve '1/1 "%.2x"'
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
895 }
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
896 hexize="hexize_hd"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
897 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
898 fi
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
899 cat "$@" | $hexize | tr -d '\n'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
900 }
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
901 unhexize() {
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
902 if [ -z "$unhex" ]; then
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
903 if type xxd >/dev/null 2>&1; then
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
904 unhex="xxd -p -r"
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
905 elif type perl >/dev/null 2>&1; then
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
906 cat >$tmpd/unhex.pl<<EOF
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
907 s/([0-9a-f]{2})/print chr hex \$1/gie
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
908 EOF
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
909 # Perl refuses -e in setuid circumstances, which can be absurdly
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
910 # avoided by creating scripts in a file where its parent directory is
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
911 # world writable...:)
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
912 unhex="perl -n $tmpd/unhex.pl"
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
913 fi
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
914 fi
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
915 cat "$@" | $unhex
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
916 # cat $1 | tee /tmp/uh.in| $unhex | tee /tmp/uh.out
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
917 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
918 percenthex() {
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
919 hexize "$@" | sed 's/\(..\)/%\1/g'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
920 }
155
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
921 htmlescape() {
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
922 sed -e 's/\&/\&amp;/g' -e 's/"/\&quot;/g' -e "s/'/\&apos;/g" \
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
923 -e "s/</\&lt;/g; s/>/\&gt;/g"
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
924 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
925 enascii() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
926 if [ -z "$enascii" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
927 if type kakasi >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
928 enascii="kakasi -Ha -Ka -Ja -Ea -ka"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
929 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
930 enascii_now=`date +%FT%T`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
931 enascii_sed() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
932 nkf -Z0Z1Z2 \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
933 | sed -e "s/^/$enascii_now/" -e "s|[^-0-9.A-z/,()_=]|x|g"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
934 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
935 enascii="enascii_sed"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
936 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
937 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
938 cat "$@" | $enascii
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
939 }
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
940 size_h() {
164
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
941 i="$1" oi=$1
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
942 set -- B B KB MB GB TB
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
943 while [ $((i)) -gt 9 -a -n "$1" ]; do # -gt 9 means $oi > 1024
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
944 oi=$i
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
945 i=$((i/1024))
164
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
946 shift
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
947 done
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
948 echo ${oi}$1
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
949 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
950 gettblconf() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
951 if [ -z "$tconfs" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
952 ## tconfs=`sq $db \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
953 tconfs=`query \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
954 "select tbl||'/'||col||'='||keytype||'/'||objtype from $conftbl;"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
955 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
956 # /tb1/col1=p/text /tb1/col2=s/text /tb1/col3=m/image /tb2/col1=p/text ...
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
957 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
958 gettblkeys() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
959 # $1=tbl
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
960 gettblconf
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
961 echo "$tconfs" | fgrep "/$1/" | \
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
962 (type="" keys="" fks="" cols="" scols="" mcols="" hcols=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
963 while IFS='=' read tc conf; do # tc=/tb1/col1 conf=s/text
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
964 col=${tc##*/} type=${conf%%/*}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
965 case $type in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
966 *p*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
967 cols=$cols"${cols:+:}$col"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
968 keys=$keys"${keys:+:}$col" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
969 *f*) cols=$cols"${cols:+:}$col"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
970 fks=$fks"${fks:+:}$col" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
971 *m*) mcols=$mcols"${mcols:+:}$col" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
972 *s*) scols=$scols"${scols:+:}$col" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
973 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
974 case $type in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
975 *h*) hcols=$hcols"${hcols:+:}$col" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
976 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
977 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
978 echo "_keys=$keys _fks=$fks _cols=$cols _scols=$scols _mcols=$mcols _hcols=$hcols")
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
979 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
980 gettblpkey() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
981 # $1=tbl
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
982 gettblkeys $1 | cut -d ' ' -f 1 | sed -e 's/.*=//' -e 's/:/ /g'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
983 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
984 gettblfkey() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
985 (x=`gettblkeys $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
986 x=${x#*_fks=} # cut before "_fks=" including
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
987 echo ${x%% *} | tr ':' ' ')
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
988 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
989 gettblcols() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
990 (x=`gettblkeys $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
991 x=${x#*_cols=} # cut before "_cols=" including
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
992 echo ${x%% *} | tr ':' ' ')
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
993 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
994 gettbl_s_cols() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
995 (x=`gettblkeys $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
996 x=${x#*_scols=} # cut before "_scols=" including
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
997 echo ${x%% *} | tr ':' ' ')
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
998 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
999 gettbl_m_cols() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1000 (x=`gettblkeys $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1001 x=${x#*_mcols=} # cut before "_mcols=" including
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1002 echo ${x%% *} | tr ':' ' ')
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1003 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1004 gettbl_h_cols() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1005 (x=`gettblkeys $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1006 x=${x#*_hcols=} # cut before "_hcols=" including
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1007 echo ${x%% *} | tr ':' ' ')
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1008 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1009 gettbl_coltype() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1010 gettblconf
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1011 x=`echo "$tconfs"|fgrep $1=`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1012 x=${x#*=} # cut before =
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1013 echo ${x#*/} # cut before p/ including
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1014 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1015 is_hidden() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1016 # $1=Tbl $2=col
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1017 gettblconf
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1018 x=`echo "$tconfs"|fgrep /$1/$2=`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1019 x=${x#*=} # cut before =
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1020 x=${x%%/*} # cut after /
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1021 case $x in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1022 *h*) return 0 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1023 *) return 1 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1024 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1025 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1026
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1027 dbsetbyid() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1028 # $1=tbl $2=id $3=col $4=val/filename - &optional - $5=content-type
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1029 (t0=$1 t=$1 p=$2 c=$3
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1030 tsc=$t/$c val=$4
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1031 quotedp=$(sqlquotestr "$p")
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1032 unset primary update
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1033 gettblconf
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1034 #err tsc=$tsc, tconfs="$tconfs"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1035 conf=`echo "$tconfs"|fgrep "$tsc"=`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1036 #err conf=$conf
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1037 case ${conf#*=} in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1038 p*) primary=1 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1039 f*) update=1 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1040 u*) ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1041 m*) t=${t}_m;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1042 s*) t=${t}_s;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1043 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1044 #err t=$t
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1045 type=string fn=""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1046 case $conf in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1047 */password)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1048 type=encoded ### val=`echo $val|encode`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1049 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1050 */image*|*/document*)
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1051 type=`file --mime-type - < "$val" | cut -d' ' -f2`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1052 bin="X'`hexize "$val"`'"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1053 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1054 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1055 pkey=`echo "$tconfs"|grep "${t0}/.*=p"|sed 1q`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1056 pkey=${pkey#/*/} # cut $tbl/
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1057 pkey=${pkey%=p/*} # cut =p/... -> primary key
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1058 if [ "$primary" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1059 nulls=`echo "$tconfs"|grep "$t/.*=[fu]/"|sed 's/^.*/, NULL/'|tr -d '\n'`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1060 ###sq $db "replace into $t values(\"$val\"$nulls)"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1061 query "replace into $t values(\"$val\"$nulls);"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1062 elif [ "$update" ]; then
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1063 query "update $1 set $c=\"$val\" where $pkey=$quotedp;"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1064 else
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1065 query "replace into $t values($quotedp, \"$c\", \"$type\", \"$val\", \"$bin\");"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1066 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1067 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1068 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1069 expire() (
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1070 at="${1:-$timeout}"
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1071 FMT="${2:-%F %T}"
6
7ccd9c2eb97e Add templates
HIROSE Yuuji <yuuji@gentei.org>
parents: 4
diff changeset
1072 TZ=GMT gdate -d "$at" +"$FMT"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1073 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1074 addsession() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1075 # expireをセット
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1076 # loginの先にどの画面に行くかの状態遷移表書式を決める
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1077 expire=`expire ${2:-"+1min"}`
309
4188f5b3fd67 Use "quier()" instead of "sq $db" at parameter setup
HIROSE Yuuji <yuuji@gentei.org>
parents: 308
diff changeset
1078 query "replace into session values('$1', '$expire');"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1079 # Remove old session parameters
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1080 now=`expire now`
309
4188f5b3fd67 Use "quier()" instead of "sq $db" at parameter setup
HIROSE Yuuji <yuuji@gentei.org>
parents: 308
diff changeset
1081 query "delete from session where expire < '$now';"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1082 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1083 gencookie() (
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1084 for kv; do
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1085 expire="`expire '' '%a, %d-%b-%Y %H:%M:%S GMT'`"
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1086 echo "Set-Cookie: $kv; expires=$expire"
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1087 done
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1088 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1089 contenttype() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1090 echo "Content-type: ${1:-text/html; charset=utf-8}"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1091 contenttype() {} # Only need to work once
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1092 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1093 putheader() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1094
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1095 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1096 putfooter() {
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1097 _m4 -D_TITLE_="${TITLE:-$myname}" $layout/footer.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1098 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1099 getcookie() (
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1100 for kv in `echo $HTTP_COOKIE|sed 's/[;, ]/ /g'`; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1101 k="${kv%%=*}"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1102 v="`echo ${kv#*=}|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1103 query "replace into cookie values('$session', '$k', 'string', \"$v\");"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1104 done
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1105 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1106 genrandom() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1107 # $1=columns (default: 10)
468
c00857f0e9d2 Avoid `+' and `=' in random string in case of being used as CGI args
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
1108 dd if=/dev/urandom count=1 2>/dev/null|nkf -MB \
c00857f0e9d2 Avoid `+' and `=' in random string in case of being used as CGI args
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
1109 | tr -d '+='|fold -w${1:-10}|sed -n 10p
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1110 }
268
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
1111 genserial() {
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
1112 echo $((($(date +%s)-1433084400)/10))c$$
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
1113 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1114 smail() {
166
32557aa9af94 $SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents: 164
diff changeset
1115 # smail rcpts subj (file)
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
1116 # $SMAIL_TO <- Recipient value of To: header
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
1117 # $MAIL_FROM <- From: header value
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
1118 from=`echo "${MAIL_FROM:-$admin}"|nkf -jM|tr -d '\n'`
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 400
diff changeset
1119 rcpt=`echo $1|tr ' ' '\n'|sort -u|tr '\n' ' '` # uniq and strip newlines
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1120 subj=`echo $2|nkf -jM|tr -d '\n'`
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
1121 (_m4 -D_RCPT_="${SMAIL_TO:-$rcpt}" -D_SUBJ_="\`$subj'" -D_FROM_="$from" $msgdir/mail-header.m4
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1122 cat $3 | nkf -jd ) | sendmail -f $admin $rcpt
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1123 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1124 setviastring() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1125 table=$1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1126 oifs="$IFS"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1127 IFS="&"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1128 for us in $2; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1129 k=${us%%=*}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1130 v="`echo ${us#*=}|tr '%+' '= '|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`"
309
4188f5b3fd67 Use "quier()" instead of "sq $db" at parameter setup
HIROSE Yuuji <yuuji@gentei.org>
parents: 308
diff changeset
1131 query "replace into $table values('$session', '$k', 'string', \"$v\");"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1132 #echo $k=$v
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1133 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1134 IFS="$oifs"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1135 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1136 checkdomain() (
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1137 # Check the validity of domain by referring DNS
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1138 item=$1
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1139 err checkdomain $1
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1140 host ${item#*@} 1>&3 2>&3
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1141 host ${item#*@} >/dev/null 2>&1
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1142 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1143 pwcheck() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1144 # $1=passwd
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1145 dbpswd=`getpwfield $user pswd`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1146 encpswd=`mycrypt "$1" "$dbpswd"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1147 ## err user=$user, pswd=$1, db=$dbpswd, enc=$encpswd
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1148 [ x"$dbpswd" = x"$encpswd" ]
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1149 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1150 mypwhash() {
540
b61881cfe57f Password string can contain blanks
HIROSE Yuuji <yuuji@gentei.org>
parents: 533
diff changeset
1151 mycrypt "`cat`" `genrandom 5`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1152 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1153 wasureta() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1154 user=$1
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1155 if ! checkdomain $user; then
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1156 contenttype; echo
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1157 _m4 -D_TITLE_='Invalid email' $layout/title-only.html
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1158 echo "ユーザ名($user)には正しいメイルアドレスが必要です。" | html p
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1159 putfooter
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1160 exit 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1161 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1162 newpswd=`genrandom` # newsalt=`genrandom 5`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1163 #encpswd=`mycrypt "$newpswd" "$newsalt"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1164 encpswd=`echo $newpswd|mypwhash`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1165 dbsetbyid user $user pswd "$encpswd"
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
1166 # Avoid $user substitution with m4, because $url comes from user input.
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1167 _m4 -D_PSWD_="$newpswd" -D_URL_="$url" -D_ADMIN_="$admin" \
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1168 $msgdir/mail-newaccount.m4 \
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
1169 | sed "s/_USER_/$user/g" \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1170 | smail $user "New Account"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1171 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1172 checkauth() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1173 user=`getpar user`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1174 skc=`getpar skey` # from cookie
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1175 [ -z "$user" ] && return 3
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1176 skey="`getpwfield $user skey`"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1177 if [ -n "$skey" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1178 if [ x"$skey" = x"$skc" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1179 return 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1180 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1181 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1182 pswd=`getpar pswd`
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1183 quser=`sqlquotestr "$user"`
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1184 dbuser=`query "SELECT name FROM user WHERE name=$quser;"`
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1185 if [ -z "$dbuser" ]; then
299
b38514180d13 Fake wasureta for invalid user
HIROSE Yuuji <yuuji@gentei.org>
parents: 298
diff changeset
1186 return 1
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1187 elif [ x"$pswd" = x"wasureta" ]; then
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1188 wasureta "$user"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1189 return 1 # wasureta error
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1190 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1191 # dbpswd="`sq $db \"select pswd from passwd where name='$user'\"`"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1192 # putheader; echo; echo user=$user, db=$dbpswd, enc=$encpswd
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1193 if pwcheck "$pswd"; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1194 newsession=`genrandom 50`
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1195 dbsetbyid user "$user" skey "$newsession"
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1196 dbsetbyid user "$user" login "`date '+%F %T'`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1197 gencookie "user=$user" "skey=$newsession"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1198 return 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1199 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1200 return 2 # Password mismatch
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1201 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1202 showlogin() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1203 args=`echo $myargs|tr ' ' '+'`
514
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1204 s4name=${S4NAME:-s4}
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1205 ( sed '/^<body/q' $layout/html.m4.html
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1206 cat $layout/login.m4.html
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1207 echo '</body></html>'
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1208 ) | _m4 \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1209 -D_BODYCLASS_="login" \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1210 -D_TITLE_="$s4name" \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1211 -D_SYSNAME_="Welcome to $s4name" \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1212 -D_MYNAME_="$myname${args+?}$args" ${S4CSS:+-D_S4CSS_="$S4CSS"}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1213 exit 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1214 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1215 dologin() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1216 checkauth
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1217 st=$?
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1218 if [ $st != 0 ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1219 contenttype; echo
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1220 _m4 -D_USER_="$user" -D_URL_="$url" -D_ADMIN_="$admin" \
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1221 $msgdir/login-fail-$st.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1222 showlogin # and EXIT
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1223 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1224 }
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1225
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1226 # Do instant jobs here
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
1227 dbsetup
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1228 trap cleanup INT HUP EXIT TERM PIPE
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
1229 # trap cleanup INT HUP
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1230
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1231 err() {
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1232 echo "$@" 1>&3
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1233 }
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1234
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1235 cgiinit() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1236 session=`date +%F-$$`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1237 tmpf=tmp/stream
11
3565d93c2fb1 add mpsplit.pl
HIROSE Yuuji <yuuji@gentei.org>
parents: 8
diff changeset
1238 tmpd=`tmpd=$tmpdir mktempd`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1239 tmpfiles=$tmpfiles" $tmpd"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1240 addsession $session
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1241 getcookie
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1242 case "$REQUEST_METHOD" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1243 get|GET) s="$QUERY_STRING" ;;
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1244 post|POST) ## dd count=$CONTENT_LENGTH bs=1 of=$tmpf 2>/dev/null #slow
137
1731efcb74c7 Add comment on dd bs=LARGE
HIROSE Yuuji <yuuji@gentei.org>
parents: 136
diff changeset
1245 ## dd bs=$CONTENT_LENGTH count=1 of=$tmpf # NOT working
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1246 # cat > $tmpf # too much?
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1247 head -c $CONTENT_LENGTH > $tmpf # safe?
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1248 (echo CL=$CONTENT_LENGTH; ls -lF $tmpf) 1>&3
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1249 s="`cat tmp/stream`"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1250 tmpfiles=$tmpfiles"${tmpfiles+ }$tmpf"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1251 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1252 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1253 case "$CONTENT_TYPE" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1254 *boundary*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1255 bndry=${CONTENT_TYPE#*boundary=}
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1256 #for us in `LC_CTYPE=C ./mpsplit.rb "$bndry" $tmpd < $tmpf`
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1257 for us in `LC_CTYPE=C ./mpsplit.pl "$bndry" $tmpd < $tmpf`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1258 do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1259 k=${us%%\=*}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1260 #echo u=$us
11
3565d93c2fb1 add mpsplit.pl
HIROSE Yuuji <yuuji@gentei.org>
parents: 8
diff changeset
1261 #v="`echo ${us#*=}|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`"
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1262 v="`echo ${us#*=}|unhexize|sed -e 's/\"/\"\"/g'`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1263 # err k=$k v=$v
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1264 case "$k" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1265 *:filename)
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1266 mimetype=`file --mime-type - < "$tmpd/$v"|cut -d' ' -f2`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1267 type='file'; k=${k%:filename}
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1268 # DO NOT ALLOW Space and '|' in file names
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1269 newv=`echo "$v"|sed 's/[ \|]/X/g'`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1270 if [ x"$v" != x"$newv" ]; then
329
e4fedb216119 Making sure whether it runs on ksh
HIROSE Yuuji <yuuji@gentei.org>
parents: 328
diff changeset
1271 :
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1272 fi
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1273 # (echo k=$k v="[$v]"; ls -lF "$tmpd/$v"; file --mime-type "$tmpd/$v") 1>&3
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1274 case "$mimetype" in
132
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1275 [Ii]mage/x-xcf)
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1276 bzip2 "$tmpd/$v"
132
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1277 v=${v}.bz2
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1278 ;;
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1279 [Ii]mage/x-*|*/vnd.*) ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1280 [Ii]mage/*)
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1281 mogrify -resize $maximagexy'>' "$tmpd/$v"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1282 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1283 esac
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1284 if ! echo "$mimetype" | egrep "$file_accept_egrep" >/dev/null 2>&1
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1285 then
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1286 replpar text string " *添付できない形式です($v)* $file_warn"
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1287 continue
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1288 elif [ `wc -c < "$tmpd/$v"` -gt "$filesize_max" ]; then
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1289 replpar text string \
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1290 " *添付ファイル($v)は${filesize_max}バイト以下にしてください* $file_warn"
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1291 continue
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1292 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1293 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1294 *)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1295 type='string'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1296 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1297 esac
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1298 #sq $db "replace into par values('$session', '$k', '$type', \"$v\")"
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1299 setpar "$k" "$type" "$v"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1300 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1301 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1302 *)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1303 setviastring par "$s"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1304 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1305 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1306 }
58
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1307 email4group() {
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1308 # Get for-$1=group email address(es) for $2...=users
58
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1309 qgrp=`sqlquote "$1"`; shift
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1310 users=`for i; do sqlquote "$i"; done`
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1311 users=`echo $users|tr ' ' ','`
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
1312 sql="select coalesce(s.val, g.user) from grp_mem g
58
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1313 left join grp_mem_s s on g.gname=s.gname and g.user=s.user
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1314 and s.key='email'
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1315 where g.gname=$qgrp and g.user in ($users);"
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
1316 query "$sql"
58
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1317 }
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1318 email4groupbyuid() {
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1319 # Get for-$1=group email address(es) for $2...=user-ids
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1320 qgrp=`sqlquote "$1"`; shift
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1321 uids=`echo "$@"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1322 uids=`echo $uids|tr ' ' ','`
240
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1323 sql="WITH
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1324 grpemails AS (
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1325 SELECT gname, user, val email
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1326 FROM grp_mem NATURAL JOIN grp_mem_s
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1327 WHERE key='email' AND gname=$qgrp),
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1328 useremails AS (
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1329 SELECT user.rowid rid, user.name, val email
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1330 FROM user
507
145fb3cca3fb User email values are in user_m, not user_s.
HIROSE Yuuji <yuuji@gentei.org>
parents: 502
diff changeset
1331 LEFT JOIN user_m
145fb3cca3fb User email values are in user_m, not user_s.
HIROSE Yuuji <yuuji@gentei.org>
parents: 502
diff changeset
1332 ON user.name=user_m.name AND user_m.key='email')
145fb3cca3fb User email values are in user_m, not user_s.
HIROSE Yuuji <yuuji@gentei.org>
parents: 502
diff changeset
1333 SELECT DISTINCT coalesce(g.email, u.email, u.name)
240
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1334 FROM useremails u LEFT JOIN grpemails g
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1335 ON u.name=g.user
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1336 WHERE u.rid in ($uids);"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1337 ## err email4gByid `echo $sql`
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1338 query "$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1339 }
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1340 collectmembersbyid() {
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1341 # Collect user names of group specified by grid
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1342 rid=${1%%[!0-9]*} # Cleaning
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1343 query "SELECT user FROM grp_mem \
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1344 WHERE gname=(SELECT gname FROM grp WHERE rowid=$rid);"
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1345 }
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1346 collectmembersbyid() {
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1347 # Collect user names of group name
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1348 qgrp=`sqlquote "$1"`
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1349 query "SELECT user FROM grp_mem WHERE gname=$qgrp;"
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1350 }
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1351 collectgecosesbyid() {
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1352 # Collect user gecoses of group
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1353 rid=${1%%[!0-9]*} # Cleaning
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1354 query<<-EOF
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1355 SELECT gecos
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1356 FROM gecoses
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1357 WHERE name IN (SELECT user FROM grp_mem
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1358 WHERE gname=(SELECT gname FROM grp WHERE rowid=$rid));
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1359 EOF
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1360 }
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1361 collectemail() (
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1362 # Collect email addresses for group $1
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1363 # If $TEAM is set, filter by team name
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1364 # If $EXCEPT is set as username(s) delimited by comma,
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1365 # remove $EXCEPT from list: ....NOT IN ($EXCEPT)
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1366 for e; do
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1367 if isuser "$e"; then
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1368 em=`query "select val from user_m where name='$e' and key='email';"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1369 [ -n "$em" ] && echo "$em" || echo "$e"
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1370 else
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
1371 qgrp=`sqlquote "$e"`
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1372 if [ -z "$TEAM" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1373 gmem="grp_mem"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1374 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1375 tm=`sqlquote "$TEAM"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1376 gmem="(SELECT gname, user FROM grp_mem_m WHERE gname='$e' AND key='team' AND val=$tm)"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1377 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1378 ex=${EXCEPT:+"AND g.user NOT IN ($EXCEPT)"}
62
5ca8f194faf2 Collect emails for group give a preference to email values in user_m.
HIROSE Yuuji <yuuji@gentei.org>
parents: 61
diff changeset
1379 sql="select coalesce(s.val,um.val,g.user) from
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1380 $gmem g left join grp_mem_s s
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1381 on g.gname=s.gname and g.user=s.user and s.key='email'
62
5ca8f194faf2 Collect emails for group give a preference to email values in user_m.
HIROSE Yuuji <yuuji@gentei.org>
parents: 61
diff changeset
1382 left join user_m um on g.user=um.name and um.key='email'
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1383 where g.gname=$qgrp $ex;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1384 ## err CollectEmail: `echo "$sql"`
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1385 query "$sql"
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1386 fi
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1387 done
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1388 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1389 sendinvitation() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1390 # $1=email
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1391 iss="invite-`date +%s`-$user"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1392 addsession $iss +${memoplimitdays}days # 1 week due date
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1393 query "replace into par values('$iss', 'invite', 'string', \"$1\");"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1394 gecos=`gecos`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1395 name=$user"${gecos:+($gecos)}"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1396 regist="$urlbase?reg+$iss"
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1397 _m4 -D_URL_="$urlbase" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1398 -D_USER_="$name" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1399 -D_EMAIL_="$1" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1400 -D_REGIST_="$regist" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1401 -D_ADMIN_="$admin" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1402 $msgdir/mail-invite.m4 \
554
0c6e28f7a7a8 s/BBS/SNS/
HIROSE Yuuji <yuuji@gentei.org>
parents: 550
diff changeset
1403 | smail $1 "SNSへの御招待"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1404 return 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1405 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1406 emaildomaincheck() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1407 case "$1" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1408 *@*@*) echo "無効なアドレスです"; return 1 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1409 *@*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1410 local=${1%@*} domain=${1#*@}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1411 if ! host $domain >/dev/null 2>&1; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1412 echo "ドメイン($domain)が見付かりません。"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1413 return 2
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1414 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1415 return 0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1416 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1417 *) echo "正しいメイルアドレスをいれてください"; return 3 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1418 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1419 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1420 invite() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1421 email=`getpar email`
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1422 case "$email" in
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1423 *@*@*|*\ *) repo="無効なアドレスです" ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1424 *@*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1425 local=${email%@*} domain=${email#*@}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1426 if ! repo=`emaildomaincheck $email`; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1427 repo="招待アドレスのエラー: $repo"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1428 elif [ -n "`query \"select * from user where name='$email';\"`" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1429 repo="$email さんは既に加入しています。"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1430 elif sendinvitation $email; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1431 repo="アドレス($email)宛に案内を送信しました。"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1432 fi ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1433 "") repo="招待したい人のメイルアドレスを入力してください。" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1434 *) repo="無効なアドレスです" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1435 esac
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1436 addr=`query "select val from par where sessid like 'invite-%-$user';"`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1437 if [ -n "$addr" ]; then
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1438 susp="<h2>招待済みで加入待ちのアドレス</h2><pre>$addr</pre>"
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1439 fi
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1440 _m4 -D_TITLE_="招待" -D_REPORT_="\`$repo'" -D_ACTION_="?invite" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1441 -D_BODYCLASS_="default" -D_SUSPENDED_="$susp" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1442 $layout/html.m4.html $layout/invite.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1443 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1444 regist() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1445 # $1=session-id-for-invitation
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1446 _m4 -D_TITLE_="Invitation" $layout/html.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1447 if [ -z "$1" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1448 echo "bye bye" | html p
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1449 reutrn
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1450 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1451 email=`session=$1 getpar invite`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1452 if [ -z "$email" ];then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1453 cat<<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1454 <p>無効な招待状チケットです。</p>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1455 <p>招待状の有効期限(1週間)が切れているか、チケット番号が異なっています。
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1456 加入している人に、再度招待してもらいましょう。</p>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1457 EOF
65
HIROSE Yuuji <yuuji@gentei.org>
parents: 62
diff changeset
1458 return
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1459 fi
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1460 echo "$email さんようこそ" | html h2
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1461 query "replace into user values('$email');"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1462 # Fake login password to wasureta
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1463 query "replace into par values('$session', 'pswd', 'string', 'wasureta'),
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1464 ('$session', 'user', 'string', '$email');"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1465 wasureta $email
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1466 echo "このアドレスに初期パスワードを送信しました。" |html p
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1467 echo "新着メイルを確認してログインしてください。" |html p
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1468 addsession $1 # for removal after 1 minute
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1469 _m4 -D_SYSNAME_="Initial Login" -D_MYNAME_="$myname?userconf" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1470 $layout/login.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1471 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1472 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1473 group_safename() {
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1474 # Convert $1 to safe group name
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1475 echo "$1" | tr -d '"'"'",
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1476 }
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1477 groupupdate() {
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1478 gname=`getpar gname`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
1479 qgname=`sqlquote "$gname"`
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1480 if [ -n "$gname" ]; then
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1481 # See ALSO same job in showgroup()
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1482 newgname=`group_safename "$gname"`
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1483 err newgname=$newgname
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1484 if [ x"$newgname" != x"$gname" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1485 err NewGNAME: gname=$newgname
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1486 gname=$newgname
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1487 echo "使用禁止文字を除去し $gname としました。" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1488 replpar gname string "$gname"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1489 fi
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1490 # Name confliction check
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1491 parow=`getpar rowid`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1492 ## err parow=$parow
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
1493 qgname=`sqlquote "$gname"` # Set again in case gname modified
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1494 query "BEGIN EXCLUSIVE;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1495 ## err "select count(gname) from grp where rowid != ${parow:-0} and gname = $qgname;"
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1496 count=$(query "select count(gname) from grp where rowid != ${parow:-0} and gname = $qgname;")
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1497 if [ $count -gt 0 ]; then
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1498 echo "そのグループ名は既にあります。" | html p
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1499 query "END;"
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1500 return
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1501 fi
123
718abe22a5d1 Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents: 122
diff changeset
1502 par2table $formdir/grp.def
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1503 query "END TRANSACTION;"
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
1504 # Remove orphan
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1505 : <<EOF
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1506 select a.id,b.val from (select * from blog where id in
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1507 (select id from blog_s where key='owner'
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1508 and val not in (select name from user union select gname from grp)))
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1509 a left join blog_s b on a.id=b.id and b.key='owner';
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1510 EOF
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1511 rm=`getpar rm` cfm=`getpar confirm`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1512 ## err groupupdate:::: after par2tbl rmcfm=$rm$cfm
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1513 if [ x"$rm$cfm" = x"yesyes" ]; then
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1514 if [ -z "`query \"select gname from grp where gname=$qgname;\"`" ]; then
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1515 sql="delete from blog where id in
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1516 (select id from blog_s where key='owner' and val=$qgname);"
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1517 err rm-grp cleaning sql=`echo $sql`
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1518 query "$sql";
307
e7a7f6cb9627 When removing a group, switch to grp-list and return
HIROSE Yuuji <yuuji@gentei.org>
parents: 306
diff changeset
1519 grps # When removing a group, switch to grp-list
e7a7f6cb9627 When removing a group, switch to grp-list and return
HIROSE Yuuji <yuuji@gentei.org>
parents: 306
diff changeset
1520 return # and return
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1521 fi
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1522 fi
305
e751156de740 Do not add email address to grp_mem_s at new group creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 302
diff changeset
1523 [ -z "$parow" ] && joingrp "$gname" "$user" yes "" as-admin
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1524 fi
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1525 sql="select rowid from grp where gname=$qgname;"
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1526 grid=$(query $sql)
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1527 ## err grpupdate:new-grid=$grid, sql=$sql
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1528 grp $grid
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1529 }
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1530 groupclone() {
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1531 # $1=grp-rowid of clone-base group
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1532 qgrp=`query "SELECT quote(gname) FROM grp WHERE rowid=$1;"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1533 if [ -z "$qgrp" ]; then
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1534 echo "無効なグループIDです($1)" | html p
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1535 return
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1536 fi
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1537 i=0
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1538 while true; do
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1539 copy="-copy$i"
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1540 newqname=`query "SELECT quote($qgrp || '$copy');"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1541 # err Trying new grp=$newqname with copy=$copy
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1542 test=`query "SELECT gname FROM grp WHERE gname=$newqname;"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1543 if [ -n "$test" ]; then
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1544 i=$((i++))
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1545 continue
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1546 fi
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1547 break
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1548 done
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1549 # Creating New group "$newqname" with members of old group
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1550 # err Creating new grp=$newqname with copy=$copy
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1551 query<<-EOF
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1552 BEGIN;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1553 INSERT INTO grp VALUES($newqname); -- Create NEW one
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1554 REPLACE INTO grp_s(gname, key, val) -- Copy tag
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1555 SELECT $newqname, key, val
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1556 FROM grp_s WHERE gname=$qgrp AND key IN ('tag', 'mode');
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1557 REPLACE INTO grp_s(gname, key, type, val) -- Copy gecos with "copy$n"
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1558 SELECT $newqname, key, type, val || '$copy'
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1559 FROM grp_s WHERE gname=$qgrp AND key='gecos';
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1560 -- Copy members and their configuration --
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1561 REPLACE INTO grp_mem SELECT $newqname, user
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1562 FROM grp_mem WHERE gname=$qgrp;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1563 REPLACE INTO grp_mem_s SELECT $newqname, user, key, type, val, bin
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1564 FROM grp_mem_s WHERE gname=$qgrp;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1565 REPLACE INTO grp_mem_m SELECT $newqname, user, key, type, val, bin
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1566 FROM grp_mem_m WHERE gname=$qgrp;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1567 -- Copy administrators --
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1568 REPLACE INTO grp_adm SELECT $newqname, user
383
93ba4a8f3398 Oops, grp_adm should not be copied from grp_mem
HIROSE Yuuji <yuuji@gentei.org>
parents: 382
diff changeset
1569 FROM grp_adm WHERE gname=$qgrp;
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1570 COMMIT;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1571 EOF
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1572 newrowid=`query "SELECT rowid FROM grp WHERE gname=$newqname;"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1573 STOPCLONEMSG=1 groupconf "$newrowid"
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1574 }
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1575 groupman() {
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1576 note="<p>グループ名に使用できない文字は自動的に削除されます。</p>"
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1577
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1578 GF_STAGE="grpconf"
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1579 GF_STAGE=groupupdate
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1580 DT_VIEW=grp dumptable html grp 'gname gecos:DESC mtime:TIME' 'order by b.TIME desc' \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1581 |_m4 -D_TITLE_="グループ作成" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1582 -D_FORM_="$note`genform $formdir/grp.def`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1583 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1584 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1585 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1586 userconf() {
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1587 [ -n "`getpar rowid`" ] && par2table $formdir/user.def
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1588 _m4 -D_BODYCLASS_=userconf -D_TITLE_="ユーザ情報編集" $layout/html.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1589 GF_ACTION="?home" edittable "$formdir/user.def" "user" "$user"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1590 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1591 groupconf() {
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1592 # $1=rowid in grp (2015-07-21 changed from gname)
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1593 [ -n "`getpar rowid`" ] && par2table $formdir/grp.def
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1594 _m4 -D_BODYCLASS_=groupconf -D_TITLE_="グループ情報編集" $layout/html.m4.html
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1595 #rowid=`query "select rowid from grp where gname='$1';"`
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1596 rowid=${1%%[!A-Z0-9a-z_]*}
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1597 # GF_ACTION="?grp+$1" edittable "$formdir/grp.def" "grp" "$rowid" #2015-0804
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1598 GF_STAGE="groupupdate" edittable "$formdir/grp.def" "grp" "$rowid"
384
305381d205bb Shring anchored portion of link to groupclone()
HIROSE Yuuji <yuuji@gentei.org>
parents: 383
diff changeset
1599 if [ -z "$STOPCLONEMSG" ]; then
305381d205bb Shring anchored portion of link to groupclone()
HIROSE Yuuji <yuuji@gentei.org>
parents: 383
diff changeset
1600 echo "同じ構成員で新規グループ<a href=\"?groupclone+$rowid\">作成</a>" \
305381d205bb Shring anchored portion of link to groupclone()
HIROSE Yuuji <yuuji@gentei.org>
parents: 383
diff changeset
1601 | html p
305381d205bb Shring anchored portion of link to groupclone()
HIROSE Yuuji <yuuji@gentei.org>
parents: 383
diff changeset
1602 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1603 }
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1604 mems() {
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1605 _m4 -D_TITLE_="参加者一覧" -D_BODYCLASS_=listmember $layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1606 kwd=`getpar kwd`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1607 listmember $kwd
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1608 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1609 grps() {
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1610 _m4 -D_TITLE_="グループ一覧" -D_BODYCLASS_=listgroup $layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1611 kwd=`getpar kwd`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1612 listgroup $kwd \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1613 | _m4 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1614 -D_TITLE_="グループ関連操作" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1615 -D_FORM_="<a href=\"?groupman\">新規グループ作成</a>" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1616 $layout/form+dump.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1617 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1618 grp() { # $1=group-rowid
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1619 gpg=`getpar grp`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1620 grid=${1:-$gpg}
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1621 grp=`getgroupbyid "$grid"`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1622 ## . ./s4-blog.sh
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1623 jg=`getpar joingrp`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1624 if [ -n "$jg" ]; then
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1625 [ -n "$jg" -a -n "$grp" ] &&
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1626 joingrp "$grp" "$user" "$jg" "`getpar email`"
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1627 fi
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
1628 htmlheader=$layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1629 showgroup "$grid"
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1630 }
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1631 sql4interestblogs() {
177
1adafaf079a0 remove debug code
HIROSE Yuuji <yuuji@gentei.org>
parents: 176
diff changeset
1632 cat<<EOF
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1633 CREATE TEMPORARY VIEW interestblogs AS
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1634 SELECT blog.rowid rid, id, author
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1635 FROM blog
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1636 NATURAL JOIN
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1637 (SELECT id, val owner FROM blog_s WHERE key='owner') bs
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1638 WHERE CASE WHEN (SELECT name FROM user where name=bs.owner) IS NOT NULL
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1639 THEN 1 -- blog owner is an user, READABLE
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1640 WHEN (SELECT user FROM grp_mem
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1641 WHERE gname=bs.owner AND user='$user') IS NULL
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1642 THEN 0
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1643 ELSE 1
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1644 END;
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1645 EOF
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1646 }
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1647 listnewblogsql() { # $1=user
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1648 deftime=`query "SELECT coalesce((SELECT max(time) FROM acclog
345
8134b548b385 Taking default access time broken, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 343
diff changeset
1649 WHERE user='$user'
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1650 AND tblrowid IN
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1651 ($blogreadflagrowid,
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1652 $blogcutoffflagrowid)),
345
8134b548b385 Taking default access time broken, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 343
diff changeset
1653 "0");"`
392
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
1654 cat<<EOF
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1655 `sql4interestblogs`
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1656 WITH article_ctime as (
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1657 SELECT id,blogid,author,max(val) ctime
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1658 FROM article join article_s s using(id)
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1659 WHERE s.key='ctime' AND s.val > '$deftime'
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1660 GROUP BY id
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1661 ), blog_title_owner as (
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1662 SELECT blg.rid brid, id,
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1663 max(case key when 'title' then val end) title,
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1664 max(case key when 'owner' then val end) owner
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1665 FROM interestblogs blg, blog_s using(id) group by id
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1666 ), blogall as (
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1667 SELECT * FROM blog_title_owner b JOIN article_ctime ac ON b.id=ac.blogid
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1668 ), news as (
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1669 SELECT brid, bl.id blid, bl.title, ctime,
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1670 coalesce(al.time, '$deftime') atime,
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1671 count(bl.id) "新着", bl.author
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1672 FROM blogall bl
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1673 LEFT JOIN
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1674 (SELECT * FROM acclog WHERE user='$user' AND tbl='blog') al
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1675 ON bl.brid=al.tblrowid
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1676 WHERE atime < bl.ctime
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1677 GROUP by bl.id ORDER BY ctime desc,"新着" desc, bl.id
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1678 LIMIT 10
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1679 ) SELECT brid LINK, "新着",
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1680 (SELECT count(*) FROM article WHERE blogid=blid) "総数",
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1681 ctime, title,
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1682 (SELECT gecos FROM gecoses WHERE name=author) gecos
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
1683 FROM news;
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1684 EOF
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1685 }
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1686
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1687 search_form() {
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
1688 # $1 = { author=<AUTHOR> | grp=<GROUP> }
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
1689 # $2(optional) = pre-input keywords
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 300
diff changeset
1690 help="(1)空白区切りの単語で本文検索
302
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
1691 (2)@YYYY-MM-DD 日付け(シェルパターン可)で日付け検索
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
1692 @2016-0[1-6] → 2016年1月から6月
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
1693 @>2016-01 @<2016-02-15 → 2016年1月から2月14日までの期間
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
1694 @week → 最近一週間
302
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
1695 (3)#番号 で記事ID検索
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
1696 (1)と(2)は組み合わせOK
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
1697 例: @2016-10-0[1-9] 芋煮
445
12548e1a4ff8 Add comment about quiz board exclusion from search
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1698 → 2016年10月上旬でキーワード「芋煮」を含む記事検索
12548e1a4ff8 Add comment about quiz board exclusion from search
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1699 ※クイズ板は検索対象から外されます。"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1700 auth=""
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1701 placeholder="全記事からの検索"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1702 case "$1" in
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1703 author=*)
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1704 a=`echo "${1#author=}"|htmlescape`
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1705 g=`gecos ${1#author=}`
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1706 auth="<input type=\"hidden\" name=\"author\" value=\"$a\">"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1707 placeholder="このユーザの書込検索"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1708 help="★★ $g さんの書き込みから検索します$nl$help"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1709 ;;
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1710 grp=*)
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1711 a=`echo "${1#grp=}"|htmlescape`
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1712 g=`gecos ${1#grp=}`
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1713 auth="<input type=\"hidden\" name=\"owner\" value=\"$a\">"
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1714 placeholder="このグループからの検索"
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1715 ;;
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1716 esac
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
1717 inikwd="$2" # no need to htmlescape
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1718 cat<<-EOF
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
1719 <div class="right">
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1720 <form action="$myname">$auth
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
1721 <input type="text" name="kwd" value="$inikwd" title="$help"
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
1722 placeholder=" $placeholder " width="10" accesskey="k">
509
d34b8f36501c Progressive search does not restrict author
HIROSE Yuuji <yuuji@gentei.org>
parents: 508
diff changeset
1723 <!-- POST SENTENCE -->
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
1724 ${touchpanel:+<p class="help">$help</p>}
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1725 <input type="hidden" name="stage" value="searchart">
509
d34b8f36501c Progressive search does not restrict author
HIROSE Yuuji <yuuji@gentei.org>
parents: 508
diff changeset
1726 <!-- EOF -->
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1727 </form>
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1728 </div>
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1729 EOF
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1730 }
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1731
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1732 imgsrc_cache() (
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1733 # $1 = directory for cache'ing
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1734 # $2 = table (user_m or grp_m)
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1735 # $3 = keycond (was: condition for choosingowner)
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1736 # $4 = size : S = Small, M = Medium, O = Original
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1737 dir="$1" tbl="$2"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1738 keycond="$3"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1739 whos="$keycond AND key='profimg' AND type LIKE 'file:image%'
327
5e56160ad1f5 Use the last profimg as profile image instead of first one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
1740 ORDER BY rowid DESC LIMIT 1"
332
9dc6f9e60f6a Quote file names. Select last profimg in listentry.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
1741 [ -d "$dir" ] || mkdir -p "$dir"
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1742 tmpf=$tmpd/imgsrc_cache.$$
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1743 case "$4" in
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1744 [Ss]) size=S ;;
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1745 [Oo]) size=O ;;
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1746 *) size=M ;;
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1747 esac
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1748 # ImageCache filename storing schema:
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1749 # <table_s>.{key, val}={"profimgcache_S", "$cacheimg_S"}
312
b8a8e627b376 Remove debugging code. Stay revealed profile image rows.
HIROSE Yuuji <yuuji@gentei.org>
parents: 311
diff changeset
1750 sql0="SELECT val || '//' || type FROM $tbl WHERE $whos;"
b8a8e627b376 Remove debugging code. Stay revealed profile image rows.
HIROSE Yuuji <yuuji@gentei.org>
parents: 311
diff changeset
1751 sql1="SELECT hex(bin) FROM $tbl WHERE $whos;"
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1752 valtype=`query "$sql0"`
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1753 filename=${valtype%%//*}
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1754 filetype=${valtype##*//file:}
339
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
1755 if [ x"$filename" = x"${filename%.*}" ]; then
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
1756 # If nor filename extension found, set it to image type
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
1757 case "$filetype" in
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
1758 image/*) filename=$filename.${filetype#image/} ;;
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
1759 esac
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
1760 fi
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1761 cacheimg_S=$dir/S_$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1762 cacheimg_M=$dir/M_$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1763 cacheimg_O=$dir/$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1764 cacheimg=$dir/${size}_$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1765 sumfile="$dir/$filename.sum"
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1766 sum=`query "$sql1" | tee $tmpf | encode` # encode() is maybe sha1
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1767 if test -s "$sumfile" && [ x"`cat \"$sumfile\"`" = x"$sum" ] \
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1768 && test -s "$cacheimg_S" && test -s "$cacheimg_M" ; then
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1769 # if cache is fresh and has the same checksum,
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1770 echo "<img src=\"$cacheimg\">"
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1771 else
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1772 fifo=`mktemp "$tmpf.fifo.XXXXXXX"`
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1773 rm -f $fifo # Safe, because $tmpf is in mktemp dir.
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1774 fifo2=$fifo.2
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1775 mkfifo $fifo $fifo2
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1776 fmt=${filename##*.}
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1777 ## [[ NOTE ]]
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1778 ## a. convert oldimage newimage
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1779 ## b. convert oldimage fmt:- | convert - newimage
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1780 ## b is much smaller than a
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1781 cat $tmpf | unhexize \
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1782 | tee $fifo \
392
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
1783 | convert -define ${fmt}:size=${iconxy_M} \
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
1784 -resize ${iconxy_M}'>' - ${fmt}:- \
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1785 | tee $fifo2 \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1786 | convert - "$cacheimg_M" &
392
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
1787 cat $fifo | convert -define ${fmt}:size=${iconxy_S} \
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
1788 -resize ${iconxy_S}'>' - ${fmt}:- \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1789 | convert - "$cacheimg_S" &
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1790 printf '%s' "<img src=\"data:${filetype},"
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
1791 hexize "$fifo2" |sed 's/\(..\)/%\1/g' # Use medium as pre-cached image
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1792 echo '">'
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1793 echo "$sum" > $sumfile
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1794 fi
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1795 ## Now preparing cache image, done.
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1796 ## Store this information to DB
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1797 stbl=${tbl%_m}_s # user_s or grp_s
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1798 pkey=${keycond%%=*} # Primary Key name
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1799 pval=${keycond#*=} # Primary Key value
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1800 query <<-EOF
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1801 REPLACE INTO $stbl($pkey, key, type, val)
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1802 VALUES($pval, '$iconcachekey', 'string', `sqlquote "$cacheimg_S"`);
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1803 EOF
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1804 )
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1805
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1806 showhome() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1807 # $1=userRowIdToShow
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1808 err showhome \$1=$1
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1809 case "$1" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1810 *@*) uname=`getvalbypkey user name "$1"` ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1811 *) uname=`getvalbyid user name $1` ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1812 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1813 ## err ShowHome: uname=$uname
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1814 td=`getcachedir home/"$1"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1815 gecos=`gecos "$uname"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1816 ## err SH:gecos=$gecos
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1817 GF_VIEWONLY=1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1818 cond="gname in (select gname from grp_mem where user='$uname')"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1819 search_form_args=""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1820 if [ x"$user" = x"$uname" ]; then
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
1821 usermenu="<a href=\"?userconf\" accesskey=\"e\"
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 340
diff changeset
1822 title=\"E\">プロフィールの編集</a> /
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 340
diff changeset
1823 <a href=\"?blog\" accesskey=\"n\" title=\"N\">新規話題の作成</a>"
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1824 # Display folders
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1825 sql="select count(id) from article_m where id
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1826 in (select id from article where author='$user')
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1827 and type like 'file:%';"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1828 ## err nfile-sql=`echo "$sql"`
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1829 nfile=`query "$sql"`
312
b8a8e627b376 Remove debugging code. Stay revealed profile image rows.
HIROSE Yuuji <yuuji@gentei.org>
parents: 311
diff changeset
1830 # err nfile=$nfile
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1831 if [ $nfile -gt 0 ]; then
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
1832 usermenu="$usermenu / <a href=\"?lsmyfile\" accesskey=\"l\"
342
385b3174d265 Accesskey batting resolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
1833 title=\"L\">過去の提出ファイル</a>"
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
1834 fi
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1835 else
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
1836 latestlog=`query "SELECT max(time) FROM acclog WHERE user='$uname' \
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
1837 GROUP BY user;"`
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
1838 usermenu="<p>Last seen on $latestlog</p>"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
1839 search_form_args="author=$uname"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1840 fi
17
01f579d2c889 Rename to s4
HIROSE Yuuji <yuuji@gentei.org>
parents: 16
diff changeset
1841 . ./s4-blog.sh
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1842
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
1843 tf=$tmpd/title.$$ pf=$tmpd/profile.$$ bf=$tmpd/blogs.$$ sf=$tmpd/search.$$
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
1844 search_form "$search_form_args" > $sf
549
2a48690b8cbc Put $S4NAME in title
HIROSE Yuuji <yuuji@gentei.org>
parents: 543
diff changeset
1845 printf "%s さん" "$gecos" > $tf
319
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
1846 { echo "<div class=\"noprofimg\">"
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
1847 viewtable $formdir/user.def user $1
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
1848 echo "</div>"
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
1849 } > $pf
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
1850
147
HIROSE Yuuji <yuuji@gentei.org>
parents: 146
diff changeset
1851 sqcond="WHERE name='$uname' AND key='profimg' AND type LIKE 'file:image%'"
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
1852 img=`query "SELECT type FROM user_m $sqcond LIMIT 1;"`
148
afc3bf5c9dbb profimg should be saved in $tmpd
HIROSE Yuuji <yuuji@gentei.org>
parents: 147
diff changeset
1853 imf=$tmpd/profimg.$$; touch $imf
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
1854 if [ -n "$img" ]; then
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1855 if true; then
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1856 tbl=user_m
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1857 enticond="name='$uname'"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1858 imgsrc_cache "$td/main" user_m "$enticond" M
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1859 else
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1860 { printf '%s' "<IMG src=\"data:${img#file:},"
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1861 query "SELECT hex(bin) FROM user_m $sqcond ORDER BY rowid LIMIT 1;" \
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1862 | sed 's/\(..\)/%\1/g'
151
7bb7086ea0d0 Unclosed tag, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 150
diff changeset
1863 echo '">'
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1864 }
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
1865 fi > $imf
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
1866 fi
150
6ee08d8b0f5f Display the number of blogs of the user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 149
diff changeset
1867 nblog=`query "SELECT count(id) FROM blog_s WHERE key='owner' AND \
6ee08d8b0f5f Display the number of blogs of the user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 149
diff changeset
1868 val='$uname';"`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1869 listblog $uname > $bf
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1870
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1871 hometail=$tmpd/tail.$$
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1872 mkfifo $hometail
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1873
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1874 #Calling listgroupbytable, originally here
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1875
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1876 (
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1877 # Display Most Recent Entry
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1878 shortval=${dumpcollen:+"substr(val, 0, $dumpcollen)"}
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1879 shortval=${shortval:-val}
252
75dfaceac01f Link to newest article of the blog in the recent writing place
HIROSE Yuuji <yuuji@gentei.org>
parents: 251
diff changeset
1880
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
1881 # The m.aid in the next line is suspicious. But works fine in SQLite3...
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1882 DT_SQL="SELECT b.rowid || '#' || m.aid LINK,
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1883 ctime,
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1884 (SELECT $shortval FROM blog_s WHERE key='title' AND id=b.id) title,
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1885 (SELECT gecos FROM gecoses
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1886 WHERE name=(SELECT val FROM blog_s
257
5d0dbbf9310c Show text in the table of recent writing articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 255
diff changeset
1887 WHERE key='owner' AND id=b.id)) owner,
5d0dbbf9310c Show text in the table of recent writing articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 255
diff changeset
1888 (SELECT $shortval val FROM article_s WHERE id=m.aid AND key='text') text
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1889 FROM blog b
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1890 JOIN
254
8a0cf46afb0a Revise SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 253
diff changeset
1891 (SELECT distinct blogid, a.id aid, max(val) ctime
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1892 FROM article a, article_s s
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1893 ON a.id=s.id AND a.author='$uname' AND s.key='ctime'
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1894 GROUP BY blogid ORDER BY val DESC LIMIT 50
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1895 ) m
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1896 ON b.id=m.blogid;"
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1897 # This should be as follows
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1898 : <<EOF
255
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1899 WITH arts AS(
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1900 SELECT (SELECT rowid FROM blog WHERE id=a.blogid) brid,
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1901 a.blogid, a.id id, s.val ctime
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1902 FROM article a NATURAL JOIN article_s s
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1903 WHERE s.key = 'ctime' AND a.author='$user'
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1904 GROUP by s.id
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1905 )
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1906 SELECT a0.brid,a0.blogid,a0.id,a0.ctime
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1907 FROM arts a0
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1908 JOIN
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1909 (SELECT blogid,max(ctime) mct FROM arts a1 GROUP BY blogid) a1
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1910 ON a0.blogid=a1.blogid AND a0.ctime=a1.mct
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1911 ORDER BY ctime DESC LIMIT 50;
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
1912 EOF
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
1913
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1914 cat<<-EOF
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
1915 `cgi_radio foldtabs yes 'id="mre" accesskey="d"'`<label
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 340
diff changeset
1916 for="mre" title="D">最近の書き込み先</label>
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1917 <div class="lcto">
194
b1847cc3912a Display Most Recent Entry of user's
HIROSE Yuuji <yuuji@gentei.org>
parents: 187
diff changeset
1918 `DT_VIEW=replyblog dumptable html blog`
b1847cc3912a Display Most Recent Entry of user's
HIROSE Yuuji <yuuji@gentei.org>
parents: 187
diff changeset
1919 </div>
b1847cc3912a Display Most Recent Entry of user's
HIROSE Yuuji <yuuji@gentei.org>
parents: 187
diff changeset
1920 EOF
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1921 unset DT_SQL
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1922 if [ x"$user" = x"$uname" ]; then
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1923 # Display NEWS
351
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1924 # 2016-06-26
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1925 if [ x"`getpar readchk``getpar read`" = x"yesyes" ]; then
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1926 acclog blog $blogreadflagrowid
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1927 # echo "全部既読にしました" | html p
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
1928 fi
351
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1929 # 2016-02-19 Counting NEWS without using dumptable.
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1930 sql=`listnewblogsql "$user"`
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1931 # echo "$sql" > tmp/listnew
351
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
1932 new10=`DT_SQL="$sql" DT_VIEW=replyblog dumptable html blog`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1933 cont=`echo "$new10"|grep "^<TR>"|wc -l`
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1934 cont=$((cont-1))
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1935 err newcount=$cont
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1936 if [ $cont -gt 0 ]; then
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1937 #echo "全体の新着記事${cont}傑" | html h2
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
1938 cgi_radio foldtabs yes 'id="new10" accesskey="f"'
428
2e32349c4dd6 "NEWS" Tab's indicator should be "F", not "X"
HIROSE Yuuji <yuuji@gentei.org>
parents: 426
diff changeset
1939 echo "<label for=\"new10\" title=\"F\">新着${cont}傑</label><div>"
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
1940 cat<<-EOF | html form 'action="?home"'
262
f7939f4297d4 Rewrote a cgi variable by mistake, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 260
diff changeset
1941 `cgi_checkbox readchk yes 'id="read"'`<label
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
1942 for="read">新着ふくめて全部読んだことにする</label>
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1943 `cgi_submit '確定'`
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
1944 `cgi_hidden read yes`
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
1945 EOF
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1946 echo "$new10 <!-- new10 -->"
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1947 echo "</div>"
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1948 else # If news is 0, set log cut off flag
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
1949 acclog blog $blogcutoffflagrowid # for speed
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1950 fi
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
1951 else # Not My Home ($user != $uname)
329
e4fedb216119 Making sure whether it runs on ksh
HIROSE Yuuji <yuuji@gentei.org>
parents: 328
diff changeset
1952 : # DT_SQL=
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1953 fi
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1954 ) > $hometail & # Is background call safe to m4??
128
42234d2d6e9c Add Full-Range search
HIROSE Yuuji <yuuji@gentei.org>
parents: 127
diff changeset
1955 #
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1956 listgroupbytable $formdir/grp.def $cond |
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1957 _m4 -D_BODYCLASS_=home -D_TITLE_="spaste(\`$tf')" \
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
1958 -D_PROFILE_="spaste(\`$pf')$usermenu" \
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1959 -D_PROFIMG_="spaste(\`$imf')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1960 -D_BLOGS_="spaste(\`$bf')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1961 -D_SEARCH_="spaste(\`$sf')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1962 -D_NBLOG_="$nblog" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1963 -D_GROUPS_="syscmd(\`cat')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1964 -D_HOMETAIL_="syscmd(\`cat $hometail')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1965 $layout/html.m4.html $layout/home.m4.html
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
1966
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1967 # Record access log
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1968 [ -n "$1" ] && [ x"$1" != x"$user" ] && acclog user $1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1969 }
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1970 commission() { # $1=grp-rowid $2=user-rowid
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1971 contenttype; echo
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1972 ## err commission: "$@"
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1973 gname=`getgroupbyid $1`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1974 echo "グループ $gname 管理者委任" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1975 | _m4 -D_TITLE_="syscmd(\`cat')" $layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1976 if [ -n "$2" ]; then
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1977 grp_reg_adm "$@"
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1978 else
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1979 echo "無効な指定です。普通のアクセスならここに来ないはず。"|html p
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1980 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1981 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1982 listgroupbytable() {
52
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
1983 # $1=deffile $2...=condition
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1984 tagline=`grep :tag: $1`; shift
52
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
1985 and="${1:+and }" where=${1:+where }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1986 href="<a href=\"$myname?grp+"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1987 echo '<div class="listgroup">'
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1988 NGsql="select distinct tag from\
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1989 (select gname, max(case key when 'tag' then val end) as tag, \
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1990 max(case key when 'ctime' then val end) as ctime\
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1991 from grp_s group by gname order by ctime);"
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1992 sql="select val from grp_s where key='tag' $and$* group by val;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1993 ## err ListGRP: query sql="$sql"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1994 for tag in `query "$sql"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1995 do
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1996 ## err ListGrp: tag=$tag
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1997 tn=${tagline%%=${tag}*}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1998 tn=${tn##*[ :]}
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1999 sql="select rowid||':'||gname as 'グループ名',説明 from
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2000 (select (select rowid from grp g where g.gname=grp_s.gname)
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2001 as rowid,
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2002 gname,
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2003 max(case key when 'gecos' then val end) as '説明',
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2004 max(case key when 'tag' then val end) as 'tag',
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2005 max(case key when 'mtime' then val end) as mtime from grp_s
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2006 $where$* group by gname having tag='$tag' order by mtime desc);"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2007 ## err PersonalGroupList= `echo $sql`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2008 echo "<h2>$tn</h2>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2009 echo '<table class="b listgroup">'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2010 sq -header -html $db "$sql" \
494
6906c140431a Fix pattern: Allow spaces for group name in group listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 492
diff changeset
2011 | sed "s,\(<TR><TD>\)\([0-9]*\):\([^<]*\)</TD>,\1$href\2\">\3</a>,"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2012 echo '</table>'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2013 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2014 echo '</div>'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2015 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2016 iconhref() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2017 # $1=icon-file, $2=Href $3=title $4...=anchor
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
2018 data=`percenthex "$1"`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
2019 ct=`file --mime-type - < "$1"|cut -d' ' -f2`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2020 ## err iconhref: \$1=$1 \$2=$2 \$3="$@"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2021 href=$2; title=$3; shift 3
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2022 echo "<a href=\"$href\"><img title=\"$title\" src=\"data:$ct,$data\">$@</a>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2023 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2024 iconhref2() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2025 # $1=icon-file, $2=Href $3=title $4...=anchor
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2026 src=$1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2027 href=$2; title=$3; shift 3
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2028 echo "<a href=\"$href\"><img title=\"$title\" src=\"$src\">$@</a>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2029 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2030 listentry() (
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2031 # $1=user/group $2=SearchKeyword $3=condition(if any) $4=grprowid(if in grp)
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2032 # Referring variable $iamowner=$grp to attach owner-request links
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2033 ## err listentry: \$1=$1 \$2=$2 \$3=$3
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2034 cond='' hiddens=''
447
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2035 offset=`getpar offset`; offset=${offset%%[!0-9]*}
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2036 if [ -z "$offset" ]; then
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2037 offset=`getpar start`; offset=${offset%%[!0-9]*}
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2038 offset=$((offset-1))
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2039 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2040 offset=$((offset + 0)) # change to numeric forcibly
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2041 [ $offset -lt 0 ] && offset=0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2042 limit=30
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
2043 dir=`getcachedir "$1"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2044 if [ x"$1" = x"user" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2045 hrb="$myname?home"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2046 deficon=person-default.png
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2047 entity="ユーザ" tbl=user link=rowid nm=name # stage=mems
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2048 [ -n "$4" ] && hiddens=`cgi_hidden grid $4`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2049 gcs=gecos
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2050 else # if group
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2051 hrb="$myname?grp"
22
9951e231df30 Add default group icon
HIROSE Yuuji <yuuji@gentei.org>
parents: 17
diff changeset
2052 deficon=group-default.png
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
2053 entity="グループ" tbl=grp link=rowid nm=gname stage=grps
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2054 gcs=name
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2055 tagline=`grep :tag: $formdir/grp.def|cut -d: -f5-`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2056 if [ -n "$tagline" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2057 tagconv=`echo $tagline|sed 's/\([^= :]*\)=\([^= :]*\)/-D\2=\1/g'`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2058 ## err tagconv=$tagconv
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2059 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2060 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2061 if [ ! -d $dir ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2062 mkdir -p $dir
131
9782a978d53c Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 128
diff changeset
2063 fi
9782a978d53c Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 128
diff changeset
2064 if [ ! -s $dir/$deficon ]; then
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2065 convert -geometry $thumbxy $imgdir/$deficon $dir/$deficon
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2066 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2067 if [ -n "$2" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2068 cond="where nick like '%$2%' or b.name like '%$2%'"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2069 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2070
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2071 # XX: これ複雑すぎるかな。もっとシンプルにしたい。$3条件も。2015-07-08
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2072 # grpは呼出し元の動的スコープ変数でよくないな...
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2073 ##qgrp=`sqlquote $grp`
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2074 getgrp="(select gname from grp where rowid=${rowid:--1})"
220
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2075 sql="select a.rowid, a.$link,
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2076 coalesce(b.$gcs, a.$nm) as nick,
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2077 quote(a.$nm) as qname,
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2078 (SELECT val FROM ${tbl}_s
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2079 WHERE $nm=a.$nm AND key='$iconcachekey') icon,
220
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2080 coalesce(b.gecos, a.$nm) /* If group, concat (Nusers) */
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2081 || case when a.$nm in (select gname from grp)
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2082 then printf('(%d名)',
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2083 (select count(user) from grp_mem where gname=a.$nm))
233
1ad7ef38c0a0 Display gecos correctly in listentry(user)
HIROSE Yuuji <yuuji@gentei.org>
parents: 232
diff changeset
2084 else ' <'||a.$nm||'>'
220
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2085 end
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2086 as name,
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2087 b.tag,
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2088 case when a.$nm in (select user from grp_adm
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
2089 where gname=$getgrp) then '(管理者)'
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2090 when '$user' in (select user from grp_adm where gname=a.$nm)
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2091 then '(ADMIN)'
171
cdade692e17d Add "is-member" flag to group list
HIROSE Yuuji <yuuji@gentei.org>
parents: 166
diff changeset
2092 when '$user' in (select user from grp_mem where gname=a.$nm)
cdade692e17d Add "is-member" flag to group list
HIROSE Yuuji <yuuji@gentei.org>
parents: 166
diff changeset
2093 then '(Member)'
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2094 when '$iamowner' = '' then ''
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2095 else ',not='||a.rowid end as ownerlink,
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2096 CASE '$entity'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2097 WHEN 'グループ'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2098 THEN coalesce(
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2099 (SELECT val FROM grp_s WHERE gname=a.$nm AND key='regmode'),
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2100 'open')
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2101 ||
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2102 CASE WHEN '$user'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2103 IN (SELECT user FROM grp_mem WHERE gname=a.$nm)
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2104 THEN ' ismember'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2105 ELSE ''
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2106 END
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2107 ELSE 'user'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2108 END regmode
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2109 from $tbl a left join
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2110 (select $nm as name,
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2111 max(case key when 'gecos' then val end) as gecos,
297
8933d3701c00 Newer edited group has more precedence of sorting in group list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 295
diff changeset
2112 max(case key when 'tag' then val end) as tag,
387
2c928bb47c90 Sort condition missing
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
2113 max(case key when 'mtime' then val end) as mtime,
475
c01081811298 typo of SQL statement
HIROSE Yuuji <yuuji@gentei.org>
parents: 474
diff changeset
2114 max(case key when 'wtime' then val end) as wtime,
474
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2115 max(case key when 'login' then val end) as login
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2116 from ${tbl}_s group by $nm)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2117 b on a.$nm=b.name $cond $3
474
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2118 order by b.wtime desc, b.login desc,
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2119 b.mtime desc, b.tag desc, a.rowid asc"
297
8933d3701c00 Newer edited group has more precedence of sorting in group list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 295
diff changeset
2120 # Give precedence to newer maintained groups (2016-09-24)
8933d3701c00 Newer edited group has more precedence of sorting in group list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 295
diff changeset
2121 # Note that mtime is stored only in grp_s.
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2122 ## err LE:sql.1="$sql"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2123 total=`query "with x as ($sql) select count(*) from x;"`
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2124 echo "${entity} 一覧" | html h2
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2125 if [ $total -gt $limit ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2126 echo '<div class="right">'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2127 cgi_form $stage <<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2128 <label>次の語を含む${entity}で検索:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2129 `cgi_text kwd $kwd`</label>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2130 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2131 echo '</div>'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2132 fi
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2133 hiddens="$hiddens
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2134 `cgi_hidden kwd \"$kwd\"`
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2135 `cgi_hidden stage \"$stage\"`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2136 cat<<EOF
447
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2137 <form action="$myname" method="POST">
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2138 <p>${total}件中の<input class="hidesub" type="text" name="start"
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2139 value="$((offset+1))" size="3">件めから${kwd:+" - 検索語: $kwd"}$hiddens
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2140 <input type="submit" value="確定"></p>
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2141 </form>
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2142 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2143 if [ $((offset+limit)) -lt $total ]; then
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2144 nextbtn=$(
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2145 cat<<EOF
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2146 <div class="right clear"><form action="$myname" method="POST">
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2147 `cgi_submit 次の${limit}件`
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2148 $hiddens
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2149 `cgi_hidden offset $((offset + limit))`</form></div>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2150 EOF
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2151 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2152 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2153 if [ $offset -gt 0 ]; then
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2154 prevbtn=$(
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2155 cat<<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2156 <form action="$myname" method="POST">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2157 `cgi_submit 前の${limit}件`
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2158 $hiddens
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2159 `cgi_hidden offset $((offset - limit))`</form>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2160 EOF
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2161 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2162 fi
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2163 pnbtn="$nextbtn$prevbtn"
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2164 echo $pnbtn
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2165
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2166 ## err ListEntry: `echo "$sql"\;`
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2167 # sq $db here??? 2016-11-28
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2168 query "$sql limit $limit ${offset:+offset $offset};" \
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2169 | while IFS='|' read id lnk name qname icon gecos tag ownerp type; do
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
2170 err name=$name owner=$ownerp lnk=$lnk
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2171 err newlnk=$lnk regmode=$regmode
230
67c8b9558572 Allow duplicated file names in icon.
HIROSE Yuuji <yuuji@gentei.org>
parents: 229
diff changeset
2172 icondir=$dir/$id
332
9dc6f9e60f6a Quote file names. Select last profimg in listentry.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
2173 # Pick up only last icon
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2174 echo "<div class=\"iconlist xy$thumbxy $type\">
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2175 <p class=\"tag _$tag\">$tag</p>" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2176 | _m4 $tagconv
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2177 if [ -n "$NOSPEEDUP" ]; then
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2178 files=`getvalbyid $tbl profimg $id $icondir`
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2179 if [ -n "$files" ]; then
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2180 icon=`echo "$files"|tail -1`
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2181 iconhref2 "$icondir/$icon" "$hrb+$lnk" "$gecos"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2182 else
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2183 iconhref "$dir/$deficon" "$hrb+$lnk" "$gecos"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2184 fi
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2185 elif [ -n "$icon" -a -s "$icon" ]; then
474
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2186 iconhref2 "$icon" "$hrb+$lnk" "$gecos<br>$mt"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2187 else
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2188 cond="$nm=$qname"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2189 # err imgsrc_cache "$dir/list" ${tbl}_m "$cond" S
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2190 # err query "SELECT type FROM ${tbl}_m $cond LIMIT 1;"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2191 img=`query "SELECT type FROM ${tbl}_m WHERE $cond AND key='profimg' LIMIT 1;"`
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2192 # err "img=[$img]"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2193 if [ -n "$img" ]; then
390
5a40f38d7daf Do not forget link to home
HIROSE Yuuji <yuuji@gentei.org>
parents: 388
diff changeset
2194 echo "<a href=\"$hrb+$lnk\">"
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2195 imgsrc_cache "$icondir" ${tbl}_m "$nm=$qname" S
390
5a40f38d7daf Do not forget link to home
HIROSE Yuuji <yuuji@gentei.org>
parents: 388
diff changeset
2196 echo "</a>"
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2197 else
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2198 iconhref2 "$dir/$deficon" "$hrb+$lnk" "$gecos"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2199 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2200 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2201 echo "<br>$name${ownerp:+<br>$ownerp}"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2202 echo "</div>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2203 done
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2204 echo ${pnbtn:+"<hr>$nextbtn$prevbtn"}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2205 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2206 listmember() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2207 listentry user "$@"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2208 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2209 listgroup() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2210 listentry group "$@"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2211 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2212 hexteams() { # $1=gname, $2(optional)=user
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2213 cond=${2:+" AND user='$2'"}
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2214 query "SELECT DISTINCT hex(val) FROM grp_mem_m
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2215 WHERE gname='$1' AND key='team'$cond;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2216 }
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2217 showgroup() { # $1=group-rowid
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2218 if [ -z "$1" ]; then
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2219 grid=`getpar grid`
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2220 grid=${grid%%[!0-9]*}
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2221 [ -n "$grid" ] && grp=`getgroupbyid $grid`
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2222 else
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2223 grid=$1
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2224 fi
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2225 grp=`getgroupbyid $grid`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2226 qgrp=`sqlquote "$grp"`
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2227 ## err showgroup2: grid=$grid grp=$grp qgrp="[$qgrp]"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2228 if isgroup "$grp"; then
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2229 tf=$tmpd/title.$$
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2230 sf=$tmpd/search.$$
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2231 bodyclass=`query "SELECT val FROM grp_s
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2232 WHERE gname=$qgrp AND key='regmode';"`
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2233 if ismember "$user" "$grp"; then
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2234 ismember="ismember"
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2235 qgrp=`sqlquote "$grp"`
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2236 bodyclass="$bodyclass${bodyclass:+ }ismember"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2237 else
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2238 ismember="" # bodyclass="group"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2239 fi
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2240 bodyclass="$bodyclass grouphome"
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2241 echo "<div class=\"search\">`search_form grp=\"$grp\"`</div>"> $sf
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2242 echo "グループ $grp" > $tf
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2243
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2244 showgroupsub $formdir/grp.def "$grid" | \
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2245 _m4 -D_TITLE_="syscmd(\`cat $tf')" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2246 -D_FORM_="syscmd(\`cat')" \
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2247 -D_BODYCLASS_="$bodyclass" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2248 -D_DUMPTABLE_="" \
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2249 $htmlheader $sf $layout/form+dump.m4.html
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2250 # $htmlheader $layout/form+dump.m4.html
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2251 # $htmlheader is defined in grp()
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2252 else # if $grp is removed at par2table
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2253 listgroup
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2254 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2255 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2256 showgroupsub() {
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2257 # $1=def-file $2=group-rowid
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2258 # Using $ismember
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2259 rowid=$2
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2260 grp=`getgroupbyid $2`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2261 qgrp=`sqlquote "$grp"`
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2262 td=`getcachedir grp/"$2"`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2263 #rowid=`sq $db "select rowid from grp where gname=$qgrp"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2264 if [ -z "$rowid" ]; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2265 #rowid=`sq $db "select rowid from grp where rowid=$grp"`
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2266 #grp=`sq $db "select gname from grp where rowid=$grp"`
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2267 echo "showgroupsub: invalid argument($1 $2)" | html p
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2268 return
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2269 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2270 val=`getvalbyid grp profimg $rowid $tmpd`
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2271 enticond="gname=$qgrp"
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2272 img=`query "SELECT type FROM grp_m WHERE $enticond LIMIT 1;"`
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2273 if [ -n "$img" ]; then
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2274 cat<<-EOF
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2275 <p class="groupimg">
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2276 `imgsrc_cache $td/main grp_m "$enticond" M`</p>
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2277 EOF
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2278 fi
319
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2279 echo "<div class=\"noprofimg\">"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2280 viewtable $1 grp $rowid
319
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2281 echo "</div>"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2282 if isgrpowner "$user" "$grp"; then
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
2283 echo "<p><a href=\"?groupconf+$rowid\">グループ情報の編集</a>"
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2284 iamowner=$rowid
371
302eae8f723b Display blog-mode only when user is group owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 370
diff changeset
2285 colmd=" mode"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2286 fi
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2287 if [ -n "$ismember" ]; then
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2288 echo "${iamowner:+ / }<a href=\"?blog+$rowid\">グループの新規話題作成</a>"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2289 echo "/ <a href=\"?grpaction+$rowid\">メンバーを個別選択しての操作</a></p>"
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2290 # div.fold input[type="checkbox"]:checked ~ div {display: block;}
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2291 cat<<EOF
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2292 <form action="?send2mem" method="POST" enctype="multipart/form-data">
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2293 <div class="fold clear">
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2294 `cgi_checkbox send yes id="send"`<label
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2295 for="send">グループ全員にメッセージ送信</label>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2296 <div>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2297 `cgi_textarea message "" "cols=60"`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2298 `cgi_submit 送信`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2299 `cgi_reset リセット`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2300 </div>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2301 `cgi_hidden grp $rowid`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2302 </div></form>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2303 EOF
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2304 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2305 # 加入ボタン + 加入者リスト
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2306 if [ -n "$ismember" ]; then
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2307 ismem='checked' state="(参加中)"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2308 else
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2309 nomem='checked' state="(現在非加入)"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2310 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2311 # このグループでの加入アドレス
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2312 eml=`query "select val from grp_mem_s where gname=$qgrp and user='$user' \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2313 and key='email';"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2314 ##err EML: "select val from grp_mem_s where gname='$2' and user='$user' \
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2315 ## and key='email';"
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2316 ##err email=$eml
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2317 cat <<EOF
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2318 <div class="fold clear">
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2319 `cgi_checkbox reg yes id="reg"`<label
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2320 for="reg">自身の加入状態を操作する</label>$state
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2321 <div>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2322 EOF
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2323 cgi_form grp <<EOF
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2324 <p>このグループに</p>
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2325 <table class="b">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2326 <tr><th>メンバーとして</th><td>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2327 <label>`cgi_radio joingrp "yes" $ismem`参加</label> /
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2328 <label>`cgi_radio joingrp "no" $nomem`参加しない</label></td></tr>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2329 <tr><th>参加する場合のメイルアドレス<br>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2330 <small>(メインのアドレスとは違うものにする場合に記入<br>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2331 同じでよい場合は空欄に)</small></th>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2332 <td>`cgi_text email $eml`</td></tr>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2333 </table>
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2334 `cgi_hidden grp $rowid`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2335 EOF
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2336 if [ x`getgroupattr $grp regmode` = x'moderated' -a -z "$ismem" ]; then
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2337 echo "moderated (承認加入の)グループなので実際に参加できるのは
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2338 グループ管理者が承認操作をした後になります。" | html p 'class="warn"'
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2339 fi
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2340 echo '</div></div>'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2341 echo '<h2>話題一覧</h2>'
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2342 thelp="1ヶ月分のまとめには上部検索窓に @month と入れてください。"
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2343 cat<<-EOF
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2344 <form class="summary" action="$myname" title="$thelp">
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2345 `cgi_hidden owner "$grp"`
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2346 `cgi_hidden kwd "@week"`
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2347 `cgi_hidden stage searchart`
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2348 `cgi_submit "一週間のまとめ"`
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2349 </form>
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2350 EOF
60
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
2351 cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by ctime desc"
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
2352 colstate="state:稼動状態:frozen=rowclass=凍結"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2353 DT_CHLD=article:blogid \
371
302eae8f723b Display blog-mode only when user is group owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 370
diff changeset
2354 DT_VIEW=replyblog dumptable html blog \
438
bd72a82f0a9c In group home table, move team field after heading followed by notify.
HIROSE Yuuji <yuuji@gentei.org>
parents: 437
diff changeset
2355 "ctime title heading team notify:通知$colmd $colstate" "$cond"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2356
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2357 getgname="(select gname from grp where rowid=$rowid)"
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2358 c="group by a.name having a.name in (select user from grp_mem where gname=$getgname)"
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2359 cm="?commission+$rowid"
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2360 thumbxy=50x50 listmember "" "$c" "$rowid" \
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2361 |sed -e "s|\(<br>\),not=\(.*\)|\1|" # 間違って押しやすい
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2362 # team list
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2363 hexteams=`hexteams "$grp"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2364 if [ -n "$hexteams" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2365 echo "チーム一覧" | html h2
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2366 echo '<div class="dumptable"><table class="b">'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2367 sq $db -html -header<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2368 SELECT val TEAM,
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2369 group_concat((SELECT gecos FROM gecoses WHERE name=user), ',')
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2370 MEMBERS
224
5ac0684fc3ac correction from debug code
HIROSE Yuuji <yuuji@gentei.org>
parents: 223
diff changeset
2371 FROM grp_mem_m WHERE gname=$qgrp AND key='team' GROUP BY val;
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2372 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2373 echo '</table></div>'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2374 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2375 }
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2376 grp_getbodyclass() {
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2377 # Get css class name for document.
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2378 # `moderated' for moderated groups
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2379 # `ismember' for groups where user belongs
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2380 # $1=GroupName (w/o quote)
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2381 # $user=userNameCurrentlyLogin
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2382 ## err grp_getbodyclass: 1="$1"
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2383 qgrp=`sqlquote "$1"`
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2384 query<<-EOF
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2385 SELECT coalesce(
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2386 (SELECT val FROM grp_s WHERE gname=$qgrp AND key='regmode'),
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2387 'open')
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2388 ||
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2389 CASE WHEN '$user'
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2390 IN (SELECT user FROM grp_mem WHERE gname=$qgrp)
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2391 THEN ' ismember'
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2392 ELSE ''
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2393 END;
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2394 EOF
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2395 }
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2396 grpaction() { # $1=group-rowid
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2397 err GRP_ACTION:IN
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2398 grid=${1:-`getpar grp`}
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2399 grp=`getgroupbyid "$grid"`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2400 if [ -z "$grp" ]; then
118
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
2401 echo "無効な指定です。" | html p; return
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
2402 fi
433
03ced2f9f271 Quote group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 431
diff changeset
2403 if ! ismember $user "$grp"; then
118
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
2404 echo "加入者のみに許可された操作です。" | html p; return
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2405 fi
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2406 echo "グループ $grp 個別選択操作" \
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2407 | _m4 -D_TITLE_="syscmd(\`cat')" \
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2408 -D_BODYCLASS_="`grp_getbodyclass \"$grp\"`" \
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2409 $layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2410
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2411 isowner=""
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2412 isgrpowner "$user" "$grp" && isowner="yes"
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2413 usel=`getpar usel`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2414 if [ -n "$usel" ]; then
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2415 uids=$(echo `echo $usel`|tr ' ' ',')
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2416 ## err grpaction-1: grp=$grp, `echo $sql`
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2417 text=`getpar text`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2418
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2419 rm=`getpar rm` cfm=`getpar confirm`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2420 ## err rm=$rm cfm=$cfm
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2421 if [ x"$rm" = x"yes" ]; then
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2422 if [ "$isowner" ]; then
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2423 if [ x"$rm$cfm" = x"yesyes" ]; then
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2424 # Eliminate
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2425 cond="where gname=(select gname from grp where rowid=$grid) and user in (select name from user where rowid in ($uids))"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2426 for tbl in grp_mem grp_mem_s grp_mem_m; do
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2427 sql="delete from $tbl $cond;"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2428 # echo "sql=$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2429 query "$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2430 err rmGRPuser "$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2431 done
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2432 num=`query "select count(*) from user where rowid in ($uids);"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2433 #err num=$num
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2434 if [ 0$num -gt 0 ]; then
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2435 sql="select coalesce(b.val,a.name) from user a left join \
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2436 user_s b on a.name=b.name and key='gecos' where a.rowid in ($uids);"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2437 # err `echo "$sql"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2438 html pre<<EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2439 以下の${num}名のグループ $grp 登録を解除しました。
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2440 `query "$sql"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2441 EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2442 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2443 else
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2444 echo "確認のチェックがないのでやめておきます。" | html p
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2445 return
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2446 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2447 else # not Group Owner
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2448 echo "グループ管理者でないのでメンバー操作はできません。" | html p
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2449 return
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2450 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2451 cat<<EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2452
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2453 EOF
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2454 elif [ x"$rm" = x"send" ]; then # if sendmsg mode
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2455 if [ -z "$text" ]; then # if msg is empty
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2456 echo "なにかメッセージを..." | html p
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2457 return 0
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2458 fi
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2459 gecos=`gecos $user`
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2460 mkfrom=`getpar mkfrom`
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2461 if [ x"$mkfrom" = x"yes" ]; then
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2462 safegc=`echo "$gecos" | tr -d '<>@'`
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2463 myuid=`query "SELECT rowid FROM user WHERE name='$user';"`
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2464 fromad=`email4groupbyuid "$grp" "$myuid"`
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2465 mail_from="$safegc <$fromad>"
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2466 else
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2467 mail_from="$admin"
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2468 fi
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2469 MAIL_FROM=$mail_from \
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2470 smail "`email4groupbyuid "$grp" $usel` $user" \
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2471 "$gecos さんからのメッセージ" <<EOF
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2472 $url
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2473 のグループ「$grp」のメンバーである $gecos さんから、
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2474 あなた宛へのメッセージです。
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2475 ----------------------------------------------------------
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2476 $text
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2477 EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2478 if [ $? = 0 ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2479 echo "Note: 以下のメンバーにメッセージを送信しました。" | html p
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2480 sql="select coalesce(b.val, a.name) from
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2481 (select name from user where rowid in ($uids)) a
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2482 left join user_s b on a.name=b.name and b.key='gecos';"
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2483 html pre<<EOF
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2484 `query "$sql"`
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2485 (送信者である $gecos さんも含まれます)
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2486 EOF
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2487 err SendDone: `echo $sql`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2488 fi
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2489 elif [ x"$rm" = x"commission" ]; then
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2490 grp_reg_adm $grid $usel
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2491 elif [ x"$rm" = x"addteam" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2492 team=`getpar team|sed "s/'/''/g"` # for single quotation
440
dc7acfdb6bfc Add comment
HIROSE Yuuji <yuuji@gentei.org>
parents: 439
diff changeset
2493 newteam=`echo $team|tr -d ,` # ..and strip spaces of both ends
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2494 if [ x"$team" != x"$newteam" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2495 echo "チーム名に使えない文字を除去しました" | html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2496 team=newteam
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2497 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2498 if [ -z "$team" -o x"$team" = x"なし" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2499 cat<<-EOF | html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2500 有効なチーム名を入力してください。
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2501 カンマだけ、「なし」という名前は使えません。
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2502 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2503 echo "有効なチーム名を入力してください。" | html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2504 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2505 grp_add_team $grid "$team" $usel
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2506 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2507 elif [ x"$rm" = x"rmteam" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2508 if [ x"yes" = x"`getpar teamconfirm`" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2509 rmteam=`getpar rmteam|sed "s/'/''/g"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2510 if [ -n "`query \"SELECT val FROM grp_mem_m WHERE\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2511 gname='$grp' AND user='$user' AND key='team'\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2512 AND val='$rmteam';\"`" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2513 grp_rm_team $grid "$rmteam" $usel
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2514 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2515 echo "所属していないチームの除去操作はできません。"|html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2516 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2517 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2518 echo "確認チェックなしなのでチーム除去しませんでした。"|html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2519 fi
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2520 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2521 fi
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2522 # POST count summary
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2523 from=`getpar from`; to=`getpar to`
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2524 from_input="<input type=\"date\" name=\"from\" placeholder=\"YYYY-MM-DD\" value=\"${from}\">"
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2525 to_input="<input type=\"date\" name=\"to\" value=\"${to:-9999}\">"
492
35458671d18c Quoting error fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 491
diff changeset
2526 fromtonote="<p>POST集計: $from_input - $to_input</p><!-- $from - $to -->"
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2527 # New entry
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2528 sql="WITH mems AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2529 SELECT g.rowid, name, gecos FROM grp_mem gm LEFT JOIN gecoses g
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2530 ON gm.user=g.name
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2531 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid)
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2532 ), target_article AS (
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2533 SELECT id FROM article_s
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2534 WHERE key='ctime' AND val BETWEEN '${from:-0000}' AND '${to:-9999}'
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2535 ), posts AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2536 SELECT author, count(author) post
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2537 FROM article NATURAL JOIN article_s NATURAL JOIN target_article
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2538 WHERE blogid IN (SELECT id FROM blog_s
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2539 WHERE key='owner'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2540 AND val=(SELECT gname FROM grp WHERE rowid=$grid))
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2541 AND key='text'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2542 GROUP BY author
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2543 ), teams AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2544 SELECT user, group_concat(val, ', ') team
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2545 FROM grp_mem_m
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2546 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid)
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2547 AND key='team'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2548 GROUP BY user
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2549 ), user_post AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2550 SELECT m.rowid, name, m.gecos, coalesce(post, 0) as POST
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2551 FROM mems m LEFT JOIN posts
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2552 ON m.name=posts.author
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2553 GROUP by m.rowid
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2554 )
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2555 SELECT
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2556 CASE
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2557 WHEN (SELECT user FROM grp_adm
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2558 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid)
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2559 AND user=up.name) IS NOT NULL
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2560 then 'k'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2561 ELSE ''
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2562 END || rowid || ',' || gecos NAME,
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2563 post POST, team TEAM
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2564 FROM user_post up LEFT JOIN teams t
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2565 ON up.name=t.user
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
2566 ORDER BY gecos;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2567 ## err grpaction: "`echo \"$sql\"`"
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2568 tf=$tmpd/title.$$
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2569 echo "グループ[<a href=\"?grp+$grid\">$grp</a>]参加メンバーに対する操作" > $tf
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2570 cmmsg="`cgi_radio rm commission id=\"cmadmin\"`<label
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2571 for=\"cmadmin\">グループ管理者委任</label>
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
2572 <div><p>このグループでの全権を付与します。信頼できる人に託してください。
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2573 </p></div>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2574 excmsg="`cgi_radio rm yes id=\"conf\"`<label
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2575 for=\"conf\">グループ登録解除</label>
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2576 <div>本当に消します! `cgi_checkbox confirm yes` 確認
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2577 <p>この操作による通知は本人に行きません。
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2578 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p>
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2579 </div>"
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2580 # Get team list to which current user belongs into $hexteams
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2581 myhexteams=$(hexteams "$grp" "$user")
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2582 allhexteams=$(hexteams "$grp")
227
ce24afbd3139 Team-removal control should obey $myhexteams.
HIROSE Yuuji <yuuji@gentei.org>
parents: 226
diff changeset
2583 if [ -n "$myhexteams" ]; then
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2584 rmteammsg="`cgi_radio rm rmteam 'id=\"cmrmteam\"'`<label
292
3866eb7c2a23 Shorten heading string
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
2585 for=\"cmrmteam\">チーム属性除去</label>
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
2586 <div>チーム属性:`cgi_select_h rmteam \"2d2d2d\" $myhexteams`
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2587 を除去します: `cgi_checkbox teamconfirm yes` 確認
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2588 <p>この操作による通知は本人に行きません。
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2589 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p>
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
2590 </div><!-- end of $rmteammsg -->
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2591 "
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2592 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2593 b1='<label> <input type="checkbox" name="usel" value="'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2594 ba='<label class="admin"><input type="checkbox" name="usel" value="'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2595 #b2='"> <span>' b3='</span></label>'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2596 # | sed -e "s|^\(<TR><TD>\)k\([0-9]*\),\([^<]*\)|\1$ba\2$b2\3$b3|" \
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2597 # -e "s|^\(<TR><TD>\)\([0-9]*\),\([^<]*\)|\1$b1\2$b2\3$b3|" \
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2598 lnk='"> <span>\3</span></label> [<a href="?home+\2">HOME</a>]'
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2599 cgi_form grpaction<<EOF \
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2600 | sed -e "s|^\(<TR><TD>\)k\([0-9]*\),\([^<]*\)|\1$ba\2$lnk|" \
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2601 -e "s|^\(<TR><TD>\)\([0-9]*\),\([^<]*\)|\1$b1\2$lnk|" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2602 | _m4 -D_TITLE_="spaste(\`$tf')" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2603 -D_SUBTITLE_="チェック後操作ボタン" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2604 -D_FORM_="syscmd(cat)" -D_DUMPTABLE_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2605 $layout/form+dump.m4.html
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2606 <p>下でチェックした人を対象として:</p>
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2607 <div class="foldtabs">
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2608 `cgi_radio rm addteam 'id="cmteam"'`<label
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2609 for="cmteam">同じチーム属性を付与</label>
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2610 <div>チーム名:`cgi_text team "" 'id="inteam" list="teams"'`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2611 `cgi_datalist_h teams $allhexteams`
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2612 </div>
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
2613 ${rmteammsg}
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2614 `cgi_radio rm send id="sendmsg"`<label
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2615 for="sendmsg">メッセージ送信</label>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2616 <div>
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2617 `cgi_checkbox mkfrom yes 'id="mkfrom" checked'`<label for="mkfrom"
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2618 >差出人を自分に(チェックを外すと相手が返事できない)</label><br>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2619 `cgi_textarea text "" cols=40`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2620 </div>
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2621 ${isowner:+$cmmsg$excmsg}
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
2622 `cgi_radio rm close id="x"`<label for="x">×</label>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2623 </div>
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
2624 <h4>$grp 参加者一覧</h4>$fromtonote
275
b82007959b54 The 2nd column of grpaction-member-list should be right aligned
HIROSE Yuuji <yuuji@gentei.org>
parents: 274
diff changeset
2625 <table class="td2r">
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2626 `sq $db -header -html "$sql"`
207
355fcbdc3b49 Add 'file_accept'
HIROSE Yuuji <yuuji@gentei.org>
parents: 203
diff changeset
2627 </table>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2628 `cgi_hidden grp $grid`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2629 EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2630 }
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2631 crview4article() { # $1=rowid of blog, $2(optional)=extra SQL
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2632 # Create TEMPORARY VIEW
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2633 query<<EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2634 CREATE TEMPORARY VIEW writeusers AS
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2635 SELECT DISTINCT author FROM article
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2636 WHERE id in (
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2637 select id from article where blogid=(select id from blog where rowid=$1)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2638 );
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2639 CREATE TEMPORARY VIEW movablegroups AS
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2640 SELECT g.rowid growid , g.gname
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2641 FROM (SELECT grp.rowid, grp.gname FROM grp JOIN grp_mem gm
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2642 ON grp.gname=gm.gname -- そのユーザが属している
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2643 AND user='$user') g -- グループに絞る
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2644 WHERE (SELECT author FROM writeusers
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2645 EXCEPT
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2646 SELECT user FROM grp_mem gm WHERE gm.gname = g.gname)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2647 IS NULL;
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2648 $2
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2649 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2650 }
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2651 sql4readableblogs() {
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2652 # Create view of blogs that can be readable to $user
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2653 # Blog is readable when:
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2654 # 1: blog owner is an user
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2655 # 2: else, 2.1: owner-group where the $user belongs
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2656 # 2.2: else, owner-group is not moderated
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2657 # blog(id, author), blog_s(id, key='owner', val= ->owner)
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
2658 cat<<EOF ## | tee tmp/sql.out
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2659 CREATE TEMPORARY VIEW readableblogs AS
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2660 SELECT blog.rowid rid, id, author
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2661 FROM blog
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2662 NATURAL JOIN
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2663 (SELECT id,
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2664 max(CASE key WHEN 'owner' THEN val END) owner,
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2665 max(CASE key WHEN 'mode' THEN val END) mode
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2666 FROM blog_s GROUP by id) bs
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2667 WHERE CASE WHEN (SELECT name FROM user where name=bs.owner) IS NOT NULL
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2668 THEN 1 -- blog owner is an user, READABLE
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2669 WHEN (SELECT val FROM grp_s
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2670 WHERE gname=bs.owner AND key='regmode') = 'moderated'
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2671 AND
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2672 (SELECT user FROM grp_mem
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2673 WHERE gname=bs.owner AND user='$user') IS NULL
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2674 THEN 0
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2675 WHEN mode = 'quiz'
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2676 THEN 0 -- "quiz" mode blog cannot be searched
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2677 ELSE 1
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2678 END;
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2679 EOF
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
2680 }
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2681 editheading() { # $1=rowid-of-heading
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2682 rowid=${1%%[!A-Z0-9a-z_]*}
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2683 if [ -z "$rowid" ]; then
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2684 echo "話題番号が未指定です。" | html p
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2685 return
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2686 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2687 owner=`getvalbyid blog owner $rowid`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2688 title=`getvalbyid blog title $rowid`
121
34b72806cd22 Too much quoting
HIROSE Yuuji <yuuji@gentei.org>
parents: 120
diff changeset
2689 GF_ACTION="?blog" edittable $formdir/blog.def blog $rowid \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2690 | _m4 -D_TITLE_="修正" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2691 -D_SUBTITLE_="[$title]@$owner" -D_DIARY_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2692 -D_BLOGS_="" -D_DUMPTABLE_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2693 -D_FORM_="syscmd(\`cat')" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2694 $layout/html.m4.html $layout/form+dump.m4.html
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2695 # Move to group
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2696 if isuser "$owner"; then
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2697 crview4article $rowid
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2698 n=`query "SELECT count(*) FROM writeusers;"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2699 ## err N=$n
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2700 if [ $((n)) -gt 0 ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2701 ## err ROWID=$rowid
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2702 sql="SELECT growid || ':' || gname FROM movablegroups;"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2703 cat<<-EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2704 <div class="fold">
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2705 `cgi_checkbox mv send id="mv"`<label
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2706 for="mv">この話題をグループ所有に移動する</label>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2707 <div>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2708 <form action="?mvart" method="POST" enctype="multipart/form-data">
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2709 移動先グループ:
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2710 <select name="mv2grp">
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2711 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2712 query ".mode html"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2713 query<<-EOF |
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2714 $sql
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2715 .mode list
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2716 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2717 sed -e '/<\/TR>/d' -e 's,<TR>,,' -e 's,TD>,option>,g' \
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2718 -e 's,n>\([0-9]*\):\(.*\)<,n value="\1">\2<,'
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2719 cat<<-EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2720 </select>
214
e4dd3cf443b0 Add comment to article moving page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 213
diff changeset
2721 <p>(移動できるグループは、この「話題」に書き込んでいる人全てが
e4dd3cf443b0 Add comment to article moving page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 213
diff changeset
2722 そのグループに加入しているものに限られます)</p>
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2723 <p>`cgi_checkbox cfm yes`<label>確認
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2724 (この操作は元に戻すことができません)</label></p>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2725 `cgi_hidden blogrowid $rowid`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2726 `cgi_submit 移動`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2727 `cgi_reset Reset`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2728 </form>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2729 </div>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2730 </div>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2731 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2732 fi
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2733 # end of isuser "$owner"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2734 elif { hexteams=$(hexteams "$owner" ) # blog is of GROUP
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2735 [ -n "$hexteams" ];}; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2736 none="`echo なし|hexize`"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2737 cat<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2738 <div class="fold">
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2739 `cgi_checkbox mv2team send id="mv2team"`<label
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2740 for="mv2team">この話題を以下のチームのものにする</label>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2741 <div><p>現在の所属チーム設定:
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2742 `query "SELECT
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2743 coalesce((SELECT val FROM blog_s
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2744 WHERE id=(SELECT id FROM blog WHERE rowid=$rowid)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2745 AND key='team'),
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2746 ':なし');"`</p>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2747 <form action="?mvart" method="POST" enctype="multipart/form-data">
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2748 移動先チーム: `cgi_select_h mv2team $none $hexteams`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2749 <p>`cgi_checkbox cfm yes`<label>確認</label></p>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2750 `cgi_hidden blogrowid $rowid`<br>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2751 `cgi_submit 移動`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2752 `cgi_reset Reset`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2753 </form></div></div>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2754 EOF
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2755 fi
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2756 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2757 mvart() { # move diary to some group or team
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2758 # or move blog of group to team which belong to the group
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2759 blogrowid=`getpar blogrowid`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2760 cfm=`getpar cfm`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2761 ##### echo move blog:$blogrowid to $mv2grp | html p
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2762 blogrowid=${blogrowid%%[!A-Z0-9a-z_]*} # Purify
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2763 . ./s4-blog.sh
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2764 if [ -z "$blogrowid" ]; then
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2765 echo "無効な指定です(mvart)。" | html p
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2766 return
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2767 elif [ x"$cfm" != x"yes" ]; then
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2768 echo "記事移動の確認にチェックがないので通常表示に戻ります。" | html p
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2769 elif { mv2grp=`getpar mv2grp`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2770 mv2grp=${mv2grp%%[!A-Z0-9a-z_]*} # Purify
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2771 [ -n "$mv2grp" ]; }; then
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2772 crview4article $blogrowid
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2773 ########## TRANSACTION BEGIN
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2774 query "BEGIN;"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2775 n=`query "SELECT count(*) FROM writeusers;"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2776 ## err Nwriteuser=$n
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2777 if [ $((n)) -gt 0 ]; then
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2778 query<<-EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2779 UPDATE blog_s SET val=(SELECT gname FROM grp WHERE rowid=$mv2grp)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2780 WHERE key='owner'
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2781 AND id=(SELECT id FROM blog WHERE rowid=$blogrowid)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2782 AND $mv2grp IN (SELECT growid FROM movablegroups);
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2783 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2784 fi
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2785 query "END;"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2786 ########## TRANSACTION END
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2787 elif { mv2team=`getpar mv2team|sed "s/'/''/g"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2788 [ -n "$mv2team" ];}; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2789 # blog owner can move it to ANY team
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2790 case "$mv2team" in
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2791 'なし')
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2792 cat<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2793 DELETE FROM blog_s
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2794 WHERE id=(SELECT id FROM blog WHERE rowid=$blogrowid)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2795 AND key='team';
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2796 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2797 ;;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2798 "") ;;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2799 *)cat<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2800 BEGIN;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2801 REPLACE INTO blog_s(id, key, val)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2802 VALUES((SELECT id FROM blog WHERE rowid=$blogrowid),
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2803 'team', '$mv2team');
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2804 REPLACE INTO blog_s(id, key, val)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2805 VALUES((SELECT id FROM blog WHERE rowid=$blogrowid),
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2806 'notify', 'all'); -- Change notify to all
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2807 END;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2808 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2809 esac | query
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2810 fi
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2811 blog_reply $blogrowid
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
2812 echo yes | html p
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2813 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2814 editart() { # $1=article-rowid $2=blogrowid
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2815 rowid=${1%%[!A-Z0-9a-z_]*}
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2816 blogrowid=${2%%[!A-Z0-9a-z_]*}
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2817 if [ -z "$rowid" -o -z "$blogrowid" ]; then
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2818 echo "表示する記事番号が未指定です。" | html p
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2819 return
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2820 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2821 owner=`getvalbyid blog owner $blogrowid`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2822 title=`getvalbyid blog title $blogrowid`
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2823 author=`getvalbyid article author $rowid`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2824 ## err EDITart: owner=$owner, author=$author
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
2825 if isgrpowner "$user" "$owner"; then
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2826 : EDIT OK
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2827 elif [ x"$owner" != x"$user" -a x"$author" != x"$user" ]; then
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2828 echo "本人か所有者しか編集できません." | html p
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2829 return
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2830 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2831 aid=`query "select id from article where rowid=$rowid;"`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2832 tmpout=$tmpd/editart.$$.out
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2833 GF_ACTION="?replyblog+$blogrowid#$aid" \
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2834 edittable $formdir/article.def article $rowid \
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2835 > $tmpout
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2836 rm -f /tmp/editart.out
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2837 # Cannot use pipelining to m4 with genform() because of stdin stack
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2838 _m4 -D_TITLE_="コメントの修正" -D_DIARY_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2839 -D_FORM_="syscmd(cat $tmpout)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2840 -D_SUBTITLE_="`gecos $owner`の「$title」" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2841 -D_BLOGS_= -D_DUMPTABLE_= \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2842 $layout/html.m4.html $layout/form+dump.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2843 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2844 send2mem() {
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2845 rowid=`getpar grp`
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2846 rowid=${rowid%%[!0-9]*} # Cleaning
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2847 if [ -z "$rowid" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2848 echo "グループが未指定です。" | html p
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2849 return
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2850 fi
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2851 message=`getpar message`
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2852 if [ -z "$message" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2853 echo "文章を入れてください。" | html p
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2854 return
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2855 fi
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2856 grp=`getgroupbyid $rowid`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2857 members=`collectemail $grp`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2858 # smail rcpt subj (file)
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2859 SMAIL_TO="`echo "$grp" | nkf -jM | tr -d '\n'` readers <$admin>" \
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2860 smail "$members" "グループ $grp 宛メッセージ(from `gecos $user`)" <<EOF
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2861 $urlbase?grp+$rowid
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2862 グループ $grp に所属する
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2863 `gecos $user` さんよりメッセージ:
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2864
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2865 $message
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2866 EOF
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2867 cat<<EOF
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2868 <p>以下のユーザに送信しました。</p>
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2869 <pre>
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
2870 `collectgecosesbyid "$rowid" | sed 's/$/ さん/'`
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2871 </pre>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2872 <p><a href="?grp+$rowid">グループ $grp</a>に戻る。</p>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2873 EOF
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2874 }
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2875 joingrpadmit() {
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2876 # $1=yes/no $2=session-key
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2877 if [ -z "$2" ]; then
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2878 echo "bye bye" | html p; return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2879 fi
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2880 t_usr=`session=$2 getpar user`
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2881 t_grp=`session=$2 getpar group`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2882 ## err joingrpadmit: t_usr=$t_usr, t_grp=$t_grp
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2883 _m4 -D_TITLE_="joingrp" $layout/html.m4.html
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2884 if [ -z "$t_usr" -o -z "$t_grp" ]; then
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2885 echo "無効な加入依頼です。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2886 echo "有効期限が切れたか、
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2887 他の管理者がいる場合は処理済みの可能性があります。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2888 return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2889 fi
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
2890 if ! isgrpowner "$user" "$t_grp"; then
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2891 echo "グループ管理者のみの機能です。" | html p; return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2892 fi
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2893 case $1 in
308
e38ea2702570 Call joingrp() without $4(extra email address)
HIROSE Yuuji <yuuji@gentei.org>
parents: 307
diff changeset
2894 yes) joingrp "$t_grp" "$t_usr" yes ;;
e38ea2702570 Call joingrp() without $4(extra email address)
HIROSE Yuuji <yuuji@gentei.org>
parents: 307
diff changeset
2895 no) joingrp "$t_grp" "$t_usr" no ;;
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2896 *)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2897 echo "無効な指定です($1)。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2898 return ;;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2899 esac
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2900 gid=$(query "select rowid from grp where gname=`sqlquote \"$t_grp\"`;")
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2901 rcpts="`getgroupadminmails $t_grp` $user"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2902 ## err admit: msgdir=$msgdir, rcpts="["$rcpts"]"
310
e8f1847eebca Add link to group name in joingrpadmit report screen
HIROSE Yuuji <yuuji@gentei.org>
parents: 309
diff changeset
2903 body="グループ <a href=\"?grp+$gid\">$t_grp</a>
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2904
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2905 $t_usr
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2906 `[ x$1 = xyes ] && echo 'を追加' || echo 'の解除操作を'`
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2907 しました。"
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2908 (echo "$body"; echo; echo "$url?grp+$gid") | smail "$rcpts" "joingrp $1"
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2909 query "delete from session where id='$2';"
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2910 echo "$body" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2911 }
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2912
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2913 joingrprequest() {
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2914 # $1=group $2=user $3=yes/no $4=email(if any $5=AsAdmin)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2915 jss="joingrp-`date +%s`-`genrandom 12`"
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2916 addsession $jss +${memoplimitdays}days
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2917 query "replace into par values('$jss', 'group', 'string', `sqlquote \"$1\"`),
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2918 ('$jss', 'user', 'string', `sqlquote \"$user\"`);"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2919 smail "$(collectemail `getgroupadmins $1`)" "Join request to $1"<<EOF
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2920 $url
270
707ff3870ad1 Put user name in joingrprequest mail
HIROSE Yuuji <yuuji@gentei.org>
parents: 268
diff changeset
2921 $user さんから
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2922 グループ $1
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2923 に加入依頼がありました。
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2924
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2925 承認する:
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2926 $urlbase?joingrpadmit+yes+$jss
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2927
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2928 白紙に戻す:
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2929 $urlbase?joingrpadmit+no+$jss
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2930 EOF
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2931 echo "管理者に加入依頼を出しました。
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2932 ${memoplimitdays}日以内に加入承認操作がされれば加入できますが、
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2933 グループ運用方針に懸かることですので直接の問い合わせが重要です。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2934 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2935 joingrp() {
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2936 # $1=group $2=user $3=yes/no $4=email(if any $5=AsAdmin)
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2937 ## err joingrp: \$1=$1 \$2=$2 \$3=$3 \$4=$4
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2938 if isgrpowner "$user" "$1"; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2939 isowner="yes"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2940 elif [ -n "$5" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2941 isowner="yes"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2942 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2943 isowner=""
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2944 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2945 ## err jg:isgrpowner: isowner="$isowner"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2946 if [ -n "$isowner" ]; then
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
2947 : # GROUP OWNER CAN DO EVERYTHING ABOUT REGISTRATION/RETIREMENT
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2948 elif [ x"$2" != x"$user" ]; then # if user is not login user
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2949 echo "本人か、グループ管理者しか加入操作はできません。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2950 return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2951 elif [ x"$3" = x"no" ]; then
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
2952 : # Do not pursue those who leave
271
a8bb72580c91 Member can change own email address for the joining moderated group
HIROSE Yuuji <yuuji@gentei.org>
parents: 270
diff changeset
2953 elif [ x"$3" = x"yes" ] && ismember "$user" "$grp"; then
a8bb72580c91 Member can change own email address for the joining moderated group
HIROSE Yuuji <yuuji@gentei.org>
parents: 270
diff changeset
2954 : # Member can change own email address for the joining moderated group
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2955 else # adding user is $user itself
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2956 case `getgroupattr $1 regmode` in
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2957 moderated)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2958 joingrprequest "$@" # Request only
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2959 return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2960 ;;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2961 *)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2962 ;;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2963 esac
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2964 fi
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2965 qgname=`sqlquote "$1"`
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
2966 grid=`query "SELECT rowid FROM grp WHERE gname=$qgname;"`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2967 cond="where gname=$qgname and user='$2'"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2968 if [ x"$3" = x"yes" ]; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2969 query "replace into grp_mem values($qgname, '$2');"
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
2970 # Notify joingrp to admin
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
2971 action="に加入しました。"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2972 if [ -n "$4" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2973 if msg=`emaildomaincheck "$4"`; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2974 query "replace into grp_mem_s values($qgname, '$user', 'email', \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2975 'string', '$4', NULL);"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2976 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2977 echo $msg
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2978 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2979 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2980 query "delete from grp_mem_s $cond and key='email';"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2981 fi
306
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2982 if [ -n "$5" ]; then # as ADMIN
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2983 # Coming here means newly created group
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2984 sql="select case\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2985 when (select count(*) from grp_mem where gname=$qgname)=1\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2986 then (select user from grp_mem\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2987 where gname=$qgname and user='$user')\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2988 else '' end; "
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2989 err NewGrpChk: $sql
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2990 if [ -n "`query \"$sql\"`" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2991 ## err ADMIN: "replace into grp_adm values($qgname, '$user');"
306
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2992 query "replace into grp_adm values($qgname, '$user');"
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2993 fi
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
2994 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2995 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2996 query "delete from grp_mem $cond;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2997 delete from grp_mem_s $cond;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2998 delete from grp_mem_m $cond;"
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
2999 action="から脱退しました。"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3000 fi
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3001 smail "$(collectemail `getgroupadmins $1`)" "Member change of $1"<<-EOF
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3002 $url?grp+$grid
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3003 $user (`gecos $user`)さんが
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3004 グループ $1
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3005 $action
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3006 EOF
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3007 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3008 grp_add_team() (
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3009 # $1=grp-rowid $2=team $3...=user-rowid(s)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3010 grp=`getgroupbyid $1`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3011 team=$2; shift; shift
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3012 [ -z "$grid" -o -z "$team" -o -z "$1" ] && return
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3013 { echo "BEGIN;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3014 for user; do
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3015 echo "REPLACE INTO grp_mem_m(gname, user, key, type, val) VALUES(\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3016 '$grp',\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3017 (SELECT name FROM user WHERE rowid=$user),\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3018 'team', 'string', '$team');"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3019 done
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3020 echo "END;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3021 } | query
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3022 )
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3023 grp_rm_team() (
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3024 # $1=grp-rowid $2=team $3...=user-rowid(s)
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3025 grid=$1
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3026 qgrp=$(sqlquote "`getgroupbyid $grid`")
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3027 team=$2; shift; shift
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3028 [ -z "$grid" -o -z "$team" ] && return
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3029 { echo "BEGIN;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3030 for user; do
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3031 echo "DELETE FROM grp_mem_m\
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3032 WHERE gname=$qgrp \
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3033 AND user=(SELECT name FROM user WHERE rowid=$user)\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3034 AND key='team' AND val='$team';"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3035 done
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3036 cat<<-EOF
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3037 DELETE FROM blog_s
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3038 WHERE rowid=(
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3039 SELECT rowid
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3040 FROM blog_s a
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3041 WHERE key='team'
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3042 AND id IN (SELECT id FROM blog_s WHERE key='owner' AND val=$qgrp)
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3043 AND NOT EXISTS (SELECT * FROM grp_mem_m
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3044 WHERE key='team' AND val=a.val -- a.val=team
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3045 AND gname = (SELECT val FROM blog_s b
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3046 WHERE a.id=b.id AND key='owner')
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3047 ));
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3048 EOF
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3049
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3050 echo "END;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3051 } | query
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3052 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3053 grp_reg_adm() {
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3054 # $1=grp-rowid $2...=user-rowid
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3055 grid=$1
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3056 grp=`getgroupbyid "$1"`
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3057 if [ -z "$grp" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3058 echo "無効なグループIDです" | html p; return
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3059 fi
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
3060 if ! isgrpowner "$user" "$grp"; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3061 echo "$grp グループの管理者しかこの操作はできません。" | html p; return
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3062 fi
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3063 shift
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3064 for urid; do
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3065 newadm=`query "select name from user where rowid=$urid;"`
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3066 if [ -z "$newadm" ]; then
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3067 echo "指定ユーザIDがおかしいようです。" | html p; return
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3068 fi
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
3069 err GRP_reg_adm: "replace into grp_adm values(`sqlquote \"$grp\"`, '$newadm');"
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3070 err ismember $newadm $grp
434
cf20459261cb Quote $grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 433
diff changeset
3071 if ismember $newadm "$grp"; then
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3072 # OK, go ahead
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3073 getgname="(select gname from grp where rowid=$grid)"
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3074 query "replace into grp_adm values($getgname, '$newadm');"
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3075 # confirm insertion
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3076 sql="select * from grp_adm where gname=$getgname and user='$newadm'"
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3077 if [ -n "`query \"$sql;\"`" ]; then
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3078 echo "追加完了: $newadm" | html p
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3079 else
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3080 echo "追加失敗($1 $urid)" | html p
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3081 fi
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3082 fi
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3083 showgroup $grid
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3084 done
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3085 }
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3086 dt_rowhack() {
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3087 # From: <TR>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3088 # ....
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3089 # <TD>rowclass=foo</TD>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3090 # </TR>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3091 # To: <TR class="foo">....<TD>foo</TD></TR>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3092 sed -e '
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3093 /^<TR>/ {
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3094 :loop
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3095 s/\n//
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3096 N
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3097 /<\/TR>/ {
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3098 s/\n//
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3099 s,^<TR>\(.*\)<TD>rowclass=\(.*\)\(</TD></TR>\),<TR class="\2">\1<TD>\2\3,
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3100 n
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3101 }
400
0a5fdb619325 $p produces duplicated final line on gsed(fixed)
HIROSE Yuuji <yuuji@gentei.org>
parents: 398
diff changeset
3102 $q
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3103 b loop
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3104 }'
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3105 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3106 dumptable() {
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3107 # $1=mode $2=Table $3=column-list-of-*_s(defaults to *) $4=conditions(if any)
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3108 # textのフィールドだけ全てダンプにしたほうがいいか
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3109 # $DT_VIEW sets link
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3110 # 6/17の次: editリンクじゃなくてスレッドVIEWリンクでいいんちゃう?
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3111 ### elink="<a href=\"$myname?edittable+$2+\\2\">EDIT</a>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3112 VIEW=${DT_VIEW-replyblog}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3113 if [ -n "$VIEW" ]; then
362
955cd7b517d3 Anchor of link-to-bottom expands from `W' to `EW'
HIROSE Yuuji <yuuji@gentei.org>
parents: 361
diff changeset
3114 dvlink=" <a href=\"$myname?$VIEW+\\2\\3\">VI</a><a href=\"$myname?$VIEW+\\2#bottom\">EW</a>"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3115 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3116 # $DT_CHLD=ChildTable:BindColumn
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3117 if [ -n "$DT_CHLD" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3118 _t=${DT_CHLD%:*} _i=${DT_CHLD#*:}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3119 cntall="(select count($_i) from $_t where $_i=a.id)"
281
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3120 # XXX: Dirty workaround for slow subquery of acclog
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3121 presql="CREATE TEMPORARY TABLE IF NOT EXISTS myacclog AS
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3122 SELECT * FROM acclog WHERE user='$user' and tbl='$2';"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3123 cntnew="(select count(val) from ${_t}_s where key='ctime' \
281
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3124 and id in (select id from $_t where $_i=a.id) \
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3125 and val > coalesce((select time from myacclog where \
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3126 tblrowid=a.rowid),\
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3127 '1970-01-01'))"
60
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3128 cnt="$cntnew as '新着', $cntall as '総数',"
252
75dfaceac01f Link to newest article of the blog in the recent writing place
HIROSE Yuuji <yuuji@gentei.org>
parents: 251
diff changeset
3129 dt_class=" td2r td3r dumpblogs"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3130 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3131 # Construct join expression
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3132 eav="" scols=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3133 pk=`gettblpkey $2`
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3134 substr=${dumpcollen:+"substr(%s, 0, $dumpcollen)"}
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3135 substr=${substr:-%s}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3136 for col in ${3:-`gettbl_s_cols $2`}; do
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3137 valvar=val
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3138 case $col in
60
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3139 gecos) scols="$scols${scols:+, }${col#}"
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3140 continue ;; # built-in column name
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3141 *:*) as=${col#*:} # as can be 稼動状態:frozen=凍結中
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3142 col=${col%%:*} # stage:稼動状態:frozen=凍結中 -> stage
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3143 case "$as" in
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3144 *:*=*) cnd=${as#*:}
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3145 h=${cnd%%=*} v=${cnd#*=}
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3146 h=`sqlquotestr "$h"`
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3147 v=`sqlquotestr "$v"`
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3148 valvar="CASE val WHEN $h THEN $v END"
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3149 as=${as%%:*} ;;
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3150 esac
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3151 ;;
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3152 *) as=${col} ;;
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3153 esac
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3154 ss=`printf "$substr" "$valvar"`
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3155 eav=$eav${eav:+,}" max(case key when '$col' then $ss end) as $as"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3156 scols="$scols${scols:+, }b.$as"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3157 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3158 #case author when '$user' then a.rowid else '---' end as ID,
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
3159 sql=${DT_SQL:-"select \
203
c120ade0c9c3 Change table header ID to LINK
HIROSE Yuuji <yuuji@gentei.org>
parents: 200
diff changeset
3160 a.rowid as LINK,\
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3161 $cnt\
60
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3162 $scols from $2 a left join\
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3163 (select $pk,$eav,
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3164 max(case key when 'owner'
207
355fcbdc3b49 Add 'file_accept'
HIROSE Yuuji <yuuji@gentei.org>
parents: 203
diff changeset
3165 then (SELECT gecos FROM gecoses WHERE name=val) END) as gecos
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
3166 from ${2}_s c group by $pk) b on a.$pk=b.$pk $4;"}
357
78c0a2b43ec1 More deactivation of debug log
HIROSE Yuuji <yuuji@gentei.org>
parents: 356
diff changeset
3167 ## err dt:SQL="`echo \"$presql$sql\"|tr -d '\n'`"
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3168 cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)\(#[0-9a-fxs]*\)*</TD>,\1$elink$dvlink</TD>," | dt_rowhack
200
ffc676bd8277 Protect div.dumptable from div.fold
HIROSE Yuuji <yuuji@gentei.org>
parents: 196
diff changeset
3169 <div> <!-- for folding by check button (s4-funcs.sh:dumptable()) -->
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3170 <div class="dumptable">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3171 <table class="b$dt_class">
281
dd8629e6d67e Ugly workaround to speed up count-new
HIROSE Yuuji <yuuji@gentei.org>
parents: 280
diff changeset
3172 `sq -header -cmd ".mode $1" $db "$presql$sql"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3173 </table>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3174 </div> <!-- dumptable -->
200
ffc676bd8277 Protect div.dumptable from div.fold
HIROSE Yuuji <yuuji@gentei.org>
parents: 196
diff changeset
3175 </div> <!-- for folding by check button (s4-funcs.sh:dumptable()) -->
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3176 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3177 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3178
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3179 par2table() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3180 # copy current parameters of par into destination table
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3181 # $1=definition-file
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3182 # Using $user and $session
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3183 # Return value:
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3184 # 0: Stored successfully
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3185 # 1: Insufficient fillings
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3186 # 2: No permission to modify the record
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3187 # 3: Invalid rowid
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3188 # 4: SUCCESS to delete
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3189 # 5: Stop deletion for lack of confirm check
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3190 # 6: Password length too short
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3191 # 7: Password mismatch
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3192 # 8: Old password incorrect
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3193 rowid=`getpar rowid`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3194 if [ ! -e $1 ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3195 echo "テーブル定義ファイルが見付かりません" | html p
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3196 exit 1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3197 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3198 tbl=${1%.def}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3199 tbl=${tbl##*/}
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
3200 if [ -n "$rowid" ]; then # Modify existing entry
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3201 if [ x"$tbl" = x"user" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3202 rowowner=`query "select name from $tbl where rowid=$rowid;"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3203 elif [ x"$tbl" = x"grp" ]; then
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3204 sql="select gname from $tbl where rowid=$rowid;"
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3205 ##err p2t:grp:q $sql
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
3206 isgrpowner "$user" "`query $sql`" && rowowner=$user
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3207 else
394
f095e97066c5 Remove "SELECT owner"
HIROSE Yuuji <yuuji@gentei.org>
parents: 393
diff changeset
3208 # 2016-12-05 There's no owner column in $tbl (need confirmation)
f095e97066c5 Remove "SELECT owner"
HIROSE Yuuji <yuuji@gentei.org>
parents: 393
diff changeset
3209 rowowner=`query "SELECT author FROM $tbl WHERE rowid=$rowid;"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3210 fi
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3211 ### err rowowner=$rowowner
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3212 if [ x"$user" != x"$rowowner" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3213 echo "他人のレコードはいじれないの" | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3214 return 2
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3215 elif [ -z "$rowowner" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3216 echo "指定したレコードはないみたい" | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3217 return 3
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3218 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3219 rm=`getpar rm` cfm=`getpar confirm`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3220 # Editing existent entry
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3221 if [ x"$rm" = x"yes" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3222 if [ x"$rm$cfm" = x"yesyes" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3223 query "delete from $tbl where rowid=$rowid;"
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3224 return 4
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3225 else
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3226 echo "消去確認のチェックがないので消さなかったの..." | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
3227 return 5
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3228 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3229 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3230 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3231
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3232 ts=${tbl}_s tm=${tbl}_m val="" pval="" formaster=""
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3233 if [ -n "$rowid" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3234 # Update of existing record
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3235 for col in `gettblcols $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3236 val=`getparquote $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3237 [ -z "$val" ] && continue
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3238 ## err query "update $tbl set $col=$val where rowid=$rowid"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3239 ## XX: THIS IS DIRTY hack to ensure non-foreign key in blog_s
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3240 sql="update $tbl set $col=$val where rowid=$rowid;"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3241 if [ x"$tbl" = x"grp" -a x"$col" = x"gname" \
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3242 -o x"tbl" = x"user" -a x"$col" = x"name" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3243 ## User name cannot be changed with interface provided with this
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3244 ## script. But we offer the trigger to change owner user
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3245 ## of blog_s table.
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3246 #err "select quote($col) from $tbl where rowid=$rowid;"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3247 old=`query "select quote($col) from $tbl where rowid=$rowid;"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3248 cat<<-EOF | query
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
3249 -- Here we cannot use BEGIN-COMMIT because groupupdate()
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
3250 -- should use EXCLUSIVE transaction outside of this.
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
3251 SAVEPOINT par2table;
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3252 $sql
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3253 update blog_s set val=$val
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3254 where key='owner' and val=$old;
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
3255 RELEASE SAVEPOINT par2table;
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3256 EOF
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3257 ## XX: DIRTY Hack Ends here
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3258 ## We should keep blog's owner as a single column which has
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3259 ## foreign key constraint with primary key of grp/user.
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3260 else
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3261 query "$sql"
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
3262 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3263 done
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3264 # Then, set up $pval for further insertion of tbl_s and tbl_m
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3265 for col in `gettblpkey $tbl`; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3266 val=`query "select $col from $tbl where rowid=$rowid;"|sed -e 's/\"/\"\"/g'`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3267 pval="$pval${pval:+, }\"$val\""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3268 done
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3269 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3270 # New entry
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3271 # Generate values() for primary keys
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3272 for col in `gettblpkey $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3273 # Genuine primary keys for _m and _s
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3274 val=`getvalquote $tbl $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3275 [ -z "$val" ] && continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3276 pval="$pval${pval:+, }$val"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3277 done
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3278 ##err pval=$pval
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3279 for col in `gettblfkey $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3280 # args for values() to insertion into master table
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3281 val=`getvalquote $tbl $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3282 [ -z "$val" ] && continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3283 formaster=$formaster"${formaster:+, }$val"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3284 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3285 formaster="$pval${formaster:+, }$formaster"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3286 ## err formaster=$formaster
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3287 if [ -z "$formaster" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3288 echo "項目を全て埋めてください" | html pre
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3289 return 1
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3290 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3291 ## err "replace into $tbl values($formaster);"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3292 query "replace into $tbl values($formaster);"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3293 ## Insertion to master table, done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3294 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3295
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3296 for kt in s m; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3297 tb2=${tbl}_$kt
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3298 for col in `gettbl_${kt}_cols $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3299 ptype=`getpartype $col "limit 1"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3300
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3301 # First, check update of existing entries in _m
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3302 if [ $kt = m ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3303 # sessID|address.1.22|string|Somewhere-x.y.z
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3304 sql=""
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3305 ##err dots from query "select var from par where var like '$col.%';"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3306 for v in `query "select var from par where var like '$col.%';"`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3307 # v=address.1.22
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3308 st_rowid=${v##*.}
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3309 origcol=${v%%.*} # original column derived from
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3310 ##err Updating for $v st_rowid=$st_rowid, partype=`getpartype $v`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3311 ##case `getpartype $v` in
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3312 ## err CASE `gettbl_coltype $tbl/$origcol` in
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3313 ## err edit flag = `getpar action.$v`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3314 case `getpar action.$v` in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3315 rm)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3316 if [ x`getpar confirm.$v` = x"yes" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3317 newsql="delete from $tb2"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3318 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3319 echo "削除確認未チェック" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3320 fi ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3321 edit)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3322 case `gettbl_coltype $tbl/$origcol` in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3323 image|document|binary)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3324 file=$tmpd/`getparfilename $v`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3325 ## err type=file=$file
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3326 [ -z "$file" ] && continue
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
3327 bn=`sqlquotestr "${file##*/}"`
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3328 bin="X'"$(hexize "$file")"'"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3329 ct=`file --mime-type - < "$file" |cut -d' ' -f2`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3330 type=\"file:$ct\"
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
3331 newsql="update $tb2 set val=$bn, type=$type, bin=$bin"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3332 cachedir=`getcachedir "$tbl/$rowid"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3333 err getcache tbl/rowid=$tbl/$rowid, rm -r $cachedir
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3334 rm -rf $cachedir
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3335 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3336 *)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3337 newsql="update $tb2 set val=(select val from par where var \
75
5e95c17f6b78 variable separation
HIROSE Yuuji <yuuji@gentei.org>
parents: 74
diff changeset
3338 like '$col.%.$st_rowid')"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3339 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3340 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3341 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3342 *) # maybe "keep", do not modify value
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3343 continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3344 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3345 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3346 # err newsql=$newsql
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3347 sql=$sql$nl"$newsql where rowid=$st_rowid;"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3348 done
124
9742dbee5cba Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents: 123
diff changeset
3349
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3350 if [ x"$bin" = x"NULL" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3351 ## err repl:normal sql=`echo $sql`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3352 query "$sql
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
3353 delete from $tb2 where type='string' and val='';"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3354 ## err repl:normal done
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3355 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3356 sqlfile="$tmpd/sqlf.$$"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3357 echo "$sql" > $sqlfile
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3358 ## err repl:sqlfile=`ls -lF $sqlfile`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3359 query ".read $sqlfile"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3360 ## err repl:done
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3361 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3362 # Rest of kt==m: set multiple mode
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3363 nr=`getparcount $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3364 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3365 nr=1 # for kt==s, number of records is 1
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3366 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3367
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3368 i=0
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3369 while [ $i -lt $nr ]; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3370 limit="limit 1 offset $i"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3371 i=$((i+1)) # increase beforehand against continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3372 val=`getvalquote $tbl $col "$limit"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3373 [ -z "$val" -o x"$val" = x'""' -o x"$val" = x"NULL" ] && continue
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3374 ## err $col=$val
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3375 bin=NULL
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3376 ## err partype$col=`getpartype $col "$limit"`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3377 case $ptype in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3378 file) file=$tmpd/`getparfilename $col "$limit"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3379 ## err parfile-$col=$file
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3380 [ -z "$file" ] && continue
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3381 bin="X'"$(hexize "$file")"'"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3382 ct=`file --mime-type - < "$file"|cut -d' ' -f2`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3383 type=\"file:$ct\" ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3384 "*"*) continue ;; # foreign table
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3385 *) type=\"string\" ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3386 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3387 case `gettbl_coltype $tbl/$col` in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3388 password) # special care for password
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3389 # name={password,pswd1,pswd2}
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3390 p1=`getpar pswd1 "$limit"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3391 if [ -z "$p1" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3392 continue # SKIP password setting, if p1 is empty
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3393 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3394 pswd=`getpar pswd "$limit"` p2=`getpar pswd2 "$limit"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3395 ## err pswd=$pswd
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3396 if pwcheck "$pswd"; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3397 if [ x"$p1" = x"$p2" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3398 case "$p1" in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3399 ??????????*) ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3400 *) echo "パスワードは10字以上にしてください。" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3401 return 6;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3402 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3403 val="\"`echo $p1|mypwhash`\""
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3404 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3405 echo "2つの新パスワード不一致" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3406 return 7
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3407 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3408 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3409 echo "旧パスワード違います" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3410 return 8
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3411 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3412 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3413 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3414 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3415 ## err p2t: "replace into $tb2 values($pval, \"$col\", $type, $val, bin...);"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3416 #query "replace into $tb2 values($pval, \"$col\", $type, $val, $bin);"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3417 sql="replace into $tb2 values($pval, \"$col\", $type, $val, $bin);"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3418 if [ x"$bin" = x"NULL" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3419 ## err Normal-query: `echo $sql`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3420 query "$sql"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3421 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3422 sqlfile="$tmpd/query.$$"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3423 echo "$sql" > $sqlfile
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3424 ## err sqlfile=`ls -lF $sqlfile`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3425 query ".read $sqlfile"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3426 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3427 ## err p2t done
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3428 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3429 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3430 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3431 return 0
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
3432 ##err donee
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3433 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3434 genform() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3435 # $1 = form definition file
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3436 # $2, $3 (optional)= table name and ROWID
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3437 # If $GF_VIEWONLY set and nonNull, output values without form
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 218
diff changeset
3438 # If $GF_ARGS set, use it as content-strings in the form
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3439 # If $GF_OWNER set, use it as value of name="owner"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3440 # If $GF_STAGE set, use it as value of name="stage"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3441 forms="" hiddens="" rowid=$3
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3442 if [ ! -e "$1" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3443 echo "そのようなデータベースはないようです($2)。" | html p
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3444 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3445 elif [ -n "$2" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3446 rec=`query "select * from $2 where rowid='$rowid';"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3447 if [ -z "$rec" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3448 pk=`gettblpkey $2`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3449 ###rec=`sq $db "select rowid from $2 where $pk='$rowid'"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3450 rec=`query "select rowid from $2 where $pk='$rowid';"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3451 rowid=$rec
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3452 rec=$3
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3453 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3454 if [ -z "$rec" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3455 echo "そんなレコードはないみたいね..." | html p
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3456 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3457 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3458 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3459 if [ -z "$GF_VIEWONLY" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3460 rm='<input id="rm" name="rm" type="checkbox"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3461 value="yes"><label for="rm">このエントリの削除</label>
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3462 <span>ほんとうに消しますよ(確認)!
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3463 <input name="confirm" type=checkbox value="yes">はい</span>'
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3464 fi
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3465 # Image Cache dir
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3466 ## err genform: getcache=$2/$rowid
77
10bd684f07d2 Argument for getcache fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 76
diff changeset
3467 td=`getcachedir "$2/$rowid"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3468 while IFS=: read prompt name keytype type args; do
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3469 [ -z "${prompt%%\#*}" ] && continue # skip comment line(#)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3470 sp="${args:+ }"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3471 form="" val=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3472 if [ -n "$rowid" ]; then
141
6da489b573ca Do not try to cat cached file when return val is null.
HIROSE Yuuji <yuuji@gentei.org>
parents: 137
diff changeset
3473 # err genform2a: Seeking for "$2.$name, type=$type"
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
3474 rawval=`getvalbyid $2 $name $rowid $td`
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
3475 val=`echo "$rawval"|htmlescape`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3476 ## err genform3a: getvalbyid $2 $name $rowid $td
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3477 ## err genform3b: val="[$val]" type="$type"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3478 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3479 if [ -n "$GF_VIEWONLY" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3480 is_hidden "$2" "$name" && continue
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3481 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3482 case "$type" in
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3483 text*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3484 cgiform=cgi_multi_$type
141
6da489b573ca Do not try to cat cached file when return val is null.
HIROSE Yuuji <yuuji@gentei.org>
parents: 137
diff changeset
3485 if [ -s $td/$name.count -a -n "$val" ]; then
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3486 form=`$cgiform $name $td`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3487 val=$(echo "$val"|
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3488 while read fn; do
208
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
3489 echo "<tr><td>`cat $td/$fn|htmlescape|hreflink`
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
3490 </td></tr>$nl"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3491 done)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3492 val="<table>$nl$val$nl</table>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3493 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3494 #form="<input name=\"$name\" value=\"$val\" type=\"$type\"$sp$args>$nl"
361
34076e5a4018 Should not htmlescape at calling cgi_type*
HIROSE Yuuji <yuuji@gentei.org>
parents: 359
diff changeset
3495 form=`cgi_$type $name "$rawval" "$args"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3496 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3497 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3498 [Rr][Aa][Dd][Ii][Oo])
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
3499 fh="<label><input type=\"radio\" name=\"$name\""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3500 form="`echo $args|sed -e \
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
3501 \"s,\([^ =][^=]*\)=\([^= ][^= ]*\),$fh value=\\"\2\\">\1</label>,g\"`"
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
3502 ;;
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
3503 [Cc][Hh][Ee][Cc][Kk][Bb][Oo][Xx])
101
4aefd0ddf88b name=... missing
HIROSE Yuuji <yuuji@gentei.org>
parents: 100
diff changeset
3504 form="<label><input type=\"checkbox\" name=\"$name\" value=\"${args#*=}\">${args%=*}</label>"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3505 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3506 [Ss][Ee][Ll][Ee][Cc][Tt])
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3507 fh="<select name=\"$name\">$nl"
112
cec40085a1d4 Seed for form of "select" now requires no values
HIROSE Yuuji <yuuji@gentei.org>
parents: 102
diff changeset
3508 form=$(for l in $args; do
cec40085a1d4 Seed for form of "select" now requires no values
HIROSE Yuuji <yuuji@gentei.org>
parents: 102
diff changeset
3509 echo "<option value=\"${l#*=}\">${l%=*}</option>"
cec40085a1d4 Seed for form of "select" now requires no values
HIROSE Yuuji <yuuji@gentei.org>
parents: 102
diff changeset
3510 done)
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3511 if [ -n "$val" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3512 form=`echo $form|sed -e "s,\(value=.$val.\),\\1 selected,"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3513 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3514 form="$fh$form</select>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3515 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3516 [Ii][Mm][Aa][Gg][Ee]|[Dd][Oo][Cc][Uu][Mm][Ee][Nn][Tt]|[Bb]inary)
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3517 if [ -s $td/$name.count ]; then
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3518 form=`cgi_multi_file $name $td "$args"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3519 if [ -n "$val" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3520 hrfb="$myname?showattc+$2_m"
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
3521 val=$(echo "$rawval" \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3522 | while read fn; do
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3523 data=`percenthex "$td/$fn"`
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3524 #ct=`cat $td/$fn.content-type`
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3525 ct=`file --mime-type - < "$td/$fn"|cut -d' ' -f2`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3526 ri=`cat "$td/$fn.rowid"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3527 ## err fn=$fn, name=$name, ri=$ri; ls -lF "$td/" 1>&3
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3528 #imgsrc="<img src=\"data:$ct,$data\">"
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
3529 #echo "<a href=\"$hrfb+$ri\">$imgsrc</a><br>"
472
38bf8d300b12 For slower connection, it's better to use img-link over data:
HIROSE Yuuji <yuuji@gentei.org>
parents: 471
diff changeset
3530 iconhref2 "$td/$fn" "$hrfb+$ri" ""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3531 done)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3532 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3533 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3534 form="<input type=\"file\" name=\"$name\" $args>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3535 if [ -n "$val" ]; then
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3536 imgs=$(echo "$rawval"\
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3537 |while read fn;do
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3538 data=`percenthex "$td/$fn"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3539 echo "<img src=\"data:image/png,$data\">$fn<br>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3540 done)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3541 form=$form"<br>$imgs"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3542 val=$imgs # 2015-06-15
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3543 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3544 form="<input type=\"file\" name=\"$name\" $args>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3545 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3546 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3547 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3548 [Hh][Ii][Dd][Dd][Ee][Nn])
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3549 if [ -n "$GF_STAGE" -a x"$name" = x"stage" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3550 args="value=\"$GF_STAGE\""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3551 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3552 form="<input type=\"hidden\" name=\"$name\" $args>"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3553 prompt='' # Remove prompt
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3554 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3555 [Aa][Uu][Tt][Hh][Oo][Rr])
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
3556 [ -n "$GF_VIEWONLY" ] && continue
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3557 form="<input type=\"hidden\" name=\"author\" value=\"$user\">"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3558 prompt="" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3559 [Oo][Ww][Nn][Ee][Rr])
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
3560 [ -n "$GF_VIEWONLY" ] && continue
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3561 val=${GF_OWNER:-$val}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3562 val=${val:-$user}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3563 form="<input type=\"hidden\" name=\"owner\" value=\"$val\">"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3564 prompt="" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3565 [Uu][Ss][Ee][Rr])
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3566 # XXX: is null $user ok?
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3567 #form="<input type=\"hidden\" name=\"user\" value=\"$user\">"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3568 [ -n "$GF_VIEWONLY" ] && continue
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3569 form="$user"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3570 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3571 [Pp]assword)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3572 [ -n "$GF_VIEWONLY" ] && continue
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3573 form="`cgi_passwd`"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3574 val=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3575 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3576 [Ss][Ee][Rr][Ii][Aa][Ll]|[Ss][Tt][Aa][Mm][Pp])
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
3577 [ -n "$GF_VIEWONLY" ] && continue
127
c17964aa7715 Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents: 124
diff changeset
3578 if [ -z "$rowid" ]; then
268
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
3579 val=`genserial`
127
c17964aa7715 Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents: 124
diff changeset
3580 fi
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
3581 form="<input type=\"hidden\" name=\"$name\" value=\"$val\">"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3582 prompt="" ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3583 [Ss][Ee][Ss][Ss][Ii][Oo][Nn])
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3584 prompt=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3585 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3586 parent|path|blog*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3587 prompt=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3588 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3589 "*"*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3590 tail=$tail"``"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3591 continue ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3592 esac
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3593 if [ -n "$prompt" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3594 if [ -n "${GF_VIEWONLY}" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3595 form=$val
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3596 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3597 :
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3598 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3599 forms=$forms" <tr class=\"$name\"><th>$prompt</th><td>$form</td></tr>$nl"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3600 else
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3601 hiddens=$hiddens$nl"$form"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3602 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3603 done < $1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3604 # enctype="multipart/form-data"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3605 cat<<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3606 <form action="${GF_ACTION:-$myname}" method="POST" enctype="multipart/form-data">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3607 ${rowid:+$rm}
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3608 <table class="b $2">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3609 $forms
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3610 </table>$hiddens
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3611 ${GF_STAGE:+`cgi_hidden stage $GF_STAGE`}
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
3612 ${rowid:+<input type="hidden" name="rowid" value="$rowid">}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3613 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3614 if [ -z $GF_VIEWONLY ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3615 cat<<EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3616 <input type="submit" name="sub" value="OK">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3617 <input type="reset" name="res" value="Reset">
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3618 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3619 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3620 cat<<EOF
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 218
diff changeset
3621 $GF_ARGS</form>
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3622 $tail
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3623 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3624 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3625 edittable() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3626 # $1=form-def $2=table $3 rowid
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3627 genform "$@"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3628 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3629 viewtable() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3630 GF_VIEWONLY=1 genform "$@"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3631 }
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3632 showattc() {
350
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3633 # $1=table_m $2=rowid &optional $3=RawFlag
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3634 ## err \$1=$1 \$2=$2 \$3=$3
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3635 if ! isfilereadable $user $1 $2; then
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3636 contenttype; echo
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3637 echo "このファイルは管理者のみしか見られません" | html p
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3638 putfooter; exit
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3639 fi
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3640 idir=`umask 002; mktempd` || exit 1
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3641 # tmpfiles=$tmpfiles"${tmpfiles+ }$idir"
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3642 bin=$idir/$myname-$$.bin
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3643 sql="select quote(bin) from $1 where rowid='$2';"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3644 ## err showattc: sql: $sql
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3645 sq $db "$sql" | unhexize > $bin
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3646 tv=`query "select type||'//'||val from $1 where rowid='$2';"`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
3647 type=${tv%//*} fn=${tv#*//}
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3648 ## err tv=$tv type=$type fn=$fn, tp2=${tv%\|*}
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3649 ct=${type#file:}
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3650 case $ct in # all text/* changed to text/plain
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3651 text/*)
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3652 charset=`nkf -g $bin|cut -d' ' -f1`
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3653 case $charset in
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3654 ASCII*) charset="" ;;
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3655 esac
350
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3656 if [ -z "$3" ]; then
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3657 ct="text/html${charset:+; charset=$charset}"
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3658 link="?showattc+$1+$2+raw"
395
3d82052c3cd3 Do htmlescape() for euc-jp string and restore to original charset
HIROSE Yuuji <yuuji@gentei.org>
parents: 394
diff changeset
3659 nkf -e $bin | htmlescape | nkf --oc="$charset" \
350
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3660 | sed 's,^,<span></span>,' \
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3661 | _m4 -D_TITLE_="$fn" -D_CONTENT_TYPE_="$ct" \
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3662 -D_LINK_="$link" \
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3663 -D_BODY_="syscmd(\`cat')" $layout/pretty.m4.txt
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3664 exit $?
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3665 fi
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
3666 ct="text/plain${charset:+; charset=$charset}"
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3667 ;;
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3668 esac
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3669 contenttype "$ct"
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3670 echo "Content-Disposition: filename=\"$fn\""
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3671 echo "Content-Length: " `cat $bin | wc -c`; echo
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3672 #echo "Content-Type: " ${type#file:}; echo
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3673 cat $bin
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
3674 }
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3675 #
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3676 # Some default stupid handler on CGI values
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3677 #
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3678 default_storedb() {
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3679 # ARG: $1=table-def-file
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3680 # RET: $tbl=table-name, $col=mail-column, $cols=columns
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3681 tbl=`basename $1`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3682 tbl=${tbl%.def}
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3683 cols="`grep :text $1|cut -d: -f2`"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3684 col=`echo "$cols"|head -1`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3685 vcol=`getpar $col`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3686 err default0: \$1=$1 col=$col cols="[$cols]" vcol=$vcol
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3687 if [ -n "$vcol" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3688 par2table $1
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3689 else
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3690 return 2 # No insertion occurred
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3691 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3692 }
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3693
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3694 default_view() { # $1=def-file
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3695 ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3696 ## DT_VIEW="edittable+$tbl" dumptable html $tbl "name memo file" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3697 default_storedb "$@"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3698 query "select rowid from $tbl order by rowid desc;" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3699 | while read rowid; do
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3700 viewtable $1 $tbl $rowid
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3701 done | _m4 -D_TITLE_="$tbl" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3702 -D_FORM_="`genform $1`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3703 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3704 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3705 }
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3706 default_viewtext() { # $1=def-file
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3707 ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3708 default_storedb "$@"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3709 DT_VIEW="viewtable+$tbl" dumptable html $tbl "name memo file" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3710 | _m4 -D_TITLE_="$tbl" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3711 -D_FORM_="`genform $1`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3712 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3713 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3714 }
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3715 default_smail() {
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3716 default_storedb "$@"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3717 if [ $? -eq 2 ]; then
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3718 _m4 -D_TITLE_="入力" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3719 -D_FORM_="`genform $1`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3720 -D_DUMPTABLE_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3721 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3722 return
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3723 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3724 cond=""
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3725 for pk in `gettblpkey $tbl`; do
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
3726 pv=$(sqlquote "$(getpar $pk)")
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3727 cond="$cond${cond:+ and }$pk=$pv"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3728 done
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3729 sql="select rowid from $tbl where $cond;"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3730 rowid=`query "$sql"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3731 ## err smail1 - "$sql" "-> rowid=$rowid"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3732
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3733 while IFS=: read prompt name keytype type args; do # Read from $1
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3734 val=`getpar $name`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3735 if [ -n "$val" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3736 text="$text
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3737 $prompt
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3738 $name=$val
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3739 ---------------------------------------------------------"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3740 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3741 case "$type" in
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3742 image|document|file)
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3743 fn="`getvalbyid $tbl $name $rowid $tmpd`"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3744 fns=$(echo "$fn"|while read fn; do
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3745 err mv $tmpd/$fn.orig $tmpd/$fn
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3746 mv $tmpd/$fn.orig $tmpd/$fn
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3747 rm $tmpd/$fn.rowid # Remove cache flag
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3748 ## err "`ls $tmpd/$fn`"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3749 echo $fn
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3750 done)
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3751 files="$files $fns"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3752 ;;
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3753 esac
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3754 done < $1
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3755 ## err FILES=$files "`ls -lF $tmpd`"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3756 subj="from ${REMOTE_ADDR}"
102
7cdaac365897 s/$URL/$url/
HIROSE Yuuji <yuuji@gentei.org>
parents: 101
diff changeset
3757 (echo "$url"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3758 echo "への書き込みがありました。"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3759 echo "------"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3760 echo "$text"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3761 ) | (cd $tmpd &&
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3762 err LS="`ls -lF`" &&
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3763 $mydir/sendmultipart.sh -t "$admin" -s "$subj" $files)
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3764 _m4 -D_TITLE_="入力完了" $layout/html.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3765 echo "以下の内容で送信しました。" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3766 viewtable $1 $tbl \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3767 `query "select rowid from $tbl order by rowid desc limit 1;"`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3768 echo "戻る" | html a "href=\"?\""
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
3769 }

yatex.org