Mercurial > hgrepos > hgweb.cgi > s4
annotate s4-funcs.sh @ 178:ed2915aa2826
Remove superfluous condition in listnewblogsql
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 20 Feb 2016 09:13:33 +0859 |
parents | 1adafaf079a0 |
children | 479b57681014 |
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 | 3 # $HGid$ |
26 | 4 |
5 [ -f s4-config.sh ] && . ./s4-config.sh | |
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="$@" |
8 | 10 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
|
11 tmpdir=${TMPDIR:-tmp} |
2 | 12 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
|
13 tmpfiles="" |
2 | 14 db=${DB:-$dbdir/cgi.sq3} |
83
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
15 admin=${ADMIN:-hostmaster@example.org} |
3 | 16 templ=${TEMPL:-templ} |
67 | 17 layout=${LAYOUT:-$templ/default} |
18 formdir=${FORMDIR:-$templ/form} | |
19 imgdir=${IMGDIR:-img} | |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
20 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
|
21 urlbase=${url%%\?*} |
117 | 22 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
|
23 timeout="+2 days" |
117 | 24 memoplimitdays="7" |
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
|
25 dumpcollen=20 |
67 | 26 #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
|
27 thumbxy=96x96 |
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 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
|
29 ### maximagexy=400x400 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
30 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
|
31 imgcached=imgcache.`date +%Y/%m` |
4
6822f4362bf9
New system name declared as yas4
HIROSE Yuuji <yuuji@gentei.org>
parents:
3
diff
changeset
|
32 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
|
33 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
|
34 " |
17 | 35 . ./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
|
36 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
37 : <<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
|
38 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
39 資料配布、グループ管理・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
|
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
|
41 ひとつの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
|
42 |
120 | 43 8/4 ○グループに承認加入モードを追加 |
44 ○グループに参加していない場合は grpaction できない | |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
45 Web |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
46 締切設定 |
120 | 47 |
48 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
|
49 ○自分の提出物リスト |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
50 |
52
46e53418e28f
missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
51 7/19 ○設置 |
46e53418e28f
missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
52 ○一斉送信 |
46e53418e28f
missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
53 ○getparfilename の tmpd の扱い |
46e53418e28f
missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
54 ○やっぱりs4にしようかな |
4
6822f4362bf9
New system name declared as yas4
HIROSE Yuuji <yuuji@gentei.org>
parents:
3
diff
changeset
|
55 7/18 ○書込著者からホームへのリンク |
2 | 56 7/17 ○個人blogに「レポート提出用」がついたときの挙動 |
57 ○添付ファイル回収 | |
58 ○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
|
59 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
|
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 |
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 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
|
63 ○レポート提出はどうしよう |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
64 → ○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
|
65 ○レポート提出モード |
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 クリッカーは別立てメニューにしないと(管理者が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
|
68 ○添付ファイルの読み出し権(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
|
69 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
70 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
71 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
|
72 △グループメンバの操作 → 要不要を吟味 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
73 ○グループ情報編集の行先はそのグループがいい? |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
74 ○新規グループの作成はどこから入るか |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
75 △グループホームとユーザホームを揃える |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
76 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
77 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
|
78 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
79 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
|
80 ○グループ検索 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
81 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
82 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
|
83 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
84 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
85 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
|
86 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
|
87 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
88 ○ 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
|
89 ○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
|
90 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
|
91 →とすると 一気に |
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 ## 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
|
94 ## 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
|
95 ## 必須カラム、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
|
96 ## ユーザ管理とグループ管理はデフォルトで持たせてしまえ |
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 ## 縦持ちデータの入力/編集を供給する関数 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
|
99 ## 持てるテーブル構造はシステム標準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
|
100 ## 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
|
101 ## 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
|
102 ## 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
|
103 ## 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
|
104 ## 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
|
105 ## 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
|
106 ## 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
|
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 ## ● 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
|
109 ## 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
|
110 ## ● 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
|
111 ## 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
|
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 ## グループ属性: 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
|
114 ## ○ 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
|
115 ## 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
|
116 ## 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
|
117 |
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 ## 書き込みオブジェクトとは何か? |
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 ## 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
|
120 ## 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
|
121 ## 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
|
122 ## 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
|
123 ## 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
|
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 ## 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
|
126 ## 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
|
127 ## 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
|
128 ## 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
|
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 ## 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
|
131 ↓ |
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 ↓以下に変更 |
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 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
|
134 (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
|
135 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
|
136 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
|
137 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
|
138 |
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 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
|
141 (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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 |
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 |
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 ## 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
|
150 ## 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
|
151 ## 埋め込み画像 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
|
152 |
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 ## 考え得るノードタイプ |
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 ## 日報 - 個人所属かグループ所属か |
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 ## 課題提出 - 個人所属かグループ所属か |
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 ## 個人情報管理 |
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 ## |
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 |
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 ## 例: 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
|
161 ## - 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
|
162 ## 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
|
163 ## 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
|
164 ## 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
|
165 ## 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
|
166 ## 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
|
167 ## 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
|
168 ## 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
|
169 ## 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
|
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 ## 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
|
173 |
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 |
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 |
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 ■表設計 |
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 * 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
|
178 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
|
179 * *_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
|
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 |
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 |
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 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
|
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 * 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
|
187 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
|
188 * 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
|
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 * 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
|
191 自動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
|
192 * 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
|
193 入力 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
|
194 変更 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
|
195 * 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
|
196 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
|
197 * 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
|
198 入力 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
|
199 * 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
|
200 入力 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
|
201 * 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
|
202 入力 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
|
203 * 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
|
204 入力時の $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
|
205 * 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
|
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 * 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
|
208 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
|
209 * 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
|
210 木構造の場合の親の位置 |
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 * 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
|
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 * 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
|
216 表 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
|
217 * 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
|
218 表 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
|
219 |
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 オブジェクトタイプ |
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 * 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
|
222 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
|
223 * 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
|
224 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
|
225 * 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
|
226 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
|
227 * 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
|
228 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
|
229 * 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
|
230 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
|
231 * 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
|
232 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
|
233 * 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
|
234 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
|
235 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
|
236 |
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 |
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 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
|
239 "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
|
240 "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
|
241 "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
|
242 "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
|
243 "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
|
244 "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
|
245 "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
|
246 "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
|
247 {"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
|
248 "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
|
249 "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
|
250 "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
|
251 "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
|
252 "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
|
253 "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
|
254 {"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
|
255 |
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 |
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 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
|
258 ユーザ名(英数字):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
|
259 パスワード: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
|
260 説明(日本語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
|
261 セッションキー: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
|
262 メイルアドレス: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
|
263 住所: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
|
264 プロフィール画像: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
|
265 履歴書: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
|
266 |
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 変換表 |
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 /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
|
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:= |
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 シリアル: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
|
272 タイトル: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
|
273 所有者: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
|
274 時刻: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
|
275 リード文: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
|
276 リプライ: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
|
277 |
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 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
|
279 シリアル: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
|
280 筆者: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
|
281 時刻: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
|
282 参照元: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
|
283 パス: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
|
284 本文: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
|
285 画像: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
|
286 |
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 履歴書: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
|
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 |
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 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
|
291 |
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 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
|
293 # ./args.rb -cmd ".timeout 3000" "$@" |
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 sqlite3 -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000" "$@" |
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 } |
163 | 296 dbsetup() { |
297 [ -d $tmpdir ] || mkdir -m 1777 $tmpdir | |
298 [ -d $dbdir ] || mkdir -m 1775 $dbdir | |
299 sqi=$tmpdir/sqi.$$ | |
300 sqo=$tmpdir/sqo.$$ | |
301 mkfifo $sqi $sqo | |
302 #tail -f $sqi | sq $db & # "tail -f" is too heavy. DO NOT USE!! | |
303 sq $db < $sqi & | |
304 sq3pid="`jobs -p` $!" | |
305 exec 2>> $tmpdir/error.out | |
306 exec 3>> $tmpdir/debug.out | |
307 exec 5> $sqi # Turning $sqi access through fd5 for continuous open state | |
308 rm $sqi | |
309 } | |
310 cleanup() { | |
311 echo .quit >&5 | |
312 kill $sq3pid | |
313 kill $sq3pid | |
314 rm -f $sqo $sqi | |
315 rm -rf $tmpfiles | |
118
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
316 } |
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
|
317 query() { |
163 | 318 cat<<EOF >&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
|
319 .once $sqo |
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 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
|
322 cat $sqo |
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 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
324 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
325 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
|
326 # $1=user, $2=group |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
327 err ismem: "select user from grp_mem where gname=$(sqlquote $2) and user='$1';" |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
328 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
|
329 } |
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 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
|
331 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
|
332 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
333 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
|
334 err isgroup: "select gname from grp where gname=$(sqlquote $1);" |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
335 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
|
336 } |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
337 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
|
338 # $1=user, $2=group |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
339 gn=`sqlquote "$2"` |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
340 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
|
341 err isgrpowner: $sql |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
342 test -n "`query $sql`" |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
343 ) |
117 | 344 getgroupadminmails() { |
345 # $1=group | |
346 for i in $(getgroupadmins $1); do | |
347 email4group "$1" "$i" ; | |
348 done | |
349 } | |
56 | 350 getgroupadmins() { # $1=group |
351 # This function is called in a backquote, so needn't to be subshellized | |
352 qgrp=`sqlquote "$1"` | |
353 query "select user from grp_adm where gname=$qgrp;" | |
354 } | |
117 | 355 getgroupattr() { # $1=group $2=attr |
356 # This function is called in a backquote, so needn't to be subshellized | |
357 getvalbyid grp $2 \ | |
358 $(query "select rowid from grp where gname=`sqlquote $1`;") | |
359 } | |
56 | 360 getgroupbyid() { |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
361 # $1=id|gname |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
362 sql="select coalesce((select gname from grp where gname=$(sqlquote $1)), |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
363 (select gname from grp where rowid=$(sqlquote $1)));" |
71 | 364 # err ggbyid: `echo $sql` |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
365 query $sql |
56 | 366 } |
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
|
367 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
|
368 # 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
|
369 [ -z "$1" -o -z "$2" -o -z "$3" ] && return 1 # invalid argument |
78 | 370 |
371 # Return true when anonymous mode | |
372 [ "$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
|
373 # 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
|
374 # 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
|
375 # *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
|
376 # 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
|
377 # 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
|
378 # 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
|
379 # 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
|
380 # [ 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
|
381 # 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
|
382 # 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
|
383 # ↑ 要はこういう処理を↓で一気にやっている |
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 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
|
385 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
|
386 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
|
387 (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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 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
|
400 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
|
401 user='$1')\ |
39
5ed3caba8dd1
report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents:
33
diff
changeset
|
402 when (select author from article where\ |
5ed3caba8dd1
report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents:
33
diff
changeset
|
403 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
|
404 then 'user+author' |
5ed3caba8dd1
report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents:
33
diff
changeset
|
405 else '' end;" |
5ed3caba8dd1
report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents:
33
diff
changeset
|
406 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
|
407 # 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
|
408 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
|
409 [ -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
|
410 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
|
411 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
412 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
|
413 # $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
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
423 acclog() { |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
424 # $1=table, $2=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
|
425 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
|
426 now=`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
|
427 query "replace into acclog values('$user', '$1', '$2', '$now');" |
176
2194af7e96f3
Tbl of collecting time of acclog for listnewblogs should be 'blog'
HIROSE Yuuji <yuuji@gentei.org>
parents:
175
diff
changeset
|
428 #query "replace into acclog values('$user', '$1', $2, '$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
|
429 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
|
430 } |
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 gecos() ( |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
432 u=`sqlquote ${1:-$user}` |
2 | 433 #gecos=`query "select val from user_s where name='$u' and key='gecos';"` |
173 | 434 # sql="select case when (select name from user where name=$u) is not null |
435 # then coalesce( | |
436 # (select val from user_s where name=$u and key='gecos'), | |
437 # $u) | |
438 # when (select gname from grp where gname=$u) is not null | |
439 # then coalesce( | |
440 # (select val from grp_s where gname=$u and key='gecos'), | |
441 # $u) | |
442 # else $u | |
443 # end;" | |
444 #query "$sql" | |
445 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
|
446 ) |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
447 setpar() { |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
448 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
|
449 } |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
450 replpar() { |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
451 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
|
452 } |
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
|
453 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
|
454 err getpar: "select val 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
|
455 val=`query "select val from par where var='$1' and sessid='$session' $2;"` |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
456 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
|
457 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
|
458 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
|
459 fi |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
460 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
|
461 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 esac |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
469 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
|
470 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
|
471 } |
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 |
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 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
|
474 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
|
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 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
|
477 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
|
478 } |
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 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
|
480 # 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
|
481 (f=`query "select val from par where var='$1' and sessid='$session' and type='file' $2;"` |
13 | 482 [ -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
|
483 } |
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 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
|
485 (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
|
486 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
|
487 "") 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
|
488 "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
|
489 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
|
490 *\"*) # 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
|
491 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
|
492 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
|
493 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
|
494 *.*.*|*-*-*|*[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
|
495 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
|
496 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
|
497 *) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
505 mktempd() { |
11 | 506 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
|
507 } |
69 | 508 getcachedir() { # $1=maintable |
509 if [ -n "$imgcached" ]; then | |
510 echo $tmpdir/$imgcached/$(echo ${1:-hoge}|md5)/$thumbxy | |
511 else | |
512 echo $tmpd/$thumbxy | |
513 fi | |
514 } | |
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
|
515 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
|
516 # $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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 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
|
522 serial) |
67 | 523 (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
|
524 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
|
525 *) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
526 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
|
527 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
|
528 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
529 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
530 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
|
531 # $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
|
532 (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
|
533 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
|
534 "") 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
|
535 *) 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
|
536 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
|
537 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
538 getparquote() { |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
539 sqlquote `getpar $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
|
540 } |
78 | 541 getbinbyid() { |
542 # $1=tbl $2=col $3=rowid $4=tmpdirForBinary | |
543 | |
544 } | |
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
|
545 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
|
546 # $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
|
547 # 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
|
548 # 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
|
549 # 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
|
550 ## 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
|
551 |
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
|
552 (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
|
553 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
|
554 err "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
|
555 ###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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 key=`query "select $pk from $1 where rowid=$3;"` |
33 | 562 getkey="(select $pk from $1 where 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
|
563 ### 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
|
564 for kt in s m; do |
13 | 565 td=${4:-$tmpd} |
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
|
566 [ -d $td ] || mkdir -p $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
|
567 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
|
568 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
|
569 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
|
570 if [ x"$2" = x"$c" ]; then |
33 | 571 #### cond="$t where $pk=\"$key\" and key=\"$c\"" #2015-07-22 |
572 cond="$t where $pk=$getkey and key=\"$c\"" | |
3 | 573 val=`query "select val from $cond limit 1;"` |
574 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
|
575 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
|
576 ###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
|
577 # 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
|
578 val=`query "select val from $cond and type like 'file:%' order by rowid;"` |
59 | 579 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
|
580 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
|
581 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
|
582 i=0 |
59 | 583 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
|
584 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
|
585 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
|
586 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
|
587 fn=$c.$i |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
588 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
|
589 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
|
590 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
|
591 #file=$td/$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
|
592 file=$td/`query "select val from $cond $slice;"` |
47
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
593 # FOR SPEED: Skip file generation if imgcache exists |
131
9782a978d53c
Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents:
128
diff
changeset
|
594 [ -s $file -a -s $td/$fn.rowid -a -s $file.rowid ] && continue |
78 | 595 # err gvbid-get="select quote(bin) from $cond $slice;" |
8 | 596 sq $db<<EOF | unhexize > $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
|
597 .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
|
598 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
|
599 .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
|
600 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
|
601 .output $file.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
|
602 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
|
603 .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
|
604 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
|
605 EOF |
131
9782a978d53c
Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents:
128
diff
changeset
|
606 ## err gvbid-get2: "`ls -lF $file`" |
3 | 607 ## err i=$i - file=$file rowid=`cat $td/$fn.rowid` |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
608 cp $td/$fn.rowid $file.rowid 2>&3 # for convenience |
78 | 609 cp $file $file.orig 2>&3 |
136 | 610 ls -lh $file | awk '{print $5"B"}'|sed 's/BB/B/' > $file.size |
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
|
611 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
|
612 *:[Ii]mage*) mogrify -geometry $thumbxy $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
|
613 ### ここのアイコンを増やしたい |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
614 *|*:[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
|
615 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
|
616 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
|
617 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
618 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
|
619 ;; |
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 *) |
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 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
|
622 .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
|
623 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
|
624 .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
|
625 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
|
626 EOF |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
627 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
|
628 ;; |
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 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
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 | 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
|
637 file=$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
|
638 if [ ! -s $file ]; 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
|
639 ## 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
|
640 query "select quote(bin) from $cond and val=\"$fn\";" \ |
8 | 641 | unhexize > $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
|
642 echo ${type#file:} > $file.content-type |
2 | 643 # err TTTTTTTTTTTTTTTT: $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
|
644 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
|
645 *:[Ii]mage*) mogrify -geometry $thumbxy $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
|
646 *:[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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 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
|
652 ;; |
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 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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 } |
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 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
|
662 # $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
|
663 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
|
664 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
|
665 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
|
666 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
667 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
|
668 # $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
|
669 ###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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
675 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
|
676 # 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
|
677 # 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 } |
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 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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 $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
|
697 } |
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 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
|
699 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
|
700 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
|
701 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
|
702 '$'*'$'*) 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
|
703 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
|
704 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
|
705 echo -n '$4$'"$salt"'$' |
144 | 706 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
|
707 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
708 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
|
709 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
|
710 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
|
711 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
|
712 else |
8 | 713 hexize_hd() { |
714 hexdump -ve '1/1 "%.2x"' | |
715 } | |
716 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
|
717 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
|
718 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
|
719 cat $1 | $hexize | 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
|
720 } |
8 | 721 unhexize() { |
722 if [ -z "$unhex" ]; then | |
723 if type xxd >/dev/null 2>&1; then | |
724 unhex="xxd -p -r" | |
725 elif type perl >/dev/null 2>&1; then | |
726 cat >$tmpd/unhex.pl<<EOF | |
727 s/([0-9a-f]{2})/print chr hex \$1/gie | |
728 EOF | |
729 # Perl refuses -e in setuid circumstances, which can be absurdly | |
730 # avoided by creating scripts in a file where its parent directory is | |
731 # world writable...:) | |
732 unhex="perl -n $tmpd/unhex.pl" | |
733 fi | |
734 fi | |
735 cat $1 | $unhex | |
736 # cat $1 | tee /tmp/uh.in| $unhex | tee /tmp/uh.out | |
737 } | |
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
|
738 percenthex() { |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
739 hexize $1 | sed 's/\(..\)/%\1/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
|
740 } |
155
511406c0cbbe
Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents:
154
diff
changeset
|
741 htmlescape() { |
511406c0cbbe
Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents:
154
diff
changeset
|
742 sed -e 's/\&/\&/g' -e 's/"/\"/g' -e "s/'/\'/g" \ |
511406c0cbbe
Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents:
154
diff
changeset
|
743 -e "s/</\</g; s/>/\>/g" |
511406c0cbbe
Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents:
154
diff
changeset
|
744 } |
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 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
|
746 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
|
747 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
|
748 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 | 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
|
754 } |
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 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
|
756 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
|
757 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
|
758 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
|
759 } |
154
75598f2d3118
TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents:
153
diff
changeset
|
760 size_h() { |
164
0cc22764899e
size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents:
163
diff
changeset
|
761 i="$1" oi=$1 |
0cc22764899e
size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents:
163
diff
changeset
|
762 set -- B B KB MB GB TB |
0cc22764899e
size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents:
163
diff
changeset
|
763 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
|
764 oi=$i |
75598f2d3118
TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents:
153
diff
changeset
|
765 i=$((i/1024)) |
164
0cc22764899e
size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents:
163
diff
changeset
|
766 shift |
154
75598f2d3118
TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents:
153
diff
changeset
|
767 done |
75598f2d3118
TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents:
153
diff
changeset
|
768 echo ${oi}$1 |
75598f2d3118
TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents:
153
diff
changeset
|
769 } |
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 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
|
771 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
|
772 ## 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
|
773 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
|
774 "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
|
775 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
|
776 # /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
|
777 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
778 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
|
779 # $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
|
780 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
|
781 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
|
782 (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
|
783 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
|
784 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
|
785 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
|
786 *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
|
787 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
|
788 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
|
789 *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
|
790 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
|
791 *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
|
792 *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
|
793 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
|
794 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
|
795 *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
|
796 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
|
797 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
|
798 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
|
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 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
|
801 # $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
|
802 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
|
803 } |
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 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
|
805 (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
|
806 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
|
807 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
|
808 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
809 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
|
810 (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
|
811 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
|
812 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
|
813 } |
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 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
|
815 (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
|
816 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
|
817 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
|
818 } |
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 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
|
820 (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
|
821 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
|
822 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
|
823 } |
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 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
|
825 (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
|
826 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
|
827 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
|
828 } |
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 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 ) |
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 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
|
836 # $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
|
837 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
|
838 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
|
839 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
|
840 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
|
841 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
|
842 *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
|
843 *) 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
|
844 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
|
845 } |
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 |
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 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
|
848 # $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
|
849 (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
|
850 tsc=$t/$c val=$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
|
851 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
|
852 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
|
853 #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
|
854 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
|
855 #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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 #err t=$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
|
864 type=text 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
|
865 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
|
866 */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
|
867 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
|
868 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
869 */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
|
870 type=`file --mime-type $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
|
871 bin="X'`hexize $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
|
872 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 ###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
|
880 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
|
881 elif [ "$update" ]; 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
|
882 ###sq $db "update $1 set $c=\"$val\" where $pkey=\"$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
|
883 query "update $1 set $c=\"$val\" where $pkey=\"$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
|
884 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
|
885 #err "replace into $t values(\"$p\", \"$c\", \"$type\", \"$val\", \"$bin\")" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
886 ###sq $db "replace into $t values(\"$p\", \"$c\", \"$type\", \"$val\", \"$bin\")" |
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 query "replace into $t values(\"$p\", \"$c\", \"$type\", \"$val\", \"$bin\");" |
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 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
|
889 ) |
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 } |
3 | 891 expire() ( |
892 at="${1:-$timeout}" | |
893 FMT="${2:-%F %T}" | |
6 | 894 TZ=GMT gdate -d "$at" +"$FMT" |
3 | 895 ) |
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
|
896 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
|
897 # 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
|
898 # 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
|
899 expire=`expire ${2:-"+1min"}` |
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 err addsession "$1" exp=$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
|
901 sq $db "replace into session values('$1', '$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
|
902 # 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
|
903 now=`expire now` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
904 sq $db "delete from session where expire < '$now'" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
905 } |
3 | 906 gencookie() ( |
907 for kv; do | |
908 expire="`expire '' '%a, %d-%b-%Y %H:%M:%S GMT'`" | |
909 echo "Set-Cookie: $kv; expires=$expire" | |
910 done | |
911 ) | |
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
|
912 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
|
913 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
|
914 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
|
915 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
916 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
|
917 |
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 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
919 putfooter() { |
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 m4 -D_TITLE_="${TITLE:-$myname}" $layout/footer.m4.html |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
921 } |
3 | 922 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
|
923 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
|
924 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
|
925 v="`echo ${kv#*=}|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`" |
3 | 926 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
|
927 done |
3 | 928 ) |
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
|
929 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
|
930 # $1=columns (default: 10) |
3 | 931 dd if=/dev/urandom count=1 2>/dev/null|nkf -MB|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
|
932 } |
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 smail() { |
166
32557aa9af94
$SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents:
164
diff
changeset
|
934 # smail rcpts subj (file) |
32557aa9af94
$SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents:
164
diff
changeset
|
935 # $SMAIL_TO <- Recipient value of To: header |
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
|
936 rcpt=`echo $1` # strip newlines |
117 | 937 subj=`echo $2|nkf -jM|tr -d '\n'` |
166
32557aa9af94
$SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents:
164
diff
changeset
|
938 (m4 -D_RCPT_="${SMAIL_TO:-$rcpt}" -D_SUBJ_="\`$subj'" -D_FROM_=$admin $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
|
939 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
|
940 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
941 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
|
942 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 v="`echo ${us#*=}|tr '%+' '= '|nkf -Ww -mQ|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
|
948 sq $db "replace into $table values('$session', '$k', 'string', \"$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
|
949 #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
|
950 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
|
951 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
|
952 } |
3 | 953 checkdomain() ( |
954 # Check the validity of domain by referring DNS | |
955 item=$1 | |
83
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
956 err checkdomain $1 |
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
957 host ${item#*@} 1>&3 2>&3 |
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
958 host ${item#*@} >/dev/null 2>&1 |
3 | 959 ) |
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
|
960 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
|
961 # $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
|
962 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
|
963 encpswd=`mycrypt "$1" "$dbpswd"` |
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 err user=$user, pswd=$1, 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
|
965 [ 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
|
966 } |
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 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
|
968 mycrypt `cat` `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
|
969 } |
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 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
|
971 user=$1 |
83
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
972 if ! checkdomain $user; then |
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
973 contenttype; echo |
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
974 m4 -D_TITLE_='Invalid email' $layout/title-only.html |
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
975 echo "ユーザ名($user)には正しいメイルアドレスが必要です。" | html p |
815840076efa
Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents:
81
diff
changeset
|
976 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
|
977 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
|
978 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
|
979 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
|
980 #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
|
981 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
|
982 dbsetbyid user $user pswd "$encpswd" |
100 | 983 # Avoid $user substitution with m4, because $url comes from user input. |
984 m4 -D_PSWD_="$newpswd" -D_URL_="$url" -D_ADMIN_="$admin" \ | |
117 | 985 $msgdir/mail-newaccount.m4 \ |
100 | 986 | 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
|
987 | 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
|
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 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
|
990 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
|
991 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
|
992 [ -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
|
993 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
|
994 err user=$user skey=$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
|
995 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
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 pswd=`getpar 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
|
1001 if [ x"$pswd" = x"wasureta" ]; 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
|
1002 wasureta $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
|
1003 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
|
1004 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
|
1005 # 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
|
1006 # 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
|
1007 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
|
1008 newsession=`genrandom 50` |
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 dbsetbyid 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
|
1010 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
|
1011 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
|
1012 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
|
1013 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
|
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 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
|
1016 args=`echo $myargs|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
|
1017 m4 -D_SYSNAME_="Welcome" -D_MYNAME_="$myname${args+?}$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
|
1018 $layout/login.m4.html |
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 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
|
1020 } |
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 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
|
1022 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
|
1023 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
|
1024 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
|
1025 contenttype; echo |
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 m4 -D_USER_="$user" -D_URL_="$url" -D_ADMIN_="$admin" \ |
117 | 1027 $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
|
1028 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
|
1029 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
|
1030 } |
67 | 1031 |
1032 # Do instant jobs here | |
163 | 1033 dbsetup |
1034 trap cleanup INT HUP EXIT | |
1035 # trap cleanup INT HUP | |
67 | 1036 |
1037 err() { | |
1038 echo "$@" 1>&3 | |
1039 } | |
1040 | |
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
|
1041 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
|
1042 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
|
1043 tmpf=tmp/stream |
11 | 1044 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
|
1045 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
|
1046 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
|
1047 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
|
1048 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
|
1049 get|GET) s="$QUERY_STRING" ;; |
13 | 1050 post|POST) ## dd count=$CONTENT_LENGTH bs=1 of=$tmpf 2>/dev/null #slow |
137 | 1051 ## dd bs=$CONTENT_LENGTH count=1 of=$tmpf # NOT working |
13 | 1052 # cat > $tmpf # too much? |
1053 head -c $CONTENT_LENGTH > $tmpf # safe? | |
1054 (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
|
1055 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
|
1056 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
|
1057 ;; |
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 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
|
1059 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
|
1060 *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
|
1061 bndry=${CONTENT_TYPE#*boundary=} |
13 | 1062 #for us in `LC_CTYPE=C ./mpsplit.rb "$bndry" $tmpd < $tmpf` |
1063 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
|
1064 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
|
1065 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
|
1066 #echo u=$us |
11 | 1067 #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
|
1068 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
|
1069 # 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
|
1070 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
|
1071 *: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
|
1072 type='file'; k=${k%:filename} |
13 | 1073 (echo k=$k; ls -lF $tmpd/$v; file --mime-type $tmpd/$v) 1>&3 |
1074 case `file --mime-type $tmpd/$v|cut -d' ' -f2` in | |
132 | 1075 [Ii]mage/x-xcf) |
1076 bzip2 $tmpd/$v | |
1077 v=${v}.bz2 | |
1078 ;; | |
1079 [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
|
1080 [Ii]mage/*) |
13 | 1081 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
|
1082 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1083 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
|
1084 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1085 *) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1086 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
|
1087 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1088 esac |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1089 #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
|
1090 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
|
1091 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
|
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 *) |
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 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
|
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 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
|
1097 } |
58
ccd0c6736215
Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1098 email4group() { |
59 | 1099 # 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
|
1100 qgrp=`sqlquote "$1"`; shift |
ccd0c6736215
Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1101 users=`for i; do sqlquote "$i"; done` |
ccd0c6736215
Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1102 users=`echo $users|tr ' ' ','` |
56 | 1103 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
|
1104 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
|
1105 and s.key='email' |
ccd0c6736215
Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1106 where g.gname=$qgrp and g.user in ($users);" |
56 | 1107 err `echo $sql` |
1108 query "$sql" | |
58
ccd0c6736215
Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1109 } |
59 | 1110 email4groupbyuid() { |
1111 # Get for-$1=group email address(es) for $2...=user-ids | |
1112 qgrp=`sqlquote "$1"`; shift | |
1113 err em4gbid-IN: "\$1=$1 qgrp=$qgrp" | |
1114 uids=`echo "$@"` | |
1115 uids=`echo $uids|tr ' ' ','` | |
1116 sql="select coalesce(s.val, g.user) from grp_mem g | |
1117 left join grp_mem_s s on g.gname=s.gname and g.user=s.user | |
1118 and s.key='email' | |
1119 where g.gname=$qgrp and g.user in | |
1120 (select name from user where rowid in ($uids));" | |
1121 err email4gByid `echo $sql` | |
1122 query "$sql" | |
1123 } | |
47
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1124 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
|
1125 # Collect email addresses for group $1 |
47
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1126 for e; do |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1127 if isuser "$e"; then |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1128 em=`query "select val from user_m where name='$e' and key='email';"` |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1129 [ -n "$em" ] && echo "$em" || echo "$e" |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1130 else |
26 | 1131 # sql="with recursive allmem as |
1132 # (select gname,val from grp_m where gname='$1' | |
1133 # union all select grp_m.gname,grp_m.val from grp_m,allmem | |
1134 # where allmem.val=grp_m.gname) | |
1135 # select coalesce(b.val,a.val) | |
1136 # from allmem a left join grp_mem_s b | |
1137 # on a.gname=b.gname and a.val=b.user and b.key='email' | |
1138 # where a.val in (select name from user) limit 10000;" | |
47
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1139 # tmp tmp tmp tmp tmp tmp tmp |
56 | 1140 qgrp=`sqlquote "$e"` |
62
5ca8f194faf2
Collect emails for group give a preference to email values in user_m.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1141 sql="select coalesce(s.val,um.val,g.user) from |
5ca8f194faf2
Collect emails for group give a preference to email values in user_m.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1142 grp_mem g left join grp_mem_s s |
26 | 1143 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
|
1144 left join user_m um on g.user=um.name and um.key='email' |
26 | 1145 where g.gname=$qgrp;" |
47
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1146 err CollectEmail: `echo "$sql"` |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1147 query "$sql" |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1148 fi |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1149 done |
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
1150 ) |
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
|
1151 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
|
1152 # $1=email |
26 | 1153 iss="invite-`date +%s`-$user" |
117 | 1154 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
|
1155 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
|
1156 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
|
1157 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
|
1158 regist="$urlbase?reg+$iss" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1159 m4 -D_URL_="$urlbase" \ |
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 -D_USER_="$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
|
1161 -D_EMAIL_="$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
|
1162 -D_REGIST_="$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
|
1163 -D_ADMIN_="$admin" \ |
117 | 1164 $msgdir/mail-invite.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
|
1165 | smail $1 "BBSへの御招待" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1166 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
|
1167 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1168 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
|
1169 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
|
1170 *@*@*) 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
|
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 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
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 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
|
1178 ;; |
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 *) 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
|
1180 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
|
1181 } |
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 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
|
1183 email=`getpar 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
|
1184 case $email 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
|
1185 *@*@*) 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
|
1186 *@*) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1187 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
|
1188 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
|
1189 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
|
1190 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
|
1191 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
|
1192 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
|
1193 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
|
1194 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
|
1195 "") 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
|
1196 *) 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
|
1197 esac |
26 | 1198 addr=`query "select val from par where sessid like 'invite-%-$user';"` |
1199 err addr=$addr | |
1200 if [ -n "$addr" ]; then | |
1201 susp="<h2>招待済みで加入待ちのアドレス</h2><pre>$addr</pre>" | |
1202 fi | |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1203 m4 -D_TITLE_="招待" -D_REPORT_="\`$repo'" -D_ACTION_="?invite" \ |
26 | 1204 -D_BODYCLASS_="default" -D_SUSPENDED_="$susp" \ |
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
|
1205 $layout/html.m4.html $layout/invite.m4.html |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1206 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1207 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
|
1208 # $1=session-id-for-invitation |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1209 m4 -D_TITLE_="Invitation" $layout/html.m4.html |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1210 if [ -z "$1" ]; then |
61 | 1211 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
|
1212 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
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 <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
|
1218 <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
|
1219 加入している人に、再度招待してもらいましょう。</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
|
1220 EOF |
65 | 1221 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
|
1222 fi |
61 | 1223 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
|
1224 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
|
1225 # 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
|
1226 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
|
1227 ('$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
|
1228 wasureta $email |
61 | 1229 echo "このアドレスに初期パスワードを送信しました。" |html p |
1230 echo "新着メイルを確認してログインしてください。" |html p | |
26 | 1231 addsession $1 # for removal after 1 minute |
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
|
1232 m4 -D_SYSNAME_="Initial Login" -D_MYNAME_="$myname?userconf" \ |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1233 $layout/login.m4.html |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1234 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
|
1235 } |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1236 newgrpchk() { |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1237 # Check if $1 is existing and |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1238 } |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1239 groupupdate() { |
78 | 1240 gname=`getpar gname` |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1241 qgname=`sqlquote $gname` |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1242 err Enter:groupupdate |
78 | 1243 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
|
1244 # See ALSO same job in showgroup() |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1245 newgname=`echo "$gname"|tr -d '\"'"'"` |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1246 err newgname=$newgname |
78 | 1247 if [ x"$newgname" != x"$gname" ]; then |
1248 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
|
1249 gname=$newgname |
78 | 1250 echo "使用禁止文字を除去し $gname としました。" | html p |
1251 replpar gname string "$gname" | |
1252 fi | |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1253 # Name confliction check |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1254 parow=`getpar rowid` |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1255 err parow=$parow |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1256 qgname=`sqlquote $gname` # Set again in case gname modified |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1257 query "BEGIN EXCLUSIVE;" |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1258 err "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
|
1259 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
|
1260 if [ $count -gt 0 ]; then |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1261 echo "そのグループ名は既にあります。" | html p |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1262 query "END;" |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1263 return |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1264 fi |
123
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
1265 par2table $formdir/grp.def |
122
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1266 query "END TRANSACTION;" |
163 | 1267 # Remove orphan |
122
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1268 : <<EOF |
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1269 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
|
1270 (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
|
1271 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
|
1272 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
|
1273 EOF |
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1274 rm=`getpar rm` cfm=`getpar confirm` |
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1275 err groupupdate:::: after par2tbl rmcfm=$rm$cfm |
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1276 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
|
1277 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
|
1278 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
|
1279 (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
|
1280 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
|
1281 query "$sql"; |
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1282 fi |
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
1283 fi |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1284 [ -z "$parow" ] && joingrp "$gname" "$user" yes "$user" as-admin |
78 | 1285 fi |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1286 sql="select rowid from grp where gname=$qgname;" |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1287 grid=$(query $sql) |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1288 err grpupdate:new-grid=$grid, sql=$sql |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1289 grp $grid |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1290 } |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1291 groupman() { |
78 | 1292 note="<p>グループ名に使用できない文字は自動的に削除されます。</p>" |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1293 |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1294 GF_STAGE="grpconf" |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1295 GF_STAGE=groupupdate |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1296 DT_VIEW=grp dumptable html grp 'gname gecos:DESC mtime:TIME' 'order by b.TIME desc' \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1297 |m4 -D_TITLE_="グループ作成" \ |
78 | 1298 -D_FORM_="$note`genform $formdir/grp.def`" \ |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1299 -D_DUMPTABLE_="syscmd(cat)" \ |
78 | 1300 $layout/html.m4.html $layout/form+dump.m4.html |
1301 } | |
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
|
1302 userconf() { |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1303 [ -n "`getpar rowid`" ] && par2table $formdir/user.def |
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
|
1304 m4 -D_BODYCLASS_=userconf -D_TITLE_="ユーザ情報編集" $layout/html.m4.html |
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 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
|
1306 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1307 groupconf() { |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1308 # $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
|
1309 [ -n "`getpar rowid`" ] && par2table $formdir/grp.def |
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
|
1310 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
|
1311 #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
|
1312 rowid=${1%%[!A-Z0-9a-z_]*} |
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
|
1313 err gcon \$1=$1 rowid=$rowid |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1314 # 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
|
1315 GF_STAGE="groupupdate" edittable "$formdir/grp.def" "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
|
1316 } |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1317 mems() { |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1318 m4 -D_TITLE_="参加者一覧" -D_BODYCLASS_=listmember $layout/html.m4.html |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1319 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
|
1320 listmember $kwd |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1321 } |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1322 grps() { |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1323 m4 -D_TITLE_="グループ一覧" -D_BODYCLASS_=listgroup $layout/html.m4.html |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1324 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
|
1325 listgroup $kwd \ |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1326 | m4 -D_DUMPTABLE_="syscmd(cat)" \ |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1327 -D_TITLE_="グループ関連操作" \ |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1328 -D_FORM_="<a href=\"?groupman\">新規グループ作成</a>" \ |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1329 $layout/form+dump.m4.html |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1330 } |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1331 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
|
1332 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
|
1333 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
|
1334 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
|
1335 err grp: getpar-grp"(gpg)=[$grp]" |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1336 ## . ./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
|
1337 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
|
1338 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
|
1339 err jg=$jg, grp=$grp |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1340 [ -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
|
1341 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
|
1342 fi |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1343 echo "グループ $grp"|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
|
1344 showgroup "$grid" |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1345 } |
175 | 1346 listnewblogsql() { # $1=user |
177 | 1347 cat<<EOF |
175 | 1348 with article_ctime as ( |
1349 select id,blogid,author,val ctime | |
1350 from article join article_s s using(id) | |
1351 where s.key='ctime' | |
1352 ), blog_title_owner as ( | |
1353 select blog.rowid, id, | |
1354 max(case key when 'title' then val end) title, | |
1355 max(case key when 'owner' then val end) owner | |
1356 from blog, blog_s using(id) group by id | |
1357 ), acclog_user as ( | |
176
2194af7e96f3
Tbl of collecting time of acclog for listnewblogs should be 'blog'
HIROSE Yuuji <yuuji@gentei.org>
parents:
175
diff
changeset
|
1358 select * from acclog where user='$user' and tbl='blog' |
175 | 1359 ), blogall as ( |
1360 select b.id, b.rowid, b.owner, b.title, ctime, ac.author | |
1361 from blog_title_owner b, article_ctime ac | |
1362 on b.id=ac.blogid | |
1363 ) | |
1364 select rowid ID, | |
1365 sum(case when l.time is null then 1 | |
1366 when l.time < ctime then 1 | |
1367 else 0 | |
1368 end) "新着", | |
1369 count(id) "総数", ctime, title, | |
1370 owner gecos -- (select gecos from gecoses where name=bl.owner) gecos | |
1371 from blogall bl left join acclog_user l | |
176
2194af7e96f3
Tbl of collecting time of acclog for listnewblogs should be 'blog'
HIROSE Yuuji <yuuji@gentei.org>
parents:
175
diff
changeset
|
1372 on bl.rowid=round(l.tblrowid) |
175 | 1373 where case when (select name from user where owner=name) is not null |
1374 then 1 /* user's diary is always readable */ | |
1375 when (select val from grp_s | |
1376 where gname=owner and key='regmode') = 'moderated' | |
1377 and -- moderated group and nonmember can't read, not counting | |
1378 (select user from grp_mem | |
1379 where gname=owner and user='$user') is null | |
1380 then 0 | |
1381 else 1 | |
1382 end | |
1383 group by bl.id | |
1384 having "新着" > 0 order by "新着" desc, bl.id | |
1385 limit 10; | |
1386 EOF | |
1387 } | |
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 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
|
1390 # $1=userRowIdToShow |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1391 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
|
1392 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
|
1393 *@*) 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
|
1394 *) 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
|
1395 esac |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1396 err ShowHome: uname=$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
|
1397 gecos=`gecos "$uname"` |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1398 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
|
1399 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
|
1400 cond="gname in (select gname from grp_mem where user='$uname')" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1401 if [ x"$user" = x"$uname" ]; 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
|
1402 conflink="<a href=\"?userconf\">プロフィールの編集</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
|
1403 <a href=\"?blog\">新規話題の作成</a>" |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1404 # Display folders |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1405 sql="select count(id) from article_m where id |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1406 in (select id from article where author='$user') |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1407 and type like 'file:%';" |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1408 err nfile-sql=`echo "$sql"` |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1409 nfile=`query "$sql"` |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1410 err nfile=$nfile |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1411 if [ $nfile -gt 0 ]; then |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1412 conflink="$conflink / |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1413 <a href=\"?lsmyfile\">過去の提出ファイル</a>" |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
1414 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
|
1415 fi |
17 | 1416 . ./s4-blog.sh |
3 | 1417 |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1418 tf=$tmpd/title.$$ pf=$tmpd/profile.$$ bf=$tmpd/blogs.$$ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1419 echo "$gecos さん" > $tf |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1420 viewtable $formdir/user.def user $1 > $pf |
146 | 1421 |
147 | 1422 sqcond="WHERE name='$uname' AND key='profimg' AND type LIKE 'file:image%'" |
146 | 1423 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
|
1424 imf=$tmpd/profimg.$$; touch $imf |
146 | 1425 if [ -n "$img" ]; then |
149
0e28561bf73a
Specify `max-width: 400px' to p.profimg img
HIROSE Yuuji <yuuji@gentei.org>
parents:
148
diff
changeset
|
1426 { printf '%s' "<img src=\"data:${img#file:}," |
146 | 1427 query "SELECT hex(bin) FROM user_m $sqcond LIMIT 1;" \ |
1428 | sed 's/\(..\)/%\1/g' | |
151 | 1429 echo '">' |
146 | 1430 } > $imf |
1431 fi | |
150
6ee08d8b0f5f
Display the number of blogs of the user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
149
diff
changeset
|
1432 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
|
1433 val='$uname';"` |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1434 listblog $uname > $bf |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1435 listgroupbytable $formdir/grp.def $cond \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1436 | m4 -D_BODYCLASS_=home -D_TITLE_="spaste(\`$tf')" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1437 -D_PROFILE_="spaste(\`$pf')$conflink" \ |
146 | 1438 -D_PROFIMG_="spaste(\`$imf')" \ |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1439 -D_BLOGS_="spaste(\`$bf')" \ |
150
6ee08d8b0f5f
Display the number of blogs of the user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
149
diff
changeset
|
1440 -D_NBLOG_="$nblog" \ |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1441 -D_GROUPS_="syscmd(\`cat')" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1442 $layout/html.m4.html $layout/home.m4.html |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1443 |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1444 if [ x"$user" = x"$uname" ]; then |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1445 # Display NEWS |
175 | 1446 if false; then |
1447 cond="where 新着 > 0 order by 新着 desc,ctime desc limit 10" | |
1448 new10=`DT_CHLD=article:blogid \ | |
60 | 1449 DT_VIEW=replyblog dumptable html blog "ctime title gecos" "$cond"` |
175 | 1450 else |
1451 # 2016-02-19 Counting NEWS without using dumptable. | |
1452 sql=`listnewblogsql "$user"` | |
1453 new10=`DT_SQL="$sql" DT_VIEW=replyblog dumptable html blog` | |
1454 fi | |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1455 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
|
1456 cont=$((cont-1)) |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1457 err newcount=$cont |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1458 if [ $cont -gt 0 ]; then |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1459 echo "全体の新着記事${cont}傑" | html h2 |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1460 echo "$new10" |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1461 fi |
128 | 1462 cat<<EOF |
1463 <div class="fold"> | |
1464 `cgi_checkbox srchall yes id="sa"`<label | |
1465 for="sa">SNS全体から検索</label> | |
1466 <div> | |
1467 EOF | |
1468 cgi_form searchart<<EOF | |
1469 <label>`cgi_text kwd`という語を含む記事を全部から検索</label> | |
1470 EOF | |
1471 cat<<EOF | |
1472 </div></div> | |
1473 EOF | |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1474 fi |
128 | 1475 # |
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
|
1476 # 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
|
1477 [ -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
|
1478 } |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1479 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
|
1480 contenttype; echo |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1481 err commission: "$@" |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1482 gname=`getgroupbyid $1` |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1483 echo "グループ $gname 管理者委任" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1484 | 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
|
1485 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
|
1486 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
|
1487 else |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1488 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
|
1489 fi |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1490 } |
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
|
1491 listgroupbytable() { |
52
46e53418e28f
missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1492 # $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
|
1493 tagline=`grep :tag: $1`; shift |
52
46e53418e28f
missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1494 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
|
1495 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
|
1496 echo '<div class="listgroup">' |
26 | 1497 NGsql="select distinct tag from\ |
1498 (select gname, max(case key when 'tag' then val end) as tag, \ | |
1499 max(case key when 'ctime' then val end) as ctime\ | |
1500 from grp_s group by gname order by ctime);" | |
1501 sql="select val from grp_s where key='tag' $and$* group by val;" | |
1502 err ListGRP: query sql="$sql" | |
13 | 1503 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
|
1504 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
|
1505 err ListGrp: tag=$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
|
1506 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
|
1507 tn=${tn##*[ :]} |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1508 sql="select rowid||':'||gname as 'グループ名',説明 from |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1509 (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
|
1510 as rowid, |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1511 gname, |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1512 max(case key when 'gecos' then val end) as '説明', |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1513 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
|
1514 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
|
1515 $where$* group by gname having tag='$tag' order by mtime desc);" |
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
|
1516 err PersonalGroupList= `echo $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
|
1517 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
|
1518 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
|
1519 sq -header -html $db "$sql" \ |
31 | 1520 | 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
|
1521 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
|
1522 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
|
1523 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
|
1524 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1525 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
|
1526 # $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
|
1527 data=`percenthex $1` |
3 | 1528 ct=`file --mime-type $1|cut -d' ' -f2` |
1529 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
|
1530 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
|
1531 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
|
1532 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1533 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
|
1534 # $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
|
1535 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
|
1536 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
|
1537 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
|
1538 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1539 listentry() ( |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1540 # $1=user/group $2=SearchKeyword $3=condition(if any) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1541 # Referring variable $iamowner=$grp to attach owner-request links |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1542 err listentry: \$1=$1 \$2=$2 \$3=$3 |
33 | 1543 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
|
1544 offset=`getpar offset` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1545 offset=${offset%%[!0-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
|
1546 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
|
1547 [ $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
|
1548 limit=30 |
78 | 1549 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
|
1550 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
|
1551 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
|
1552 deficon=person-default.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
|
1553 entity="ユーザ" tbl=user link=rowid nm=name stage=mems |
33 | 1554 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
|
1555 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
|
1556 hrb="$myname?grp" |
22 | 1557 deficon=group-default.png |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1558 entity="グループ" tbl=grp link=rowid nm=gname stage=grps |
33 | 1559 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
|
1560 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
|
1561 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
|
1562 tagconv=`echo $tagline|sed 's/\([^= :]*\)=\([^= :]*\)/-D\2=\1/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
|
1563 err tagconv=$tagconv |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1564 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
|
1565 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
|
1566 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
|
1567 mkdir -p $dir |
131
9782a978d53c
Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents:
128
diff
changeset
|
1568 fi |
9782a978d53c
Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents:
128
diff
changeset
|
1569 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
|
1570 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
|
1571 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
|
1572 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
|
1573 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
|
1574 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
|
1575 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1576 # XX: これ複雑すぎるかな。もっとシンプルにしたい。$3条件も。2015-07-08 |
33 | 1577 # grpは呼出し元の動的スコープ変数でよくないな... |
1578 ##qgrp=`sqlquote $grp` | |
1579 getgrp="(select gname from grp where rowid=${rowid:--1})" | |
1580 sql="select a.rowid, a.$link, coalesce(b.$gcs, a.$nm) as nick, | |
1581 coalesce(b.gecos, a.$nm) as name, | |
1582 b.tag, | |
13 | 1583 case when a.$nm in (select user from grp_adm |
69 | 1584 where gname=$getgrp) then '(管理者)' |
13 | 1585 when '$user' in (select user from grp_adm where gname=a.$nm) |
1586 then '(ADMIN)' | |
171
cdade692e17d
Add "is-member" flag to group list
HIROSE Yuuji <yuuji@gentei.org>
parents:
166
diff
changeset
|
1587 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
|
1588 then '(Member)' |
13 | 1589 when '$iamowner' = '' 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
|
1590 else ',not='||a.rowid end as ownerlink |
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 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
|
1592 (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
|
1593 max(case key when 'gecos' then val end) as 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
|
1594 max(case key when 'tag' then val end) as 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
|
1595 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
|
1596 b on a.$nm=b.name $cond $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
|
1597 order by b.tag desc, a.rowid asc" |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1598 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
|
1599 total=`query "with x as ($sql) select count(*) from x;"` |
61 | 1600 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
|
1601 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
|
1602 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
|
1603 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
|
1604 <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
|
1605 `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
|
1606 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
|
1607 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
|
1608 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
|
1609 cat<<EOF |
33 | 1610 <p>${total}件中の$((offset+1))件めから${kwd:+" - 検索語: $kwd"}</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
|
1611 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
|
1612 if [ $((offset+limit)) -lt $total ]; 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
|
1613 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
|
1614 <div class="right"><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
|
1615 `cgi_submit 次の${limit}件` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1616 `cgi_hidden kwd "$kwd"` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1617 `cgi_hidden stage "$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
|
1618 `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
|
1619 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
|
1620 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
|
1621 if [ $offset -gt 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
|
1622 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
|
1623 <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
|
1624 `cgi_submit 前の${limit}件` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1625 `cgi_hidden stage "$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
|
1626 `cgi_hidden kwd "$kwd"` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1627 `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
|
1628 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
|
1629 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
|
1630 |
69 | 1631 err ListEntry: `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
|
1632 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1633 query "$sql limit $limit ${offset:+offset $offset};" \ |
33 | 1634 | while IFS='|' read id lnk name gecos tag ownerp; do |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1635 err name=$name owner=$ownerp lnk=$lnk |
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1636 err newlnk=$lnk |
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
|
1637 files=`getvalbyid $tbl profimg $id $dir` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1638 # Pick up only first icon |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1639 echo "<div class=\"iconlist xy$thumbxy\"><p class=\"tag _$tag\">$tag</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
|
1640 | m4 $tagconv |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1641 if [ -n "$files" ]; 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
|
1642 icon=`echo "$files"|head -1` |
33 | 1643 iconhref $dir/$icon "$hrb+$lnk" "$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
|
1644 else |
33 | 1645 iconhref $dir/$deficon "$hrb+$lnk" "$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
|
1646 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
|
1647 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
|
1648 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
|
1649 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
|
1650 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1651 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
|
1652 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
|
1653 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1654 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
|
1655 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
|
1656 } |
33 | 1657 showgroup() { # $1=group-rowid |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1658 # gname=`getpar gname` |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1659 # if [ -n "$gname" ]; then |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1660 # err UPdating/Removing of group::::::: |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1661 # # See ALSO same job in groupman() |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1662 # newgname=`echo "$gname"|tr -d '\"'"'"` |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1663 # ###newgname=$gname |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1664 # err gname=$gname newgname=$newgname |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1665 # if [ x"$newgname" != x"$gname" ]; then |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1666 # err NewGNAME: gname=$newgname |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1667 # gname=$newgname |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1668 # echo "使用禁止文字を除去し $gname としました。" | html p |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1669 # replpar gname string "$gname" |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1670 # fi |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1671 # par2table $formdir/grp.def |
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
1672 # fi |
33 | 1673 grp=`getgroupbyid $1` |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1674 err showgroup2: grp=$grp qgrp="[$(sqlquote $grp)]" |
13 | 1675 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
|
1676 tf=$tmpd/title.$$ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1677 echo "グループ $grp" > $tf |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1678 showgroupsub $formdir/grp.def "$1" | \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1679 m4 -D_TITLE_="spaste(\`$tf')" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1680 -D_FORM_="syscmd(\`cat')" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1681 -D_DUMPTABLE_="" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1682 $layout/form+dump.m4.html |
13 | 1683 else # if $grp is removed at par2table |
1684 listgroup | |
1685 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
|
1686 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1687 showgroupsub() { |
33 | 1688 # $1=def-file $2=group-rowid |
1689 rowid=$2 | |
1690 grp=`getgroupbyid $2` | |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1691 qgrp=`sqlquote $grp` |
33 | 1692 #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
|
1693 if [ -z "$rowid" ]; then |
33 | 1694 #rowid=`sq $db "select rowid from grp where rowid=$grp"` |
1695 #grp=`sq $db "select gname from grp where rowid=$grp"` | |
61 | 1696 echo "showgroupsub: invalid argument($1 $2)" | html p |
1697 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
|
1698 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
|
1699 val=`getvalbyid grp profimg $rowid $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
|
1700 # 6/14の次グループのHOMEで出す情報を作る 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
|
1701 viewtable $1 grp $rowid |
13 | 1702 if isgrpowner "$user" "$grp"; then |
16
636df1c1bdf2
Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents:
14
diff
changeset
|
1703 echo "<p><a href=\"?groupconf+$rowid\">グループ情報の編集</a>" |
33 | 1704 iamowner=$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
|
1705 fi |
13 | 1706 if ismember "$user" "$grp"; then |
59 | 1707 echo "${iamowner:+ / }<a href=\"?blog+$rowid\">グループの新規話題作成</a>" |
1708 echo "/ <a href=\"?grpaction+$rowid\">メンバーを個別選択しての操作</a></p>" | |
26 | 1709 # div.fold input[type="checkbox"]:checked ~ div {display: block;} |
1710 cat<<EOF | |
1711 <form action="?send2mem" method="POST" enctype="multipart/form-data"> | |
1712 <div class="fold"> | |
1713 `cgi_checkbox send yes id="send"`<label | |
1714 for="send">グループ全員にメッセージ送信</label> | |
1715 <div> | |
1716 `cgi_textarea message "" "cols=60"` | |
1717 `cgi_submit 送信` | |
1718 `cgi_reset リセット` | |
1719 </div> | |
1720 `cgi_hidden grp $rowid` | |
1721 </div></form> | |
1722 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
|
1723 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
|
1724 # 加入ボタン + 加入者リスト |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1725 err ismember $user $grp |
13 | 1726 ismember "$user" "$grp" && ismem='checked' || nomem='checked' |
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
|
1727 # このグループでの加入アドレス |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1728 eml=`query "select val from grp_mem_s where gname='$2' and 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
|
1729 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
|
1730 err EML: "select val from grp_mem_s where gname='$2' and 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
|
1731 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
|
1732 err email=$eml |
26 | 1733 cat <<EOF |
1734 <div class="fold"> | |
1735 `cgi_checkbox reg yes id="reg"`<label | |
1736 for="reg">自身の参加状態を操作する</label> | |
1737 <div> | |
1738 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
|
1739 cgi_form grp <<EOF |
26 | 1740 <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
|
1741 <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
|
1742 <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
|
1743 <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
|
1744 <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
|
1745 <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
|
1746 <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
|
1747 同じでよい場合は空欄に)</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
|
1748 <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
|
1749 </table> |
33 | 1750 `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
|
1751 EOF |
117 | 1752 if [ x`getgroupattr $grp regmode` = x'moderated' -a -z "$ismem" ]; then |
1753 echo "moderated (承認加入の)グループなので実際に参加できるのは | |
1754 グループ管理者が承認操作をした後になります。" | html p 'class="warn"' | |
1755 fi | |
26 | 1756 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
|
1757 echo '<h2>話題一覧</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
|
1758 cgi_form searchart<<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
|
1759 <label>`cgi_text 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
|
1760 `cgi_hidden owner $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
|
1761 EOF |
60 | 1762 cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by ctime desc" |
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
|
1763 DT_CHLD=article:blogid \ |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1764 DT_VIEW=replyblog dumptable html blog 'ctime title heading' "$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
|
1765 |
33 | 1766 getgname="(select gname from grp where rowid=$rowid)" |
1767 c="group by b.name having b.name in (select user from grp_mem where gname=$getgname)" | |
1768 cm="?commission+$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
|
1769 thumbxy=50x50 listmember "" "$c" \ |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1770 |sed -e "s|\(<br>\),not=\(.*\)|\1|" # 間違って押しやすい |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1771 ## |sed -e "s|\(<br>\),not=\(.*\)|\1<a href=\"$cm+\2\">管理者委託</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
|
1772 } |
59 | 1773 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
|
1774 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
|
1775 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
|
1776 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
|
1777 if [ -z "$grp" ]; then |
118
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
1778 echo "無効な指定です。" | html p; return |
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
1779 fi |
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
1780 if ! ismember $user $grp; then |
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
1781 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
|
1782 fi |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1783 echo "グループ $grp 個別選択操作" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1784 | 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
|
1785 |
117 | 1786 isowner="" |
1787 isgrpowner "$user" "$grp" && isowner="yes" | |
59 | 1788 usel=`getpar usel` |
1789 if [ -n "$usel" ]; then | |
1790 uids=$(echo `echo $usel`|tr ' ' ',') | |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1791 err grpaction-1: grp=$grp, `echo $sql` |
59 | 1792 text=`getpar text` |
1793 | |
1794 rm=`getpar rm` cfm=`getpar confirm` | |
1795 err rm=$rm cfm=$cfm | |
1796 if [ x"$rm" = x"yes" ]; then | |
117 | 1797 if [ "$isowner" ]; then |
59 | 1798 if [ x"$rm$cfm" = x"yesyes" ]; then |
1799 # Eliminate | |
1800 cond="where gname=(select gname from grp where rowid=$grid) and user in (select name from user where rowid in ($uids))" | |
1801 for tbl in grp_mem grp_mem_s grp_mem_m; do | |
1802 sql="delete from $tbl $cond;" | |
1803 # echo "sql=$sql" | |
1804 query "$sql" | |
1805 err rmGRPuser "$sql" | |
1806 done | |
1807 num=`query "select count(*) from user where rowid in ($uids);"` | |
1808 #err num=$num | |
1809 if [ 0$num -gt 0 ]; then | |
1810 sql="select coalesce(b.val,a.name) from user a left join \ | |
1811 user_s b on a.name=b.name and key='gecos' where a.rowid in ($uids);" | |
1812 # err `echo "$sql"` | |
1813 html pre<<EOF | |
1814 以下の${num}名のグループ $grp 登録を解除しました。 | |
1815 `query "$sql"` | |
1816 EOF | |
1817 fi | |
1818 else | |
61 | 1819 echo "確認のチェックがないのでやめておきます。" | html p |
59 | 1820 return |
1821 fi | |
1822 else # not Group Owner | |
61 | 1823 echo "グループ管理者でないのでメンバー操作はできません。" | html p |
59 | 1824 return |
1825 fi | |
1826 cat<<EOF | |
1827 | |
1828 EOF | |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1829 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
|
1830 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
|
1831 echo "なにかメッセージを..." | html p |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1832 return 0 |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1833 fi |
59 | 1834 smail "`email4groupbyuid "$grp" $usel` $user" \ |
1835 "`gecos $user` さんからのメッセージ" <<EOF | |
1836 $url | |
1837 のグループ「$grp」のメンバーである `gecos $user` さんから、 | |
1838 あなた宛へのメッセージです。 | |
1839 ---------------------------------------------------------- | |
1840 $text | |
1841 EOF | |
1842 if [ $? = 0 ]; then | |
61 | 1843 echo "Note: 以下のメンバーにメッセージを送信しました。" | html p |
59 | 1844 sql="select coalesce(b.val, a.name) from |
1845 (select name from user where rowid in ($uids)) a | |
1846 left join user_s b on a.name=b.name and b.key='gecos';" | |
61 | 1847 html pre<<EOF |
1848 `query "$sql"` | |
1849 (送信者である `gecos $user` さんも含まれます) | |
1850 EOF | |
59 | 1851 err SendDone: `echo $sql` |
1852 fi | |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1853 elif [ x"$rm" = x"commission" ]; then |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1854 grp_reg_adm $grid $usel |
59 | 1855 fi |
1856 fi | |
1857 # New entry | |
1858 sql="select u.rowid||','||j.* from user u | |
1859 join (select a.user as name,coalesce(b.val,a.user) | |
1860 from (select gname,user from grp_mem | |
1861 where gname=(select gname from grp where rowid=$1)) | |
1862 a left join (select gname,user,val from grp_mem_s where key='email') | |
1863 b using(gname,user)) | |
1864 j using(name) order by u.name;" | |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1865 sql="select /* Ahh, ugly SQL, I wanna fix... */ |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1866 case |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1867 when (select user from grp_adm where |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1868 gname=(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
|
1869 and user=a.name) is not null |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1870 then 'k' |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1871 else '' |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1872 end || a.rowid|| |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1873 ','||coalesce(val,a.name) as name from |
59 | 1874 (select rowid,name from user where name in |
1875 (select user from grp_mem where | |
117 | 1876 gname=(select gname from grp where rowid=$grid))) |
59 | 1877 a left join user_s on a.name=user_s.name and key='gecos' |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1878 order by coalesce(val,a.name);" |
59 | 1879 err grpaction: `echo $sql` |
1880 b1='<label> <input type="checkbox" name="usel" value="' | |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1881 ba='<label class="admin"><input type="checkbox" name="usel" value="' |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1882 b2='"> <span>' b3='</span></label>' |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1883 tf=$tmpd/title.$$ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1884 echo "グループ[$grp]参加メンバーに対する操作" > $tf |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1885 cmmsg="<div class=\"fold\"> |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1886 `cgi_radio rm commission id=\"cmadmin\"` <label |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1887 for=\"cmadmin\">下でチェックした人にグループ管理者委任</label> |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1888 <div><p>このグループでの全権を付与します。信頼できる人に託してください。 |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1889 </p></div></div>" |
117 | 1890 excmsg="<div class=\"fold\"> |
1891 `cgi_radio rm yes ` 下でチェックした人のグループ登録解除 | |
1892 <div> | |
1893 本当に消します! `cgi_checkbox confirm yes` 確認 | |
1894 <p>この操作による通知は本人に行きません。 | |
1895 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p> | |
1896 </div> | |
1897 </div>" | |
59 | 1898 cgi_form grpaction<<EOF \ |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1899 | sed -e "s|^\(<TR><TD>\)k\([0-9]*\),\([^<]*\)|\1$ba\2$b2\3$b3|" \ |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1900 -e "s|^\(<TR><TD>\)\([0-9]*\),\([^<]*\)|\1$b1\2$b2\3$b3|" \ |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1901 | m4 -D_TITLE_="spaste(\`$tf')" \ |
59 | 1902 -D_SUBTITLE_="チェック後操作ボタン" \ |
1903 -D_FORM_="syscmd(cat)" -D_DUMPTABLE_="" \ | |
67 | 1904 $layout/form+dump.m4.html |
59 | 1905 <div class="fold"> |
1906 `cgi_radio rm send id="sendmsg"`<label | |
1907 for="sendmsg">下でチェックした人にメッセージを送信する</label> | |
1908 <div> | |
1909 `cgi_textarea text "" cols=40` | |
1910 </div> | |
1911 </div> | |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
1912 ${isowner:+$cmmsg$excmsg} |
59 | 1913 <h4>$grp 参加者一覧</h4> |
1914 <table> | |
1915 `sq $db -html "$sql"` | |
1916 `cgi_hidden grp $grid` | |
1917 </table> | |
1918 EOF | |
1919 } | |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1920 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
|
1921 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
|
1922 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
|
1923 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
|
1924 return |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1925 fi |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1926 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
|
1927 title=`getvalbyid blog title $rowid` |
121 | 1928 GF_ACTION="?blog" edittable $formdir/blog.def blog $rowid \ |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1929 | m4 -D_TITLE_="修正" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1930 -D_SUBTITLE_="[$title]@$owner" -D_DIARY_="" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1931 -D_BLOGS_="" -D_DUMPTABLE_="" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1932 -D_FORM_="syscmd(\`cat')" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1933 $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
|
1934 } |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1935 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
|
1936 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
|
1937 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
|
1938 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
|
1939 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
|
1940 return |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1941 fi |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1942 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
|
1943 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
|
1944 author=`getvalbyid article author $rowid` |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1945 err EDITart: owner=$owner, author=$author |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1946 if isgrpowner $user $owner; then |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1947 : EDIT OK |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1948 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
|
1949 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
|
1950 return |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1951 fi |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1952 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
|
1953 tmpout=$tmpd/editart.$$.out |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1954 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
|
1955 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
|
1956 > $tmpout |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1957 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
|
1958 # Cannot use pipelining to m4 with genform() because of stdin stack |
79
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1959 m4 -D_TITLE_="コメントの修正" -D_DIARY_="" \ |
81
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1960 -D_FORM_="syscmd(cat $tmpout)" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1961 -D_SUBTITLE_="`gecos $owner`の「$title」" \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1962 -D_BLOGS_= -D_DUMPTABLE_= \ |
ddc8a4c0b8d9
All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents:
80
diff
changeset
|
1963 $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
|
1964 } |
f088d45dfdf2
Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents:
78
diff
changeset
|
1965 send2mem() { |
26 | 1966 rowid=`getpar grp` |
1967 if [ -z "$rowid" ]; then | |
61 | 1968 echo "グループが未指定です。" | html p |
26 | 1969 return |
1970 fi | |
1971 message=`getpar message` | |
117 | 1972 if [ -z "$message" ]; then |
61 | 1973 echo "文章を入れてください。" | html p |
26 | 1974 return |
1975 fi | |
1976 grp=`getgroupbyid $rowid` | |
1977 members=`collectemail $grp` | |
1978 # smail rcpt subj (file) | |
1979 smail "$members" "グループ $grp 宛メッセージ(from `gecos $user`)" <<EOF | |
1980 $urlbase?grp+$rowid | |
1981 グループ $grp に所属する | |
1982 `gecos $user` さんよりメッセージ: | |
1983 | |
1984 $message | |
1985 EOF | |
1986 cat<<EOF | |
1987 <p>以下の宛先に送信しました。</p> | |
1988 <pre> | |
1989 $members | |
1990 </pre> | |
1991 <p><a href="?grp+$rowid">グループ $grp</a>に戻る。</p> | |
1992 EOF | |
1993 } | |
117 | 1994 joingrpadmit() { |
1995 # $1=yes/no $2=session-key | |
1996 if [ -z "$2" ]; then | |
1997 echo "bye bye" | html p; return | |
1998 fi | |
1999 t_usr=`session=$2 getpar user` | |
2000 t_grp=`session=$2 getpar group` | |
2001 err joingrpadmit: t_usr=$t_usr, t_grp=$t_grp | |
2002 m4 -D_TITLE_="joingrp" $layout/html.m4.html | |
2003 if [ -z "$t_usr" -o -z "$t_grp" ]; then | |
2004 echo "無効な加入依頼です。" | html p | |
2005 echo "有効期限が切れたか、 | |
2006 他の管理者がいる場合は処理済みの可能性があります。" | html p | |
2007 return | |
2008 fi | |
2009 if ! isgrpowner "$user" $t_grp; then | |
2010 echo "グループ管理者のみの機能です。" | html p; return | |
2011 fi | |
2012 case $1 in | |
2013 yes) joingrp "$t_grp" "$t_usr" yes "$t_usr" ;; | |
2014 no) joingrp "$t_grp" "$t_usr" no "$t_usr" ;; | |
2015 *) | |
2016 echo "無効な指定です($1)。" | html p | |
2017 return ;; | |
2018 esac | |
2019 gid=$(query "select rowid from grp where gname=`sqlquote $t_grp`;") | |
2020 rcpts="`getgroupadminmails $t_grp` $user" | |
2021 err admit: msgdir=$msgdir, rcpts="["$rcpts"]" | |
2022 body="グループ $t_grp | |
2023 に | |
2024 $t_usr | |
2025 `[ x$1 = xyes ] && echo 'を追加' || echo 'の解除操作を'` | |
2026 しました。" | |
2027 (echo "$body"; echo; echo "$url?grp+$gid") | smail "$rcpts" "joingrp $1" | |
2028 query "delete from session where id='$2';" | |
2029 echo "$body" | html p | |
2030 } | |
2031 | |
2032 joingrprequest() { | |
2033 # $1=group $2=user $3=yes/no $4=email(if any $5=AsAdmin) | |
2034 jss="joingrp-`date +%s`-`genrandom 12`" | |
2035 addsession $jss +${memoplimitdays}days | |
2036 query "replace into par values('$jss', 'group', 'string', `sqlquote $1`), | |
2037 ('$jss', 'user', 'string', `sqlquote $user`);" | |
2038 smail "$(collectemail `getgroupadmins $1`)" "Join request to $1"<<EOF | |
2039 $url | |
2040 グループ $1 | |
2041 に加入依頼がありました。 | |
2042 | |
2043 承認する: | |
2044 $urlbase?joingrpadmit+yes+$jss | |
2045 | |
2046 白紙に戻す: | |
2047 $urlbase?joingrpadmit+no+$jss | |
2048 EOF | |
2049 echo "管理者に加入依頼を出しました。 | |
2050 ${memoplimitdays}日以内に加入承認操作がされれば加入できますが、 | |
2051 グループ運用方針に懸かることですので直接の問い合わせが重要です。" | html p | |
2052 } | |
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
|
2053 joingrp() { |
13 | 2054 # $1=group $2=user $3=yes/no $4=email(if any $5=AsAdmin) |
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 err joingrp: \$1=$1 \$2=$2 \$3=$3 \$4=$4 |
13 | 2056 isgrpowner "$user" "$1" && isowner="yes" || isowner="" |
117 | 2057 err jg:isgrpowner: isowner="$isowner" |
2058 if [ -n "$isowner" ]; then | |
120 | 2059 : # GROUP OWNER CAN DO EVERYTHING ABOUT REGISTRATION/RETIREMENT |
117 | 2060 elif [ x"$2" != x"$user" ]; then # if user is not login user |
2061 echo "本人か、グループ管理者しか加入操作はできません。" | html p | |
2062 return | |
2063 elif [ x"$3" = x"no" ]; then | |
120 | 2064 : # Do not pursue those who leave |
117 | 2065 else # adding user is $user itself |
2066 case `getgroupattr $1 regmode` in | |
2067 moderated) | |
2068 joingrprequest "$@" # Request only | |
2069 return | |
2070 ;; | |
2071 *) | |
2072 ;; | |
2073 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
|
2074 fi |
33 | 2075 qgname=`sqlquote $1` |
2076 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
|
2077 if [ x"$3" = x"yes" ]; then |
33 | 2078 query "replace into grp_mem values($qgname, '$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
|
2079 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
|
2080 if msg=`emaildomaincheck "$4"`; then |
33 | 2081 err "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
|
2082 'string', '$4', NULL);" |
33 | 2083 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
|
2084 'string', '$4', NULL);" |
13 | 2085 if [ -n "$5" ]; then # as ADMIN |
2086 # Coming here means newly created group | |
2087 sql="select case\ | |
33 | 2088 when (select count(*) from grp_mem where gname=$qgname)=1\ |
13 | 2089 then (select user from grp_mem\ |
33 | 2090 where gname=$qgname and user='$user')\ |
13 | 2091 else '' end;" |
2092 err NewGrpChk: $sql | |
2093 if [ -n "`query \"$sql\"`" ]; then | |
33 | 2094 err ADMIN: "replace into grp_adm values($qgname, '$user');" |
2095 query "replace into grp_adm values($qgname, '$user');" | |
13 | 2096 fi |
2097 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
|
2098 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
|
2099 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
|
2100 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
|
2101 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
|
2102 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
|
2103 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
|
2104 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
|
2105 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
|
2106 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
|
2107 delete from grp_mem_m $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
|
2108 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
|
2109 } |
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 grp_reg_adm() { |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2111 # $1=grp-rowid $2...=user-rowid |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2112 grid=$1 |
33 | 2113 grp=`getgroupbyid "$1"` |
2114 if [ -z "$grp" ]; then | |
61 | 2115 echo "無効なグループIDです" | html p; return |
33 | 2116 fi |
2117 if ! isgrpowner $user "$grp"; then | |
61 | 2118 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
|
2119 fi |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2120 shift |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2121 for urid; do |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2122 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
|
2123 if [ -z "$newadm" ]; then |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2124 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
|
2125 fi |
153
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2126 err GRP_reg_adm: "replace into grp_adm values(`sqlquote $grp`, '$newadm');" |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2127 err ismember $newadm $grp |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2128 if ismember $newadm $grp; then |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2129 # OK, go ahead |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2130 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
|
2131 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
|
2132 # confirm insertion |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2133 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
|
2134 if [ -n "`query \"$sql;\"`" ]; then |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2135 echo "追加完了: $newadm" | html p |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2136 else |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2137 echo "追加失敗($1 $urid)" | html p |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2138 fi |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2139 fi |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2140 showgroup $grid |
f7b4f7e5df2a
Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents:
151
diff
changeset
|
2141 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
|
2142 } |
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 dumptable() { |
13 | 2144 # $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
|
2145 # 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
|
2146 # $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
|
2147 # 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
|
2148 ### 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
|
2149 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
|
2150 if [ -n "$VIEW" ]; then |
122
0681534f9451
When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents:
121
diff
changeset
|
2151 dvlink=" <a href=\"$myname?$VIEW+\\2\">VIE</a><a href=\"$myname?$VIEW+\\2#bottom\">W</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
|
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 # $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
|
2154 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
|
2155 _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
|
2156 cntall="(select count($_i) from $_t where $_i=a.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
|
2157 cntnew="(select count(val) from ${_t}_s where key='ctime' \ |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2158 and id in (select id from $_t where $_i=a.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
|
2159 and val > coalesce((select time from acclog where \ |
174
fe8a381f9483
Column "rowid" in acclog renamed to tblrowid
HIROSE Yuuji <yuuji@gentei.org>
parents:
173
diff
changeset
|
2160 user='$user' and tbl='$2' and tblrowid=a.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
|
2161 '1970-01-01'))" |
60 | 2162 cnt="$cntnew as '新着', $cntall as '総数'," |
2163 dt_class=" td2r td3r" | |
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
|
2164 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
|
2165 # 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
|
2166 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
|
2167 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
|
2168 substr=${dumpcollen:+"substr(val, 0, $dumpcollen)"} |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2169 substr=${substr:-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
|
2170 for col in ${3:-`gettbl_s_cols $2`}; do |
13 | 2171 case $col in |
60 | 2172 gecos) scols="$scols${scols:+, }${col#}" |
2173 continue ;; # built-in column name | |
13 | 2174 *:*) col=${col%:*} as=${col#*:} ;; |
2175 *) as=${col} ;; | |
2176 esac | |
2177 eav=$eav${eav:+,}" max(case key when '$col' then $substr end) as $as" | |
2178 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
|
2179 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
|
2180 #case author when '$user' then a.rowid else '---' end as ID, |
175 | 2181 sql=${DT_SQL:-"select \ |
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
|
2182 a.rowid as 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
|
2183 $cnt\ |
60 | 2184 $scols from $2 a left join\ |
2185 (select $pk,$eav, | |
2186 max(case key when 'owner' | |
2187 then coalesce((select val from user_s us | |
2188 where us.key='gecos' and us.name=c.val), val) end) as gecos | |
175 | 2189 from ${2}_s c group by $pk) b on a.$pk=b.$pk $4;"} |
2190 err 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
|
2191 cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)</TD>,\1$elink$dvlink</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
|
2192 <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
|
2193 <table class="b$dt_class"> |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2194 `sq -header -cmd ".mode $1" $db "$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
|
2195 </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
|
2196 </div> <!-- 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
|
2197 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
|
2198 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2199 |
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 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
|
2201 # 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
|
2202 # $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
|
2203 # Using $user and $session |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2204 # Return value: |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2205 # 0: Stored successfully |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2206 # 1: Insufficient fillings |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2207 # 2: No permission to modify the record |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2208 # 3: Invalid rowid |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2209 # 4: SUCCESS to delete |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2210 # 5: Stop deletion for lack of confirm check |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2211 # 6: Password length too short |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2212 # 7: Password mismatch |
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2213 # 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
|
2214 rowid=`getpar rowid` |
8 | 2215 err ...........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
|
2216 if [ ! -e $1 ]; then |
61 | 2217 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
|
2218 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
|
2219 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
|
2220 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
|
2221 tbl=${tbl##*/} |
2 | 2222 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
|
2223 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
|
2224 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
|
2225 elif [ x"$tbl" = x"grp" ]; then |
13 | 2226 sql="select gname from $tbl where rowid=$rowid;" |
2227 ##err p2t:grp:q $sql | |
2228 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
|
2229 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
|
2230 rowowner=`query "select owner 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
|
2231 rowowner=${rowowner:-`query "select author from $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
|
2232 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
|
2233 fi |
13 | 2234 ### 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
|
2235 if [ x"$user" != x"$rowowner" ]; then |
61 | 2236 echo "他人のレコードはいじれないの" | html p |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2237 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
|
2238 elif [ -z "$rowowner" ]; then |
61 | 2239 echo "指定したレコードはないみたい" | html p |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2240 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
|
2241 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
|
2242 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
|
2243 # 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
|
2244 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
|
2245 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
|
2246 query "delete from $tbl where rowid=$rowid;" |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2247 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
|
2248 else |
61 | 2249 echo "消去確認のチェックがないので消さなかったの..." | html p |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2250 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
|
2251 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
|
2252 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
|
2253 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
|
2254 # XX: Subshelling here is unnecessary 2015-07-05 |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
2255 (ts=${tbl}_s tm=${tbl}_m val="" pval="" formaster="" |
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
|
2256 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
|
2257 # Update of existing record |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2258 for col in `gettblcols $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
|
2259 val=`getparquote $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
|
2260 [ -z "$val" ] && continue |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
2261 err query "update $tbl set $col=$val 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
|
2262 query "update $tbl set $col=$val 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
|
2263 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
|
2264 # 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
|
2265 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
|
2266 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
|
2267 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
|
2268 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
|
2269 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
|
2270 # New 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
|
2271 # Generate values() for primary keys |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2272 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
|
2273 # Genuine primary keys for _m and _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
|
2274 val=`getvalquote $tbl $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
|
2275 [ -z "$val" ] && 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
|
2276 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
|
2277 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
|
2278 err pval=$pval |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2279 for col in `gettblfkey $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
|
2280 # args for values() to insertion into master 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
|
2281 val=`getvalquote $tbl $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
|
2282 [ -z "$val" ] && 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
|
2283 formaster=$formaster"${formaster:+, }$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
|
2284 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
|
2285 formaster="$pval${formaster:+, }$formaster" |
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 err formaster=$formaster |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2287 if [ -z "$formaster" ]; then |
61 | 2288 echo "項目を全て埋めてください" | html pre |
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
|
2289 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
|
2290 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
|
2291 err "replace into $tbl values($formaster);" |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
2292 query "replace into $tbl values($formaster);" |
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
|
2293 ## Insertion to master table, 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
|
2294 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
|
2295 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2296 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
|
2297 tb2=${tbl}_$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
|
2298 for col in `gettbl_${kt}_cols $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
|
2299 ptype=`getpartype $col "limit 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
|
2300 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2301 # First, check update of existing entries in _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
|
2302 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
|
2303 # sessID|address.1.22|string|Somewhere-x.y.z |
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 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
|
2305 err dots from query "select var from par where var like '$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
|
2306 for v in `query "select var from par where var like '$col.%';"`; 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
|
2307 # v=address.1.22 |
75 | 2308 st_rowid=${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
|
2309 origcol=${v%%.*} # original column derived from |
75 | 2310 err Updating for $v st_rowid=$st_rowid, partype=`getpartype $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
|
2311 ##case `getpartype $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
|
2312 err CASE `gettbl_coltype $tbl/$origcol` 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
|
2313 err edit flag = `getpar action.$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
|
2314 case `getpar action.$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
|
2315 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
|
2316 if [ x`getpar confirm.$v` = 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
|
2317 newsql="delete from $tb2" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2318 else |
61 | 2319 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
|
2320 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
|
2321 edit) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2322 case `gettbl_coltype $tbl/$origcol` 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
|
2323 image|document|binary) |
13 | 2324 file=$tmpd/`getparfilename $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
|
2325 err type=file=$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
|
2326 [ -z "$file" ] && 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
|
2327 bn=${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
|
2328 bin="X'"$(hexize $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
|
2329 ct=`file --mime-type $file|cut -d' ' -f2` |
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 type=\"file:$ct\" |
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 newsql="update $tb2 set val='$bn', type=$type, bin=$bin" |
75 | 2332 cachedir=`getcachedir "$tbl/$rowid"` |
2333 err getcache tbl/rowid=$tbl/$rowid, rm -r $cachedir | |
73
a8b4eb19a2fb
Remove cachedir when image updated
HIROSE Yuuji <yuuji@gentei.org>
parents:
72
diff
changeset
|
2334 rm -r $cachedir |
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 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2336 *) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2337 newsql="update $tb2 set val=(select val from par where var \ |
75 | 2338 like '$col.%.$st_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
|
2339 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2340 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
|
2341 ;; |
124
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2342 *) # maybe "keep", do not modify value |
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
|
2343 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
|
2344 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2345 esac |
124
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2346 # err newsql=$newsql |
75 | 2347 sql=$sql$nl"$newsql where rowid=$st_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
|
2348 done |
124
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2349 |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2350 if [ x"$bin" = x"NULL" ]; then |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2351 err repl:normal sql=`echo $sql` |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2352 query "$sql |
113
3bad3f525dfc
Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents:
112
diff
changeset
|
2353 delete from $tb2 where type='string' and val='';" |
124
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2354 err repl:normal done |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2355 else |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2356 sqlfile="$tmpd/sqlf.$$" |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2357 echo "$sql" > $sqlfile |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2358 err repl:sqlfile=`ls -lF $sqlfile` |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2359 query ".read $sqlfile" |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2360 err repl:done |
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2361 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
|
2362 # Rest of kt==m: set multiple 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
|
2363 nr=`getparcount $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
|
2364 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
|
2365 nr=1 # for kt==s, number of records is 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
|
2366 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
|
2367 |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2368 i=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
|
2369 while [ $i -lt $nr ]; 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
|
2370 limit="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
|
2371 i=$((i+1)) # increase beforehand against 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
|
2372 val=`getvalquote $tbl $col "$limit"` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2373 [ -z "$val" -o x"$val" = x'""' -o x"$val" = x"NULL" ] && 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
|
2374 err $col=$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
|
2375 bin=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
|
2376 err partype$col=`getpartype $col "$limit"` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2377 case $ptype in |
13 | 2378 file) file=$tmpd/`getparfilename $col "$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
|
2379 err parfile-$col=$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
|
2380 [ -z "$file" ] && 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
|
2381 bin="X'"$(hexize $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
|
2382 ct=`file --mime-type $file|cut -d' ' -f2` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2383 type=\"file:$ct\" ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2384 "*"*) continue ;; # foreign 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
|
2385 *) 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
|
2386 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
|
2387 case `gettbl_coltype $tbl/$col` 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
|
2388 password) # special care for 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
|
2389 # name={password,pswd1,pswd2} |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2390 p1=`getpar pswd1 "$limit"` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2391 if [ -z "$p1" ]; 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
|
2392 continue # SKIP password setting, if p1 is empty |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2393 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
|
2394 pswd=`getpar pswd "$limit"` p2=`getpar pswd2 "$limit"` |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2395 ## err pswd=$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
|
2396 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
|
2397 if [ x"$p1" = x"$p2" ]; 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
|
2398 case "$p1" in |
47
c37cbb154e01
collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents:
43
diff
changeset
|
2399 ??????????*) ;; |
143
d4abf37a5ea2
Clarify password error message
HIROSE Yuuji <yuuji@gentei.org>
parents:
142
diff
changeset
|
2400 *) echo "パスワードは10字以上にしてください。" | html p |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2401 return 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
|
2402 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
|
2403 val="\"`echo $p1|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
|
2404 else |
61 | 2405 echo "2つの新パスワード不一致" | html p |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2406 return 7 |
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
|
2407 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
|
2408 else |
61 | 2409 echo "旧パスワード違います" | html p |
80
39e69daa2071
New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents:
79
diff
changeset
|
2410 return 8 |
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
|
2411 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
|
2412 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
|
2413 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2414 esac |
118
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
2415 err p2t: "replace into $tb2 values($pval, \"$col\", $type, $val, bin...);" |
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
2416 #query "replace into $tb2 values($pval, \"$col\", $type, $val, $bin);" |
123
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2417 sql="replace into $tb2 values($pval, \"$col\", $type, $val, $bin);" |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2418 if [ x"$bin" = x"NULL" ]; then |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2419 err Normal-query: `echo $sql` |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2420 query "$sql" |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2421 else |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2422 sqlfile="$tmpd/query.$$" |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2423 echo "$sql" > $sqlfile |
124
9742dbee5cba
Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents:
123
diff
changeset
|
2424 err sqlfile=`ls -lF $sqlfile` |
123
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2425 query ".read $sqlfile" |
718abe22a5d1
Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents:
122
diff
changeset
|
2426 fi |
118
45d1b0f09e48
grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents:
117
diff
changeset
|
2427 err p2t 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
|
2428 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
|
2429 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
|
2430 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
|
2431 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
|
2432 err donee) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2433 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2434 par2table_old() { |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2435 # 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
|
2436 # $1=dst-table $2=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
|
2437 # Using $user and $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
|
2438 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
|
2439 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
|
2440 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
|
2441 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
|
2442 sq $db "delete from $1 where rowid=$rowid and owner=\"$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
|
2443 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
|
2444 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
|
2445 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
|
2446 cat $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
|
2447 | (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
|
2448 while IFS=: read prompt name 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
|
2449 [ x"$name" = x"stage" ] && 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
|
2450 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
|
2451 val=`getpar $name|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
|
2452 sq $db "update $1 set $name=\"$val\" where rowid=$rowid and owner=\"$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
|
2453 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
|
2454 eav=$eav${eav+,}" max(case var when '$name' then val end)" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2455 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
|
2456 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
|
2457 [ -n "$rowid" ] && 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
|
2458 cond="where sessid='$session' group by sessid" |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2459 sq $db "replace into $1 select $eav,\"$user\" from par $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
|
2460 # Think over again about putting $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
|
2461 ) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2462 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2463 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
|
2464 # $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
|
2465 # $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
|
2466 # If $GF_VIEWONLY set and nonNull, output values without 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
|
2467 # If $GF_HIDDEN set, use it hidden values |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2468 # 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
|
2469 # 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
|
2470 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
|
2471 if [ ! -e "$1" ]; then |
61 | 2472 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
|
2473 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
|
2474 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
|
2475 err genform1: "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
|
2476 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
|
2477 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
|
2478 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
|
2479 ###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
|
2480 err "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
|
2481 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
|
2482 err rec-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
|
2483 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
|
2484 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
|
2485 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
|
2486 if [ -z "$rec" ]; then |
61 | 2487 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
|
2488 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
|
2489 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
|
2490 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
|
2491 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
|
2492 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
|
2493 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
|
2494 <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
|
2495 <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
|
2496 fi |
69 | 2497 # Image Cache dir |
77 | 2498 err genform: getcache=$2/$rowid |
2499 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
|
2500 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
|
2501 [ -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
|
2502 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
|
2503 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
|
2504 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
|
2505 # err genform2a: Seeking for "$2.$name, type=$type" |
155
511406c0cbbe
Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents:
154
diff
changeset
|
2506 val=`getvalbyid $2 $name $rowid $td|htmlescape` |
69 | 2507 err genform3a: getvalbyid $2 $name $rowid $td |
33 | 2508 err genform3b: 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
|
2509 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
|
2510 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
|
2511 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
|
2512 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
|
2513 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
|
2514 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
|
2515 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
|
2516 if [ -s $td/$name.count -a -n "$val" ]; then |
69 | 2517 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
|
2518 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
|
2519 while read fn; do |
69 | 2520 echo "<tr><td>`cat $td/$fn`</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
|
2521 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
|
2522 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
|
2523 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
|
2524 #form="<input name=\"$name\" value=\"$val\" type=\"$type\"$sp$args>$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
|
2525 err genform: cgi_$type $name $val "$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
|
2526 form=`cgi_$type $name "$val" "$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
|
2527 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
|
2528 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2529 [Rr][Aa][Dd][Ii][Oo]) |
100 | 2530 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
|
2531 form="`echo $args|sed -e \ |
100 | 2532 \"s,\([^ =][^=]*\)=\([^= ][^= ]*\),$fh value=\\"\2\\">\1</label>,g\"`" |
2533 ;; | |
2534 [Cc][Hh][Ee][Cc][Kk][Bb][Oo][Xx]) | |
101 | 2535 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
|
2536 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2537 [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
|
2538 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
|
2539 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
|
2540 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
|
2541 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
|
2542 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
|
2543 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
|
2544 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
|
2545 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
|
2546 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2547 [Ii][Mm][Aa][Gg][Ee]|[Dd][Oo][Cc][Uu][Mm][Ee][Nn][Tt]|[Bb]inary) |
69 | 2548 if [ -s $td/$name.count ]; then |
2549 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
|
2550 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
|
2551 hrfb="$myname?showattc+$2_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
|
2552 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
|
2553 | while read fn; do |
69 | 2554 data=`percenthex $td/$fn` |
2555 #ct=`cat $td/$fn.content-type` | |
2556 ct=`file --mime-type $td/$fn|cut -d' ' -f2` | |
2557 ri=`cat $td/$fn.rowid` | |
2558 ## err fn=$fn, name=$name, ri=$ri; ls -lF $td 1>&3 | |
2559 #imgsrc="<img src=\"data:$ct,$data\">" | |
2560 #echo "<a href=\"$hrfb+$ri\">$imgsrc</a><br>" | |
2561 iconhref $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
|
2562 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
|
2563 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
|
2564 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
|
2565 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
|
2566 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
|
2567 imgs=$(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
|
2568 |while read fn;do |
69 | 2569 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
|
2570 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
|
2571 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
|
2572 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
|
2573 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
|
2574 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
|
2575 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
|
2576 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
|
2577 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
|
2578 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2579 [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
|
2580 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
|
2581 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
|
2582 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
|
2583 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
|
2584 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
|
2585 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2586 [Aa][Uu][Tt][Hh][Oo][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
|
2587 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
|
2588 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
|
2589 [Oo][Ww][Nn][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
|
2590 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
|
2591 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
|
2592 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
|
2593 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
|
2594 [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
|
2595 # 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
|
2596 #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
|
2597 [ -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
|
2598 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
|
2599 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2600 [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
|
2601 [ -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
|
2602 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
|
2603 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
|
2604 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2605 [Ss][Ee][Rr][Ii][Aa][Ll]|[Ss][Tt][Aa][Mm][Pp]) |
127
c17964aa7715
Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents:
124
diff
changeset
|
2606 if [ -z "$rowid" ]; then |
c17964aa7715
Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents:
124
diff
changeset
|
2607 val=$((($(date +%s)-1433084400)/10))c$$ |
c17964aa7715
Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents:
124
diff
changeset
|
2608 fi |
67 | 2609 ## form="<input type=\"hidden\" name=\"serial\" value=\"$val\">" |
2610 ## 2015-07-31 | |
2611 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
|
2612 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
|
2613 [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
|
2614 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
|
2615 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2616 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
|
2617 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
|
2618 ;; |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2619 "*"*) |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2620 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
|
2621 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
|
2622 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
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 : |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2628 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
|
2629 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
|
2630 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
|
2631 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
|
2632 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
|
2633 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
|
2634 # 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
|
2635 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
|
2636 <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
|
2637 ${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
|
2638 <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
|
2639 $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
|
2640 </table>$hiddens |
13 | 2641 ${GF_STAGE:+`cgi_hidden stage $GF_STAGE`} |
8 | 2642 ${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
|
2643 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
|
2644 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
|
2645 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
|
2646 <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
|
2647 <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
|
2648 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
|
2649 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
|
2650 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
|
2651 </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
|
2652 $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
|
2653 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
|
2654 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2655 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
|
2656 # $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
|
2657 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
|
2658 } |
b8a890828283
add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2659 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
|
2660 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
|
2661 } |
68
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2662 showattc() { |
71 | 2663 # $1=table_m $2=rowid |
2664 err \$1=$1 \$2=$2 | |
68
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2665 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
|
2666 contenttype; echo |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2667 echo "このファイルは管理者のみしか見られません" | html p |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2668 putfooter; exit |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2669 fi |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2670 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
|
2671 # tmpfiles=$tmpfiles"${tmpfiles+ }$idir" |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2672 bin=$idir/$myname-$$.bin |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2673 sql="select quote(bin) from $1 where rowid='$2';" |
69 | 2674 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
|
2675 sq $db "$sql" | unhexize > $bin |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2676 tv=`query "select type,val from $1 where rowid='$2';"` |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2677 type=${tv%\|*} fn=${tv#*\|} |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2678 err tv=$tv type=$type fn=$fn, tp2=${tv%\|*} |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2679 ct=${type#file:} |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2680 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
|
2681 text/*) |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2682 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
|
2683 case $charset in |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2684 ASCII*) charset="" ;; |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2685 esac |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2686 ct="text/plain${charset:+; charset=$charset}" |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2687 ;; |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2688 esac |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2689 contenttype "$ct" |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2690 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
|
2691 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
|
2692 #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
|
2693 cat $bin |
7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
2694 } |
78 | 2695 # |
2696 # Some default stupid handler on CGI values | |
2697 # | |
2698 default_storedb() { | |
2699 # ARG: $1=table-def-file | |
2700 # RET: $tbl=table-name, $col=mail-column, $cols=columns | |
2701 tbl=`basename $1` | |
2702 tbl=${tbl%.def} | |
2703 cols="`grep :text $1|cut -d: -f2`" | |
2704 col=`echo "$cols"|head -1` | |
2705 vcol=`getpar $col` | |
2706 err default0: \$1=$1 col=$col cols="[$cols]" vcol=$vcol | |
2707 if [ -n "$vcol" ]; then | |
2708 par2table $1 | |
2709 else | |
2710 return 2 # No insertion occurred | |
2711 fi | |
2712 } | |
2713 | |
2714 default_view() { # $1=def-file | |
2715 ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \ | |
2716 ## DT_VIEW="edittable+$tbl" dumptable html $tbl "name memo file" \ | |
2717 default_storedb "$@" | |
2718 query "select rowid from $tbl order by rowid desc;" \ | |
2719 | while read rowid; do | |
2720 viewtable $1 $tbl $rowid | |
2721 done | m4 -D_TITLE_="$tbl" \ | |
2722 -D_FORM_="`genform $1`" \ | |
2723 -D_DUMPTABLE_="syscmd(cat)" \ | |
2724 $layout/html.m4.html $layout/form+dump.m4.html | |
2725 } | |
2726 default_viewtext() { # $1=def-file | |
2727 ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \ | |
2728 default_storedb "$@" | |
2729 DT_VIEW="viewtable+$tbl" dumptable html $tbl "name memo file" \ | |
2730 | m4 -D_TITLE_="$tbl" \ | |
2731 -D_FORM_="`genform $1`" \ | |
2732 -D_DUMPTABLE_="syscmd(cat)" \ | |
2733 $layout/html.m4.html $layout/form+dump.m4.html | |
2734 } | |
2735 default_smail() { | |
2736 default_storedb "$@" | |
2737 if [ $? -eq 2 ]; then | |
2738 m4 -D_TITLE_="入力" \ | |
2739 -D_FORM_="`genform $1`" \ | |
2740 -D_DUMPTABLE_="" \ | |
2741 $layout/html.m4.html $layout/form+dump.m4.html | |
2742 return | |
2743 fi | |
2744 cond="" | |
2745 for pk in `gettblpkey $tbl`; do | |
2746 pv=$(sqlquote $(getpar $pk)) | |
2747 cond="$cond${cond:+ and }$pk=$pv" | |
2748 done | |
2749 sql="select rowid from $tbl where $cond;" | |
2750 rowid=`query "$sql"` | |
2751 err smail1 - "$sql" "-> rowid=$rowid" | |
2752 | |
2753 while IFS=: read prompt name keytype type args; do # Read from $1 | |
2754 val=`getpar $name` | |
2755 if [ -n "$val" ]; then | |
2756 text="$text | |
2757 $prompt | |
2758 $name=$val | |
2759 ---------------------------------------------------------" | |
2760 fi | |
2761 case "$type" in | |
2762 image|document|file) | |
2763 fn="`getvalbyid $tbl $name $rowid $tmpd`" | |
2764 fns=$(echo "$fn"|while read fn; do | |
2765 err mv $tmpd/$fn.orig $tmpd/$fn | |
2766 mv $tmpd/$fn.orig $tmpd/$fn | |
2767 rm $tmpd/$fn.rowid # Remove cache flag | |
2768 err "`ls $tmpd/$fn`" | |
2769 echo $fn | |
2770 done) | |
2771 files="$files $fns" | |
2772 ;; | |
2773 esac | |
2774 done < $1 | |
2775 err FILES=$files "`ls -lF $tmpd`" | |
2776 subj="from ${REMOTE_ADDR}" | |
102 | 2777 (echo "$url" |
78 | 2778 echo "への書き込みがありました。" |
2779 echo "------" | |
2780 echo "$text" | |
2781 ) | (cd $tmpd && | |
2782 err LS="`ls -lF`" && | |
2783 $mydir/sendmultipart.sh -t "$admin" -s "$subj" $files) | |
2784 m4 -D_TITLE_="入力完了" $layout/html.m4.html | |
2785 echo "以下の内容で送信しました。" | html p | |
2786 viewtable $1 $tbl \ | |
2787 `query "select rowid from $tbl order by rowid desc limit 1;"` | |
2788 echo "戻る" | html a "href=\"?\"" | |
2789 } |