annotate s4-funcs.sh @ 1027:f389a311a8d4 draft

Rename function name
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 06 Dec 2023 20:13:42 +0900
parents a3ec2a73dd33
children 6e24f1ecf13e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1 #!/bin/sh
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2 # Here's global variable table. Do not use this names.
1
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
3 # $HGid$
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
4
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
5 [ -f s4-config.sh ] && . ./s4-config.sh
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
6
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 770
diff changeset
7 test -n "$HTTP_HOST" && isCGI=true || isCGI=false
757
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
8 if $isCGI; then
767
2cff065862fd Initialization of DB location fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 765
diff changeset
9 case "$SCRIPT_NAME" in
757
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
10 *-world-*)
767
2cff065862fd Initialization of DB location fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 765
diff changeset
11 S4WORLD=${SCRIPT_NAME#*world-}
757
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
12 S4WORLD=${S4WORLD%.*}
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
13 echo S4WORLD=$S4WORLD >&2
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
14 worldconf=s4-config-${S4WORLD}.sh
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
15 ;;
786
809caeb20758 Migration caller set arguments beforehand
HIROSE Yuuji <yuuji@gentei.org>
parents: 781
diff changeset
16 *)
809caeb20758 Migration caller set arguments beforehand
HIROSE Yuuji <yuuji@gentei.org>
parents: 781
diff changeset
17 worldconf=s4-config.sh
809caeb20758 Migration caller set arguments beforehand
HIROSE Yuuji <yuuji@gentei.org>
parents: 781
diff changeset
18 ;;
757
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
19 esac
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
20 echo worldconf=$worldconf >&2
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
21 [ -n "$worldconf" -a -e "$worldconf" ] && . ./$worldconf
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
22 echo DB=$DB >&2
2d45b0478d45 s4-funcs.sh stay callable from command line
HIROSE Yuuji <yuuji@gentei.org>
parents: 756
diff changeset
23 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
24 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
25 mydir=`dirname ${SCRIPT_FILENAME:-$0}`
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 770
diff changeset
26 cgiext=${CGIEXT:-.cgi}
0
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 myargs="$@"
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
28 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
29 tmpdir=${TMPDIR:-tmp}
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
30 dbdir=${DBDIR:-db}
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
31 logdir=${LOGDIR:-tmp}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
32 tmpfiles=""
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
33 querylog=${QUERYLOG:-$logdir/query.log}
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
34 searchlog=${SEARCHLOG:-$logdir/search.log}
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
35 defaultdb=$dbdir/cgi.sq3
965
b6d1384e1b2c s4-newworld fixed so that account sychronization done at the time
HIROSE Yuuji <yuuji@gentei.org>
parents: 963
diff changeset
36 db=${S4INITDB:-${DB:-$defaultdb}}
767
2cff065862fd Initialization of DB location fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 765
diff changeset
37 sessdb=${SESSDB:-$dbdir/sess.sq3}
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
38 userupdateflag=$dbdir/userupdate
688
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
39 sesstb=tmp.sess
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
40 workdb=$dbdir/tmpdata.sq3
610
dfd83a6d09fb Label fixed and local value loading introduced
HIROSE Yuuji <yuuji@gentei.org>
parents: 609
diff changeset
41 listentlimit=${LISTENTLIMIT:-30}
801
d368b937956e Limit the number of articles to show by default
HIROSE Yuuji <yuuji@gentei.org>
parents: 775
diff changeset
42 listartlimit=${LISTARTLIMIT:-50}
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
43 admin=${ADMIN:-hostmaster@example.org}
613
51e0cc07a79a Make NO-REPLY address for direct message to avoid miscommunication
HIROSE Yuuji <yuuji@gentei.org>
parents: 612
diff changeset
44 noreply=${NOREPLY:-noreply@example.org}
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
45 noreply_from="${S4NAME:-s4} message notification <$noreply>"
624
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
46 invite_policy=${INVITE_POLICY:-"このコミュニティに関りのあるあなたの信頼できる人を招きます。"}
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
47 templ=${TEMPL:-templ}
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
48 layout=${LAYOUT:-$templ/default}
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
49 formdir=${FORMDIR:-$templ/form}
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
50 imgdir=${IMGDIR:-img}
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
51 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
52 urlbase=${url%%\?*}
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
53 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
54 timeout="+2 days"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
55 memoplimitdays="7"
252
75dfaceac01f Link to newest article of the blog in the recent writing place
HIROSE Yuuji <yuuji@gentei.org>
parents: 251
diff changeset
56 dumpcollen=22
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
57 #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
58 thumbxy=96x96
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
59 iconxy_S=80x80
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
60 iconxy_M=400x400
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
61 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
62 ### maximagexy=400x400
995
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
63 filesize_max=${FILESIZE_MAX:-$((5*1024*1024))}
513
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
64 filesize_max_MB="$((filesize_max/1024/1024))MB"
983
c69cf72ea116 Allow sqlite3 db file
HIROSE Yuuji <yuuji@gentei.org>
parents: 965
diff changeset
65 file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*,application/sqlite*,application/csv"'
1022
739106e031ab Add suffix ".glb"
HIROSE Yuuji <yuuji@gentei.org>
parents: 1019
diff changeset
66 file_accept='accept=".jpg,.jpeg,.gif,.png,.tiff,.pdf,.odt,.ods,.odp,.odg,.mp3,.mp4,.m4a,.m4v,.mkv,.obj,.avi,.ogg,.mov,.webm,.gpx,.json,.geojson,.umap,.kml,.kmz,.html,.css,.js,.java,.el,.go,.cc,.rb,.rs,.py,.pl,lua,.awk,.sh,.c,.h,.log,.txt,.tex,.sty,.zip,.xcf,.bz2,.gz,.xz,.7z,.csv,.dat,.db,.sq3,.blend,.gltf,.glb"'
1024
79aa2ae39103 glTF is not application/*, but model/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 1023
diff changeset
67 file_accept_egrep='^(text/|message/|image/|audio/|video/|application/(vnd.(oasis|sqlite)|pdf|epub|xml|.*zip|[xz]-|json|csv|javascript|octet-stream)|model/)'
562
3b5561ea2117 Ooops, file_accept pattern was wrong...
HIROSE Yuuji <yuuji@gentei.org>
parents: 555
diff changeset
68 file_accept_help="
3b5561ea2117 Ooops, file_accept pattern was wrong...
HIROSE Yuuji <yuuji@gentei.org>
parents: 555
diff changeset
69 添付可能ファイル: テキスト、画像、音声、動画、ODF、PDF、
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
70 圧縮ファイル、データベースファイル
513
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
71 (いずれも ${filesize_max_MB} 以内)
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
72 "
3fcaea2892a8 File accept warnings added
HIROSE Yuuji <yuuji@gentei.org>
parents: 512
diff changeset
73 file_warn="$file_accept_help
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
74 [編集]リンクから修正してください。"
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
75 hidden_mode="('quiz', 'enquete')"
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
76 blogreadflagrowid=0
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
77 blogcutoffflagrowid=-1
816
ed2c8aab742d Archiving world provides no new-group link
HIROSE Yuuji <yuuji@gentei.org>
parents: 812
diff changeset
78 nonewgroupworld=${NONEWGROUPWORLD:-*archive*}
625
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
79 whatsnewdays=${WHATS_NEW_DAYS:-14}
737
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
80 main_session=`date +%F-$$`
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
81 session=$main_session
952
d5e87825195f Supply some useful macros for MathJax.
HIROSE Yuuji <yuuji@gentei.org>
parents: 951
diff changeset
82 mathjax=${MATHJAX:-'<script>MathJax = {
d5e87825195f Supply some useful macros for MathJax.
HIROSE Yuuji <yuuji@gentei.org>
parents: 951
diff changeset
83 tex: {tags: "ams",
d5e87825195f Supply some useful macros for MathJax.
HIROSE Yuuji <yuuji@gentei.org>
parents: 951
diff changeset
84 macros: {warn: ["\\fcolorbox{red}{white}{#1}", 1],
d5e87825195f Supply some useful macros for MathJax.
HIROSE Yuuji <yuuji@gentei.org>
parents: 951
diff changeset
85 Warn: ["{\\Large \\warn{#1}}", 1]}}};</script>
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
86 <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>'}
207
355fcbdc3b49 Add 'file_accept'
HIROSE Yuuji <yuuji@gentei.org>
parents: 203
diff changeset
87
0
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 tconfs=""
781
4dcfeeb59b8f Cache directories should be separated by WORLD
HIROSE Yuuji <yuuji@gentei.org>
parents: 778
diff changeset
89 imgcached=cache/${S4WORLD:+$S4WORLD/}img.`date +%Y/%m`
4
6822f4362bf9 New system name declared as yas4
HIROSE Yuuji <yuuji@gentei.org>
parents: 3
diff changeset
90 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
91 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
92 "
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
93 likeesc=`printf '\037'` # ESCAPE char of LIKE operator
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
94 iconcachekey="profimgcache_S"
905
5acef432b1de TD-class delimiter changed to :::
HIROSE Yuuji <yuuji@gentei.org>
parents: 897
diff changeset
95 asdelim=":::" # delimiter of dumptable td-class specifier
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
96
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
97 # Start debug logging
886
99187e4ad69b Enclose process id with parens instead of brackets
HIROSE Yuuji <yuuji@gentei.org>
parents: 885
diff changeset
98 logtag="($$)${S4WORLD:+{$S4WORLD\}}"
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
99 exec 3>> $logdir/debug.out
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
100 err() {
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
101 # echo "[`date +%F-%T%z`]$logtag $@" 1>&3
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
102 # Avoid backslash escape sequences
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
103 cat<<EOF 1>&3
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
104 [`date +%F-%T%z`]$logtag $@
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
105 EOF
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
106 }
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
107 case "$HTTP_USER_AGENT" in
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
108 *i[Pp]hone*|*[Aa]ndroid*) touchpanel=1 ;;
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
109 *) touchpanel="" ;;
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
110 esac
754
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
111
756
a4523e15dfd6 s/annex/world/
HIROSE Yuuji <yuuji@gentei.org>
parents: 755
diff changeset
112 # If S4MASTERDB is set, behave in another world
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
113 ### if [ -n "$S4MASTERDB" -a -s "$S4MASTERDB" ]; then
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
114 # If S4WORLDLIST is set, this s4 have world!
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
115 if [ -n "$S4WORLDLIST" ]; then
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
116 . ./s4-world.sh 2>> $logdir/debug.out
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
117 # Variables set in s4-world.sh
797
56adb6e5ee68 Add world-links to Grps entry of topmenu
HIROSE Yuuji <yuuji@gentei.org>
parents: 796
diff changeset
118 # $S4WORLDS, $S4WROLDNAME, $S4WORLDGRPS
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
119 # Files created in s4-world.sh
797
56adb6e5ee68 Add world-links to Grps entry of topmenu
HIROSE Yuuji <yuuji@gentei.org>
parents: 796
diff changeset
120 # $worldlistfile, $worldoptionfile, $worldnamefile, $worldgrpfile
755
1a8291d7fa3d Annex strategy shifted to World strategy
HIROSE Yuuji <yuuji@gentei.org>
parents: 754
diff changeset
121 fi
754
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
122
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
123
515
0b47ddf9c8de Load s4-cgi if necessary
HIROSE Yuuji <yuuji@gentei.org>
parents: 514
diff changeset
124 [ -f ./s4-cgi.sh ] && . ./s4-cgi.sh
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
125
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 : <<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
127
249
6bb5513efb8e Add caution comment to the beginning of description
HIROSE Yuuji <yuuji@gentei.org>
parents: 248
diff changeset
128 !! 検索等でblogテーブル参照時は sql4readableblogs() で定義される
6bb5513efb8e Add caution comment to the beginning of description
HIROSE Yuuji <yuuji@gentei.org>
parents: 248
diff changeset
129 !! readableblogs テーブルを使うこと
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
130 資料配布、グループ管理・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
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 ひとつの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
133
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
134 [2016]
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
135 7/12 根本への反省
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
136 * cgi自身の $1, $2 での切り替えでなく、CGI変数での受け渡しにすべき。
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
137 arg1/arg2/arg3 的に $1 に / 区切りでつけた方がよかったかな。
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
138
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
139 [以下2015]
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
140 8/4 ○グループに承認加入モードを追加
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
141 ○グループに参加していない場合は grpaction できない
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
142 Web
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
143 締切設定
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
144
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
145 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
146 ○自分の提出物リスト
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
147
52
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
148 7/19 ○設置
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
149 ○一斉送信
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
150 ○getparfilename の tmpd の扱い
46e53418e28f missing selection condition added
HIROSE Yuuji <yuuji@gentei.org>
parents: 47
diff changeset
151 ○やっぱりs4にしようかな
4
6822f4362bf9 New system name declared as yas4
HIROSE Yuuji <yuuji@gentei.org>
parents: 3
diff changeset
152 7/18 ○書込著者からホームへのリンク
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
153 7/17 ○個人blogに「レポート提出用」がついたときの挙動
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
154 ○添付ファイル回収
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
155 ○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
156 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
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 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
160 ○レポート提出はどうしよう
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 → ○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
162 ○レポート提出モード
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
163 添付ファイル (誰が見たかログ)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
164 クリッカーは別立てメニューにしないと(管理者が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
165 ○添付ファイルの読み出し権(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
166
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
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/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
169 △グループメンバの操作 → 要不要を吟味
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 △グループホームとユーザホームを揃える
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 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
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 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
177 ○グループ検索
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
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 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
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 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
183 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
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 ○ 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
186 ○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
187 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
188 →とすると 一気に
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
189
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
190 ## 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
191 ## 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
192 ## 必須カラム、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
193 ## ユーザ管理とグループ管理はデフォルトで持たせてしまえ
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
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 ## 縦持ちデータの入力/編集を供給する関数 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
196 ## 持てるテーブル構造はシステム標準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
197 ## 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
198 ## 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
199 ## 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
200 ## 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
201 ## 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
202 ## 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
203 ## 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
204
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 ## ● 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
206 ## 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
207 ## ● 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
208 ## 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
209
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 ## グループ属性: 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
211 ## ○ 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
212 ## 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
213 ## 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
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 ## 書き込みオブジェクトとは何か?
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 ## 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
217 ## 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
218 ## 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
219 ## 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
220 ## 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
221
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
222 ## 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
223 ## 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
224 ## 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
225 ## 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
226 ## できたー!
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 ## 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
228
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 ↓以下に変更
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 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
231 (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
232 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
233 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
234 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
235
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 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
238 (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
239 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
240 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
241 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
242 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
243 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
244
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
245
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
246 ## 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
247 ## 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
248 ## 埋め込み画像 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
249
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 ## 考え得るノードタイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
251 ## 日報 - 個人所属かグループ所属か
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
252 ## 課題提出 - 個人所属かグループ所属か
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
253 ## グループ管理
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 ## 個人情報管理
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 ## 例: 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
258 ## - 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
259 ## 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
260 ## 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
261 ## 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
262 ## 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
263 ## 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
264 ## 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
265 ## 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
266 ## 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
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 ## ログテーブル
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 ## 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
270
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
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
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 ■表設計
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 * 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
275 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
276 * *_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
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
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
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 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
281
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 ■抽象エントリタイプ
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 * 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
284 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
285 * 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
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 * 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
288 自動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
289 * 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
290 入力 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
291 変更 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
292 * 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
293 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
294 * 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
295 入力 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
296 * 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
297 入力 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
298 * 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
299 入力 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
300 * 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
301 入力時の $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
302 * 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
303 グループとしての所有者で、外部キー制約が付く
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
304 * 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
305 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
306 * 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
307 木構造の場合の親の位置
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
308 * 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
309 木構造の場合の自分の位置
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
310
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
311 格納タイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
312 * 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
313 表 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
314 * 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
315 表 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
316
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 オブジェクトタイプ
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
318 * 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
319 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
320 * 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
321 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
322 * 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
323 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
324 * 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
325 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
326 * 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
327 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
328 * 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
329 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
330 * 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
331 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
332 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
333
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
334
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
335 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
336 "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
337 "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
338 "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
339 "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
340 "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
341 "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
342 "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
343 "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
344 {"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
345 "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
346 "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
347 "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
348 "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
349 "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
350 "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
351 {"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
352
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
353
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
354 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
355 ユーザ名(英数字):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
356 パスワード: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
357 説明(日本語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
358 セッションキー: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
359 メイルアドレス: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
360 住所: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
361 プロフィール画像: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
362 履歴書: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
363
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
364 変換表
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
365 /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
366
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 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
368 シリアル: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
369 タイトル: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
370 所有者: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
371 時刻: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
372 リード文: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
373 リプライ: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
374
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 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
376 シリアル: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
377 筆者: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
378 時刻: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
379 参照元: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
380 パス: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
381 本文: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
382 画像: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
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 履歴書: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
385
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
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 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
388
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
389 logstart() {
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
390 echo "`date '+%F %T'`:[${user:-NULL}]$logtag <<<" >> ${1:-$querylog}
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
391 }
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
392 logend() {
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
393 echo ">>>$logtag" >> ${1:-$querylog}
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
394 }
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
395 sqlog() {
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
396 logstart
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
397 if [ -z "$1" ]; then
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
398 cat >> $querylog
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
399 else
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
400 echo "$*" >> $querylog
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
401 fi
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
402 logend
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
403 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
404 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
405 # ./args.rb -cmd ".timeout 3000" "$@"
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
406 logstart
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
407 if [ -z "$1" ]; then
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
408 tee -a $querylog|sqlite3 -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000"
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
409 else
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
410 echo "$@" >> $querylog
713
0d13e282441d Not well tested, disable meanwhile
HIROSE Yuuji <yuuji@gentei.org>
parents: 712
diff changeset
411 sqlite3 -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000" "$@"
0d13e282441d Not well tested, disable meanwhile
HIROSE Yuuji <yuuji@gentei.org>
parents: 712
diff changeset
412 ###sqlite3 -bail -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000" "$@"
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
413 fi
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
414 logend
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
415 }
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
416 dbsetup() {
711
695ab5c2c1a5 Random generation fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 710
diff changeset
417 pipedir=$tmpdir/pipedir
695ab5c2c1a5 Random generation fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 710
diff changeset
418 [ -d $pipedir ] || mkdir -p -m 1777 $pipedir
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
419 [ -d $dbdir ] || mkdir -m 1775 $dbdir
711
695ab5c2c1a5 Random generation fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 710
diff changeset
420 suf=`date +%s`
695ab5c2c1a5 Random generation fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 710
diff changeset
421 sqi=$pipedir/sqi-$suf.$$
695ab5c2c1a5 Random generation fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 710
diff changeset
422 sqo=$pipedir/sqo-$suf.$$
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
423 mkfifo $sqi $sqo
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
424 #tail -f $sqi | sq $db & # "tail -f" is too heavy. DO NOT USE!!
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
425 sq $db < $sqi &
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
426 sq3pid="`jobs -p` $!"
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 770
diff changeset
427 if $isCGI; then
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
428 exec 2>> $logdir/error.out
531
01b9e2b16d7a Redirect stderr to file only if being called via CGI
HIROSE Yuuji <yuuji@gentei.org>
parents: 517
diff changeset
429 fi
01b9e2b16d7a Redirect stderr to file only if being called via CGI
HIROSE Yuuji <yuuji@gentei.org>
parents: 517
diff changeset
430 exec 5> $sqi # Turning $sqi access through fd5 for continuous open state
798
91016ff5edb3 Gather logs of all worlds into master logfile
HIROSE Yuuji <yuuji@gentei.org>
parents: 797
diff changeset
431 chmod o-r $logdir/error.out $logdir/debug.out
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
432 rm $sqi
688
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
433 # Attach supplemental DB
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
434 cat >&5 <<-EOF
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
435 .output /dev/null
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
436 ATTACH DATABASE "$sessdb" AS tmp;
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
437 CREATE TABLE IF NOT EXISTS $sesstb(user, skey, expire, UNIQUE(user, skey));
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
438 DELETE FROM $sesstb WHERE expire < datetime('now', 'localtime');
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
439 DELETE FROM $sesstb WHERE expire is NULL or expire = '';
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
440 .output stdout
1aa16edc28e5 Partial Committing Starts:
HIROSE Yuuji <yuuji@gentei.org>
parents: 687
diff changeset
441 EOF
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
442 }
396
cacd961d3405 Dirty workaround for produced zombie processes
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
443 cleanup2() { # Dirty workaround for produced zombie processes
517
6cdd032070e3 $TTY not set on sh-script
HIROSE Yuuji <yuuji@gentei.org>
parents: 516
diff changeset
444 if [ -n "$HTTP_USER_AGENT" ]; then # When called from httpd
516
575e321179c3 Do not call pkill cleanup on terminal
HIROSE Yuuji <yuuji@gentei.org>
parents: 515
diff changeset
445 pkill -9 -u `id -u` -P 1
575e321179c3 Do not call pkill cleanup on terminal
HIROSE Yuuji <yuuji@gentei.org>
parents: 515
diff changeset
446 fi
698
b036a06cad90 Make sure to chmod o-r
HIROSE Yuuji <yuuji@gentei.org>
parents: 697
diff changeset
447 chmod o-r $querylog $db $sessdb # make sure
396
cacd961d3405 Dirty workaround for produced zombie processes
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
448 }
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
449 cleanup() {
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 332
diff changeset
450 trap '' INT HUP EXIT TERM PIPE
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
451 echo .quit >&5
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
452 kill $sq3pid
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
453 kill $sq3pid
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
454 rm -f $sqo $sqi
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
455 rm -rf $tmpfiles
396
cacd961d3405 Dirty workaround for produced zombie processes
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
456 cleanup2
118
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
457 }
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
458 # We want to use piped function to put querylog, but we use
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
459 # simple redirection for the sake of speed.
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
460 query() {
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
461 # echo ".once $sqo" >&5
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
462 echo ".output $sqo" >&5
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
463 logstart
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
464 if [ -z "$1" ]; then
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
465 tee -a $querylog
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
466 else
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
467 printf '%s\n' "$@" >> $querylog
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
468 printf '%s\n' "$@"
358
8166096f4b36 Record query into log
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
469 fi >&5
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
470 echo ".output stdout" >&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
471 cat $sqo
714
d7c5f86d9c75 Auth check more rigidly
HIROSE Yuuji <yuuji@gentei.org>
parents: 713
diff changeset
472 rc=$?
510
2a70b6c7ffad Add search-log and %-escaping
HIROSE Yuuji <yuuji@gentei.org>
parents: 509
diff changeset
473 logend
714
d7c5f86d9c75 Auth check more rigidly
HIROSE Yuuji <yuuji@gentei.org>
parents: 713
diff changeset
474 return $rc
0
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 }
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
476 _m4() {
549
2a48690b8cbc Put $S4NAME in title
HIROSE Yuuji <yuuji@gentei.org>
parents: 543
diff changeset
477 #S4NAME=f,f,f
754
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
478 m4 ${S4NAME:+"-D_S4NAME_=${S4NAME}"} ${S4CSS:+-D_S4CSS_="$S4CSS"} \
797
56adb6e5ee68 Add world-links to Grps entry of topmenu
HIROSE Yuuji <yuuji@gentei.org>
parents: 796
diff changeset
479 ${S4WORLD:+-D_S4WORLD_="$S4WORLD"} \
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
480 ${S4WORLDNAME:+-D_S4WORLDNAME_="$S4WORLDNAME"} \
797
56adb6e5ee68 Add world-links to Grps entry of topmenu
HIROSE Yuuji <yuuji@gentei.org>
parents: 796
diff changeset
481 ${S4WORLDGRPS:+-D_S4WORLDGRPS_="$S4WORLDGRPS"} \
787
c5b61d23052b Display WORLD name in HTML header
HIROSE Yuuji <yuuji@gentei.org>
parents: 786
diff changeset
482 ${S4WORLDS:+-D_S4WORLDS_="$S4WORLDS"} "$@"
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
483 }
0
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 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
485 # $1=user, $2=group
853
047e1c3f811e Log output revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 851
diff changeset
486 #err ismem: "select user from grp_mem where gname=$(sqlquote $2) and user='$1';"
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
487 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
488 }
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 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
490 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
491 }
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 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
493 err isgroup: "select gname from grp where gname=$(sqlquote $1);"
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
494 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
495 }
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
496 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
497 # $1=user, $2=group
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
498 gn=`sqlquote "$2"`
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
499 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
500 err isgrpowner: $sql
955
946f2db59413 quote SQL in backtick
HIROSE Yuuji <yuuji@gentei.org>
parents: 953
diff changeset
501 test -n "`query \"$sql\"`"
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
502 )
577
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
503 isgrpownerbygid() (
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
504 # $1=user, $2=group-rowid
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
505 sql="select user from grp_adm where gname=(select gname from grp where rowid=$2) and user='$1';"
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
506 err isgrpownerbygid: $sql
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
507 test -n "`query $sql`"
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
508 )
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
509 getgroupadminmails() {
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
510 # $1=group
768
891f1f5a8153 Allow spaces in group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 763
diff changeset
511 for i in $(getgroupadmins "$1"); do
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
512 email4group "$1" "$i" ;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
513 done
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
514 }
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
515 getgroupadmins() { # $1=group
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
516 # This function is called in a backquote, so needn't to be subshellized
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
517 qgrp=`sqlquote "$1"`
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
518 query "select user from grp_adm where gname=$qgrp;"
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
519 }
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
520 getgroupattr() { # $1=group $2=attr
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
521 # This function is called in a backquote, so needn't to be subshellized
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
522 getvalbyid grp $2 \
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
523 $(query "select rowid from grp where gname=`sqlquote \"$1\"`;")
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
524 }
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
525 getgroupbyid() {
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
526 # $1=id|gname
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
527 sql="select coalesce((select gname from grp where gname=$(sqlquote \"$1\")),
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
528 (select gname from grp where rowid=$(sqlquote $1)));"
71
3a157da0801d cache name fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 69
diff changeset
529 # err ggbyid: `echo $sql`
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
530 query $sql
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
531 }
0
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 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
533 # 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
534 [ -z "$1" -o -z "$2" -o -z "$3" ] && return 1 # invalid argument
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
535
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
536 # Return true when anonymous mode
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
537 [ "$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
538 # 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
539 # 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
540 # *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
541 # 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
542 # 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
543 # 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
544 # 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
545 # [ 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
546 # 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
547 # 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
548 # ↑ 要はこういう処理を↓で一気にやっている
935
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
549 case "$2" in
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
550 grp_*)
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
551 sql="SELECT 'owner'
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
552 FROM grp_adm
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
553 WHERE gname=(SELECT gname FROM $2 WHERE rowid=$3)
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
554 AND
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
555 user = '$user';"
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
556 ;;
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
557 *)
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
558 sql="with getblog as (
695
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
559 select key,val from blog_s where id=(
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
560 select blogid from article where id in
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
561 (select id from $2 where rowid=$3))),
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
562 getowner as (select val from getblog where key='owner'),
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
563 getauthor as (select author from article where id=(select id from $2 where rowid=$3)),
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
564 isgrp as (SELECT val from getowner WHERE val IN (select gname from grp)),
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
565 isgrpadm as (select user from grp_adm where
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
566 gname=(select val from getowner) and
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
567 user='$1'),
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
568 getmode as (select val from getblog where key='mode')
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
569 select case
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
570 when (select author from article where
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
571 id=(select id from $2 where rowid=$3))='$1'
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
572 then 'author'
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
573 when (select val from getmode) in ('report-open', 'normal')
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
574 then 'open'
695
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
575 when (select val from getmode) in ('quiz', 'enquete')
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
576 then CASE
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
577 WHEN (SELECT val FROM isgrp) IS NULL
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
578 THEN
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
579 CASE WHEN (SELECT val from getowner)
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
580 IN ('$user', (SELECT author FROM getauthor))
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
581 THEN 'owner-or-user-article-is-readable'
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
582 ELSE ''
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
583 END
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
584 WHEN (select user from isgrpadm) IS NOT NULL
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
585 THEN 'i-am-admin'
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
586 ELSE (SELECT author from getauthor WHERE author IN (SELECT user FROM grp_adm WHERE gname=(SELECT val FROM getowner)))
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
587 END
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
588 when (select val from getmode) is null
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
589 then 'open'
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
590 when (select val from getowner) in (select gname from grp)
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
591 then (SELECT user FROM isgrpadm)
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
592 when (select author from article where
39
5ed3caba8dd1 report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents: 33
diff changeset
593 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
594 then 'user+author'
5ed3caba8dd1 report-closed + user mode -> hidden to other user
HIROSE Yuuji <yuuji@gentei.org>
parents: 33
diff changeset
595 else '' end;"
935
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
596 ;;
c17e67348950 Separate grp_* judgement in isfilereadable()
HIROSE Yuuji <yuuji@gentei.org>
parents: 933
diff changeset
597 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
598 ## 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
599 # caseのネストで内側のcaseがスカラーtrueを返しても外側はtrue扱いにならない
695
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
600 # result=`query "$sql"`
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
601 # err FileAccessibility=$result
5cf0ba49aeab Attached file of admin in quiz-mode blog can be accessible by normal users
HIROSE Yuuji <yuuji@gentei.org>
parents: 694
diff changeset
602 [ -n "`query $sql`" ] || 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
603 }
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 linkhome() {
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
605 # $1=UserOrGroupRowid
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
606 echo -n "<a href=\"$myname?"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
607 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
608 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
609 query "select 'home+'||rowid from user where name='$1';"
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
610 name=`gecos $1|htmlescape`
0
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 else
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
612 _grid=`numericalize "$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
613 echo -n "grp+$1"
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
614 name=`query "SELECT gname FROM grp WHERE rowid=$_grid;"|htmlescape`
0
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 fi
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
616 echo "\">$name</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
617 }
208
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
618 hreflink() {
284
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
619 # s4 specific notation:
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
620 # ^href=URL
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
621 # ^iframe=URL
496
18f7f10566bf Add link notation: "video=URL"
HIROSE Yuuji <yuuji@gentei.org>
parents: 495
diff changeset
622 # ^video=URL
478
926f61977175 Add experimental search keyword link like hash-tags
HIROSE Yuuji <yuuji@gentei.org>
parents: 475
diff changeset
623 # [[#NUM]] - Jump to article ID NUM
926f61977175 Add experimental search keyword link like hash-tags
HIROSE Yuuji <yuuji@gentei.org>
parents: 475
diff changeset
624 # [[#Keyword] - Jump to keywrod search for "Keyword"
284
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
625 # OSM umap Wikistyle Notation:
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
626 # [[URL]] - Simle Link
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
627 # [[URL|Word]] - Link with anchor word
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
628 # {{URL}} - <img src="URL">
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
629 # {{URL|width}} - <img src="URL" width="width">
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
630 # {{{URL}} } - <iframe src="URL"></iframe>
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
631 # {{{URL|height}} - <iframe src="URL" height="height"></iframe>
485
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
632 # Other Style
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
633 # ---- - <hr> (In the beginning of line)
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
634 # *Word* - <em>Word</em>
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
635 # _Word_ - <em>Word</em>
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
636 # **Word** - <strong>Word</strong>
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
637 # __Word__ - <strong>Word</strong>
495
59cd8278a5b5 Trailing 2 consecutive SPC will be translated to <br>
HIROSE Yuuji <yuuji@gentei.org>
parents: 494
diff changeset
638 # SPC+SPC+$ - <br>
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
639 cb='<input type="checkbox" class="s4-checkbox" disabled'
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
640 checkboxON="${cb} checked>"
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
641 checkboxOFF="${cb}>"
267
9bfa9bda1289 Add `!' to href pattern.
HIROSE Yuuji <yuuji@gentei.org>
parents: 266
diff changeset
642 _hrefptn="[-A-Za-z0-9,.:;/~_%#&+?=@!]*"
482
3dc012eb1ad0 URL pattern fixed to exclude URL example which starts with multibyte
HIROSE Yuuji <yuuji@gentei.org>
parents: 479
diff changeset
643 _hrefptn="[A-Za-z0-9/~%+?=@!.][^][()<> ]*" # URL should start with ASCII
451
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 448
diff changeset
644 sed -e "s|\[\[\#\([0-9][0-9]*\)\]\]|<a href=\"?aid\1\">#\1</a>|g" \
479
077dc1763239 Inhibit escaping required chars from hash-tag search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 478
diff changeset
645 -e "s|\[\[#\([^]&]*\)\]\]|<a href=\"?kwd=\1\&stage=searchart\">\#\1</a>|g" \
451
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 448
diff changeset
646 -e "s|\[\[\($_hrefptn\)\|\([^]]*\)\]\]|<a href=\"\1\">\2</a>|g" \
284
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
647 -e "s|\[\[\($_hrefptn\)\]\]|<a href=\"\1\">\1</a>|" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
648 -e "s|{{{\($_hrefptn\)\|\(.*\)}}}|<iframe src=\"\1\" height=\"\2\"></iframe>|g" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
649 -e "s|{{{\($_hrefptn\)}}}|<iframe src=\"\1\"></iframe>|g" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
650 -e "s|{{\($_hrefptn\)\|\(.*\)}}|<img src=\"\1\" width=\"\2\">|g" \
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
651 -e "s|{{\($_hrefptn\)}}|<img src=\"\1\">|g"\
28284f903ddc Allow OSM Wikistyle notation in hreflink()
HIROSE Yuuji <yuuji@gentei.org>
parents: 281
diff changeset
652 -e "s|^href=\($_hrefptn\)|<a &>\1</a>|" \
425
961173fdc904 # at the beginning of the line turns to <h2>...</h2>
HIROSE Yuuji <yuuji@gentei.org>
parents: 424
diff changeset
653 -e "s|^iframe=\($_hrefptn\)|<iframe src=\"\1\"></iframe>|" \
496
18f7f10566bf Add link notation: "video=URL"
HIROSE Yuuji <yuuji@gentei.org>
parents: 495
diff changeset
654 -e "s|^video=\($_hrefptn\)|<video controls><source height=\"320\" src=\"\1\"></video>|" \
426
b3b33923638c ## at the beginning of the line turns to <h2>...</h2>
HIROSE Yuuji <yuuji@gentei.org>
parents: 425
diff changeset
655 -e "s,^#### *\(.*\),<h4>\1</h4>," \
b3b33923638c ## at the beginning of the line turns to <h2>...</h2>
HIROSE Yuuji <yuuji@gentei.org>
parents: 425
diff changeset
656 -e "s,^### *\(.*\),<h3>\1</h3>," \
483
be821d63848c Consecutive 3 or more hyphens become <hr>
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
657 -e "s,^## *\(.*\),<h2>\1</h2>," \
485
021e7943fd99 Emphasis pattern *word*, _word_ and strong pattern **word**, __word__
HIROSE Yuuji <yuuji@gentei.org>
parents: 483
diff changeset
658 -e 's,^----*$,<hr>,' \
486
44b4a45e2617 Emphasizing pattherns like *word* should have surrounding spaces.
HIROSE Yuuji <yuuji@gentei.org>
parents: 485
diff changeset
659 -e 's, \*\*\([^* |][^*|]*[^ |]\)\*\* ,<strong>\1</strong>,g' \
44b4a45e2617 Emphasizing pattherns like *word* should have surrounding spaces.
HIROSE Yuuji <yuuji@gentei.org>
parents: 485
diff changeset
660 -e 's, __\([^_ |][^_]*[^ ]\)__ ,<strong>\1</strong>,g' \
44b4a45e2617 Emphasizing pattherns like *word* should have surrounding spaces.
HIROSE Yuuji <yuuji@gentei.org>
parents: 485
diff changeset
661 -e 's, \*\([^* |][^*|]*[^ |]\)\* ,<em>\1</em>,g' \
495
59cd8278a5b5 Trailing 2 consecutive SPC will be translated to <br>
HIROSE Yuuji <yuuji@gentei.org>
parents: 494
diff changeset
662 -e 's, _\([^_ ][^_]*[^ ]\)_ ,<em>\1</em>,g' \
1019
4952d9b79b7d Add markdown notation of ~~s~~
HIROSE Yuuji <yuuji@gentei.org>
parents: 1018
diff changeset
663 -e 's,~~\([^~][^~]*\)~~,<s>\1</s>,g' \
1016
b47c4aa5f7a4 Fix escaping of \;;;
HIROSE Yuuji <yuuji@gentei.org>
parents: 1015
diff changeset
664 -e 's,\([^\\]\);;;,\1<br>,g;s,\\;;;,;;;,g' \
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
665 -e 's, $,<br>,' \
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
666 -e "s,- \[ *\]\([^|-]*\),${checkboxOFF}<label>\\1</label>,g" \
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
667 -e "s,- \[[^ ]\]\([^|-]*\),${checkboxON}<label>\\1</label>,g" \
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
668
208
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
669 }
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
670 minitbl() {
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
671 sed -n '
295
56c2d2df5b7b minitbl() detection rule modified from /^|[^|]/ to /^|.*|/
HIROSE Yuuji <yuuji@gentei.org>
parents: 292
diff changeset
672 /^|.*|/ {; # If the line begin with "|" and has 2 or more "|"
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
673 s,|$,,; # Remove trailing "|" first
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
674 s,|\* *\([^|]*\) *,<th>\1</th>,g; # "|*..." to "<th>...</th>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
675 s,| *\([^|]*\) *,<td>\1</td>,g; # "|..." to "<td>...</td>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
676 s,^,<tr>,; s,$,</tr>,; # Enclose with "<tr>" and "</tr>"
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
677 H; # Concat this line to HoldSpace
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
678 s/.*//; # Delete PatternSpace for finalization
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
679 $ b cont
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
680 d; # If in final line, output the rest, else jump to next turn
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
681 }
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
682 :cont
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
683 x; # For non-"|" lines, check HoldSpace
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
684 /^./ {; # If HoldSpace has "|" table elements
398
f50d4df067b5 Workaround regexp fix for FreeBSD sed
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
685 s|^.|<table class="mini">|; # Enclose whole elements like this:
f50d4df067b5 Workaround regexp fix for FreeBSD sed
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
686 # . of ^. is workaround for FreeBSD sed
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
687 # s|$|</table>|; # <table class="mini">..\n..</table>
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
688 p; # Print whole "table" element
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
689 s/.*//; # Erase all when done.
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
690 x; s|^|</table>|; x; # Preppend /table to the next line
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
691 }
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
692 x; # Back to the newest line
489
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
693 p; # Print rest' | miniul
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
694 }
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
695 miniul() {
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
696 sed -e '
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
697 /^\* / {; # 行頭 "* "
941
79c7e64884c4 Now miniol can handle continuing line at the first LI.
HIROSE Yuuji <yuuji@gentei.org>
parents: 937
diff changeset
698 x; s,^,<ul>,; x; # 1周目: ホールドスペース先頭に <ul> を
489
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
699 :top
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
700 s/\n//;
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
701 s/^ *//; # 2周目以降: 行頭空白削除
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
702 s,\* ,,; # まず行頭の "* " を消しておく
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
703 H; # 置き換え結果をホールドスペースに追加
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
704 s/.*//; # パターンスペースは消しておく
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
705 # ↓最終行なら残ったホールドスペース処理のため :cont へ
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
706 $ b cont
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
707 N; # 次の行を読む
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
708 s/\n//; # 空白始まりは継続行
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
709 /^ /b top
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
710 x; s/\n/<li>/; s,$,</li>,; # 継続行でなければ <li></li> で囲む
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
711 p; s/.*//;
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
712 x; # 次も "* " ならループを抜けない
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
713 /^\* /b top
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
714 s,^,</ul>,; # 次が一般行なら箇条書終わり
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
715 }
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
716
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
717 :cont
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
718 x; # 行頭| 以外の行:
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
719 /./ {; # ホールドスペースに文字列があれば
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
720 s/^\n/<li>/; s,$,</li></ul>,; # 箇条書を書き切って終わり
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
721 H; x
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
722 }
843
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
723 x' | miniol
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
724 }
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
725 miniol() {
844
ab4f89043f23 No need to use -E for miniol
HIROSE Yuuji <yuuji@gentei.org>
parents: 843
diff changeset
726 sed -e '
843
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
727 /^[1-9]\. / {; # 行頭 "N. "
941
79c7e64884c4 Now miniol can handle continuing line at the first LI.
HIROSE Yuuji <yuuji@gentei.org>
parents: 937
diff changeset
728 h;x; # 1周目: ホールドスペース先頭に <ol> を
79c7e64884c4 Now miniol can handle continuing line at the first LI.
HIROSE Yuuji <yuuji@gentei.org>
parents: 937
diff changeset
729 s,^\([1-9][0-9]*\)\. .*,<ol start="\1">,; # 初期番号付きで追加
79c7e64884c4 Now miniol can handle continuing line at the first LI.
HIROSE Yuuji <yuuji@gentei.org>
parents: 937
diff changeset
730 x;
843
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
731 :top
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
732 s/\n//;
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
733 s/^ *//; # 2周目以降: 行頭空白削除
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
734 H; # 置き換え結果をホールドスペースに追加
851
7ca68e8c2702 Attribute "start=" passed to OL
HIROSE Yuuji <yuuji@gentei.org>
parents: 848
diff changeset
735 x;
941
79c7e64884c4 Now miniol can handle continuing line at the first LI.
HIROSE Yuuji <yuuji@gentei.org>
parents: 937
diff changeset
736 s,[1-9][0-9]*\. ,,; # まず行頭の "N. " を消しておく
851
7ca68e8c2702 Attribute "start=" passed to OL
HIROSE Yuuji <yuuji@gentei.org>
parents: 848
diff changeset
737 x;
843
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
738 s/.*//; # パターンスペースは消しておく
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
739 # ↓最終行なら残ったホールドスペース処理のため :cont へ
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
740 $ b cont
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
741 N; # 次の行を読む
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
742 s/\n//; # 空白始まりは継続行
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
743 /^ /b top
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
744 x; s/\n/<li>/; s,$,</li>,; # 継続行でなければ <li></li> で囲む
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
745 p; s/.*//;
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
746 x; # 次も "* " ならループを抜けない
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
747 /^[1-9][0-9]*\. /b top
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
748 s,^,</ol>,; # 次が一般行なら箇条書終わり
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
749 }
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
750
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
751 :cont
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
752 x; # 行頭| 以外の行:
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
753 /./ {; # ホールドスペースに文字列があれば
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
754 s/^\n/<li>/; s,$,</li></ol>,; # 箇条書を書き切って終わり
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
755 H; x
a0dcf6477310 Add markdown conversion of <ol>
HIROSE Yuuji <yuuji@gentei.org>
parents: 842
diff changeset
756 }
489
075897fee2c0 minitbl() includes mini-ul translation
HIROSE Yuuji <yuuji@gentei.org>
parents: 486
diff changeset
757 x'
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
758 }
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
759 acclog() (
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
760 # $1=table, $2=rowid
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
761 n=${2%%[!-0-9]*} # Remove non-digit chars from $2(should be rowid)
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
762 if [ -n "$n" ]; then
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
763 now=`date +"%F %T"`
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
764 #query "replace into acclog values('$user', '$1', '$n', '$now');"
278
2f1607d8b56b New access log schema started
HIROSE Yuuji <yuuji@gentei.org>
parents: 276
diff changeset
765 #query "replace into acclog values('$user', '$1', $n, '$now');"
2f1607d8b56b New access log schema started
HIROSE Yuuji <yuuji@gentei.org>
parents: 276
diff changeset
766 query "replace into tblaccesses values('$user', '$1', $n, '$now');"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
767 fi
179
479b57681014 Subshellize acclog() and sanitize rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 178
diff changeset
768 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
769 gecos() (
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
770 u=`sqlquote "${1:-$user}"`
173
31e63d173d38 gecos() uses gecoses table
HIROSE Yuuji <yuuji@gentei.org>
parents: 171
diff changeset
771 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
772 )
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
773 setpar() {
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
774 # 2020/5/14 Add dirty code to cache essential params
737
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
775 if [ x"$session" = x"$main_session" ]; then
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
776 case "$1" in
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
777 user) _user="$v" ;;
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
778 skey) _skey="$v" ;;
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
779 esac
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
780 fi
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
781 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
782 }
763
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
783 unsetpar() {
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
784 for i; do
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
785 if [ x"$session" = x"$main_session" ]; then
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
786 case "$i" in
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
787 user|skey) unset _$i ;;
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
788 esac
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
789 fi
836
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
790 query "DELETE FROM par WHERE var='$i' AND sessid='$session';"
763
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
791 done
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
792 }
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
793 replpar() {
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
794 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
795 }
0
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 getpar() {
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
797 # err GETPAR=$1, _user=$_user
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
798 val=""
737
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
799 if [ x"$session" = x"$main_session" ]; then
736
1ab3cc61a462 Temporary disable variable cache'ing for joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
800 case "$1" in # Dirty cache mechanism for high-load average
1ab3cc61a462 Temporary disable variable cache'ing for joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
801 user) val=$_user ;;
1ab3cc61a462 Temporary disable variable cache'ing for joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
802 skey) val=$_skey ;;
1ab3cc61a462 Temporary disable variable cache'ing for joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
803 esac
1ab3cc61a462 Temporary disable variable cache'ing for joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
804 fi
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
805 val=${val:-`query "select val from par where var='$1' and sessid='$session' $2;"`}
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
806 ## 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
807 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
808 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
809 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
810 ## 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
811 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
812 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
813 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
814 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
815 elif ismember $user $val; then
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
816 printf '%s' "$val"; 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
817 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
818 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
819 ## err getpar/ret: "val=[$val]"
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
820 printf '%s' "$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
821 }
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
822 setskey() {
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
823 # For quick response...(?)
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
824 query "REPLACE INTO $sesstb VALUES('$1', '$2', datetime('now', 'localtime', '$timeout'));"
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
825 }
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
826 chkskey() {
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
827 # $1=sesskey, $user=LoginUserName
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
828 test -z "$1" && return 1
714
d7c5f86d9c75 Auth check more rigidly
HIROSE Yuuji <yuuji@gentei.org>
parents: 713
diff changeset
829 repl=`query "SELECT rowid,user FROM $sesstb WHERE user='$user' AND skey = '$1';"` || return 2
d7c5f86d9c75 Auth check more rigidly
HIROSE Yuuji <yuuji@gentei.org>
parents: 713
diff changeset
830 rowid=${repl%%\|*}; repuser=${repl#*\|}
d7c5f86d9c75 Auth check more rigidly
HIROSE Yuuji <yuuji@gentei.org>
parents: 713
diff changeset
831 if [ -n "$rowid" -a x"$user" = x"$repuser" ]; then
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
832 query "UPDATE $sesstb SET expire=datetime('now', 'localtime', '$timeout') WHERE rowid=$rowid;" # Errors can be ignored
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
833 return 0
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
834 fi
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
835 return 1
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
836 }
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
837 resetskey() {
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
838 if [ -n "$_user" ]; then
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
839 query "DELETE FROM $sesstb WHERE user='$_user';"
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
840 fi
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
841 }
0
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 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
843 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
844 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
845 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
846 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
847 }
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 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
849 # 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
850 (f=`query "select val from par where var='$1' and sessid='$session' and type='file' $2;"`
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
851 [ -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
852 }
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 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
854 (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
855 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
856 "") 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
857 "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
858 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
859 *\"*) # string including dbl-quote"
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
860 v=`printf '%s' "$v"|sed -e 's/\"/\"\"/g'`
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
861 printf '%s' "\"$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
862 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
863 *.*.*|*-*-*|*[Ee]*[Ee]*|[Ee]*|*[\ -,:-df-~]*) # string
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
864 printf '%s' "\"$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
865 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
866 *)
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 if expr "$v" : '[-0-9.Ee][-0-9.Ee]*$' >/dev/null 2>&1; then
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
868 printf '%s' $v # MAYBE numeric, maybe...
0
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 else
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
870 printf '%s' "\"$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
871 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
872 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
873 }
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
874 sqlquotestr() (
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
875 case "$1" in
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
876 *\'*) v=`printf '%s' "$1"| sed "s/'/''/g"`
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
877 printf '%s' "'$v'" ;;
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
878 *) printf '%s' "'$1'" ;;
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
879 esac
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
880 )
0
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 mktempd() {
11
3565d93c2fb1 add mpsplit.pl
HIROSE Yuuji <yuuji@gentei.org>
parents: 8
diff changeset
882 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
883 }
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
884 getcachedir() { # $1=maintable
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
885 if [ -n "$imgcached" ]; then
231
332092fa437e Separate cachedir
HIROSE Yuuji <yuuji@gentei.org>
parents: 230
diff changeset
886 echo $imgcached/$(echo ${1:-hoge}|md5)/$thumbxy
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
887 else
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
888 echo $tmpd/$thumbxy
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
889 fi
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
890 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
891 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
892 # $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
893 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
894 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
895 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
896 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
897 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
898 serial)
218
849e6dee3485 Rewind it to use $2 instead of "serial" (getval())
HIROSE Yuuji <yuuji@gentei.org>
parents: 217
diff changeset
899 (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
900 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
901 *)
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 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
903 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
904 }
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
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
906 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
907 # $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
908 (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
909 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
910 "") echo NULL ;;
1011
1c19b0ea0125 [TEST] There's no need to return number from getvalquote.
HIROSE Yuuji <yuuji@gentei.org>
parents: 1009
diff changeset
911 *) sqlquotestr "$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
912 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
913 }
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 getparquote() {
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
915 sqlquote "`getpar $1`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
916 }
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 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
918 # $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
919 # 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
920 # 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
921 # 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
922 ## 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
923
0
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 (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
925 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
926 ###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
927 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
928 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
929 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
930 done
231
332092fa437e Separate cachedir
HIROSE Yuuji <yuuji@gentei.org>
parents: 230
diff changeset
931 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
932 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
933 key=`query "select $pk from $1 where rowid=$3;"`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
934 getkey="(select $pk from $1 where rowid=$3)"
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
935 td=${4:-$tmpd}
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
936 [ -d $td ] || mkdir -p $td
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
937 ### 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
938 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
939 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
940 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
941 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
942 if [ x"$2" = x"$c" ]; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
943 #### cond="$t where $pk=\"$key\" and key=\"$c\"" #2015-07-22
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
944 cond="$t where $pk=$getkey and key=\"$c\""
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
945 val=`query "select val from $cond limit 1;"`
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
946 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
947 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
948 ###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
949 # 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
950 val=`query "select val from $cond and type like 'file:%' order by rowid;"`
699
b33d6e7730ac Remove some debug output and include timestamp in err()
HIROSE Yuuji <yuuji@gentei.org>
parents: 698
diff changeset
951 ## 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
952 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
953 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
954 i=0
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
955 ## 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
956 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
957 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
958 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
959 fn=$c.$i
699
b33d6e7730ac Remove some debug output and include timestamp in err()
HIROSE Yuuji <yuuji@gentei.org>
parents: 698
diff changeset
960 ## 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
961 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
962 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
963 #file=$td/$val
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
964 r_f=`query "select rowid||'//'||val from $cond $slice;"`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
965 f_rid=${r_f%%//*}
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
966 file=$td/${r_f##*//}
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
967 # FOR SPEED: Skip file generation if imgcache exists
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
968 [ -s "$file" -a -s "$td/$fn.rowid" -a -s "$file.rowid" ] \
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
969 && [ x"$f_rid" = x"`cat $td/$fn.rowid`" ] \
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
970 && continue
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
971 # err gvbid-get="select quote(bin) from $cond $slice;"
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
972 ## err output: "fn=[$fn] file=[$file]"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
973 sq $db<<EOF | unhexize > "$file"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
974 .output '$td/$fn.rowid'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
975 select rowid from $cond $slice;
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
976 .output '$td/$fn'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
977 select val from $cond $slice;
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
978 .output '$td/${fn}.content-type'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
979 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
980 .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
981 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
982 EOF
131
9782a978d53c Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 128
diff changeset
983 ## err gvbid-get2: "`ls -lF $file`"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
984 ## err i=$i - file=$file rowid=`cat $td/$fn.rowid`
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
985 cp "$td/$fn.rowid" "$file.rowid" 2>&3 # for convenience
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
986 cp "$file" "$file.orig" 2>&3
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
987 ls -lh "$file" |
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
988 awk '{print $5"B"}'|sed 's/BB/B/' > "$file.size"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
989 case "$type" in
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
990 *:[Ii]mage*) mogrify -geometry $thumbxy "$file" ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
991 ### ここのアイコンを増やしたい
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 *|*:[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
993 convert -geometry $thumbxy $imgdir/file-icon.png \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
994 png:- > "$file"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
995 ;;
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 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
997 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
998 *)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
999 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
1000 .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
1001 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
1002 .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
1003 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
1004 EOF
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1005 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
1006 ;;
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 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
1008 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
1009 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
1010 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
1011 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
1012 file:*)
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
1013 printf '%s\n' "$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
1014 | 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
1015 file=$td/$fn
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1016 if [ ! -s "$file" ]; then
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1017 ## 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
1018 query "select quote(bin) from $cond and val=\"$fn\";" \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1019 | unhexize > "$file"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1020 ##@@## -- echo ${type#file:} > "$file.content-type"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1021 case $type in
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1022 *:[Ii]mage*) mogrify -geometry $thumbxy "$file" ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1023 *:[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
1024 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
1025 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
1026 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
1027 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
1028 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
1029 ;;
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 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
1031 fi
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
1032 printf '%s' "$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
1033 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
1034 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
1035 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
1036 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
1037 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1038 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
1039 # $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
1040 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
1041 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
1042 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
1043 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1044 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
1045 # $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
1046 ###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
1047 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
1048 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
1049 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
1050 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
1051 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1052 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
1053 # 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
1054 # 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
1055 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
1056 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
1057 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
1058 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
1059 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
1060 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
1061 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
1062 }
578
c064c7d357dc Sanitize argument from cgi with numericalize()
HIROSE Yuuji <yuuji@gentei.org>
parents: 577
diff changeset
1063 numericalize() {
c064c7d357dc Sanitize argument from cgi with numericalize()
HIROSE Yuuji <yuuji@gentei.org>
parents: 577
diff changeset
1064 echo "${1%%[!0-9]*}"
c064c7d357dc Sanitize argument from cgi with numericalize()
HIROSE Yuuji <yuuji@gentei.org>
parents: 577
diff changeset
1065 }
0
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 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
1067 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
1068 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
1069 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
1070 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
1071 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
1072 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
1073 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
1074 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
1075 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
1076 $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
1077 }
915
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1078 if type gs >/dev/null 2>&1; then
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1079 gs_pdfwrite() {
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1080 gs -sDEVICE=pdfwrite -dPDFSETTINGS=/default \
917
070e933c7896 Calling gs silently
HIROSE Yuuji <yuuji@gentei.org>
parents: 915
diff changeset
1081 -dNOPAUSE -dQUIET -dBATCH -o "$2" "$1" >/dev/null 2>&1
915
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1082 }
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1083 fi
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1084 enjpeg() {
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1085 if [ -z "$cjpeg" ]; then
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1086 if type cjpeg >/dev/null 2>&1; then
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1087 cjpeg="cjpeg"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1088 else
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1089 cjpeg="convert - jpeg:-"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1090 fi
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1091 fi
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1092 $cjpeg "$@"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
1093 }
0
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 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
1095 key=$1 salt=$2
596
7ece8cc62a7a Deactivate debug output in a loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 592
diff changeset
1096 # err \$2=$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
1097 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
1098 '$'*'$'*) 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
1099 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
1100 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
1101 echo -n '$4$'"$salt"'$'
144
f9e8504bb8f2 Abort if encode fails
HIROSE Yuuji <yuuji@gentei.org>
parents: 143
diff changeset
1102 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
1103 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1104 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
1105 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
1106 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
1107 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
1108 else
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1109 hexize_hd() {
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1110 hexdump -ve '1/1 "%.2x"'
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1111 }
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1112 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
1113 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
1114 fi
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1115 cat "$@" | $hexize | tr -d '\n'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1116 }
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1117 unhexize() {
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1118 if [ -z "$unhex" ]; then
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1119 if type xxd >/dev/null 2>&1; then
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1120 unhex="xxd -p -r"
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1121 elif type perl >/dev/null 2>&1; then
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1122 cat >$tmpd/unhex.pl<<EOF
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1123 s/([0-9a-f]{2})/print chr hex \$1/gie
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1124 EOF
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1125 # Perl refuses -e in setuid circumstances, which can be absurdly
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1126 # avoided by creating scripts in a file where its parent directory is
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1127 # world writable...:)
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1128 unhex="perl -n $tmpd/unhex.pl"
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1129 fi
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1130 fi
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1131 cat "$@" | $unhex
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1132 # cat $1 | tee /tmp/uh.in| $unhex | tee /tmp/uh.out
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
1133 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1134 percenthex() {
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1135 hexize "$@" | sed 's/\(..\)/%\1/g'
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1136 }
155
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
1137 htmlescape() {
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
1138 sed -e 's/\&/\&amp;/g' -e 's/"/\&quot;/g' -e "s/'/\&apos;/g" \
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
1139 -e "s/</\&lt;/g; s/>/\&gt;/g" -e 's/`/\&#096;/g' -e 's/(/\&#040;/g' \
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
1140 -e 's/`/\&#96/'
155
511406c0cbbe Do HTML escape at value editing
HIROSE Yuuji <yuuji@gentei.org>
parents: 154
diff changeset
1141 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1142 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
1143 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
1144 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
1145 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
1146 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
1147 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
1148 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
1149 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
1150 | 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
1151 }
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 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
1153 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
1154 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
1155 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
1156 }
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
1157 size_h() {
164
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
1158 i="$1" oi=$1
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
1159 set -- B B KB MB GB TB
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
1160 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
1161 oi=$i
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
1162 i=$((i/1024))
164
0cc22764899e size_h returns more recognizable unit
HIROSE Yuuji <yuuji@gentei.org>
parents: 163
diff changeset
1163 shift
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
1164 done
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
1165 echo ${oi}$1
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 153
diff changeset
1166 }
0
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 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
1168 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
1169 ## 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
1170 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
1171 "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
1172 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
1173 # /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
1174 }
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 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
1176 # $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
1177 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
1178 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
1179 (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
1180 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
1181 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
1182 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
1183 *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
1184 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
1185 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
1186 *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
1187 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
1188 *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
1189 *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
1190 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
1191 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
1192 *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
1193 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
1194 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
1195 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
1196 }
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 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
1198 # $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
1199 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
1200 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1201 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
1202 (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
1203 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
1204 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
1205 }
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 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
1207 (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
1208 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
1209 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
1210 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1211 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
1212 (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
1213 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
1214 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
1215 }
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 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
1217 (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
1218 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
1219 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
1220 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1221 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
1222 (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
1223 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
1224 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
1225 }
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 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
1227 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
1228 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
1229 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
1230 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
1231 )
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 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
1233 # $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
1234 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
1235 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
1236 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
1237 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
1238 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
1239 *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
1240 *) 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
1241 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
1242 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1243
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1244 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
1245 # $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
1246 (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
1247 tsc=$t/$c val=$4
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1248 quotedp=$(sqlquotestr "$p")
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1249 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
1250 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
1251 #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
1252 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
1253 #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
1254 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
1255 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
1256 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
1257 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
1258 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
1259 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
1260 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
1261 #err t=$t
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1262 type=string fn=""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1263 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
1264 */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
1265 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
1266 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1267 */image*|*/document*)
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1268 type=`file --mime-type - < "$val" | cut -d' ' -f2`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1269 bin="X'`hexize "$val"`'"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1270 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1271 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
1272 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
1273 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
1274 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
1275 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
1276 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
1277 ###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
1278 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
1279 elif [ "$update" ]; then
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1280 query "update $1 set $c=\"$val\" where $pkey=$quotedp;"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1281 else
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
1282 query "replace into $t values($quotedp, \"$c\", \"$type\", \"$val\", \"$bin\");"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1283 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
1284 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1285 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1286 expire() (
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1287 at="${1:-$timeout}"
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1288 FMT="${2:-%F %T}"
6
7ccd9c2eb97e Add templates
HIROSE Yuuji <yuuji@gentei.org>
parents: 4
diff changeset
1289 TZ=GMT gdate -d "$at" +"$FMT"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1290 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1291 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
1292 # 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
1293 # 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
1294 expire=`expire ${2:-"+1min"}`
309
4188f5b3fd67 Use "quier()" instead of "sq $db" at parameter setup
HIROSE Yuuji <yuuji@gentei.org>
parents: 308
diff changeset
1295 query "replace into session values('$1', '$expire');"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1296 # 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
1297 now=`expire now`
309
4188f5b3fd67 Use "quier()" instead of "sq $db" at parameter setup
HIROSE Yuuji <yuuji@gentei.org>
parents: 308
diff changeset
1298 query "delete from session where expire < '$now';"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1299 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1300 gencookie() (
722
78cc4ba7bf42 Debug code and preparation of Path parameter added
HIROSE Yuuji <yuuji@gentei.org>
parents: 721
diff changeset
1301 path=${URL#*:/}
78cc4ba7bf42 Debug code and preparation of Path parameter added
HIROSE Yuuji <yuuji@gentei.org>
parents: 721
diff changeset
1302 path=${URL%/*}
78cc4ba7bf42 Debug code and preparation of Path parameter added
HIROSE Yuuji <yuuji@gentei.org>
parents: 721
diff changeset
1303 expire="`expire '' '%a, %d-%b-%Y %H:%M:%S GMT'`"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1304 for kv; do
722
78cc4ba7bf42 Debug code and preparation of Path parameter added
HIROSE Yuuji <yuuji@gentei.org>
parents: 721
diff changeset
1305 # echo "Set-Cookie: $kv; expires=$expire; Path=$path"
78cc4ba7bf42 Debug code and preparation of Path parameter added
HIROSE Yuuji <yuuji@gentei.org>
parents: 721
diff changeset
1306 echo "Set-Cookie: $kv; expires=$expire;"
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1307 done
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1308 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1309 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
1310 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
1311 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
1312 }
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 putheader() {
1026
a3ec2a73dd33 Add null command to empty function body
HIROSE Yuuji <yuuji@gentei.org>
parents: 1025
diff changeset
1314 :
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1315 }
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 putfooter() {
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1317 _m4 -D_TITLE_="${TITLE:-$myname}" $layout/footer.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1318 }
692
9ff4603fc920 Run getcookie() in the same process
HIROSE Yuuji <yuuji@gentei.org>
parents: 691
diff changeset
1319 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
1320 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
1321 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
1322 v="`echo ${kv#*=}|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`"
756
a4523e15dfd6 s/annex/world/
HIROSE Yuuji <yuuji@gentei.org>
parents: 755
diff changeset
1323 ## err "GetCookie: $k=[$v]"
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1324 case "$k" in
703
6f07cfc1ba86 Remove debug code
HIROSE Yuuji <yuuji@gentei.org>
parents: 702
diff changeset
1325 user) _user="$v" ;;
6f07cfc1ba86 Remove debug code
HIROSE Yuuji <yuuji@gentei.org>
parents: 702
diff changeset
1326 skey) _skey="$v" ;;
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1327 esac
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1328 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
1329 done
692
9ff4603fc920 Run getcookie() in the same process
HIROSE Yuuji <yuuji@gentei.org>
parents: 691
diff changeset
1330 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1331 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
1332 # $1=columns (default: 10)
468
c00857f0e9d2 Avoid `+' and `=' in random string in case of being used as CGI args
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
1333 dd if=/dev/urandom count=1 2>/dev/null|nkf -MB \
711
695ab5c2c1a5 Random generation fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 710
diff changeset
1334 | tr -d '+=\n'|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
1335 }
268
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
1336 genserial() {
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
1337 echo $((($(date +%s)-1433084400)/10))c$$
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
1338 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1339 smail() {
166
32557aa9af94 $SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents: 164
diff changeset
1340 # smail rcpts subj (file)
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
1341 # $SMAIL_TO <- Recipient value of To: header
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
1342 # $MAIL_FROM <- From: header value
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
1343 from=`echo "${MAIL_FROM:-$admin}"|nkf -jM|tr : /|tr -d '\n'`
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 400
diff changeset
1344 rcpt=`echo $1|tr ' ' '\n'|sort -u|tr '\n' ' '` # uniq and strip newlines
988
e77d6258ad54 Inhibit multiple To: headers.
HIROSE Yuuji <yuuji@gentei.org>
parents: 987
diff changeset
1345 ## Gmail rejects below(Duplicated headers)
e77d6258ad54 Inhibit multiple To: headers.
HIROSE Yuuji <yuuji@gentei.org>
parents: 987
diff changeset
1346 ##rcptheader=`echo $1|tr ' ' '\n'|sort -u|sed '2,$s/^/To: /g'`
995
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
1347 rcptheader=`echo $1|tr ' ' '\n'|sort -u|tr '\n' ','|sed 's/,$//'`
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1348 subj=`echo $2|nkf -jM|tr -d '\n'`
630
8874225971ff Test of setting Reply-to header
HIROSE Yuuji <yuuji@gentei.org>
parents: 628
diff changeset
1349 sender=${SENDER:-$admin}
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
1350 # Do not call m4 with directly passing text
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
1351 _r=$tmpd/rcpt
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
1352 echo -n "${SMAIL_TO:-$rcptheader}" > $_r
630
8874225971ff Test of setting Reply-to header
HIROSE Yuuji <yuuji@gentei.org>
parents: 628
diff changeset
1353 replyto=${REPLYTO:+"Reply-to: $REPLYTO$LF"}
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
1354 (_m4 -D_RCPT_="spaste(\`$_r')" -D_REPLYTO_="$replyto" -D_SUBJ_="\`$subj'" -D_FROM_="$from" $msgdir/mail-header.m4
630
8874225971ff Test of setting Reply-to header
HIROSE Yuuji <yuuji@gentei.org>
parents: 628
diff changeset
1355 cat $3 | nkf -jd ) | sendmail -f $sender $rcpt
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1356 }
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1357 smail_queue_flush() {
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1358 # $1=timelimit
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1359 timelimit=`query "SELECT datetime('now', 'localtime', '-6 hours');"`
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1360 rowids=$(sq $workdb <<-EOF
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1361 SELECT rowid FROM smailq
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1362 GROUP BY rcpts, subj
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1363 HAVING min(time) < '$timelimit';
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1364 EOF
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1365 )
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1366 for rid in $rowids; do
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1367 sq $workdb \
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1368 "SELECT hex(rcpts),hex(subj) FROM smailq WHERE rowid in ($rid)" \
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1369 | if IFS='|' read hexr hexs; then
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1370 # err "hexrcpt=[$hexr] hexsubj=[$hexs]"
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1371 rcpt=`echo "$hexr"|unhexize`
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1372 subj=`echo "$hexs"|unhexize`
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1373
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1374 # err ROWID==$rowid "sql=<<SELECT hex(rcpts),hex(subj) FROM smailq WHERE rowid=$rowid;>>"
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1375 # err "rcpt=[$rcpt] subj=[$subj]"
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1376 if sq $workdb <<-EOF | smail "$rcpt" "$subj"
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1377 .separator "\n" "------------------\n\n"
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1378 SELECT time, text FROM smailq
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1379 WHERE rcpts=(SELECT rcpts FROM smailq WHERE rowid=$rid)
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1380 AND subj=(SELECT subj FROM smailq WHERE rowid=$rid)
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1381 ORDER by time;
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1382 EOF
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1383 then
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1384 cat <<-EOF | sq $workdb
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1385 DELETE FROM smailq
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1386 WHERE rcpts=(SELECT rcpts FROM smailq WHERE rowid=$rid)
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1387 AND subj=(SELECT subj FROM smailq WHERE rowid=$rid);
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1388 EOF
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1389 fi
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1390 fi
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1391 done
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1392 }
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1393 smail_queue() {
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1394 # $1=Rcpts, $@=subj
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1395 now=`query "SELECT datetime('now', 'localtime');"`
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1396 if [ $? -eq 0 ]; then
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1397 rcpts="X'"`echo "$1"|hexize`"'"
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1398 subj="X'"`echo "$2"|hexize`"'"
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1399 text="X'"`cat | hexize`"'"
721
fce9d5977822 Put strings before hexizing to smail_queue log
HIROSE Yuuji <yuuji@gentei.org>
parents: 719
diff changeset
1400 err "smail_queue: rcpts=[$1] s=[$2] t:hex=[$text]"
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1401 mintime=$(cat <<-EOF | sq $workdb
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1402 CREATE TABLE IF NOT EXISTS smailq(rcpts, subj, text, time);
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1403 INSERT INTO smailq VALUES($rcpts, $subj, $text, '$now');
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1404 SELECT min(time) FROM smailq WHERE rcpts=$rcpts AND subj=$subj;
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1405 EOF
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1406 )
622
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1407 ## XXX: Adhoc load mitigation
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1408 case "$now" in
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1409 *[01])
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1410 err flush_queue=$mintime
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1411 smail_queue_flush ;;
5f1d4bbf9dea smail_queue frequency control
HIROSE Yuuji <yuuji@gentei.org>
parents: 614
diff changeset
1412 esac
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1413 fi
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
1414 }
0
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 setviastring() {
689
13fb1392d2f2 Function setviastring() only concerned with table 'par'.
HIROSE Yuuji <yuuji@gentei.org>
parents: 688
diff changeset
1416 table=par
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1417 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
1418 IFS="&"
689
13fb1392d2f2 Function setviastring() only concerned with table 'par'.
HIROSE Yuuji <yuuji@gentei.org>
parents: 688
diff changeset
1419 for us in $1; do
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1420 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
1421 v="`echo ${us#*=}|tr '%+' '= '|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`"
689
13fb1392d2f2 Function setviastring() only concerned with table 'par'.
HIROSE Yuuji <yuuji@gentei.org>
parents: 688
diff changeset
1422 setpar "$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
1423 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
1424 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
1425 }
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1426 checkdomain() (
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1427 # Check the validity of domain by referring DNS
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1428 item=$1
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1429 err checkdomain $1
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1430 host ${item#*@} 1>&3 2>&3
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1431 host ${item#*@} >/dev/null 2>&1
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
1432 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1433 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
1434 # $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
1435 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
1436 encpswd=`mycrypt "$1" "$dbpswd"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1437 ## err user=$user, pswd=$1, db=$dbpswd, enc=$encpswd
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1438 [ 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
1439 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1440 mypwhash() {
540
b61881cfe57f Password string can contain blanks
HIROSE Yuuji <yuuji@gentei.org>
parents: 533
diff changeset
1441 mycrypt "`cat`" `genrandom 5`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1442 }
887
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1443 flag_profupdate() {
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1444 # XXX: Sorry to use undeclared column in user.def
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1445 # This is useful to mitigate account sync load
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1446 query <<-EOF
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1447 REPLACE INTO user_s(name, key, type, val)
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1448 VALUES('$user', 'profupdate', 'string', datetime('now', 'localtime'));
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1449 EOF
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1450 touch $userupdateflag
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
1451 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1452 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
1453 user=$1
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1454 if ! checkdomain $user; then
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1455 contenttype; echo
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1456 _m4 -D_TITLE_='Invalid email' $layout/title-only.html
83
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1457 echo "ユーザ名($user)には正しいメイルアドレスが必要です。" | html p
815840076efa Directory structure refreshed
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
1458 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
1459 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
1460 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
1461 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
1462 #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
1463 encpswd=`echo $newpswd|mypwhash`
754
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
1464 dbsetbyid user $user pswd "$encpswd" && touch $userupdateflag
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
1465 # Avoid $user substitution with m4, because $url comes from user input.
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1466 _m4 -D_PSWD_="$newpswd" -D_URL_="$url" -D_ADMIN_="$admin" \
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1467 $msgdir/mail-newaccount.m4 \
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
1468 | sed "s/_USER_/$user/g" \
603
6d89f4a15778 Send reset password to all notification addresses
HIROSE Yuuji <yuuji@gentei.org>
parents: 596
diff changeset
1469 | smail "`collectemail $user`" "New Account"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1470 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1471 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
1472 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
1473 skc=`getpar skey` # from cookie
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1474 [ -z "$user" ] && return 2
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1475 ##skey="`getpwfield $user skey`"
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1476 if [ -n "$skc" ]; then
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1477 if chkskey "$skc"; then
958
a0b1e62df613 Update expiration date when logged in with skey
HIROSE Yuuji <yuuji@gentei.org>
parents: 957
diff changeset
1478 gencookie "user=$user" "skey=$skc" # 2021-12-24: Update expire
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1479 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
1480 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
1481 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
1482 pswd=`getpar pswd`
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1483 quser=`sqlquotestr "$user"`
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1484 dbuser=`query "SELECT name FROM user WHERE name=$quser;"`
691
39879f81afc8 Login failure message changed
HIROSE Yuuji <yuuji@gentei.org>
parents: 690
diff changeset
1485 if [ $? != 0 ]; then # Maybe DB locked
39879f81afc8 Login failure message changed
HIROSE Yuuji <yuuji@gentei.org>
parents: 690
diff changeset
1486 return 4 # 4=server too heavy
39879f81afc8 Login failure message changed
HIROSE Yuuji <yuuji@gentei.org>
parents: 690
diff changeset
1487 elif [ -z "$dbuser" ]; then
728
398df4c7cd27 [TEST]Log user-name failure
HIROSE Yuuji <yuuji@gentei.org>
parents: 727
diff changeset
1488 err "Login USER failed: [$user]"
691
39879f81afc8 Login failure message changed
HIROSE Yuuji <yuuji@gentei.org>
parents: 690
diff changeset
1489 return 2 # 2=login fail
298
ec267a1d27ee Do not "wasureta" for nonexistent user
HIROSE Yuuji <yuuji@gentei.org>
parents: 297
diff changeset
1490 elif [ x"$pswd" = x"wasureta" ]; then
870
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1491 if [ -n "$S4MASTERDB" ]; then
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1492 contenttype; echo
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1493 echo "Reset password is valid in BASE world." | html p
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1494 echo "パスワードリセットはベースワールドでおこなってください。" | html p
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1495 cat <<-EOF | html p
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1496 <a href="$S4MASTERURL">BASE World</a>
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1497 EOF
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1498 exit 0 # XXXXX more smart...
a7ae0d67edff XXX: Lead password resetting to base world
HIROSE Yuuji <yuuji@gentei.org>
parents: 868
diff changeset
1499 fi
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1500 wasureta "$user"
848
770f2eed24a1 Log wasureta
HIROSE Yuuji <yuuji@gentei.org>
parents: 845
diff changeset
1501 err wasureta issued for "$user"
691
39879f81afc8 Login failure message changed
HIROSE Yuuji <yuuji@gentei.org>
parents: 690
diff changeset
1502 return 1 # wasureta error
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1503 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
1504 # 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
1505 # 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
1506 if pwcheck "$pswd"; then
712
4752122ea473 Adjust sesskey length(test)
HIROSE Yuuji <yuuji@gentei.org>
parents: 711
diff changeset
1507 newsession=`genrandom 34`
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1508 if setskey "$user" "$newsession" &&
626
99863f97dee6 Add "heavy load" error message(for test)
HIROSE Yuuji <yuuji@gentei.org>
parents: 625
diff changeset
1509 dbsetbyid user "$user" login "`date '+%F %T'`"; then
99863f97dee6 Add "heavy load" error message(for test)
HIROSE Yuuji <yuuji@gentei.org>
parents: 625
diff changeset
1510 gencookie "user=$user" "skey=$newsession"
99863f97dee6 Add "heavy load" error message(for test)
HIROSE Yuuji <yuuji@gentei.org>
parents: 625
diff changeset
1511 return 0
99863f97dee6 Add "heavy load" error message(for test)
HIROSE Yuuji <yuuji@gentei.org>
parents: 625
diff changeset
1512 else
627
86058f1bf9fa Add comment
HIROSE Yuuji <yuuji@gentei.org>
parents: 626
diff changeset
1513 return 4 # Heavy load??
626
99863f97dee6 Add "heavy load" error message(for test)
HIROSE Yuuji <yuuji@gentei.org>
parents: 625
diff changeset
1514 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
1515 fi
727
1b294b80544e [TEST]Debug code added for login failure
HIROSE Yuuji <yuuji@gentei.org>
parents: 722
diff changeset
1516 err "Login failed: [$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
1517 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
1518 }
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 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
1520 args=`echo $myargs|tr ' ' '+'`
697
4461d596150d HEADS UP: session storing schema changed, which allows multi sessions
HIROSE Yuuji <yuuji@gentei.org>
parents: 695
diff changeset
1521 test -z "$args" && resetskey
514
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1522 s4name=${S4NAME:-s4}
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1523 ( sed '/^<body/q' $layout/html.m4.html
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1524 cat $layout/login.m4.html
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1525 echo '</body></html>'
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1526 ) | _m4 \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1527 -D_BODYCLASS_="login" \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1528 -D_TITLE_="$s4name" \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1529 -D_SYSNAME_="Welcome to $s4name" \
fa3f78ce3e26 Extra CSS file is taken from $S4CSS.
HIROSE Yuuji <yuuji@gentei.org>
parents: 513
diff changeset
1530 -D_MYNAME_="$myname${args+?}$args" ${S4CSS:+-D_S4CSS_="$S4CSS"}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1531 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
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 dologin() {
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 816
diff changeset
1534 test -n "$S4WORLD" && syncaccount
0
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 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
1536 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
1537 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
1538 contenttype; echo
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1539 _m4 -D_USER_="$user" -D_URL_="$url" -D_ADMIN_="$admin" \
693
5f3e94a9b7b3 Show load average at login failure on DB lock
HIROSE Yuuji <yuuji@gentei.org>
parents: 692
diff changeset
1540 -D _LOADAVG_="`uptime|awk '{print $(NF-2)}'|tr -d ,`" \
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1541 $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
1542 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
1543 fi
858
b8b939399251 Trivial fix
HIROSE Yuuji <yuuji@gentei.org>
parents: 857
diff changeset
1544 err "Auth OK: [$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
1545 }
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1546
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1547 # Do instant jobs here
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
1548 dbsetup
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1549 trap cleanup INT HUP EXIT TERM PIPE
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
1550 # trap cleanup INT HUP
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1551
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
1552
0
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 cgiinit() {
11
3565d93c2fb1 add mpsplit.pl
HIROSE Yuuji <yuuji@gentei.org>
parents: 8
diff changeset
1554 tmpd=`tmpd=$tmpdir mktempd`
723
b8f5bfb91ea2 Save streaming file in $tmpd
HIROSE Yuuji <yuuji@gentei.org>
parents: 722
diff changeset
1555 tmpf=$tmpd/stream.$$
0
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 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
1557 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
1558 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
1559 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
1560 get|GET) s="$QUERY_STRING" ;;
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1561 post|POST) ## dd count=$CONTENT_LENGTH bs=1 of=$tmpf 2>/dev/null #slow
137
1731efcb74c7 Add comment on dd bs=LARGE
HIROSE Yuuji <yuuji@gentei.org>
parents: 136
diff changeset
1562 ## dd bs=$CONTENT_LENGTH count=1 of=$tmpf # NOT working
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1563 # cat > $tmpf # too much?
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1564 head -c $CONTENT_LENGTH > $tmpf # safe?
853
047e1c3f811e Log output revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 851
diff changeset
1565 err "CONTENT_LENGTH=$CONTENT_LENGTH$nl`ls -lF $tmpf`"
724
489efda25567 tmpf should be passed by variable...
HIROSE Yuuji <yuuji@gentei.org>
parents: 723
diff changeset
1566 s="`cat $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
1567 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1568 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
1569 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
1570 *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
1571 bndry=${CONTENT_TYPE#*boundary=}
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1572 #for us in `LC_CTYPE=C ./mpsplit.rb "$bndry" $tmpd < $tmpf`
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
1573 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
1574 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
1575 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
1576 #echo u=$us
11
3565d93c2fb1 add mpsplit.pl
HIROSE Yuuji <yuuji@gentei.org>
parents: 8
diff changeset
1577 #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
1578 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
1579 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
1580 *:filename)
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1581 mimetype=`file --mime-type - < "$tmpd/$v"|cut -d' ' -f2`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1582 type='file'; k=${k%:filename}
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1583 # DO NOT ALLOW Space and '|' in file names
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1584 newv=`echo "$v"|sed 's/[ \|]/X/g'`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1585 if [ x"$v" != x"$newv" ]; then
329
e4fedb216119 Making sure whether it runs on ksh
HIROSE Yuuji <yuuji@gentei.org>
parents: 328
diff changeset
1586 :
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1587 fi
719
093be7d30a6e More debug code to cgiinit()
HIROSE Yuuji <yuuji@gentei.org>
parents: 718
diff changeset
1588 err "k=[$k] v=[$v]" # debug@2020-05-31
718
c56f8e76dff2 $user has not yet been set in cgiinit
HIROSE Yuuji <yuuji@gentei.org>
parents: 717
diff changeset
1589 err "`ls -lF $tmpd/$v` MimeType=$mimetype"
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1590 case "$mimetype" in
132
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1591 [Ii]mage/x-xcf)
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
1592 bzip2 "$tmpd/$v"
132
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1593 v=${v}.bz2
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1594 ;;
7a9cd078bf6a bzip2 *.xcf files
HIROSE Yuuji <yuuji@gentei.org>
parents: 131
diff changeset
1595 [Ii]mage/x-*|*/vnd.*) ;;
715
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1596 [Ii]mage/[Hh][Ee][Ii][Ff])
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1597 if type heif-convert >/dev/null 2>&1; then
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1598 vjpg="${v%.heic}.jpg"
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1599 err "Conv $v to $vjpg in $tmpd"
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1600 convert -quality 75 -resize $maximagexy'>' \
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1601 "$tmpd/$v" "$tmpd/$vjpg" >/dev/null 2>&1
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1602 v=$vjpg
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1603 else
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1604 mimetype="Not supported"
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1605 fi
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1606 ;;
0
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 [Ii]mage/*)
715
d890694ff8ab Trial conversion of HEIC
HIROSE Yuuji <yuuji@gentei.org>
parents: 714
diff changeset
1608 mogrify -quality 75 -resize $maximagexy'>' "$tmpd/$v"
719
093be7d30a6e More debug code to cgiinit()
HIROSE Yuuji <yuuji@gentei.org>
parents: 718
diff changeset
1609 err "Mogrified: `ls -lF $tmpd/$v`" # 2020-05-31
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1610 ;;
915
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1611 [Aa]pplication/[Pp][Dd][Ff])
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1612 if [ x"`getpar comppdf`" = x"yes" ]; then
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1613 if type gs_pdfwrite >/dev/null 2>&1; then
918
95c066490083 s/comp/compressed/
HIROSE Yuuji <yuuji@gentei.org>
parents: 917
diff changeset
1614 nv=${v%.pdf}-compressed.pdf
917
070e933c7896 Calling gs silently
HIROSE Yuuji <yuuji@gentei.org>
parents: 915
diff changeset
1615 err Calling gs from $v to $nv
070e933c7896 Calling gs silently
HIROSE Yuuji <yuuji@gentei.org>
parents: 915
diff changeset
1616 if gs_pdfwrite "$tmpd/$v" "$tmpd/$nv"; then
070e933c7896 Calling gs silently
HIROSE Yuuji <yuuji@gentei.org>
parents: 915
diff changeset
1617 err "PDF compressed: `ls -lF $tmpd/*.pdf`"
070e933c7896 Calling gs silently
HIROSE Yuuji <yuuji@gentei.org>
parents: 915
diff changeset
1618 v=$nv
070e933c7896 Calling gs silently
HIROSE Yuuji <yuuji@gentei.org>
parents: 915
diff changeset
1619 fi
915
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1620 fi
b47f64276427 Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents: 905
diff changeset
1621 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
1622 esac
511
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1623 if ! echo "$mimetype" | egrep "$file_accept_egrep" >/dev/null 2>&1
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1624 then
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1625 replpar text string " *添付できない形式です($v)* $file_warn"
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1626 continue
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1627 elif [ `wc -c < "$tmpd/$v"` -gt "$filesize_max" ]; then
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1628 replpar text string \
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1629 " *添付ファイル($v)は${filesize_max}バイト以下にしてください* $file_warn"
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1630 continue
f2dec8025291 Force restrict file type and file size
HIROSE Yuuji <yuuji@gentei.org>
parents: 510
diff changeset
1631 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
1632 ;;
883
8593ff2579f4 Ignore empty file-input form
HIROSE Yuuji <yuuji@gentei.org>
parents: 882
diff changeset
1633 image|document|binary)
8593ff2579f4 Ignore empty file-input form
HIROSE Yuuji <yuuji@gentei.org>
parents: 882
diff changeset
1634 # When no file name supplied to input[type="file"]
8593ff2579f4 Ignore empty file-input form
HIROSE Yuuji <yuuji@gentei.org>
parents: 882
diff changeset
1635 continue ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1636 *)
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 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
1638 ;;
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 esac
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1640 #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
1641 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
1642 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
1643 ;;
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 *)
689
13fb1392d2f2 Function setviastring() only concerned with table 'par'.
HIROSE Yuuji <yuuji@gentei.org>
parents: 688
diff changeset
1645 setviastring "$s"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1646 ;;
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 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
1648 }
58
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1649 email4group() {
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1650 # 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
1651 qgrp=`sqlquote "$1"`; shift
961
3444e0a72bb7 User list should be delimited by white spaces
HIROSE Yuuji <yuuji@gentei.org>
parents: 958
diff changeset
1652 users=`for i; do sqlquote "$i"; echo; done`
58
ccd0c6736215 Argument order reversed on email4group
HIROSE Yuuji <yuuji@gentei.org>
parents: 56
diff changeset
1653 users=`echo $users|tr ' ' ','`
240
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1654 sql="WITH
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1655 grpemails AS (
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1656 SELECT gname, user, val email
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1657 FROM grp_mem NATURAL JOIN grp_mem_s
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1658 WHERE key='email' AND gname=$qgrp),
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1659 useremails AS (
646
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1660 SELECT user.name, val email
240
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1661 FROM user
507
145fb3cca3fb User email values are in user_m, not user_s.
HIROSE Yuuji <yuuji@gentei.org>
parents: 502
diff changeset
1662 LEFT JOIN user_m
145fb3cca3fb User email values are in user_m, not user_s.
HIROSE Yuuji <yuuji@gentei.org>
parents: 502
diff changeset
1663 ON user.name=user_m.name AND user_m.key='email')
145fb3cca3fb User email values are in user_m, not user_s.
HIROSE Yuuji <yuuji@gentei.org>
parents: 502
diff changeset
1664 SELECT DISTINCT coalesce(g.email, u.email, u.name)
240
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1665 FROM useremails u LEFT JOIN grpemails g
3ba9493977e1 email4groupbyuid now accepts uname(email) as well as gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 236
diff changeset
1666 ON u.name=g.user
646
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1667 WHERE u.name in ($users);"
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1668 query "$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
1669 }
646
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1670 email4groupbyuid() {
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1671 # Get for-$1=group email address(es) for $2...=user-ids
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1672 g=$1; shift
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1673 uids=`echo "$@"`
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1674 uids=`echo $uids|tr ' ' ','`
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1675 sql="SELECT DISTINCT name FROM user WHERE rowid IN ($uids);"
653
22f4f91656a8 Preserved argument should be passed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 650
diff changeset
1676 email4group "$g" `query "$sql"`
646
d9bce34a863b Email4group should use same algorithm as email4groupbyuid
HIROSE Yuuji <yuuji@gentei.org>
parents: 645
diff changeset
1677 }
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
1678 myemail4group() {
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
1679 # Get my email address for $1-specified group
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
1680 email4group "$1" "$user" | sed -e 1q -e 's/[ ,].*//'
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
1681 }
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1682 collectmembersbyid() {
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1683 # Collect user names of group specified by grid
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1684 rid=${1%%[!0-9]*} # Cleaning
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1685 query "SELECT user FROM grp_mem \
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1686 WHERE gname=(SELECT gname FROM grp WHERE rowid=$rid);"
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1687 }
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1688 collectmembersbyid() {
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1689 # Collect user names of group name
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1690 qgrp=`sqlquote "$1"`
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1691 query "SELECT user FROM grp_mem WHERE gname=$qgrp;"
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1692 }
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1693 collectgecosesbyid() {
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1694 # Collect user gecoses of group
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1695 rid=${1%%[!0-9]*} # Cleaning
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1696 query<<-EOF
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1697 SELECT gecos
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1698 FROM gecoses
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1699 WHERE name IN (SELECT user FROM grp_mem
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1700 WHERE gname=(SELECT gname FROM grp WHERE rowid=$rid));
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1701 EOF
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
1702 }
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1703 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
1704 # Collect email addresses for group $1
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1705 # If $TEAM is set, filter by team name
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1706 # If $EXCEPT is set as username(s) delimited by comma,
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1707 # remove $EXCEPT from list: ....NOT IN ($EXCEPT)
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1708 for e; do
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1709 if isuser "$e"; then
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1710 em=`query "select val from user_m where name='$e' and key='email';"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1711 [ -n "$em" ] && echo "$em" || echo "$e"
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1712 else
56
7fa1ac62dfaf getgroupadmins()
HIROSE Yuuji <yuuji@gentei.org>
parents: 52
diff changeset
1713 qgrp=`sqlquote "$e"`
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1714 if [ -z "$TEAM" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1715 gmem="grp_mem"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1716 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1717 tm=`sqlquote "$TEAM"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1718 gmem="(SELECT gname, user FROM grp_mem_m WHERE gname='$e' AND key='team' AND val=$tm)"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1719 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1720 ex=${EXCEPT:+"AND g.user NOT IN ($EXCEPT)"}
62
5ca8f194faf2 Collect emails for group give a preference to email values in user_m.
HIROSE Yuuji <yuuji@gentei.org>
parents: 61
diff changeset
1721 sql="select coalesce(s.val,um.val,g.user) from
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1722 $gmem g left join grp_mem_s s
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1723 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
1724 left join user_m um on g.user=um.name and um.key='email'
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1725 where g.gname=$qgrp $ex;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1726 ## err CollectEmail: `echo "$sql"`
47
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1727 query "$sql"
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1728 fi
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1729 done
c37cbb154e01 collectemail can take multiple arguments
HIROSE Yuuji <yuuji@gentei.org>
parents: 43
diff changeset
1730 )
0
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 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
1732 # $1=email
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1733 iss="invite-`date +%s`-$user"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
1734 addsession $iss +${memoplimitdays}days # 1 week due date
581
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1735 query "DELETE FROM par WHERE var='invite' AND val='$1';"
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1736 query "REPLACE INTO par VALUES('$iss', 'invite', 'string', '$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
1737 gecos=`gecos`
581
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1738 name=$user${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
1739 regist="$urlbase?reg+$iss"
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1740 _m4 -D_URL_="$urlbase" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1741 -D_USER_="$name" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1742 -D_EMAIL_="$1" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1743 -D_REGIST_="$regist" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1744 -D_ADMIN_="$admin" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1745 $msgdir/mail-invite.m4 \
554
0c6e28f7a7a8 s/BBS/SNS/
HIROSE Yuuji <yuuji@gentei.org>
parents: 550
diff changeset
1746 | smail $1 "SNSへの御招待"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1747 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
1748 )
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 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
1750 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
1751 *@*@*) 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
1752 *@*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1753 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
1754 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
1755 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
1756 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
1757 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
1758 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
1759 ;;
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 *) 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
1761 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
1762 }
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 invite() {
581
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1764 email=`getpar email | tr '[A-Z]' '[a-z]'`
950
4099e5a30e27 Limit users who can invite others by setting INVITE_ONLYFROM
HIROSE Yuuji <yuuji@gentei.org>
parents: 946
diff changeset
1765 if [ -n "$INVITE_ONLYFROM" ]; then
4099e5a30e27 Limit users who can invite others by setting INVITE_ONLYFROM
HIROSE Yuuji <yuuji@gentei.org>
parents: 946
diff changeset
1766 if ! echo "$user" | grep -E -e "$INVITE_ONLYFROM" >/dev/null 2>&1; then
4099e5a30e27 Limit users who can invite others by setting INVITE_ONLYFROM
HIROSE Yuuji <yuuji@gentei.org>
parents: 946
diff changeset
1767 echo "招待可能ユーザに登録されていません" | html p
4099e5a30e27 Limit users who can invite others by setting INVITE_ONLYFROM
HIROSE Yuuji <yuuji@gentei.org>
parents: 946
diff changeset
1768 return
4099e5a30e27 Limit users who can invite others by setting INVITE_ONLYFROM
HIROSE Yuuji <yuuji@gentei.org>
parents: 946
diff changeset
1769 fi
4099e5a30e27 Limit users who can invite others by setting INVITE_ONLYFROM
HIROSE Yuuji <yuuji@gentei.org>
parents: 946
diff changeset
1770 fi
502
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1771 case "$email" in
46a8da2740d9 Add CheckBox WikiStyle notation "- [ ]"
HIROSE Yuuji <yuuji@gentei.org>
parents: 496
diff changeset
1772 *@*@*|*\ *) repo="無効なアドレスです" ;;
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1773 *@*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1774 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
1775 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
1776 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
1777 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
1778 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
1779 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
1780 repo="アドレス($email)宛に案内を送信しました。"
581
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1781 else # Cannot be reached here
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1782 repo="自動登録できない状況です。管理者に依頼してください。"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1783 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
1784 "") 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
1785 *) 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
1786 esac
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1787 addr=`query "select val from par where sessid like 'invite-%-$user';"`
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1788 if [ -n "$addr" ]; then
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1789 susp="<h2>招待済みで加入待ちのアドレス</h2><pre>$addr</pre>"
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1790 fi
624
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
1791 if [ -f $invite_policy ]; then
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
1792 pol="spaste(\`$invite_policy')"
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
1793 else
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
1794 pol="$invite_policy"
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
1795 fi
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1796 _m4 -D_TITLE_="招待" -D_REPORT_="\`$repo'" -D_ACTION_="?invite" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1797 -D_BODYCLASS_="default" -D_SUSPENDED_="$susp" \
624
64c84bc00700 Invatation policy displayed in invitation page
HIROSE Yuuji <yuuji@gentei.org>
parents: 622
diff changeset
1798 -D_INVITE_POLICY_="$pol" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1799 $layout/html.m4.html $layout/invite.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1800 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1801 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
1802 # $1=session-id-for-invitation
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1803 _m4 -D_TITLE_="Invitation" $layout/html.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1804 if [ -z "$1" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1805 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
1806 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
1807 fi
581
8a206c6342a8 Translate email address to all lower cases. Fix parameter expansion.
HIROSE Yuuji <yuuji@gentei.org>
parents: 578
diff changeset
1808 email=`session=$1 getpar invite | tr '[A-Z]' '[a-z]'` # Ensure lower case
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1809 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
1810 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
1811 <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
1812 <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
1813 加入している人に、再度招待してもらいましょう。</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
1814 EOF
65
HIROSE Yuuji <yuuji@gentei.org>
parents: 62
diff changeset
1815 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
1816 fi
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1817 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
1818 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
1819 # 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
1820 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
1821 ('$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
1822 wasureta $email
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1823 echo "このアドレスに初期パスワードを送信しました。" |html p
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
1824 echo "新着メイルを確認してログインしてください。" |html p
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
1825 addsession $1 # for removal after 1 minute
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1826 _m4 -D_SYSNAME_="Initial Login" -D_MYNAME_="$myname?userconf" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1827 $layout/login.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1828 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
1829 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1830 group_safename() {
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1831 # Convert $1 to safe group name
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1832 echo "$1" | tr -d '"'"'",
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1833 }
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1834 groupupdate() {
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1835 gname=`getpar gname`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
1836 qgname=`sqlquote "$gname"`
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1837 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
1838 # See ALSO same job in showgroup()
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
1839 newgname=`group_safename "$gname"`
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1840 err newgname=$newgname
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1841 if [ x"$newgname" != x"$gname" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1842 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
1843 gname=$newgname
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1844 echo "使用禁止文字を除去し $gname としました。" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1845 replpar gname string "$gname"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1846 fi
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1847 # Name confliction check
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1848 parow=`getpar rowid`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1849 ## err parow=$parow
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
1850 qgname=`sqlquote "$gname"` # Set again in case gname modified
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1851 query "BEGIN EXCLUSIVE;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1852 ## err "select count(gname) from grp where rowid != ${parow:-0} and gname = $qgname;"
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1853 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
1854 if [ $count -gt 0 ]; then
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1855 echo "そのグループ名は既にあります。" | html p
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1856 query "END;"
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1857 return
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1858 fi
123
718abe22a5d1 Call large query with SQL script in par2table()
HIROSE Yuuji <yuuji@gentei.org>
parents: 122
diff changeset
1859 par2table $formdir/grp.def
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1860 query "END TRANSACTION;"
163
87e679d3c993 Avoid using "tail -f"
HIROSE Yuuji <yuuji@gentei.org>
parents: 155
diff changeset
1861 # Remove orphan
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1862 : <<EOF
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1863 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
1864 (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
1865 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
1866 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
1867 EOF
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1868 rm=`getpar rm` cfm=`getpar confirm`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1869 ## err groupupdate:::: after par2tbl rmcfm=$rm$cfm
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1870 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
1871 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
1872 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
1873 (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
1874 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
1875 query "$sql";
763
41e443a925c8 Introduce unsetpar() for continuous page building
HIROSE Yuuji <yuuji@gentei.org>
parents: 749
diff changeset
1876 unsetpar tag kwd
307
e7a7f6cb9627 When removing a group, switch to grp-list and return
HIROSE Yuuji <yuuji@gentei.org>
parents: 306
diff changeset
1877 grps # When removing a group, switch to grp-list
e7a7f6cb9627 When removing a group, switch to grp-list and return
HIROSE Yuuji <yuuji@gentei.org>
parents: 306
diff changeset
1878 return # and return
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1879 fi
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 121
diff changeset
1880 fi
305
e751156de740 Do not add email address to grp_mem_s at new group creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 302
diff changeset
1881 [ -z "$parow" ] && joingrp "$gname" "$user" yes "" as-admin
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1882 fi
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1883 sql="select rowid from grp where gname=$qgname;"
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1884 grid=$(query $sql)
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
1885 ## err grpupdate:new-grid=$grid, sql=$sql
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1886 grp $grid
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1887 }
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1888 groupclone() {
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1889 # $1=grp-rowid of clone-base group
576
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1890 rid=${1%%[!0-9]*} # Cleaning
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1891 case "$1" in
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1892 */noteam)
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1893 noteam="AND key != 'team'" ;;
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1894 esac
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1895 qgrp=`query "SELECT quote(gname) FROM grp WHERE rowid=$rid;"`
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1896 if [ -z "$qgrp" ]; then
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1897 echo "無効なグループIDです($1)" | html p
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1898 return
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1899 fi
577
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
1900 if ! isgrpownerbygid "$user" "$rid"; then
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
1901 echo "グループ管理者のみがクローン可能です" | html p
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
1902 return
67ecd5901590 Inhibit non-group admin from cloning group
HIROSE Yuuji <yuuji@gentei.org>
parents: 576
diff changeset
1903 fi
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1904 i=0
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1905 while true; do
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1906 copy="-copy$i"
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1907 newqname=`query "SELECT quote($qgrp || '$copy');"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1908 # err Trying new grp=$newqname with copy=$copy
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1909 test=`query "SELECT gname FROM grp WHERE gname=$newqname;"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1910 if [ -n "$test" ]; then
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1911 i=$((i++))
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1912 continue
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1913 fi
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1914 break
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1915 done
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1916 # Creating New group "$newqname" with members of old group
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1917 # err Creating new grp=$newqname with copy=$copy
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1918 query<<-EOF
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1919 BEGIN;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1920 INSERT INTO grp VALUES($newqname); -- Create NEW one
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1921 REPLACE INTO grp_s(gname, key, val) -- Copy tag
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1922 SELECT $newqname, key, val
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1923 FROM grp_s WHERE gname=$qgrp AND key IN ('tag', 'mode');
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1924 REPLACE INTO grp_s(gname, key, type, val) -- Copy gecos with "copy$n"
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1925 SELECT $newqname, key, type, val || '$copy'
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1926 FROM grp_s WHERE gname=$qgrp AND key='gecos';
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1927 -- Copy members and their configuration --
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1928 REPLACE INTO grp_mem SELECT $newqname, user
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1929 FROM grp_mem WHERE gname=$qgrp;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1930 REPLACE INTO grp_mem_s SELECT $newqname, user, key, type, val, bin
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1931 FROM grp_mem_s WHERE gname=$qgrp;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1932 REPLACE INTO grp_mem_m SELECT $newqname, user, key, type, val, bin
576
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
1933 FROM grp_mem_m WHERE gname=$qgrp $noteam;
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1934 -- Copy administrators --
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1935 REPLACE INTO grp_adm SELECT $newqname, user
383
93ba4a8f3398 Oops, grp_adm should not be copied from grp_mem
HIROSE Yuuji <yuuji@gentei.org>
parents: 382
diff changeset
1936 FROM grp_adm WHERE gname=$qgrp;
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1937 COMMIT;
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1938 EOF
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1939 newrowid=`query "SELECT rowid FROM grp WHERE gname=$newqname;"`
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1940 STOPCLONEMSG=1 groupconf "$newrowid"
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
1941 }
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1942 groupman() {
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1943 note="<p>グループ名に使用できない文字は自動的に削除されます。</p>"
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1944
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1945 GF_STAGE="grpconf"
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1946 GF_STAGE=groupupdate
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
1947 DT_VIEW=grp dumptable html grp 'gname gecos:DESC mtime:TIME' 'order by b.TIME desc' \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1948 |_m4 -D_TITLE_="グループ作成" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1949 -D_FORM_="$note`genform $formdir/grp.def`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1950 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1951 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
1952 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1953 userconf() {
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
1954 [ -n "`getpar rowid`" ] && par2table $formdir/user.def
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1955 _m4 -D_BODYCLASS_=userconf -D_TITLE_="ユーザ情報編集" $layout/html.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1956 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
1957 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1958 groupconf() {
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
1959 # $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
1960 [ -n "`getpar rowid`" ] && par2table $formdir/grp.def
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
1961 _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
1962 #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
1963 rowid=${1%%[!A-Z0-9a-z_]*}
607
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1964
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1965 ### If user is not admin, lead to group home
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1966 grp=`getgroupbyid $rowid`
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1967 if ! isgrpowner "$user" "$grp"; then
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1968 echo "<p><a href=\"?grp+$rowid\">`echo "$grp"|htmlescape`</a></p>"
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1969 return
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1970 fi
d0068e9e6bd7 If user is not admin, lead to group home in groupconf()
HIROSE Yuuji <yuuji@gentei.org>
parents: 606
diff changeset
1971
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
1972 # 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
1973 GF_STAGE="groupupdate" edittable "$formdir/grp.def" "grp" "$rowid"
384
305381d205bb Shring anchored portion of link to groupclone()
HIROSE Yuuji <yuuji@gentei.org>
parents: 383
diff changeset
1974 if [ -z "$STOPCLONEMSG" ]; then
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1975 ## Setup migration menu
778
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
1976 height="10em" ## Ugly!!
796
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
1977 if [ -n "$S4WORLDLIST" ]; then
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
1978 v=`fgrep -v "value=\"$worldconf\"" $worldoptionfile`
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
1979 err v=$v
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
1980 if [ -n "$v" ]; then
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
1981 migrate=$(cat<<-EOF
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1982 `cgi_radio grpaction migrate id="migrate"`<label
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1983 for="migrate">別Worldへ移住</label>
778
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
1984 <div style="height: $height;">
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1985 <form action="?migrategrp">
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1986 <p>移住先:<select name="migrateto">$nl$v$nl</select></p>
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1987 <p>グループや掲示板のURLが変わります。
778
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
1988 外部からリンクしている場合は飛べなくなります。
789
ce8942919edf Update migration notice
HIROSE Yuuji <yuuji@gentei.org>
parents: 787
diff changeset
1989 すでにリンクされた掲示板を多数含む場合は既存グループを温存し、
ce8942919edf Update migration notice
HIROSE Yuuji <yuuji@gentei.org>
parents: 787
diff changeset
1990 「グループのクローン」で
778
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
1991 メンバーを引き継いだ上でそのクローンを移住するのがお勧めです。</p>
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1992 <p><label>`cgi_checkbox emichk yes`確認</label></p>
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1993 `cgi_hidden stage migrategrp`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1994 `cgi_hidden rowid $rowid`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1995 `cgi_submit OK`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1996 `cgi_reset Reset`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1997 </form>
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1998 </div>
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
1999 EOF
796
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
2000 )
8646ec4bd6fc Load s4-config.sh earlier
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
2001 fi
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2002 fi
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2003 html div 'class="foldtabs"' <<-EOF
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2004 `cgi_radio grpaction clone id="clone"`<label
778
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
2005 for="clone">グループのクローン作成</label>
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
2006 <div style="height: $height;">
576
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2007 <p>構成メンバーが同じ新規グループを作成します。</p>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2008 <table>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2009 <tr><td><a href="?groupclone+$rowid">
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2010 <button>クローン作成(チームも複製)</button></a></td>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2011 <td><p>(チームなどもそのままで掲示板なしの状態から)</p></td></tr>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2012 <tr><td><a href="?groupclone+$rowid/noteam">
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2013 <button>作成(チームなし)</button></a></td>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2014 <td>(チームは引き継がずメンバーのみ同じグループを作成)</td></tr>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2015 </table>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2016 <p>ボタンを押すと即作成します。不要な場合はグループ編集で
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2017 削除してください。</p>
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2018 </div>
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2019 $migrate
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2020 `cgi_radio grpaction close id="x"`<label for="x" accesskey="x">×</label>
778
3e6d36fa579d Display information improved
HIROSE Yuuji <yuuji@gentei.org>
parents: 777
diff changeset
2021 <div style="height: $height; background: transparent;"></div>
576
c81511a6b7e0 Add feature of "clone without team"
HIROSE Yuuji <yuuji@gentei.org>
parents: 575
diff changeset
2022 EOF
384
305381d205bb Shring anchored portion of link to groupclone()
HIROSE Yuuji <yuuji@gentei.org>
parents: 383
diff changeset
2023 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
2024 }
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2025 migrategrp() {
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2026 rowid=`getpar rowid`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2027 rowid=${rowid%%[!0-9]*}
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2028 grp=`getgroupbyid $rowid`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2029 if ! isgrpowner "$user" "$grp"; then
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2030 echo "<p><a href=\"?grp+$rowid\">`echo "$grp"|htmlescape`</a></p>"
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2031 return
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2032 fi
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2033 if [ x`getpar emichk` != x"yes" ]; then
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2034 echo "移住確認未チェックなので中止します。" | html p
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2035 grp "$rowid"
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2036 return
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2037 fi
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2038 destconf=`getpar migrateto`
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2039 err destconf=$destconf
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2040 if [ ! -e $destconf ]; then
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2041 echo "移住先Worldが認識できないので中止します($destconf)。" | html p
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2042 grp "$rowid"
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2043 return
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2044 fi
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2045 if [ -n "$worldconf" ]; then
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2046 srcconf=$worldconf
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2047 else
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2048 srcconf=s4-config.sh
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2049 fi
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2050 _m4 -D_TITLE_="移住操作" -D_BODYCLASS_="" $layout/html.m4.html
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2051 echo "移住操作" | html h1
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2052 echo '<pre>'
786
809caeb20758 Migration caller set arguments beforehand
HIROSE Yuuji <yuuji@gentei.org>
parents: 781
diff changeset
2053 set -- "$srcconf" "$destconf" "$rowid"
809caeb20758 Migration caller set arguments beforehand
HIROSE Yuuji <yuuji@gentei.org>
parents: 781
diff changeset
2054 err ./s4-migrate.sh "$srcconf" "$destconf" "$rowid"
809caeb20758 Migration caller set arguments beforehand
HIROSE Yuuji <yuuji@gentei.org>
parents: 781
diff changeset
2055 . ./s4-migrate.sh # Dot(.) sourcing might not pass arguments
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2056 rc=$?
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2057 echo "</pre>"
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2058 if [ $rc -eq 0 ]; then
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2059 echo "World [$world] への移住完了。" | html p
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2060 echo "<p><a href=\"$dsturl?grp+$destrowid\">移住先</a></p>"
868
2eaa037f35d0 Error handling of migration fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 864
diff changeset
2061 elif [ -n "$faillist" ]; then
2eaa037f35d0 Error handling of migration fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 864
diff changeset
2062 echo "移住後削除失敗" | html p
2eaa037f35d0 Error handling of migration fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 864
diff changeset
2063 echo "空いている時間帯に再度試して下さい。" | html p
764
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2064 else
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2065 echo "移住失敗" | html p
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2066 echo "移動先に重複がないか確認して下さい。" | html p
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2067 fi
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2068 return
d1f60cdc3e1a Migration support added
HIROSE Yuuji <yuuji@gentei.org>
parents: 759
diff changeset
2069 }
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2070 mems() {
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2071 _m4 -D_TITLE_="参加者一覧" -D_BODYCLASS_=listmember $layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2072 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
2073 listmember $kwd
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2074 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2075 grps() {
816
ed2c8aab742d Archiving world provides no new-group link
HIROSE Yuuji <yuuji@gentei.org>
parents: 812
diff changeset
2076 case "$S4WORLD" in
ed2c8aab742d Archiving world provides no new-group link
HIROSE Yuuji <yuuji@gentei.org>
parents: 812
diff changeset
2077 $nonewgroupworld) ;;
ed2c8aab742d Archiving world provides no new-group link
HIROSE Yuuji <yuuji@gentei.org>
parents: 812
diff changeset
2078 *) LINK_NEWGRP="<a href=\"?groupman\">新規グループ作成</a>" ;;
ed2c8aab742d Archiving world provides no new-group link
HIROSE Yuuji <yuuji@gentei.org>
parents: 812
diff changeset
2079 esac
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2080 _m4 -D_TITLE_="グループ一覧" -D_BODYCLASS_=listgroup $layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2081 kwd=`getpar kwd`
831
0ec2df3e879a Hidden variable of kwd should not appear in type="text" form
HIROSE Yuuji <yuuji@gentei.org>
parents: 830
diff changeset
2082 listgroup "$kwd" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2083 | _m4 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2084 -D_TITLE_="グループ関連操作" \
816
ed2c8aab742d Archiving world provides no new-group link
HIROSE Yuuji <yuuji@gentei.org>
parents: 812
diff changeset
2085 -D_FORM_="${LINK_NEWGRP}${NEWGRP_GUIDE}" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2086 $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
2087 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2088 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
2089 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
2090 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
2091 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
2092 ## . ./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
2093 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
2094 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
2095 [ -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
2096 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
2097 fi
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2098 htmlheader=$layout/html.m4.html
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2099 showgroup "$grid"
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2100 }
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2101 sql4interestblogs() {
177
1adafaf079a0 remove debug code
HIROSE Yuuji <yuuji@gentei.org>
parents: 176
diff changeset
2102 cat<<EOF
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2103 CREATE TEMPORARY VIEW interestblogs AS
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2104 SELECT blog.rowid rid, id, author
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2105 FROM blog
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2106 NATURAL JOIN
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2107 (SELECT id, val owner FROM blog_s WHERE key='owner') bs
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2108 WHERE CASE WHEN (SELECT name FROM user where name=bs.owner) IS NOT NULL
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2109 THEN 1 -- blog owner is an user, READABLE when
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2110 WHEN (SELECT user FROM grp_mem
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2111 WHERE gname=bs.owner AND user='$user') IS NULL
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2112 THEN 0
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2113 ELSE 1
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2114 END;
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2115 EOF
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2116 }
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2117 listnewblogsql() { # $1=user
625
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
2118 newdays=${WHATS_NEW_DAYS##*[!0-9]} # Shave non-digits
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
2119 newdays=${newdays%%[!0-9]*}
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
2120 newdays=${newdays:-14}
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
2121 basetime="datetime('now', 'localtime', '-${newdays} days')"
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2122 deftime=`query "SELECT coalesce((SELECT max(time) FROM acclog
345
8134b548b385 Taking default access time broken, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 343
diff changeset
2123 WHERE user='$user'
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2124 AND tblrowid IN
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2125 ($blogreadflagrowid,
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2126 $blogcutoffflagrowid)),
625
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
2127 $basetime -- "0"
74c0c2ed8ff5 New variable WHATSNEWDAYS limits the number of days of new article.
HIROSE Yuuji <yuuji@gentei.org>
parents: 624
diff changeset
2128 );"`
392
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
2129 cat<<EOF
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2130 `sql4interestblogs`
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2131 WITH article_ctime as (
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2132 SELECT id,blogid,author,max(val) ctime
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2133 FROM article join article_s s using(id)
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2134 WHERE s.key='ctime' AND s.val > '$deftime'
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2135 GROUP BY id
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2136 ), blog_title_owner as (
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2137 SELECT blg.rid brid, id,
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2138 max(case key when 'title' then val end) title,
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2139 max(case key when 'owner' then val end) owner
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2140 FROM interestblogs blg, blog_s using(id) group by id
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2141 ), blogall as (
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2142 SELECT * FROM blog_title_owner b JOIN article_ctime ac ON b.id=ac.blogid
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2143 ), news as (
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2144 SELECT brid, bl.id blid, bl.title, ctime,
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2145 coalesce(al.time, '$deftime') atime,
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2146 count(bl.id) "新着", bl.author
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2147 FROM blogall bl
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2148 LEFT JOIN
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2149 (SELECT * FROM acclog WHERE user='$user' AND tbl='blog') al
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2150 ON bl.brid=al.tblrowid
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2151 WHERE atime < bl.ctime
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2152 GROUP by bl.id ORDER BY ctime desc,"新着" desc, bl.id
343
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2153 LIMIT 10
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2154 ) SELECT brid LINK, "新着",
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2155 (SELECT count(*) FROM article WHERE blogid=blid) "総数",
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2156 ctime, title,
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2157 (SELECT gecos FROM gecoses WHERE name=author) gecos
c3311da3f059 Do not include article of the groups the user does'not belong in NEW list
HIROSE Yuuji <yuuji@gentei.org>
parents: 342
diff changeset
2158 FROM news;
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2159 EOF
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2160 }
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2161
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2162 search_form() {
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
2163 # $1 = { author=<AUTHOR> | grid=<GroupRowid> }
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
2164 # $2(optional) = pre-input keywords
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 300
diff changeset
2165 help="(1)空白区切りの単語で本文検索
302
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
2166 (2)@YYYY-MM-DD 日付け(シェルパターン可)で日付け検索
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
2167 @2016-0[1-6] → 2016年1月から6月
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
2168 @>2016-01 @<2016-02-15 → 2016年1月から2月14日までの期間
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
2169 @week → 最近一週間
302
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
2170 (3)#番号 で記事ID検索
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
2171 (1)と(2)は組み合わせOK
9edf8e87e198 Search form help more explanatory
HIROSE Yuuji <yuuji@gentei.org>
parents: 301
diff changeset
2172 例: @2016-10-0[1-9] 芋煮
445
12548e1a4ff8 Add comment about quiz board exclusion from search
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
2173 → 2016年10月上旬でキーワード「芋煮」を含む記事検索
12548e1a4ff8 Add comment about quiz board exclusion from search
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
2174 ※クイズ板は検索対象から外されます。"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2175 auth=""
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2176 placeholder="全記事からの検索"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2177 case "$1" in
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2178 author=*)
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2179 a=`echo "${1#author=}"|htmlescape`
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2180 g=`gecos ${1#author=}`
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2181 auth="<input type=\"hidden\" name=\"author\" value=\"$a\">"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2182 placeholder="このユーザの書込検索"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2183 help="★★ $g さんの書き込みから検索します$nl$help"
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2184 ;;
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
2185 grid=*)
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
2186 a=`echo "${1#grid=}"`; a=$((0 + $a))
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
2187 auth="<input type=\"hidden\" name=\"grid\" value=\"$a\">"
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2188 placeholder="このグループからの検索"
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2189 ;;
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2190 esac
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
2191 inikwd="$2" # no need to htmlescape
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2192 cat<<-EOF
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2193 <div class="right">
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2194 <form action="$myname">$auth
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
2195 <input type="text" name="kwd" value="$inikwd" title="$help"
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
2196 placeholder=" $placeholder " width="10" accesskey="k">
509
d34b8f36501c Progressive search does not restrict author
HIROSE Yuuji <yuuji@gentei.org>
parents: 508
diff changeset
2197 <!-- POST SENTENCE -->
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 351
diff changeset
2198 ${touchpanel:+<p class="help">$help</p>}
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2199 <input type="hidden" name="stage" value="searchart">
509
d34b8f36501c Progressive search does not restrict author
HIROSE Yuuji <yuuji@gentei.org>
parents: 508
diff changeset
2200 <!-- EOF -->
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2201 </form>
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2202 </div>
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2203 EOF
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2204 }
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2205
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2206 imgsrc_cache() (
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2207 # $1 = directory for cache'ing
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2208 # $2 = table (user_m or grp_m)
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2209 # $3 = keycond (was: condition for choosingowner)
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2210 # $4 = size : S = Small, M = Medium, O = Original
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2211 dir="$1" tbl="$2"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2212 keycond="$3"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2213 whos="$keycond AND key='profimg' AND type LIKE 'file:image%'
327
5e56160ad1f5 Use the last profimg as profile image instead of first one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
2214 ORDER BY rowid DESC LIMIT 1"
332
9dc6f9e60f6a Quote file names. Select last profimg in listentry.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
2215 [ -d "$dir" ] || mkdir -p "$dir"
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2216 tmpf=$tmpd/imgsrc_cache.$$
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2217 case "$4" in
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2218 [Ss]) size=S ;;
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2219 [Oo]) size=O ;;
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2220 *) size=M ;;
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2221 esac
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2222 # ImageCache filename storing schema:
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2223 # <table_s>.{key, val}={"profimgcache_S", "$cacheimg_S"}
312
b8a8e627b376 Remove debugging code. Stay revealed profile image rows.
HIROSE Yuuji <yuuji@gentei.org>
parents: 311
diff changeset
2224 sql0="SELECT val || '//' || type FROM $tbl WHERE $whos;"
b8a8e627b376 Remove debugging code. Stay revealed profile image rows.
HIROSE Yuuji <yuuji@gentei.org>
parents: 311
diff changeset
2225 sql1="SELECT hex(bin) FROM $tbl WHERE $whos;"
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2226 valtype=`query "$sql0"`
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2227 filename=${valtype%%//*}
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2228 filetype=${valtype##*//file:}
339
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
2229 if [ x"$filename" = x"${filename%.*}" ]; then
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
2230 # If nor filename extension found, set it to image type
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
2231 case "$filetype" in
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
2232 image/*) filename=$filename.${filetype#image/} ;;
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
2233 esac
47d83939666b Add extension to icon cache file if it has no one
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
2234 fi
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2235 cacheimg_S=$dir/S_$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2236 cacheimg_M=$dir/M_$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2237 cacheimg_O=$dir/$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2238 cacheimg=$dir/${size}_$filename
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2239 sumfile="$dir/$filename.sum"
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2240 sum=`query "$sql1" | tee $tmpf | encode` # encode() is maybe sha1
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2241 if test -s "$sumfile" && [ x"`cat \"$sumfile\"`" = x"$sum" ] \
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2242 && test -s "$cacheimg_S" && test -s "$cacheimg_M" ; then
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2243 # if cache is fresh and has the same checksum,
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2244 echo "<img src=\"$cacheimg\">"
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2245 else
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2246 fifo=`mktemp "$tmpf.fifo.XXXXXXX"`
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2247 rm -f $fifo # Safe, because $tmpf is in mktemp dir.
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2248 fifo2=$fifo.2
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2249 mkfifo $fifo $fifo2
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2250 fmt=${filename##*.}
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2251 ## [[ NOTE ]]
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2252 ## a. convert oldimage newimage
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2253 ## b. convert oldimage fmt:- | convert - newimage
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2254 ## b is much smaller than a
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2255 cat $tmpf | unhexize \
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2256 | tee $fifo \
392
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
2257 | convert -define ${fmt}:size=${iconxy_M} \
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
2258 -resize ${iconxy_M}'>' - ${fmt}:- \
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2259 | tee $fifo2 \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
2260 | convert - "$cacheimg_M" &
392
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
2261 cat $fifo | convert -define ${fmt}:size=${iconxy_S} \
be955399aec9 Owner should be taken via getvalbyid
HIROSE Yuuji <yuuji@gentei.org>
parents: 391
diff changeset
2262 -resize ${iconxy_S}'>' - ${fmt}:- \
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
2263 | convert - "$cacheimg_S" &
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2264 printf '%s' "<img src=\"data:${filetype},"
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2265 hexize "$fifo2" |sed 's/\(..\)/%\1/g' # Use medium as pre-cached image
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2266 echo '">'
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2267 echo "$sum" > $sumfile
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2268 fi
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2269 ## Now preparing cache image, done.
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2270 ## Store this information to DB
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2271 stbl=${tbl%_m}_s # user_s or grp_s
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2272 pkey=${keycond%%=*} # Primary Key name
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2273 pval=${keycond#*=} # Primary Key value
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2274 query <<-EOF
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2275 REPLACE INTO $stbl($pkey, key, type, val)
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2276 VALUES($pval, '$iconcachekey', 'string', `sqlquote "$cacheimg_S"`);
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2277 EOF
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2278 )
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2279
0
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 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
2281 # $1=userRowIdToShow
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2282 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
2283 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
2284 *@*) 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
2285 *) 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
2286 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2287 ## err ShowHome: uname=$uname
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2288 td=`getcachedir home/"$1"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2289 gecos=`gecos "$uname"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2290 ## 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
2291 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
2292 cond="gname in (select gname from grp_mem where user='$uname')"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2293 search_form_args=""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2294 if [ x"$user" = x"$uname" ]; then
755
1a8291d7fa3d Annex strategy shifted to World strategy
HIROSE Yuuji <yuuji@gentei.org>
parents: 754
diff changeset
2295 if [ -z "$S4MASTERDB" ]; then
754
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
2296 usermenu="<a href=\"?userconf\" accesskey=\"e\"
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
2297 title=\"Shortcut: E${nl}Edit Profile\">プロフィールの編集</a> / "
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
2298 elif [ -n "$S4MASTERURL" ]; then
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
2299 usermenu="<a href=\"$S4MASTERURL\" accesskey=\"e\"
755
1a8291d7fa3d Annex strategy shifted to World strategy
HIROSE Yuuji <yuuji@gentei.org>
parents: 754
diff changeset
2300 title=\"Shortcut: E${nl}Main Site\">Base World</a> / "
754
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
2301 fi
5bab8644024a Annex-test: sessdb = main-sessdb
HIROSE Yuuji <yuuji@gentei.org>
parents: 753
diff changeset
2302 usermenu="$usermenu
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2303 <a href=\"?blog\" accesskey=\"n\" title=\"Shortcut: N${nl}New blog\">新規話題の作成</a>"
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2304 # Display folders
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2305 sql="select count(id) from article_m where id
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2306 in (select id from article where author='$user')
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2307 and type like 'file:%';"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2308 ## err nfile-sql=`echo "$sql"`
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2309 nfile=`query "$sql"`
312
b8a8e627b376 Remove debugging code. Stay revealed profile image rows.
HIROSE Yuuji <yuuji@gentei.org>
parents: 311
diff changeset
2310 # err nfile=$nfile
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2311 if [ $nfile -gt 0 ]; then
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
2312 usermenu="$usermenu / <a href=\"?lsmyfile\" accesskey=\"l\"
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2313 title=\"Shortcut: L${nl}List All Attachment files\">過去の提出ファイル</a>"
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
2314 fi
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2315 else
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
2316 latestlog=`query "SELECT max(time) FROM acclog WHERE user='$uname' \
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
2317 GROUP BY user;"`
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
2318 usermenu="<p>Last seen on $latestlog</p>"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 329
diff changeset
2319 search_form_args="author=$uname"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2320 fi
17
01f579d2c889 Rename to s4
HIROSE Yuuji <yuuji@gentei.org>
parents: 16
diff changeset
2321 . ./s4-blog.sh
3
95cebd686c97 add templ/*
HIROSE Yuuji <yuuji@gentei.org>
parents: 2
diff changeset
2322
243
466ea3e4b039 Search box localted to the top of home page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 242
diff changeset
2323 tf=$tmpd/title.$$ pf=$tmpd/profile.$$ bf=$tmpd/blogs.$$ sf=$tmpd/search.$$
508
944739c3ac5c Continuous search available
HIROSE Yuuji <yuuji@gentei.org>
parents: 507
diff changeset
2324 search_form "$search_form_args" > $sf
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
2325 printf "%s さん%s" "$gecos" "${S4WORLDNAME:+@$S4WORLDNAME}" \
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
2326 | htmlescape > $tf
319
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2327 { echo "<div class=\"noprofimg\">"
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2328 viewtable $formdir/user.def user $1
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2329 echo "</div>"
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2330 } > $pf
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
2331
147
HIROSE Yuuji <yuuji@gentei.org>
parents: 146
diff changeset
2332 sqcond="WHERE name='$uname' AND key='profimg' AND type LIKE 'file:image%'"
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
2333 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
2334 imf=$tmpd/profimg.$$; touch $imf
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
2335 if [ -n "$img" ]; then
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2336 if true; then
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2337 tbl=user_m
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2338 enticond="name='$uname'"
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2339 imgsrc_cache "$td/main" user_m "$enticond" M
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2340 else
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2341 { printf '%s' "<IMG src=\"data:${img#file:},"
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2342 query "SELECT hex(bin) FROM user_m $sqcond ORDER BY rowid LIMIT 1;" \
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2343 | sed 's/\(..\)/%\1/g'
151
7bb7086ea0d0 Unclosed tag, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 150
diff changeset
2344 echo '">'
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2345 }
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2346 fi > $imf
146
3d0de7bdbf40 Profile image
HIROSE Yuuji <yuuji@gentei.org>
parents: 144
diff changeset
2347 fi
150
6ee08d8b0f5f Display the number of blogs of the user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 149
diff changeset
2348 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
2349 val='$uname';"`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2350 listblog $uname > $bf
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2351
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2352 hometail=$tmpd/tail.$$
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2353 mkfifo $hometail
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2354
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2355 #Calling listgroupbytable, originally here
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2356
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2357 (
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2358 # Display Most Recent Entry
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2359 shortval=${dumpcollen:+"substr(val, 0, $dumpcollen)"}
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2360 shortval=${shortval:-val}
252
75dfaceac01f Link to newest article of the blog in the recent writing place
HIROSE Yuuji <yuuji@gentei.org>
parents: 251
diff changeset
2361
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
2362 # The m.aid in the next line is suspicious. But works fine in SQLite3...
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2363 # $hidden_mode is defined in global section
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2364 DT_SQL="SELECT b.rowid || '#' || m.aid LINK,
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2365 ctime,
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2366 (SELECT $shortval FROM blog_s WHERE key='title' AND id=b.id) title,
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2367 (SELECT gecos FROM gecoses
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2368 WHERE name=(SELECT val FROM blog_s
257
5d0dbbf9310c Show text in the table of recent writing articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 255
diff changeset
2369 WHERE key='owner' AND id=b.id)) owner,
5d0dbbf9310c Show text in the table of recent writing articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 255
diff changeset
2370 (SELECT $shortval val FROM article_s WHERE id=m.aid AND key='text') text
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2371 FROM blog b
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2372 JOIN
254
8a0cf46afb0a Revise SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 253
diff changeset
2373 (SELECT distinct blogid, a.id aid, max(val) ctime
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2374 FROM article a, article_s s
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2375 ON a.id=s.id AND a.author='$uname' AND s.key='ctime'
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2376 GROUP BY blogid ORDER BY val DESC LIMIT 50
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2377 ) m
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2378 ON b.id=m.blogid
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2379 AND
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2380 ('$uname' = '$user' -- user can read all own posts
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2381 OR
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2382 -- exclude posts of others in quiz/enquete blogs
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2383 NOT EXISTS (SELECT * FROM blog_s
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
2384 WHERE id=b.id AND key='mode' AND val IN $hidden_mode));"
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2385 # This should be as follows
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2386 : <<EOF
255
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2387 WITH arts AS(
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2388 SELECT (SELECT rowid FROM blog WHERE id=a.blogid) brid,
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2389 a.blogid, a.id id, s.val ctime
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2390 FROM article a NATURAL JOIN article_s s
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2391 WHERE s.key = 'ctime' AND a.author='$user'
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2392 GROUP by s.id
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2393 )
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2394 SELECT a0.brid,a0.blogid,a0.id,a0.ctime
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2395 FROM arts a0
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2396 JOIN
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2397 (SELECT blogid,max(ctime) mct FROM arts a1 GROUP BY blogid) a1
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2398 ON a0.blogid=a1.blogid AND a0.ctime=a1.mct
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2399 ORDER BY ctime DESC LIMIT 50;
3ae8b70b8395 Add commentary about SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 254
diff changeset
2400 EOF
253
a40d258cc5aa SQL last modifed is TOO slow. Revert once to previous one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 252
diff changeset
2401
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2402 cat<<-EOF
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
2403 `cgi_radio foldtabs yes 'id="mre" accesskey="d"'`<label
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2404 for="mre" title="Shortcut: D${nl}Recent Post">最近の書き込み先</label>
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2405 <div class="lcto">
194
b1847cc3912a Display Most Recent Entry of user's
HIROSE Yuuji <yuuji@gentei.org>
parents: 187
diff changeset
2406 `DT_VIEW=replyblog dumptable html blog`
b1847cc3912a Display Most Recent Entry of user's
HIROSE Yuuji <yuuji@gentei.org>
parents: 187
diff changeset
2407 </div>
b1847cc3912a Display Most Recent Entry of user's
HIROSE Yuuji <yuuji@gentei.org>
parents: 187
diff changeset
2408 EOF
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2409 unset DT_SQL
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2410 if [ x"$user" = x"$uname" ]; then
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2411 # Display NEWS
351
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2412 # 2016-06-26
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2413 if [ x"`getpar readchk``getpar read`" = x"yesyes" ]; then
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2414 acclog blog $blogreadflagrowid
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2415 # echo "全部既読にしました" | html p
175
3d12521876f2 NEW counter SQL revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 174
diff changeset
2416 fi
351
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2417 # 2016-02-19 Counting NEWS without using dumptable.
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2418 sql=`listnewblogsql "$user"`
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2419 # echo "$sql" > tmp/listnew
351
deb4cc74a415 Remove old code and add title of accesskey
HIROSE Yuuji <yuuji@gentei.org>
parents: 350
diff changeset
2420 new10=`DT_SQL="$sql" DT_VIEW=replyblog dumptable html blog`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2421 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
2422 cont=$((cont-1))
853
047e1c3f811e Log output revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 851
diff changeset
2423 ##err newcount=$cont
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2424 if [ $cont -gt 0 ]; then
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2425 #echo "全体の新着記事${cont}傑" | html h2
340
a06cd57df83a Add accesskey-attribute to frequently used tabls and form.
HIROSE Yuuji <yuuji@gentei.org>
parents: 339
diff changeset
2426 cgi_radio foldtabs yes 'id="new10" accesskey="f"'
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2427 echo "<label for=\"new10\" title=\"Shortcut: F${nl}NEWS\">新着${cont}傑</label><div>"
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
2428 cat<<-EOF | html form 'action="?home"'
262
f7939f4297d4 Rewrote a cgi variable by mistake, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 260
diff changeset
2429 `cgi_checkbox readchk yes 'id="read"'`<label
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
2430 for="read">新着ふくめて全部読んだことにする</label>
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2431 `cgi_submit '確定'`
236
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
2432 `cgi_hidden read yes`
19b92549b5b7 Add button to clear all unread article list
HIROSE Yuuji <yuuji@gentei.org>
parents: 235
diff changeset
2433 EOF
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2434 echo "$new10 <!-- new10 -->"
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2435 echo "</div>"
471
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2436 else # If news is 0, set log cut off flag
1dacdf998892 Speed up new article listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 469
diff changeset
2437 acclog blog $blogcutoffflagrowid # for speed
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2438 fi
328
d89412dc78a1 List recent subscriptions in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 327
diff changeset
2439 else # Not My Home ($user != $uname)
329
e4fedb216119 Making sure whether it runs on ksh
HIROSE Yuuji <yuuji@gentei.org>
parents: 328
diff changeset
2440 : # DT_SQL=
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2441 fi
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2442 ) > $hometail & # Is background call safe to m4??
128
42234d2d6e9c Add Full-Range search
HIROSE Yuuji <yuuji@gentei.org>
parents: 127
diff changeset
2443 #
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2444 listgroupbytable $formdir/grp.def "$cond" $uname |
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2445 _m4 -D_BODYCLASS_=home -D_TITLE_="spaste(\`$tf')" \
469
f095f639e5bf Show lastlog in other user's home
HIROSE Yuuji <yuuji@gentei.org>
parents: 468
diff changeset
2446 -D_PROFILE_="spaste(\`$pf')$usermenu" \
260
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2447 -D_PROFIMG_="spaste(\`$imf')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2448 -D_BLOGS_="spaste(\`$bf')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2449 -D_SEARCH_="spaste(\`$sf')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2450 -D_NBLOG_="$nblog" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2451 -D_GROUPS_="syscmd(\`cat')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2452 -D_HOMETAIL_="syscmd(\`cat $hometail')" \
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2453 $layout/html.m4.html $layout/home.m4.html
1b9d45b823b8 UI changed to tab selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 259
diff changeset
2454
0
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 # 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
2456 [ -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
2457 }
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2458 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
2459 contenttype; echo
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2460 ## err commission: "$@"
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2461 gname=`getgroupbyid $1`
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
2462 echo "グループ $gname 管理者委任" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2463 | _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
2464 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
2465 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
2466 else
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2467 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
2468 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
2469 }
0
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 listgroupbytable() {
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2471 # $1=deffile $2...=condition $3(optional)=uname
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2472 tagline=`grep :tag: $1`;
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2473 and="${2:+and }" where=${2:+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
2474 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
2475 echo '<div class="listgroup">'
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2476 sql="select val from grp_s where key='tag' $and$2 group by val;"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2477 ## err ListGRP: query sql="$sql"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2478 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
2479 do
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2480 ## err ListGrp: tag=$tag
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2481 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
2482 tn=${tn##*[ :]}
113
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2483 sql="select rowid||':'||gname as 'グループ名',説明 from
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2484 (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
2485 as rowid,
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2486 gname,
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2487 max(case key when 'gecos' then val end) as '説明',
3bad3f525dfc Multiple text fields handled correctly
HIROSE Yuuji <yuuji@gentei.org>
parents: 112
diff changeset
2488 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
2489 max(case key when 'mtime' then val end) as mtime from grp_s
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2490 $where$2 group by gname having tag='$tag' order by mtime desc);"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2491 ## err PersonalGroupList= `echo $sql`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2492 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
2493 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
2494 sq -header -html $db "$sql" \
494
6906c140431a Fix pattern: Allow spaces for group name in group listing
HIROSE Yuuji <yuuji@gentei.org>
parents: 492
diff changeset
2495 | 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
2496 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
2497 done
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2498 if [ -n "$S4WORLDLIST" -a -n "$3" ]; then
833
f3d422665ea8 Modify debug output
HIROSE Yuuji <yuuji@gentei.org>
parents: 832
diff changeset
2499 err "peekgrpworlds($user) BEGIN: `gdate +%S.%03N`"
827
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2500 peekgrpworlds mem:"$3"
833
f3d422665ea8 Modify debug output
HIROSE Yuuji <yuuji@gentei.org>
parents: 832
diff changeset
2501 err "peekgrpworlds($user) END: `gdate +%S.%03N`"
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2502 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
2503 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
2504 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2505 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
2506 # $1=icon-file, $2=Href $3=title $4...=anchor
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
2507 data=`percenthex "$1"`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
2508 ct=`file --mime-type - < "$1"|cut -d' ' -f2`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2509 ## 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
2510 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
2511 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
2512 )
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 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
2514 # $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
2515 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
2516 href=$2; title=$3; shift 3
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
2517 anchor=`echo $@|htmlescape`
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
2518 echo "<a href=\"$href\"><img title=\"$title\" src=\"$src\">$anchor</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
2519 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2520 listentry() (
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2521 # $1=user/group $2=SearchKeyword $3=condition(if any) $4=grprowid(if in grp)
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2522 # Referring variable $iamowner=$grp to attach owner-request links
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2523 ## err listentry: \$1=$1 \$2=$2 \$3=$3
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2524 cond='' hiddens=''
447
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2525 offset=`getpar offset`; offset=${offset%%[!0-9]*}
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2526 if [ -z "$offset" ]; then
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2527 offset=`getpar start`; offset=${offset%%[!0-9]*}
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2528 offset=$((offset-1))
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2529 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
2530 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
2531 [ $offset -lt 0 ] && offset=0
610
dfd83a6d09fb Label fixed and local value loading introduced
HIROSE Yuuji <yuuji@gentei.org>
parents: 609
diff changeset
2532 limit=$listentlimit
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
2533 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
2534 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
2535 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
2536 deficon=person-default.png
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2537 entity="ユーザ" tbl=user link=rowid nm=name # stage=mems
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2538 [ -n "$4" ] && hiddens=`cgi_hidden grid $4`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2539 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
2540 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
2541 hrb="$myname?grp"
22
9951e231df30 Add default group icon
HIROSE Yuuji <yuuji@gentei.org>
parents: 17
diff changeset
2542 deficon=group-default.png
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 14
diff changeset
2543 entity="グループ" tbl=grp link=rowid nm=gname stage=grps
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2544 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
2545 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
2546 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
2547 tagconv=`echo $tagline|sed 's/\([^= :]*\)=\([^= :]*\)/-D\2=\1/g'`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2548 ## err tagconv=$tagconv
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2549 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
2550 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
2551 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
2552 mkdir -p $dir
131
9782a978d53c Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 128
diff changeset
2553 fi
9782a978d53c Image cach detection method modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 128
diff changeset
2554 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
2555 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
2556 fi
831
0ec2df3e879a Hidden variable of kwd should not appear in type="text" form
HIROSE Yuuji <yuuji@gentei.org>
parents: 830
diff changeset
2557 kwd=${2:-`getpar kwd`}
0ec2df3e879a Hidden variable of kwd should not appear in type="text" form
HIROSE Yuuji <yuuji@gentei.org>
parents: 830
diff changeset
2558 if [ -n "$kwd" ]; then
0ec2df3e879a Hidden variable of kwd should not appear in type="text" form
HIROSE Yuuji <yuuji@gentei.org>
parents: 830
diff changeset
2559 kwd=`echo $kwd | tr -d '";\n' | tr -d "'"`
827
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2560 case "$kwd" in
829
87f72984f3aa Make it double sure to quote user string
HIROSE Yuuji <yuuji@gentei.org>
parents: 827
diff changeset
2561 mem:*@*)
827
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2562 byuser=${kwd#*mem:}
830
HIROSE Yuuji <yuuji@gentei.org>
parents: 829
diff changeset
2563 qusr=`sqlquote "$byuser"`
829
87f72984f3aa Make it double sure to quote user string
HIROSE Yuuji <yuuji@gentei.org>
parents: 827
diff changeset
2564 cond1="(a.gname IN (SELECT gname FROM grp_mem WHERE user=$qusr))"
827
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2565 ;;
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2566 esac
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2567 if [ x"$1" = x"group" ]; then
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2568 if [ -n "$cond1" ]; then
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2569 enthead="`gecos "$byuser"|htmlescape` さんの所属"
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2570 else
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2571 cond1="(b.name like '%${kwd}%')"
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2572 fi
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2573 else
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2574 cond1="(nick like '%${kwd}%' or b.name like '%${kwd}%')"
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2575 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
2576 fi
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2577 tag=`getpar tag` tag2=`getpar tag2`
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2578 if [ x"$tag" = x"NULL" ]; then
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2579 tag="" tag2=""
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2580 fi
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2581 if [ -n "$tag$tag2" ]; then
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2582 tag=${tag:-$tag2}
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2583 qtag=`sqlquote "$tag"`
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2584 cond2="tag=$qtag"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2585 fi
647
a8a5e6437f1a Fix for member listing in group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 646
diff changeset
2586 if [ -n "$cond1$cond2" ]; then
a8a5e6437f1a Fix for member listing in group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 646
diff changeset
2587 cond="$cond1${cond2:+ AND $cond2}"
a8a5e6437f1a Fix for member listing in group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 646
diff changeset
2588 cond="WHERE ${cond# AND }"
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2589 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
2590
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 # XX: これ複雑すぎるかな。もっとシンプルにしたい。$3条件も。2015-07-08
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2592 # grpは呼出し元の動的スコープ変数でよくないな...
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2593 ##qgrp=`sqlquote $grp`
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2594 getgrp="(select gname from grp where rowid=${rowid:--1})"
220
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2595 sql="select a.rowid, a.$link,
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2596 coalesce(b.$gcs, a.$nm) as nick,
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2597 quote(a.$nm) as qname,
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2598 (SELECT val FROM ${tbl}_s
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2599 WHERE $nm=a.$nm AND key='$iconcachekey') icon,
220
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2600 coalesce(b.gecos, a.$nm) /* If group, concat (Nusers) */
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2601 || case when a.$nm in (select gname from grp)
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2602 then printf('(%d名)',
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2603 (select count(user) from grp_mem where gname=a.$nm))
233
1ad7ef38c0a0 Display gecos correctly in listentry(user)
HIROSE Yuuji <yuuji@gentei.org>
parents: 232
diff changeset
2604 else ' <'||a.$nm||'>'
220
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2605 end
7d05425e4057 Put information how many members in that group.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
2606 as name,
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2607 b.tag,
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2608 case when a.$nm in (select user from grp_adm
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2609 where gname=$getgrp) then '管理者'
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2610 when '$user' in (select user from grp_adm where gname=a.$nm)
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2611 then 'ADMIN'
171
cdade692e17d Add "is-member" flag to group list
HIROSE Yuuji <yuuji@gentei.org>
parents: 166
diff changeset
2612 when '$user' in (select user from grp_mem where gname=a.$nm)
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2613 then 'Member'
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2614 when '$iamowner' = '' then ''
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2615 else ',not='||a.rowid end as ownerlink,
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2616 CASE '$entity'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2617 WHEN 'グループ'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2618 THEN coalesce(
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2619 (SELECT val FROM grp_s WHERE gname=a.$nm AND key='regmode'),
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2620 'open')
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2621 ||
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2622 CASE WHEN '$user'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2623 IN (SELECT user FROM grp_mem WHERE gname=a.$nm)
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2624 THEN ' ismember'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2625 ELSE ''
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2626 END
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2627 ELSE 'user'
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2628 END regmode
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2629 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
2630 (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
2631 max(case key when 'gecos' then val end) as gecos,
297
8933d3701c00 Newer edited group has more precedence of sorting in group list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 295
diff changeset
2632 max(case key when 'tag' then val end) as tag,
387
2c928bb47c90 Sort condition missing
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
2633 max(case key when 'mtime' then val end) as mtime,
475
c01081811298 typo of SQL statement
HIROSE Yuuji <yuuji@gentei.org>
parents: 474
diff changeset
2634 max(case key when 'wtime' then val end) as wtime,
474
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2635 max(case key when 'login' then val end) as login
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2636 from ${tbl}_s group by $nm)
647
a8a5e6437f1a Fix for member listing in group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 646
diff changeset
2637 b on a.$nm=b.name $cond $3
474
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2638 order by b.wtime desc, b.login desc,
4f9036d35b57 Sort user by last login. Sort group by the latest article time.
HIROSE Yuuji <yuuji@gentei.org>
parents: 472
diff changeset
2639 b.mtime desc, b.tag desc, a.rowid asc"
297
8933d3701c00 Newer edited group has more precedence of sorting in group list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 295
diff changeset
2640 # Give precedence to newer maintained groups (2016-09-24)
8933d3701c00 Newer edited group has more precedence of sorting in group list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 295
diff changeset
2641 # Note that mtime is stored only in grp_s.
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2642 ## 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
2643 total=`query "with x as ($sql) select count(*) from x;"`
827
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2644 echo "$enthead${entity} 一覧" "${S4WORLDNAME:+@$S4WORLDNAME}" | html h2
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2645 echo '<div class="listentry">' # List-entry div
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2646 # Show owner/member filter button
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2647 METHOD=GET
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2648 hiddens="$hiddens
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2649 `cgi_hidden stage \"$stage\"`"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2650 if [ x"$tbl" = x"grp" ]; then
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2651 args=`grep "^種別:" $formdir/grp.def | cut -d: -f5`
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2652 fh="<select name=\"tag\">$nl"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2653 fh="$fh<option value=\"NULL\"${tag:+ selected}>グループ種別...</option>"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2654 for l in $args; do
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2655 val=${l#*=} tname=${l%=*}
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2656 if [ x"$val" = x"$tag" ]; then
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2657 s=" selected"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2658 selectedtags="(種別[${tname}]のみ)"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2659 else
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2660 s=""
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2661 fi
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2662 form=$nl$form"<option value=\"$val\"$s>$tname</option>"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2663 done
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2664 form="$fh$form</select><input type=\"submit\" value=\"で絞る\">"
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2665 cat<<-EOF
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2666 <form action="$myname" method="$METHOD">
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2667 </form>
650
0cc58da8f7af Add supplemental message
HIROSE Yuuji <yuuji@gentei.org>
parents: 647
diff changeset
2668 以下一覧のうち: `cgi_checkbox onlymem no 'id="ismembtn"'`<label
610
dfd83a6d09fb Label fixed and local value loading introduced
HIROSE Yuuji <yuuji@gentei.org>
parents: 609
diff changeset
2669 for="ismembtn">参加中以外隠す</label>
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2670 `cgi_checkbox onlyadm no 'id="isadmbtn"'`<label
610
dfd83a6d09fb Label fixed and local value loading introduced
HIROSE Yuuji <yuuji@gentei.org>
parents: 609
diff changeset
2671 for="isadmbtn">管理者参加以外隠す</label>
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2672 EOF
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2673 # limit=3
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2674 hiddens=$hiddens" "`cgi_hidden tag2 "$tag"`
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2675 fi
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2676 if [ $total -gt $limit -o \( -n "$S4WORLDLIST" -a x"$tbl" = x"grp" \) ]; then
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2677 echo '<div>'
628
5c9b7add02e9 Username search in group-home should carry grid parameter
HIROSE Yuuji <yuuji@gentei.org>
parents: 627
diff changeset
2678 METHOD=GET cgi_form $stage <<EOF
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2679 $form
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2680 <label>次の語を含む${entity}で検索:
628
5c9b7add02e9 Username search in group-home should carry grid parameter
HIROSE Yuuji <yuuji@gentei.org>
parents: 627
diff changeset
2681 `cgi_text kwd "$kwd"`</label>
5c9b7add02e9 Username search in group-home should carry grid parameter
HIROSE Yuuji <yuuji@gentei.org>
parents: 627
diff changeset
2682 $hiddens
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2683 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
2684 echo '</div>'
645
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2685 else
21522dcada92 Experimental implement of group tag selection
HIROSE Yuuji <yuuji@gentei.org>
parents: 637
diff changeset
2686 echo $selectedtags | 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
2687 fi
831
0ec2df3e879a Hidden variable of kwd should not appear in type="text" form
HIROSE Yuuji <yuuji@gentei.org>
parents: 830
diff changeset
2688 test -n "$kwd" && hiddens="$hiddens$nl`cgi_hidden kwd \"$kwd\"`"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2689 cat<<EOF
606
00837fdf1120 Search form method changed to GET from POST
HIROSE Yuuji <yuuji@gentei.org>
parents: 605
diff changeset
2690 <form action="$myname" method="$METHOD">
447
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2691 <p>${total}件中の<input class="hidesub" type="text" name="start"
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2692 value="$((offset+1))" size="3">件めから${kwd:+" - 検索語: $kwd"}$hiddens
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2693 <input type="submit" value="確定"></p>
4769510d6169 Multiple Page Listing allows user specification of starting number
HIROSE Yuuji <yuuji@gentei.org>
parents: 445
diff changeset
2694 </form>
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2695 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
2696 if [ $((offset+limit)) -lt $total ]; then
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2697 nextbtn=$(
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2698 cat<<EOF
606
00837fdf1120 Search form method changed to GET from POST
HIROSE Yuuji <yuuji@gentei.org>
parents: 605
diff changeset
2699 <div class="right clear"><form action="$myname" method="$METHOD">
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2700 `cgi_submit 次の${limit}件`
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2701 $hiddens
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2702 `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
2703 EOF
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2704 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2705 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
2706 if [ $offset -gt 0 ]; then
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2707 prevbtn=$(
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2708 cat<<EOF
606
00837fdf1120 Search form method changed to GET from POST
HIROSE Yuuji <yuuji@gentei.org>
parents: 605
diff changeset
2709 <form action="$myname" method="$METHOD">
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2710 `cgi_submit 前の${limit}件`
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2711 $hiddens
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2712 `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
2713 EOF
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2714 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2715 fi
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2716 pnbtn="$nextbtn$prevbtn"
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2717 echo $pnbtn
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2718
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2719 ## err ListEntry: `echo "$sql"\;`
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2720 # sq $db here??? 2016-11-28
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2721 query "$sql limit $limit ${offset:+offset $offset};" \
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2722 | while IFS='|' read id lnk name qname icon gecos tag ownerp type; do
596
7ece8cc62a7a Deactivate debug output in a loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 592
diff changeset
2723 # err name=$name owner=$ownerp lnk=$lnk
7ece8cc62a7a Deactivate debug output in a loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 592
diff changeset
2724 # err newlnk=$lnk regmode=$regmode
230
67c8b9558572 Allow duplicated file names in icon.
HIROSE Yuuji <yuuji@gentei.org>
parents: 229
diff changeset
2725 icondir=$dir/$id
332
9dc6f9e60f6a Quote file names. Select last profimg in listentry.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
2726 # Pick up only last icon
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
2727 htmlname=`echo $name|htmlescape`
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2728 echo "<div class=\"iconlist xy$thumbxy $type $ownerp\">
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2729 <p class=\"tag _$tag\">$tag</p>" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2730 | _m4 $tagconv
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2731 if [ -n "$NOSPEEDUP" ]; then
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2732 files=`getvalbyid $tbl profimg $id $icondir`
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2733 if [ -n "$files" ]; then
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2734 icon=`echo "$files"|tail -1`
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2735 iconhref2 "$icondir/$icon" "$hrb+$lnk" "$gecos"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2736 else
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2737 iconhref "$dir/$deficon" "$hrb+$lnk" "$gecos"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2738 fi
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2739 elif [ -n "$icon" -a -s "$icon" ]; then
567
5b911fee7e1b Remove superfluous '<br>' from TITLE attribute.
HIROSE Yuuji <yuuji@gentei.org>
parents: 566
diff changeset
2740 iconhref2 "$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
2741 else
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2742 cond="$nm=$qname"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2743 # err imgsrc_cache "$dir/list" ${tbl}_m "$cond" S
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2744 # err query "SELECT type FROM ${tbl}_m $cond LIMIT 1;"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2745 img=`query "SELECT type FROM ${tbl}_m WHERE $cond AND key='profimg' LIMIT 1;"`
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2746 # err "img=[$img]"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2747 if [ -n "$img" ]; then
390
5a40f38d7daf Do not forget link to home
HIROSE Yuuji <yuuji@gentei.org>
parents: 388
diff changeset
2748 echo "<a href=\"$hrb+$lnk\">"
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
2749 imgsrc_cache "$icondir" ${tbl}_m "$nm=$qname" S
390
5a40f38d7daf Do not forget link to home
HIROSE Yuuji <yuuji@gentei.org>
parents: 388
diff changeset
2750 echo "</a>"
388
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2751 else
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2752 iconhref2 "$dir/$deficon" "$hrb+$lnk" "$gecos"
4f6b63c25ab8 User/Group listing made fast by using imgsrc_cache()
HIROSE Yuuji <yuuji@gentei.org>
parents: 387
diff changeset
2753 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
2754 fi
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
2755 echo "<br>$htmlname${ownerp:+<br>($ownerp)}"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2756 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
2757 done
609
7eb71958a09e Add display limitation buttons in listentry()
HIROSE Yuuji <yuuji@gentei.org>
parents: 608
diff changeset
2758 echo "</div>" # End of List-entry div
235
014f459543d5 Put Prev/Next button at the bottom of list in addition to above
HIROSE Yuuji <yuuji@gentei.org>
parents: 233
diff changeset
2759 echo ${pnbtn:+"<hr>$nextbtn$prevbtn"}
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2760 if [ -n "$kwd" -a x"$tbl" = x"grp" -a -n "$S4WORLDS" ]; then
827
97be0474f268 List belonging groups
HIROSE Yuuji <yuuji@gentei.org>
parents: 825
diff changeset
2761 peekgrpworlds "$kwd"
825
e9817a71f332 List groups in other worlds
HIROSE Yuuji <yuuji@gentei.org>
parents: 817
diff changeset
2762 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
2763 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2764 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
2765 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
2766 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2767 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
2768 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
2769 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2770 hexteams() { # $1=gname, $2(optional)=user
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2771 cond=${2:+" AND user='$2'"}
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2772 query "SELECT DISTINCT hex(val) FROM grp_mem_m
677
bdf33fbd977b Sort team names
HIROSE Yuuji <yuuji@gentei.org>
parents: 675
diff changeset
2773 WHERE gname='$1' AND key='team'$cond ORDER by val;"
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2774 }
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2775 showgroup() { # $1=group-rowid
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2776 if [ -z "$1" ]; then
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2777 grid=`getpar grid`
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2778 grid=${grid%%[!0-9]*}
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2779 [ -n "$grid" ] && grp=`getgroupbyid $grid`
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2780 else
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2781 grid=$1
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2782 fi
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2783 grp=`getgroupbyid $grid`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2784 qgrp=`sqlquote "$grp"`
654
d6f464f0a212 Include more chars into htmlescape for m4 processing
HIROSE Yuuji <yuuji@gentei.org>
parents: 653
diff changeset
2785 htmlgrp=`echo "$grp"|htmlescape`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2786 ## err showgroup2: grid=$grid grp=$grp qgrp="[$qgrp]"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2787 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
2788 tf=$tmpd/title.$$
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2789 sf=$tmpd/search.$$
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2790 bodyclass=`query "SELECT val FROM grp_s
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2791 WHERE gname=$qgrp AND key='regmode';"`
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2792 if ismember "$user" "$grp"; then
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2793 ismember="ismember"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2794 bodyclass="$bodyclass${bodyclass:+ }ismember"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2795 else
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2796 ismember="" # bodyclass="group"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2797 fi
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2798 bodyclass="$bodyclass grouphome"
747
42cc0aeaa498 Avoid to pass gname to searchart()
HIROSE Yuuji <yuuji@gentei.org>
parents: 740
diff changeset
2799 echo "<div class=\"search\">`search_form grid=\"$grid\"`</div>"> $sf
654
d6f464f0a212 Include more chars into htmlescape for m4 processing
HIROSE Yuuji <yuuji@gentei.org>
parents: 653
diff changeset
2800 echo "グループ $htmlgrp" > $tf
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2801
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2802 showgroupsub $formdir/grp.def "$grid" | \
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2803 _m4 -D_TITLE_="syscmd(\`cat $tf')" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2804 -D_FORM_="syscmd(\`cat')" \
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2805 -D_BODYCLASS_="$bodyclass" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
2806 -D_DUMPTABLE_="" \
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2807 $htmlheader $sf $layout/form+dump.m4.html
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2808 # $htmlheader $layout/form+dump.m4.html
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2809 # $htmlheader is defined in grp()
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2810 else # if $grp is removed at par2table
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2811 listgroup
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2812 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
2813 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2814 showgroupsub() {
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2815 # $1=def-file $2=group-rowid
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2816 # Using $ismember
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2817 rowid=$2
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2818 grp=`getgroupbyid $2`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
2819 qgrp=`sqlquote "$grp"`
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2820 td=`getcachedir grp/"$2"`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2821 #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
2822 if [ -z "$rowid" ]; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2823 #rowid=`sq $db "select rowid from grp where rowid=$grp"`
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2824 #grp=`sq $db "select gname from grp where rowid=$grp"`
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2825 echo "showgroupsub: invalid argument($1 $2)" | html p
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
2826 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
2827 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
2828 val=`getvalbyid grp profimg $rowid $tmpd`
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2829 enticond="gname=$qgrp"
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2830 img=`query "SELECT type FROM grp_m WHERE $enticond LIMIT 1;"`
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2831 if [ -n "$img" ]; then
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2832 cat<<-EOF
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2833 <p class="groupimg">
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
2834 `imgsrc_cache $td/main grp_m "$enticond" M`</p>
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2835 EOF
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2836 fi
319
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2837 echo "<div class=\"noprofimg\">"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2838 viewtable $1 grp $rowid
319
a868f03970b5 Profimg hiding rule revised
HIROSE Yuuji <yuuji@gentei.org>
parents: 312
diff changeset
2839 echo "</div>"
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
2840 if isgrpowner "$user" "$grp"; then
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2841 echo "<p><a href=\"?groupconf+$rowid\" accesskey=\"e\"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2842 title=\"Shortcut: e${nl}Edit Group\">グループ情報の編集</a>"
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2843 iamowner=$rowid
371
302eae8f723b Display blog-mode only when user is group owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 370
diff changeset
2844 colmd=" mode"
1003
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2845 # We have to specify report-type blog to lshandoutall
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2846 repblog=`query "
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2847 WITH grpblogs AS (
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2848 SELECT id FROM blog_s
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2849 WHERE key='owner' AND val=(SELECT gname FROM grp WHERE rowid=$rowid)
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2850 ), ownerMode AS (
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2851 SELECT id,
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2852 max(CASE key WHEN 'owner' THEN val END) owner,
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2853 max(CASE key WHEN 'mode' THEN val END) mode
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2854 FROM blog_s
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2855 GROUP BY id
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2856 ), blogid AS (
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2857 SELECT id
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2858 FROM grpblogs NATURAL LEFT JOIN ownerMode
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2859 WHERE mode LIKE 'report%' LIMIT 1
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2860 ) SELECT blog.rowid FROM blogid NATURAL LEFT JOIN blog;"`
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2861 if [ -n "$repblog" ]; then
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2862 csvid="gethandoutcsv"
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2863 replink="/ <a href=\"?lshandoutall+$repblog#$csvid\">レポート全集計</a>"
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2864 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
2865 fi
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2866 if [ -n "$ismember" ]; then
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2867 #echo "${iamowner:+ / }<a href=\"?blog+$rowid\">グループの新規話題作成</a>"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2868 #echo "/ <a href=\"?grpaction+$rowid\">メンバーを個別選択しての操作</a></p>"
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2869 # div.fold input[type="checkbox"]:checked ~ div {display: block;}
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2870 cat<<-EOF
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2871 ${iamowner:+ / }<a accesskey="n" title="Shortcut: n${nl}New blog"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2872 href="?blog+$rowid">グループの新規話題作成</a>
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2873 / <a accesskey="m" title="Shortcut: m${nl}Operations on Members"
1003
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2874 href="?grpaction+$rowid">メンバーを個別選択しての操作</a>
5bd1b5125049 Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents: 995
diff changeset
2875 $replink</p>
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2876 <form action="?send2mem" method="POST" enctype="multipart/form-data">
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2877 <div class="fold clear">
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2878 `cgi_checkbox send yes id="send"`<label
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2879 for="send">グループ全員にメッセージ送信</label>
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2880 <div>
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2881 `cgi_textarea message "" "cols=60"`
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2882 `cgi_submit 送信`
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2883 `cgi_reset リセット`
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2884 </div>
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2885 `cgi_hidden grp $rowid`
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2886 </div></form>
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
2887 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
2888 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
2889 # 加入ボタン + 加入者リスト
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2890 if [ -n "$ismember" ]; then
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2891 ismem='checked' state="(参加中)"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2892 else
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2893 nomem='checked' state="(現在非加入)"
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2894 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
2895 # このグループでの加入アドレス
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2896 eml=`query "select val from grp_mem_s where gname=$qgrp and user='$user' \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2897 and key='email';"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2898 ##err EML: "select val from grp_mem_s where gname='$2' and user='$user' \
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2899 ## and key='email';"
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2900 ##err email=$eml
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2901 cat <<EOF
311
121b91ee87c1 User/Group home icon cache'ing and group icon displaying added
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
2902 <div class="fold clear">
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2903 `cgi_checkbox reg yes id="reg"`<label
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 258
diff changeset
2904 for="reg">自身の加入状態を操作する</label>$state
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2905 <div>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2906 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
2907 cgi_form grp <<EOF
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2908 <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
2909 <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
2910 <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
2911 <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
2912 <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
2913 <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
2914 <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
2915 同じでよい場合は空欄に)</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
2916 <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
2917 </table>
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2918 `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
2919 EOF
768
891f1f5a8153 Allow spaces in group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 763
diff changeset
2920 if [ x`getgroupattr "$grp" regmode` = x'moderated' -a -z "$ismem" ]; then
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2921 echo "moderated (承認加入の)グループなので実際に参加できるのは
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2922 グループ管理者が承認操作をした後になります。" | html p 'class="warn"'
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
2923 fi
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
2924 echo '</div></div>'
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2925 thelp="1ヶ月分のまとめには上部検索窓に @month と入れてください。"
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2926 cat<<-EOF
842
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2927 <div class="fold"> <!-- in showgroupsub -->
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2928 <h2>話題一覧</h2>
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2929 <form class="summary inline" action="$myname" title="$thelp">
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2930 `cgi_hidden owner "$grp"`
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2931 `cgi_hidden kwd "@week"`
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2932 `cgi_hidden stage searchart`
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2933 `cgi_submit "一週間のまとめ"`
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2934 </form>
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2935 <input type="checkbox" id="dtcheck" checked><label
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2936 for="dtcheck">話題一覧表示</label>
418
a183d6e0ed5e Search board in group home revised to similar position in user home
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
2937 EOF
882
a46e85d50954 Burry frozen state blog with ORDER BY clause
HIROSE Yuuji <yuuji@gentei.org>
parents: 881
diff changeset
2938 cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by 稼動状態, ctime desc"
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
2939 colstate="state:稼動状態:frozen=rowclass=凍結"
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2940 frzbtn='<button class="toggle-frozen"></button>'
1005
c2fc7a148d2c Suppress post-count in non-member group
HIROSE Yuuji <yuuji@gentei.org>
parents: 1004
diff changeset
2941 if [ -n "$ismember" ]; then
c2fc7a148d2c Suppress post-count in non-member group
HIROSE Yuuji <yuuji@gentei.org>
parents: 1004
diff changeset
2942 DT_COUNT=author DT_COUNT_HEADER="書" DT_COUNT_BY=$user
c2fc7a148d2c Suppress post-count in non-member group
HIROSE Yuuji <yuuji@gentei.org>
parents: 1004
diff changeset
2943 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
2944 DT_CHLD=article:blogid \
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
2945 DT_QOWNER="$qgrp" \
371
302eae8f723b Display blog-mode only when user is group owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 370
diff changeset
2946 DT_VIEW=replyblog dumptable html blog \
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2947 "ctime title heading team notify:通知$colmd $colstate" "$cond" \
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2948 | if [ -n "$iamowner" ]
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2949 then
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2950 sed -Ee "s,(<TD class=\"稼動状態\">).*(</TD>),\1$frzbtn\2,"
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2951 else
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2952 cat
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2953 fi
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
2954 ## DO not convert to frzbtn when not admin
842
de2ef47143a0 Blog list in group home can be folded by a checkbox
HIROSE Yuuji <yuuji@gentei.org>
parents: 837
diff changeset
2955 echo "</div> <!-- in showgroupsub -->"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2956
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2957 getgname="(select gname from grp where rowid=$rowid)"
246
de0a9f5cc1cf Listing users in a group couldn't show "next-30", fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 245
diff changeset
2958 c="group by a.name having a.name in (select user from grp_mem where gname=$getgname)"
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
2959 cm="?commission+$rowid"
628
5c9b7add02e9 Username search in group-home should carry grid parameter
HIROSE Yuuji <yuuji@gentei.org>
parents: 627
diff changeset
2960 thumbxy=50x50 listmember "`getpar kwd`" "$c" "$rowid" \
611
1546f1f82dcf Remove user-rowid flag from member list.
HIROSE Yuuji <yuuji@gentei.org>
parents: 610
diff changeset
2961 |sed -e "s|\(<br>\)(,not=\(.*\))|\1|" # 間違って押しやすい
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2962 # team list
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2963 hexteams=`hexteams "$grp"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2964 if [ -n "$hexteams" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2965 echo "チーム一覧" | html h2
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2966 echo '<div class="dumptable"><table class="b">'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2967 sq $db -html -header<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2968 SELECT val TEAM,
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2969 group_concat((SELECT gecos FROM gecoses WHERE name=user), ',')
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2970 MEMBERS
224
5ac0684fc3ac correction from debug code
HIROSE Yuuji <yuuji@gentei.org>
parents: 223
diff changeset
2971 FROM grp_mem_m WHERE gname=$qgrp AND key='team' GROUP BY val;
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2972 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2973 echo '</table></div>'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
2974 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
2975 }
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2976 grp_getbodyclass() {
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2977 # Get css class name for document.
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2978 # `moderated' for moderated groups
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2979 # `ismember' for groups where user belongs
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2980 # $1=GroupName (w/o quote)
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2981 # $user=userNameCurrentlyLogin
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
2982 ## err grp_getbodyclass: 1="$1"
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2983 qgrp=`sqlquote "$1"`
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2984 query<<-EOF
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2985 SELECT coalesce(
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2986 (SELECT val FROM grp_s WHERE gname=$qgrp AND key='regmode'),
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2987 'open')
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2988 ||
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2989 CASE WHEN '$user'
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2990 IN (SELECT user FROM grp_mem WHERE gname=$qgrp)
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2991 THEN ' ismember'
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2992 ELSE ''
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2993 END;
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2994 EOF
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
2995 }
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
2996 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
2997 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
2998 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
2999 grp=`getgroupbyid "$grid"`
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
3000 htmlgrp=`echo "$grp" | htmlescape`
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3001 myuid=`query "SELECT rowid FROM user WHERE name='$user';"`
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3002 if [ -z "$grp" ]; then
118
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
3003 echo "無効な指定です。" | html p; return
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
3004 fi
433
03ced2f9f271 Quote group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 431
diff changeset
3005 if ! ismember $user "$grp"; then
118
45d1b0f09e48 grpaction is limited to its member
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
3006 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
3007 fi
875
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3008 isowner=""
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3009 isgrpowner "$user" "$grp" && isowner="yes"
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3010 err 2=$2 3=$3
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3011 case "$2" in
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3012 get:teamcsv)
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3013 teamcsv "$grid"
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3014 return
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3015 ;;
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3016 esac
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
3017 echo "グループ $grp 個別選択操作" \
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
3018 | _m4 -D_TITLE_="syscmd(\`cat')" \
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
3019 -D_BODYCLASS_="`grp_getbodyclass \"$grp\"`" \
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 285
diff changeset
3020 $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
3021
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3022 usel=`getpar usel`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3023 if [ -n "$usel" ]; then
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3024 uids=$(echo `echo $usel`|tr ' ' ',')
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3025 ## err grpaction-1: grp=$grp, `echo $sql`
669
17ca38bf0a4b Remove carriage-returns in message text forcibly
HIROSE Yuuji <yuuji@gentei.org>
parents: 668
diff changeset
3026 text=`getpar text|tr -d '\r'`
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3027
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3028 rm=`getpar rm` cfm=`getpar confirm`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3029 ## err rm=$rm cfm=$cfm
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3030 if [ x"$rm" = x"yes" ]; then
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3031 if [ "$isowner" ]; then
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3032 if [ x"$rm$cfm" = x"yesyes" ]; then
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3033 # Eliminate
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3034 cond="where gname=(select gname from grp where rowid=$grid) and user in (select name from user where rowid in ($uids))"
1018
2fd483245e8e Delete user from grp_adm* table as well as from grp_mem*.
HIROSE Yuuji <yuuji@gentei.org>
parents: 1016
diff changeset
3035 for tbl in grp_mem grp_mem_s grp_mem_m grp_adm grp_adm_s grp_adm_m
2fd483245e8e Delete user from grp_adm* table as well as from grp_mem*.
HIROSE Yuuji <yuuji@gentei.org>
parents: 1016
diff changeset
3036 do
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3037 sql="delete from $tbl $cond;"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3038 # echo "sql=$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3039 query "$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3040 err rmGRPuser "$sql"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3041 done
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3042 num=`query "select count(*) from user where rowid in ($uids);"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3043 #err num=$num
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3044 if [ 0$num -gt 0 ]; then
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3045 sql="select coalesce(b.val,a.name) from user a left join \
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3046 user_s b on a.name=b.name and key='gecos' where a.rowid in ($uids);"
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3047 # err `echo "$sql"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3048 html pre<<EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3049 以下の${num}名のグループ $grp 登録を解除しました。
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3050 `query "$sql"`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3051 EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3052 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3053 else
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3054 echo "確認のチェックがないのでやめておきます。" | html p
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3055 return
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3056 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3057 else # not Group Owner
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3058 echo "グループ管理者でないのでメンバー操作はできません。" | html p
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3059 return
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3060 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3061 cat<<EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3062
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3063 EOF
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3064 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
3065 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
3066 echo "なにかメッセージを..." | html p
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3067 return 0
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3068 fi
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
3069 gecos=`gecos $user`
897
3d437261edca Remove "," from gecos name of email
HIROSE Yuuji <yuuji@gentei.org>
parents: 896
diff changeset
3070 safegc=`echo "$gecos" | tr -d '<>@,'`
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3071 #fromad=`email4groupbyuid "$grp" "$myuid" | sed -e 1q -e 's/[ ,].*//'`
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3072 fromad=`myemail4group "$grp"`
678
db77378201ab Test to let From: main username
HIROSE Yuuji <yuuji@gentei.org>
parents: 677
diff changeset
3073 ###mail_from="$safegc <$fromad>"
db77378201ab Test to let From: main username
HIROSE Yuuji <yuuji@gentei.org>
parents: 677
diff changeset
3074 mail_from="$safegc <$user>" # TEST: 2020/5/13
684
8091eb177596 Sender address set to $user in email-mode
HIROSE Yuuji <yuuji@gentei.org>
parents: 682
diff changeset
3075 test -n `getpar sender` &&
8091eb177596 Sender address set to $user in email-mode
HIROSE Yuuji <yuuji@gentei.org>
parents: 682
diff changeset
3076 export SENDER=$user # TEST: 2020/5/15
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3077 replyto=$fromad
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3078
661
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3079 ## Start parse of attachment files
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3080 if [ -n "`getpar email`" ]; then
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3081 ar=`getpar supprcpt`
668
84b26e6e4d79 Supprcpt condition fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 667
diff changeset
3082 if [ -n "$ar" ]; then
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3083 for a in $ar; do
710
8a31b90f7815 Output to error-log when supprcpt is specified in DM rcpt field.
HIROSE Yuuji <yuuji@gentei.org>
parents: 709
diff changeset
3084 if checkdomain "$a"; then
8a31b90f7815 Output to error-log when supprcpt is specified in DM rcpt field.
HIROSE Yuuji <yuuji@gentei.org>
parents: 709
diff changeset
3085 supprcpt="$supprcpt $a"
8a31b90f7815 Output to error-log when supprcpt is specified in DM rcpt field.
HIROSE Yuuji <yuuji@gentei.org>
parents: 709
diff changeset
3086 else
8a31b90f7815 Output to error-log when supprcpt is specified in DM rcpt field.
HIROSE Yuuji <yuuji@gentei.org>
parents: 709
diff changeset
3087 err "SupprcptErr=[$a] by $user"
8a31b90f7815 Output to error-log when supprcpt is specified in DM rcpt field.
HIROSE Yuuji <yuuji@gentei.org>
parents: 709
diff changeset
3088 removercpt="$removercpt $a"
8a31b90f7815 Output to error-log when supprcpt is specified in DM rcpt field.
HIROSE Yuuji <yuuji@gentei.org>
parents: 709
diff changeset
3089 fi
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3090 done
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3091 fi
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3092 subj=`getpar subject`
661
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3093 afiles=""
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
3094 for fn in `query "SELECT DISTINCT val FROM par WHERE var='image' AND sessid='$session';"`
661
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3095 do
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3096 f=$tmpd/$fn
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3097 if [ -s $f ]; then
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3098 afiles=$afiles"${afiles:+ }$f"
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3099 fi
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3100 done
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3101 else
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3102 preface=$(cat <<-EOF
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3103 $url
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3104 のグループ「$grp」のメンバーである $gecos さんから、
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3105 あなた宛のメッセージです。
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3106 ----------------------------------------------------------
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3107 EOF
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3108 )
661
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3109 fi
686
0a6ab304f1c6 (TEST)GrpAction smail should send to oneself
HIROSE Yuuji <yuuji@gentei.org>
parents: 685
diff changeset
3110 rcpts="`email4groupbyuid "$grp" $usel` $fromad$supprcpt"
694
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3111 rcpts=`echo $rcpts|tr ' ' '\n'|sort|uniq|tr '\n' ' '`
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3112 subj="${subj:-$gecos さんからのメッセージ}"
661
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3113 REPLYTO=$replyto
14a7c23f3f06 Allow supplemental rcpt address and file attachment in DM in grpAction
HIROSE Yuuji <yuuji@gentei.org>
parents: 659
diff changeset
3114 MAIL_FROM=$mail_from
679
f0396eb2dfc9 Suppress listing selected rcpt addresses in To: header(GrpAction)
HIROSE Yuuji <yuuji@gentei.org>
parents: 678
diff changeset
3115 export REPLYTO SMAIL_TO MAIL_FROM
685
a13f49da8788 Log more information on GrpAction smail
HIROSE Yuuji <yuuji@gentei.org>
parents: 684
diff changeset
3116 err "GrpActionSend: user=[$user], MAIL_FROM=[$mail_from], rcpts=[$rcpts], REPLYTO=[$replyto}"
690
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3117 for r in $rcpts; do
694
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3118 if [ x"$user" = x"$r" -o x"$fromad" = x"$r" ]; then
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3119 SMAIL_TO=$rcpts # Show all rcpts to sender oneself
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3120 else
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3121 # Show sender and rcpts address for guest
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3122 SMAIL_TO=`echo $r $user $fromad|tr ' ' '\n'|sort -u|tr '\n' ' '`
c45ab714d68e To: header for email-sender contains all recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 693
diff changeset
3123 fi
690
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3124 if [ -n "$afiles" ];then
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3125 ./sendmultipart.sh -t "$r" -s "$subj" -f "$mail_from" $afiles
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3126 else
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3127 smail "$r" "$subj"
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3128 fi <<EOF
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3129 ${preface:+$preface$nl}$text
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3130 EOF
690
87ce0eef5872 GrpAction mail sent one by one
HIROSE Yuuji <yuuji@gentei.org>
parents: 689
diff changeset
3131 done
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3132 if [ $? = 0 ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3133 echo "Note: 以下のメンバーにメッセージを送信しました。" | html p
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3134 sql="select coalesce(b.val, a.name) from
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3135 (select name from user where rowid in ($uids)) a
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3136 left join user_s b on a.name=b.name and b.key='gecos';"
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3137 html pre<<EOF
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3138 `query "$sql"`
659
a36a2c3b3056 GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents: 657
diff changeset
3139 ${supprcpt:+追加宛先 $supprcpt$nl}(送信者である $gecos さんも含まれます)
709
025ef5578ae0 Warn undeliverable recipient(s) that was removed from rcptlist.
HIROSE Yuuji <yuuji@gentei.org>
parents: 708
diff changeset
3140 ${removercpt:+アドレスエラーによる削除(送られません): <em class="warn">$removercpt</em>}
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3141 EOF
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3142 err SendDone: `echo $sql`
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3143 fi
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3144 elif [ x"$rm" = x"commission" ]; then
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3145 grp_reg_adm $grid $usel
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3146 elif [ x"$rm" = x"addteam" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3147 team=`getpar team|sed "s/'/''/g"` # for single quotation
440
dc7acfdb6bfc Add comment
HIROSE Yuuji <yuuji@gentei.org>
parents: 439
diff changeset
3148 newteam=`echo $team|tr -d ,` # ..and strip spaces of both ends
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3149 if [ x"$team" != x"$newteam" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3150 echo "チーム名に使えない文字を除去しました" | html p
700
f2971e549199 New team name regularization fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 699
diff changeset
3151 team=$newteam
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3152 fi
675
9c54908814be Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents: 669
diff changeset
3153 if [ -z "$team" -o x"$team" = x"なし" -o x"$team" = x"TEAM" ]; then
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3154 cat<<-EOF | html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3155 有効なチーム名を入力してください。
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3156 カンマだけ、「なし」という名前は使えません。
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3157 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3158 echo "有効なチーム名を入力してください。" | html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3159 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3160 grp_add_team $grid "$team" $usel
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3161 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3162 elif [ x"$rm" = x"rmteam" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3163 if [ x"yes" = x"`getpar teamconfirm`" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3164 rmteam=`getpar rmteam|sed "s/'/''/g"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3165 if [ -n "`query \"SELECT val FROM grp_mem_m WHERE\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3166 gname='$grp' AND user='$user' AND key='team'\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3167 AND val='$rmteam';\"`" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3168 grp_rm_team $grid "$rmteam" $usel
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3169 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3170 echo "所属していないチームの除去操作はできません。"|html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3171 fi
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3172 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3173 echo "確認チェックなしなのでチーム除去しませんでした。"|html p
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3174 fi
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3175 fi
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3176 fi
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3177 # POST count summary
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3178 from=`getpar from`; to=`getpar to`
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3179 from_input="<input type=\"date\" name=\"from\" placeholder=\"YYYY-MM-DD\" value=\"${from}\">"
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3180 to_input="<input type=\"date\" name=\"to\" value=\"${to:-9999}\">"
937
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3181 fromtonote="<p title=\"Count the Number of Posts from-to\">POST/ACCESS集計: $from_input - $to_input</p><!-- $from - $to -->"
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3182 # New entry
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3183 sql="WITH mems AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3184 SELECT g.rowid, name, gecos FROM grp_mem gm LEFT JOIN gecoses g
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3185 ON gm.user=g.name
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3186 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid)
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3187 ), target_article AS (
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3188 SELECT id FROM article_s
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3189 WHERE key='ctime' AND val BETWEEN '${from:-0000}' AND '${to:-9999}'
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3190 ), posts AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3191 SELECT author, count(author) post
490
e4b929e40fa8 Add feature of limiting date range of POST count
HIROSE Yuuji <yuuji@gentei.org>
parents: 489
diff changeset
3192 FROM article NATURAL JOIN article_s NATURAL JOIN target_article
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3193 WHERE blogid IN (SELECT id FROM blog_s
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3194 WHERE key='owner'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3195 AND val=(SELECT gname FROM grp WHERE rowid=$grid))
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3196 AND key='text'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3197 GROUP BY author
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3198 ), teams AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3199 SELECT user, group_concat(val, ', ') team
876
610c3fb6d52a Sort by uname at grpaction
HIROSE Yuuji <yuuji@gentei.org>
parents: 875
diff changeset
3200 FROM mems m LEFT JOIN grp_mem_m gm ON m.name=gm.user
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3201 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid)
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3202 AND key='team'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3203 GROUP BY user
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3204 ), user_post AS (
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3205 SELECT m.rowid, name, m.gecos, coalesce(post, 0) as POST
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3206 FROM mems m LEFT JOIN posts
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3207 ON m.name=posts.author
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3208 GROUP by m.rowid
937
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3209 ), user_view AS (
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3210 SELECT user vuser,count(user) cnt
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3211 FROM tblaccesses
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3212 WHERE user IN (
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3213 SELECT user FROM grp_mem
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3214 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid))
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3215 AND tbl='blog'
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3216 AND tblrowid IN (
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3217 SELECT rowid FROM blog
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3218 WHERE id IN (
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3219 SELECT id FROM blog_s
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3220 WHERE key='owner' AND val=(
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3221 SELECT gname FROM grp WHERE rowid=$grid)))
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3222 AND time BETWEEN '${from:-0000}' AND '${to:-9999}'
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3223 GROUP BY user ORDER BY cnt
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3224 )
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3225 SELECT
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3226 CASE
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3227 WHEN (SELECT user FROM grp_adm
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3228 WHERE gname=(SELECT gname FROM grp WHERE rowid=$grid)
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3229 AND user=up.name) IS NOT NULL
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3230 then 'k'
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3231 ELSE ''
876
610c3fb6d52a Sort by uname at grpaction
HIROSE Yuuji <yuuji@gentei.org>
parents: 875
diff changeset
3232 END || rowid || ','
987
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3233 || rtrim(substr(name, 1, instr(name, '@')), '@') UID,
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3234 gecos NAME,
937
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3235 post POST,
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3236 (coalesce((SELECT cnt FROM user_view WHERE vuser=name), 0)) ACCESS,
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3237 team _TEAM_
435
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3238 FROM user_post up LEFT JOIN teams t
9f7b97c8b694 Group member listing with the number of POST fasten much
HIROSE Yuuji <yuuji@gentei.org>
parents: 434
diff changeset
3239 ON up.name=t.user
888
7ca1f11ab5e8 Ensure sort by login name in grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 887
diff changeset
3240 ORDER BY up.name;"
937
7b3786b1eb4b Summarize access count as well as post count
HIROSE Yuuji <yuuji@gentei.org>
parents: 935
diff changeset
3241 ## Want to count ACCESS with JOIN, but failed to produce user-unique rows
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3242 ## err grpaction: "`echo \"$sql\"`"
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
3243 tf=$tmpd/title.$$
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
3244 echo "グループ[<a href=\"?grp+$grid\">$htmlgrp</a>]参加メンバーに対する操作" > $tf
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3245 cmmsg="`cgi_radio rm commission id=\"cmadmin\"`<label accesskey=\"f\"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3246 title=\"Shortcut: f${nl}Add to Administrator of the Group\"
665
92a2f58b723b Simplify
HIROSE Yuuji <yuuji@gentei.org>
parents: 663
diff changeset
3247 for=\"cmadmin\">管理者委任</label>
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3248 <div><p>このグループでの全権を付与します。信頼できる人に託してください。
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3249 </p></div>"
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3250 excmsg="`cgi_radio rm yes id=\"conf\"`<label accesskey=\"g\"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3251 title=\"Shortcut: g${nl}Remove from the Group\"
665
92a2f58b723b Simplify
HIROSE Yuuji <yuuji@gentei.org>
parents: 663
diff changeset
3252 for=\"conf\">GRP登録解除</label>
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3253 <div>本当に消します! `cgi_checkbox confirm yes` 確認
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3254 <p>この操作による通知は本人に行きません。
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3255 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p>
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3256 </div>"
926
ef84fef0cec8 (grpaction) Put submit button next to input field
HIROSE Yuuji <yuuji@gentei.org>
parents: 921
diff changeset
3257 submitBTN=`cgi_submit 送信`
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3258 # Get team list to which current user belongs into $hexteams
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3259 allhexteams=$(hexteams "$grp")
608
07ec77f4e224 Admin can remove all teams' attr
HIROSE Yuuji <yuuji@gentei.org>
parents: 607
diff changeset
3260 if [ -n "$isowner" ]; then
07ec77f4e224 Admin can remove all teams' attr
HIROSE Yuuji <yuuji@gentei.org>
parents: 607
diff changeset
3261 myhexteams="$allhexteams" # admin can remove all teams' attr
07ec77f4e224 Admin can remove all teams' attr
HIROSE Yuuji <yuuji@gentei.org>
parents: 607
diff changeset
3262 else
07ec77f4e224 Admin can remove all teams' attr
HIROSE Yuuji <yuuji@gentei.org>
parents: 607
diff changeset
3263 myhexteams=$(hexteams "$grp" "$user")
07ec77f4e224 Admin can remove all teams' attr
HIROSE Yuuji <yuuji@gentei.org>
parents: 607
diff changeset
3264 fi
875
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3265 if [ -n "$isowner" -a -n "$allhexteams" ]; then
921
7b887bea6ecd Team.csv with gecos names
HIROSE Yuuji <yuuji@gentei.org>
parents: 918
diff changeset
3266 gettingcsv="<p>Download: <a href=\"?getteamcsv+$grid\">Team.csv</a> (Zoom Breakout Room 事前割り当てに使えます), <a href=\"?getteamcsv+$grid+name\">Team-with-name.csv</a>(参照用名前付)</p>"
875
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3267 fi
227
ce24afbd3139 Team-removal control should obey $myhexteams.
HIROSE Yuuji <yuuji@gentei.org>
parents: 226
diff changeset
3268 if [ -n "$myhexteams" ]; then
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3269 rmteammsg="`cgi_radio rm rmteam 'id=\"cmrmteam\"'`<label accesskey=\"s\"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3270 title=\"Shortcut: s${nl}Strip a team tag from\"
292
3866eb7c2a23 Shorten heading string
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
3271 for=\"cmrmteam\">チーム属性除去</label>
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3272 <div>チーム属性:`cgi_select_h rmteam \"2d2d2d\" $myhexteams`
926
ef84fef0cec8 (grpaction) Put submit button next to input field
HIROSE Yuuji <yuuji@gentei.org>
parents: 921
diff changeset
3273 を除去します: `cgi_checkbox teamconfirm yes` 確認 $submitBTN
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3274 <p>この操作による通知は本人に行きません。
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3275 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p>
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3276 </div><!-- end of $rmteammsg -->
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3277 "
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3278 fi
675
9c54908814be Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents: 669
diff changeset
3279 stf=$tmpd/selteam.$$
9c54908814be Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents: 669
diff changeset
3280 cgi_select_h selteam "5445414d" $allhexteams > $stf
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3281 b1='<label> <input type="checkbox" name="usel" value="'
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3282 ba='<label class="admin"><input type="checkbox" name="usel" value="'
659
a36a2c3b3056 GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents: 657
diff changeset
3283 br='<span id="reverse" title="Reverse Selection"></span>'
987
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3284 # lnk='"> <span></span></label> [<a href="?home+\3">HOME</a>]'
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3285 lnk='<a href="?home+\3">\5</a>'
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3286 # (1) Join <TR> line and the next
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3287 # (2) (<TR><TD)>(k?)(1234),(userid)</TD><TD>(GECOS)</TD>
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3288 # ↓
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3289 # <TR><TD>\2<label><input ...value="\3">\4</label></TD> \
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3290 # <TD><a href="?home+\3">\5</a></TD>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3291 cgi_form grpaction<<EOF \
987
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3292 | sed -e '/^<TR>/{; N; s/\n//; }' \
876
610c3fb6d52a Sort by uname at grpaction
HIROSE Yuuji <yuuji@gentei.org>
parents: 875
diff changeset
3293 | sed -E \
987
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3294 -e "s|^(<TR><TD>)(k?)([0-9]*),(.*)</TD><TD>(.*)</TD>|\1\2$b1\3\">\4</label></td><td>$lnk</TD>|" \
876
610c3fb6d52a Sort by uname at grpaction
HIROSE Yuuji <yuuji@gentei.org>
parents: 875
diff changeset
3295 -e 's/^(<TR><TD[^>]*>)k(<label)/\1\2 class="admin"/' \
987
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3296 -e "s|^(<TR><TH>)(UID)|\1$br \2|" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3297 | _m4 -D_TITLE_="spaste(\`$tf')" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3298 -D_SUBTITLE_="チェック後操作ボタン" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3299 -D_FORM_="syscmd(cat)" -D_DUMPTABLE_="" \
675
9c54908814be Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents: 669
diff changeset
3300 $layout/form+dump.m4.html \
9c54908814be Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents: 669
diff changeset
3301 | _m4 -D_TEAM_="spaste(\`$stf')"
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3302 <p>下でチェックした人を対象として:</p>
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3303 <div class="foldtabs">
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3304 `cgi_radio rm addteam 'id="cmteam"'`<label accesskey="a"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3305 title="Shortcut: a${nl}Add a team tag to"
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3306 for="cmteam">同じチーム属性を付与</label>
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3307 <div>チーム名:`cgi_text team "" 'id="inteam" list="teams"'`
926
ef84fef0cec8 (grpaction) Put submit button next to input field
HIROSE Yuuji <yuuji@gentei.org>
parents: 921
diff changeset
3308 `cgi_datalist_h teams $allhexteams`$submitBTN
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3309 </div>
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3310 ${rmteammsg}
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3311 `cgi_radio rm send id="sendmsg"`<label accesskey="d"
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3312 title="Shortcut: d${nl}DirectMail to"
665
92a2f58b723b Simplify
HIROSE Yuuji <yuuji@gentei.org>
parents: 663
diff changeset
3313 for="sendmsg" title="Direct Message">DM送信</label>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3314 <div>
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3315 `cgi_checkbox email yes 'id="email" class="fold"'`<label for="email"
702
2c5ddb0b5f4c Add more shortcuts and baloon help messages
HIROSE Yuuji <yuuji@gentei.org>
parents: 700
diff changeset
3316 title="Using email format">email書式を使う</label>
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3317 <div class="folded">
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3318 <table>
684
8091eb177596 Sender address set to $user in email-mode
HIROSE Yuuji <yuuji@gentei.org>
parents: 682
diff changeset
3319 <tr><td>From: </td><td>$user</td></tr>
8091eb177596 Sender address set to $user in email-mode
HIROSE Yuuji <yuuji@gentei.org>
parents: 682
diff changeset
3320 <tr><td>このFrom:で送る</td>
687
19d28bbdbee8 Remove message
HIROSE Yuuji <yuuji@gentei.org>
parents: 686
diff changeset
3321 <td>`cgi_checkbox sender yes 'checked'`<small></small>
684
8091eb177596 Sender address set to $user in email-mode
HIROSE Yuuji <yuuji@gentei.org>
parents: 682
diff changeset
3322 </td></tr>
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3323 <tr><td>Subject: </td><td>`cgi_text subject`</td></tr>
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3324 <tr><td>追加宛先(通常空欄): </td><td>`cgi_text supprcpt ""`</td></tr>
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3325 <tr><td>ファイル添付: </td>
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
3326 <td>`cgi_file image "" "multiple $file_accept title=\"$file_accept_help\""`<br><small>文書ファイルはPDFに変換してから</small></td></tr>
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3327 </table>
926
ef84fef0cec8 (grpaction) Put submit button next to input field
HIROSE Yuuji <yuuji@gentei.org>
parents: 921
diff changeset
3328 <p>(下記一覧から1人以上選択していない場合は送れません$submitBTN)</p>
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3329 </div>
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3330 <div>本文:`cgi_textarea text "" cols=72`
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3331 </div>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3332 </div>
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
3333 ${isowner:+$cmmsg$excmsg}
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3334 `cgi_radio rm close id="x"`<label for="x" accesskey="x">×</label>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3335 </div>
875
380167e9cfcf Add link to generate csv file for Zoom(TM) pre-assigned rooms
HIROSE Yuuji <yuuji@gentei.org>
parents: 874
diff changeset
3336 <h4>$htmlgrp 参加者一覧</h4>$gettingcsv$fromtonote
987
e71a86651d72 Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents: 986
diff changeset
3337 <table class="td3r td4r thl">
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3338 `sq $db -header -html "$sql"`
207
355fcbdc3b49 Add 'file_accept'
HIROSE Yuuji <yuuji@gentei.org>
parents: 203
diff changeset
3339 </table>
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3340 `cgi_hidden grp $grid`
667
9ee0e242c25a Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 666
diff changeset
3341 `cgi_hidden myuid $myuid id="myuid"`
59
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3342 EOF
916d81b9c4fc Selection from group member
HIROSE Yuuji <yuuji@gentei.org>
parents: 58
diff changeset
3343 }
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3344 crview4article() { # $1=rowid of blog, $2(optional)=extra SQL
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3345 # Create TEMPORARY VIEW
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3346 query<<EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3347 CREATE TEMPORARY VIEW writeusers AS
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3348 SELECT DISTINCT author FROM article
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3349 WHERE id in (
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3350 select id from article where blogid=(select id from blog where rowid=$1)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3351 );
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3352 CREATE TEMPORARY VIEW movablegroups AS
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3353 SELECT g.rowid growid , g.gname
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3354 FROM (SELECT grp.rowid, grp.gname FROM grp JOIN grp_mem gm
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3355 ON grp.gname=gm.gname -- そのユーザが属している
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3356 AND user='$user') g -- グループに絞る
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3357 WHERE (SELECT author FROM writeusers
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3358 EXCEPT
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3359 SELECT user FROM grp_mem gm WHERE gm.gname = g.gname)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3360 IS NULL;
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3361 $2
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3362 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3363 }
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3364 sql4readableblogs() {
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3365 # Create view of blogs that can be readable by $user
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3366 # Blog is readable when:
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3367 # 1: blog owner is an user
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3368 # 2: else, 2.1: owner-group where the $user belongs
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3369 # 2.2: else, owner-group is not moderated
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3370 # blog(id, author), blog_s(id, key='owner', val= ->owner)
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3371
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3372 # $hidden_mode is defined in global section at head
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3373
300
973fb0ea5c2f Send direct message with sender's From:
HIROSE Yuuji <yuuji@gentei.org>
parents: 299
diff changeset
3374 cat<<EOF ## | tee tmp/sql.out
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3375 CREATE TEMPORARY VIEW readableblogs AS
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3376 SELECT blog.rowid rid, id, author
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3377 FROM blog
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3378 NATURAL JOIN
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3379 (SELECT id,
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3380 max(CASE key WHEN 'owner' THEN val END) owner,
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3381 max(CASE key WHEN 'mode' THEN val END) mode
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3382 FROM blog_s GROUP by id) bs
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3383 WHERE CASE WHEN (SELECT name FROM user where name=bs.owner) IS NOT NULL
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3384 THEN -- blog owner is an user, READABLE
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3385 NOT mode IN $hidden_mode
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3386 WHEN (SELECT val FROM grp_s
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3387 WHERE gname=bs.owner AND key='regmode') = 'moderated'
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3388 AND
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3389 (SELECT user FROM grp_mem
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3390 WHERE gname=bs.owner AND user='$user') IS NULL
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3391 THEN 0
957
4961963431f9 Exclude quiz/enquete articles from new posts list of other users
HIROSE Yuuji <yuuji@gentei.org>
parents: 955
diff changeset
3392 WHEN mode IN $hidden_mode
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3393 THEN 0 -- "quiz" mode blog cannot be searched
245
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3394 ELSE 1
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3395 END;
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3396 EOF
b915381669d6 Do not search from unreadable blogs
HIROSE Yuuji <yuuji@gentei.org>
parents: 243
diff changeset
3397 }
860
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3398 mvteamform() {
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3399 owner=$1
861
81063a4b220f Only assign team to new blog where user is belonging
HIROSE Yuuji <yuuji@gentei.org>
parents: 860
diff changeset
3400 hexteams=$(hexteams "$owner" "$user")
860
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3401 test -z "$hexteams" && return
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3402 none="`echo なし|hexize`"
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3403 cat<<-EOF
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3404 <!-- <div class="fold">
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3405 `cgi_checkbox mv2team send id="mv2team"`<label
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3406 for="mv2team">この話題を以下のチームのものにする</label>
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3407 <div> -->
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3408 <p>この話題をチーム所有にする:
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3409 チーム: `cgi_select_h mv2team $none $hexteams`</p>
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3410 </form></div></div>
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3411 EOF
7cb0edec73bd Allow users to assign team name to new blog
HIROSE Yuuji <yuuji@gentei.org>
parents: 858
diff changeset
3412 }
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3413 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
3414 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
3415 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
3416 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
3417 return
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3418 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3419 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
3420 title=`getvalbyid blog title $rowid`
121
34b72806cd22 Too much quoting
HIROSE Yuuji <yuuji@gentei.org>
parents: 120
diff changeset
3421 GF_ACTION="?blog" edittable $formdir/blog.def blog $rowid \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3422 | _m4 -D_TITLE_="修正" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3423 -D_SUBTITLE_="[$title]@$owner" -D_DIARY_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3424 -D_BLOGS_="" -D_DUMPTABLE_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3425 -D_FORM_="syscmd(\`cat')" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3426 $layout/html.m4.html $layout/form+dump.m4.html
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3427 # Move to group
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3428 if isuser "$owner"; then
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3429 crview4article $rowid
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3430 n=`query "SELECT count(*) FROM writeusers;"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3431 ## err N=$n
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3432 if [ $((n)) -gt 0 ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3433 ## err ROWID=$rowid
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3434 sql="SELECT growid || ':' || gname FROM movablegroups;"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3435 cat<<-EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3436 <div class="fold">
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3437 `cgi_checkbox mv send id="mv"`<label
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3438 for="mv">この話題をグループ所有に移動する</label>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3439 <div>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3440 <form action="?mvart" method="POST" enctype="multipart/form-data">
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3441 移動先グループ:
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3442 <select name="mv2grp">
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3443 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3444 query ".mode html"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3445 query<<-EOF |
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3446 $sql
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3447 .mode list
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3448 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3449 sed -e '/<\/TR>/d' -e 's,<TR>,,' -e 's,TD>,option>,g' \
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3450 -e 's,n>\([0-9]*\):\(.*\)<,n value="\1">\2<,'
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3451 cat<<-EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3452 </select>
214
e4dd3cf443b0 Add comment to article moving page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 213
diff changeset
3453 <p>(移動できるグループは、この「話題」に書き込んでいる人全てが
e4dd3cf443b0 Add comment to article moving page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 213
diff changeset
3454 そのグループに加入しているものに限られます)</p>
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3455 <p>`cgi_checkbox cfm yes`<label>確認
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3456 (この操作は元に戻すことができません)</label></p>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3457 `cgi_hidden blogrowid $rowid`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3458 `cgi_submit 移動`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3459 `cgi_reset Reset`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3460 </form>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3461 </div>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3462 </div>
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3463 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3464 fi
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3465 # end of isuser "$owner"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3466 elif { hexteams=$(hexteams "$owner" ) # blog is of GROUP
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3467 [ -n "$hexteams" ];}; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3468 none="`echo なし|hexize`"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3469 cat<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3470 <div class="fold">
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3471 `cgi_checkbox mv2team send id="mv2team"`<label
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3472 for="mv2team">この話題を以下のチームのものにする</label>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3473 <div><p>現在の所属チーム設定:
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3474 `query "SELECT
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3475 coalesce((SELECT val FROM blog_s
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3476 WHERE id=(SELECT id FROM blog WHERE rowid=$rowid)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3477 AND key='team'),
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3478 ':なし');"`</p>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3479 <form action="?mvart" method="POST" enctype="multipart/form-data">
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3480 移動先チーム: `cgi_select_h mv2team $none $hexteams`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3481 <p>`cgi_checkbox cfm yes`<label>確認</label></p>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3482 `cgi_hidden blogrowid $rowid`<br>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3483 `cgi_submit 移動`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3484 `cgi_reset Reset`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3485 </form></div></div>
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3486 EOF
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3487 fi
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3488 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3489 mvart() { # move diary to some group or team
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3490 # or move blog of group to team which belong to the group
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3491 blogrowid=`getpar blogrowid`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3492 cfm=`getpar cfm`
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3493 ##### echo move blog:$blogrowid to $mv2grp | html p
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3494 blogrowid=${blogrowid%%[!A-Z0-9a-z_]*} # Purify
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3495 . ./s4-blog.sh
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3496 if [ -z "$blogrowid" ]; then
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3497 echo "無効な指定です(mvart)。" | html p
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3498 return
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3499 elif [ x"$cfm" != x"yes" ]; then
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3500 echo "記事移動の確認にチェックがないので通常表示に戻ります。" | html p
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3501 elif { mv2grp=`getpar mv2grp`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3502 mv2grp=${mv2grp%%[!A-Z0-9a-z_]*} # Purify
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3503 [ -n "$mv2grp" ]; }; then
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3504 crview4article $blogrowid
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3505 ########## TRANSACTION BEGIN
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3506 query "BEGIN;"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3507 n=`query "SELECT count(*) FROM writeusers;"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3508 ## err Nwriteuser=$n
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3509 if [ $((n)) -gt 0 ]; then
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3510 query<<-EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3511 UPDATE blog_s SET val=(SELECT gname FROM grp WHERE rowid=$mv2grp)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3512 WHERE key='owner'
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3513 AND id=(SELECT id FROM blog WHERE rowid=$blogrowid)
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3514 AND $mv2grp IN (SELECT growid FROM movablegroups);
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3515 EOF
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3516 fi
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3517 query "END;"
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3518 ########## TRANSACTION END
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3519 elif { mv2team=`getpar mv2team|sed "s/'/''/g"`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3520 [ -n "$mv2team" ];}; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3521 # blog owner can move it to ANY team
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3522 case "$mv2team" in
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3523 'なし')
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3524 cat<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3525 DELETE FROM blog_s
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3526 WHERE id=(SELECT id FROM blog WHERE rowid=$blogrowid)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3527 AND key='team';
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3528 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3529 ;;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3530 "") ;;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3531 *)cat<<-EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3532 BEGIN;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3533 REPLACE INTO blog_s(id, key, val)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3534 VALUES((SELECT id FROM blog WHERE rowid=$blogrowid),
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3535 'team', '$mv2team');
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3536 REPLACE INTO blog_s(id, key, val)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3537 VALUES((SELECT id FROM blog WHERE rowid=$blogrowid),
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3538 'notify', 'all'); -- Change notify to all
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3539 END;
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3540 EOF
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3541 esac | query
213
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3542 fi
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3543 blog_reply $blogrowid
ca7e27d9224e Add feature of moving article from personal diary to group board.
HIROSE Yuuji <yuuji@gentei.org>
parents: 210
diff changeset
3544 echo yes | html p
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3545 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3546 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
3547 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
3548 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
3549 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
3550 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
3551 return
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3552 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3553 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
3554 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
3555 author=`getvalbyid article author $rowid`
946
420ad90116e6 MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents: 942
diff changeset
3556 math=`getvalbyid blog mathjax $blogrowid`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3557 ## err EDITart: owner=$owner, author=$author
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
3558 if isgrpowner "$user" "$owner"; then
79
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3559 : EDIT OK
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3560 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
3561 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
3562 return
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3563 fi
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3564 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
3565 tmpout=$tmpd/editart.$$.out
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
3566 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
3567 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
3568 > $tmpout
946
420ad90116e6 MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents: 942
diff changeset
3569 printf '%s' "${math:+$mathjax}" >> $tmpout
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
3570 # Cannot use pipelining to m4 with genform() because of stdin stack
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3571 _m4 -D_TITLE_="コメントの修正" -D_DIARY_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3572 -D_FORM_="syscmd(cat $tmpout)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3573 -D_SUBTITLE_="`gecos $owner`の「$title」" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3574 -D_BLOGS_= -D_DUMPTABLE_= \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3575 $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
3576 }
f088d45dfdf2 Code cleaning: move substantial jobs from s4.cgi to s4-funcs.sh
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
3577 send2mem() {
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3578 rowid=`getpar grp`
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3579 rowid=${rowid%%[!0-9]*} # Cleaning
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3580 if [ -z "$rowid" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3581 echo "グループが未指定です。" | html p
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3582 return
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3583 fi
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3584 message=`getpar message`
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3585 if [ -z "$message" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3586 echo "文章を入れてください。" | html p
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3587 return
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3588 fi
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3589 grp=`getgroupbyid $rowid`
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
3590 members=`collectemail "$grp"`
630
8874225971ff Test of setting Reply-to header
HIROSE Yuuji <yuuji@gentei.org>
parents: 628
diff changeset
3591 myuid=`query "SELECT rowid FROM user WHERE name='$user';"`
8874225971ff Test of setting Reply-to header
HIROSE Yuuji <yuuji@gentei.org>
parents: 628
diff changeset
3592 mailfrom=`email4groupbyuid "$grp" "$myuid" | sed -e 1q -e 's/[ ,].*//'`
655
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3593 mailfrom="`gecos "$user"` <$mailfrom>"
749
f9f88278f6a0 Use htmlescape more places
HIROSE Yuuji <yuuji@gentei.org>
parents: 747
diff changeset
3594 sj="グループ「$grp」宛メッセージ(from `gecos $user`)"
655
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3595 msg=$(cat<<-EOF
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3596 $urlbase?grp+$rowid
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3597 グループ $grp に所属する
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3598 `gecos $user` さんよりメッセージ:
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3599
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3600 $message
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3601 EOF
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3602 )
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3603 # smail rcpt subj (file)
655
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3604 for m in $members; do
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3605 echo "$msg" |
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3606 MAIL_FROM=$mailfrom \
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3607 SENDER=$noreply \
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3608 REPLYTO=$mailfrom \
682
b1298ce80625 Group-mail sending too much, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 679
diff changeset
3609 smail "$m" "$sj"
655
a049d3cb0389 Send group-mail each member respectively
HIROSE Yuuji <yuuji@gentei.org>
parents: 654
diff changeset
3610 done
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3611 cat<<EOF
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3612 <p>以下のユーザに送信しました。</p>
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3613 <pre>
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 440
diff changeset
3614 `collectgecosesbyid "$rowid" | sed 's/$/ さん/'`
26
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3615 </pre>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3616 <p><a href="?grp+$rowid">グループ $grp</a>に戻る。</p>
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3617 EOF
514acfff7453 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 22
diff changeset
3618 }
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3619 joingrpadmit() {
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3620 # $1=yes/no $2=session-key
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3621 if [ -z "$2" ]; then
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3622 echo "bye bye" | html p; return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3623 fi
737
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
3624 t_usr=`session=$2 getpar adduser`
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3625 t_grp=`session=$2 getpar group`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3626 ## err joingrpadmit: t_usr=$t_usr, t_grp=$t_grp
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
3627 _m4 -D_TITLE_="joingrp" $layout/html.m4.html
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3628 if [ -z "$t_usr" -o -z "$t_grp" ]; then
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3629 echo "無効な加入依頼です。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3630 echo "有効期限が切れたか、
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3631 他の管理者がいる場合は処理済みの可能性があります。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3632 return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3633 fi
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
3634 if ! isgrpowner "$user" "$t_grp"; then
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3635 echo "グループ管理者のみの機能です。" | html p; return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3636 fi
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3637 case $1 in
308
e38ea2702570 Call joingrp() without $4(extra email address)
HIROSE Yuuji <yuuji@gentei.org>
parents: 307
diff changeset
3638 yes) joingrp "$t_grp" "$t_usr" yes ;;
e38ea2702570 Call joingrp() without $4(extra email address)
HIROSE Yuuji <yuuji@gentei.org>
parents: 307
diff changeset
3639 no) joingrp "$t_grp" "$t_usr" no ;;
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3640 *)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3641 echo "無効な指定です($1)。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3642 return ;;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3643 esac
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
3644 gid=$(query "select rowid from grp where gname=`sqlquote \"$t_grp\"`;")
768
891f1f5a8153 Allow spaces in group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 763
diff changeset
3645 rcpts="`getgroupadminmails "$t_grp"` $user"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3646 ## err admit: msgdir=$msgdir, rcpts="["$rcpts"]"
775
2c5a8c5dd1ee Fix sending message of joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 769
diff changeset
3647 body="に
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3648 $t_usr
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3649 `[ x$1 = xyes ] && echo 'を追加' || echo 'の解除操作を'`
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3650 しました。"
775
2c5a8c5dd1ee Fix sending message of joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 769
diff changeset
3651 echo "$t_grp$nl$body$nl$nl$url?grp+$gid" | smail "$rcpts" "joingrp $1"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3652 query "delete from session where id='$2';"
775
2c5a8c5dd1ee Fix sending message of joingrp()
HIROSE Yuuji <yuuji@gentei.org>
parents: 769
diff changeset
3653 echo "グループ <a href=\"?grp+$gid\">$t_grp</a>$nl$body" | html p
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3654 }
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3655
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3656 joingrprequest() {
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3657 # $1=group $2=user $3=yes/no $4=email(if any $5=AsAdmin)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3658 jss="joingrp-`date +%s`-`genrandom 12`"
963
8afc139044f1 Add gecos to joingrprequest()
HIROSE Yuuji <yuuji@gentei.org>
parents: 962
diff changeset
3659 gecos=`gecos "$user"`
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3660 addsession $jss +${memoplimitdays}days
768
891f1f5a8153 Allow spaces in group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 763
diff changeset
3661 grpadmins=`getgroupadmins "$1"`
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
3662 query "replace into par values('$jss', 'group', 'string', `sqlquote \"$1\"`),
737
441768a11b84 Joingrp use var-name adduser instead of user
HIROSE Yuuji <yuuji@gentei.org>
parents: 736
diff changeset
3663 ('$jss', 'adduser', 'string', `sqlquote \"$user\"`);"
768
891f1f5a8153 Allow spaces in group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 763
diff changeset
3664 smail "$(collectemail $grpadmins)" "Join request to $1"<<EOF
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3665 $url
963
8afc139044f1 Add gecos to joingrprequest()
HIROSE Yuuji <yuuji@gentei.org>
parents: 962
diff changeset
3666 $user ${gecos:+($gecos)}さんから
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3667 グループ $1
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3668 に加入依頼がありました。
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3669
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3670 承認する:
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3671 $urlbase?joingrpadmit+yes+$jss
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3672
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3673 白紙に戻す:
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3674 $urlbase?joingrpadmit+no+$jss
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3675 EOF
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3676 echo "管理者に加入依頼を出しました。
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3677 ${memoplimitdays}日以内に加入承認操作がされれば加入できますが、
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3678 グループ運用方針に懸かることですので直接の問い合わせが重要です。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3679 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3680 joingrp() {
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3681 # $1=group $2=user $3=yes/no $4=email(if any $5=AsAdmin)
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3682 ## err joingrp: \$1=$1 \$2=$2 \$3=$3 \$4=$4
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3683 if isgrpowner "$user" "$1"; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3684 isowner="yes"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3685 elif [ -n "$5" ]; then
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3686 isowner="yes"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3687 else
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3688 isowner=""
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3689 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3690 ## err jg:isgrpowner: isowner="$isowner"
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3691 if [ -n "$isowner" ]; then
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
3692 : # GROUP OWNER CAN DO EVERYTHING ABOUT REGISTRATION/RETIREMENT
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3693 elif [ x"$2" != x"$user" ]; then # if user is not login user
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3694 echo "本人か、グループ管理者しか加入操作はできません。" | html p
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3695 return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3696 elif [ x"$3" = x"no" ]; then
120
d870eaf0e4dd Revert to "sq $db"
HIROSE Yuuji <yuuji@gentei.org>
parents: 119
diff changeset
3697 : # Do not pursue those who leave
271
a8bb72580c91 Member can change own email address for the joining moderated group
HIROSE Yuuji <yuuji@gentei.org>
parents: 270
diff changeset
3698 elif [ x"$3" = x"yes" ] && ismember "$user" "$grp"; then
a8bb72580c91 Member can change own email address for the joining moderated group
HIROSE Yuuji <yuuji@gentei.org>
parents: 270
diff changeset
3699 : # Member can change own email address for the joining moderated group
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3700 else # adding user is $user itself
768
891f1f5a8153 Allow spaces in group name
HIROSE Yuuji <yuuji@gentei.org>
parents: 763
diff changeset
3701 case `getgroupattr "$1" regmode` in
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3702 moderated)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3703 joingrprequest "$@" # Request only
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3704 return
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3705 ;;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3706 *)
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3707 ;;
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 113
diff changeset
3708 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
3709 fi
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
3710 qgname=`sqlquote "$1"`
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3711 grid=`query "SELECT rowid FROM grp WHERE gname=$qgname;"`
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3712 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
3713 if [ x"$3" = x"yes" ]; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3714 query "replace into grp_mem values($qgname, '$2');"
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3715 # Notify joingrp to admin
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3716 action="に加入しました。"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3717 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
3718 if msg=`emaildomaincheck "$4"`; then
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3719 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
3720 'string', '$4', NULL);"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3721 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
3722 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
3723 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
3724 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
3725 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
3726 fi
306
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3727 if [ -n "$5" ]; then # as ADMIN
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3728 # Coming here means newly created group
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3729 sql="select case\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3730 when (select count(*) from grp_mem where gname=$qgname)=1\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3731 then (select user from grp_mem\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3732 where gname=$qgname and user='$user')\
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3733 else '' end; "
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3734 err NewGrpChk: $sql
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3735 if [ -n "`query \"$sql\"`" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
3736 ## err ADMIN: "replace into grp_adm values($qgname, '$user');"
306
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3737 query "replace into grp_adm values($qgname, '$user');"
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3738 fi
827dd5d8653e Set admin value to $5 when $4 is empty(in joingrp())
HIROSE Yuuji <yuuji@gentei.org>
parents: 305
diff changeset
3739 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
3740 else
555
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3741 query "begin;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3742 delete from grp_mem $cond;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3743 delete from grp_mem_s $cond;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3744 delete from grp_mem_m $cond;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3745 delete from grp_adm $cond;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3746 delete from grp_adm_s $cond;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3747 delete from grp_adm_m $cond;
7e7b3b2822f6 Remove retiring user from grp-admin.
HIROSE Yuuji <yuuji@gentei.org>
parents: 554
diff changeset
3748 end;"
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3749 action="から脱退しました。"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3750 fi
614
962c954715b8 smail_queue() initially implemented
HIROSE Yuuji <yuuji@gentei.org>
parents: 613
diff changeset
3751 smail_queue "$(collectemail `getgroupadmins $1`)" "Member change of $1"<<-EOF
424
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3752 $url?grp+$grid
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3753 $user (`gecos $user`)さんが
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3754 グループ $1
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3755 $action
c250bc6da8ad Notify group join/resign of group to adminsl
HIROSE Yuuji <yuuji@gentei.org>
parents: 418
diff changeset
3756 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
3757 }
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3758 grp_add_team() (
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3759 # $1=grp-rowid $2=team $3...=user-rowid(s)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3760 grp=`getgroupbyid $1`
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3761 team=$2; shift; shift
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3762 [ -z "$grid" -o -z "$team" -o -z "$1" ] && return
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3763 { echo "BEGIN;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3764 for user; do
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3765 echo "REPLACE INTO grp_mem_m(gname, user, key, type, val) VALUES(\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3766 '$grp',\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3767 (SELECT name FROM user WHERE rowid=$user),\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3768 'team', 'string', '$team');"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3769 done
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3770 echo "END;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3771 } | query
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3772 )
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3773 grp_rm_team() (
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3774 # $1=grp-rowid $2=team $3...=user-rowid(s)
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3775 grid=$1
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3776 qgrp=$(sqlquote "`getgroupbyid $grid`")
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3777 team=$2; shift; shift
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3778 [ -z "$grid" -o -z "$team" ] && return
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3779 { echo "BEGIN;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3780 for user; do
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3781 echo "DELETE FROM grp_mem_m\
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3782 WHERE gname=$qgrp \
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3783 AND user=(SELECT name FROM user WHERE rowid=$user)\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3784 AND key='team' AND val='$team';"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3785 done
228
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3786 cat<<-EOF
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3787 DELETE FROM blog_s
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3788 WHERE rowid=(
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3789 SELECT rowid
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3790 FROM blog_s a
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3791 WHERE key='team'
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3792 AND id IN (SELECT id FROM blog_s WHERE key='owner' AND val=$qgrp)
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3793 AND NOT EXISTS (SELECT * FROM grp_mem_m
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3794 WHERE key='team' AND val=a.val -- a.val=team
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3795 AND gname = (SELECT val FROM blog_s b
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3796 WHERE a.id=b.id AND key='owner')
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3797 ));
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3798 EOF
ab1693ac909a Avoid reusing variable
HIROSE Yuuji <yuuji@gentei.org>
parents: 227
diff changeset
3799
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3800 echo "END;"
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3801 } | query
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 220
diff changeset
3802 )
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3803 grp_reg_adm() {
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3804 # $1=grp-rowid $2...=user-rowid
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3805 grid=$1
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3806 grp=`getgroupbyid "$1"`
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3807 if [ -z "$grp" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3808 echo "無効なグループIDです" | html p; return
33
54dba4c5e61d Use group-id, not gname
HIROSE Yuuji <yuuji@gentei.org>
parents: 31
diff changeset
3809 fi
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
3810 if ! isgrpowner "$user" "$grp"; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
3811 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
3812 fi
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3813 shift
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3814 for urid; do
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3815 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
3816 if [ -z "$newadm" ]; then
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3817 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
3818 fi
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
3819 err GRP_reg_adm: "replace into grp_adm values(`sqlquote \"$grp\"`, '$newadm');"
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3820 err ismember $newadm $grp
434
cf20459261cb Quote $grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 433
diff changeset
3821 if ismember $newadm "$grp"; then
153
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3822 # OK, go ahead
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3823 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
3824 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
3825 # confirm insertion
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3826 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
3827 if [ -n "`query \"$sql;\"`" ]; then
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3828 echo "追加完了: $newadm" | html p
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3829 else
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3830 echo "追加失敗($1 $urid)" | html p
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3831 fi
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3832 fi
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3833 showgroup $grid
f7b4f7e5df2a Commission of grp_adm pulled back into grpaction()
HIROSE Yuuji <yuuji@gentei.org>
parents: 151
diff changeset
3834 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
3835 }
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3836 dt_colhack() {
905
5acef432b1de TD-class delimiter changed to :::
HIROSE Yuuji <yuuji@gentei.org>
parents: 897
diff changeset
3837 # FROM: <TD>xxx:::yyy</TD>
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3838 # TO: <TD class="xxx">yyy</TD>
905
5acef432b1de TD-class delimiter changed to :::
HIROSE Yuuji <yuuji@gentei.org>
parents: 897
diff changeset
3839 sed -Ee 's,<TD>([^:<"]+)'$asdelim'([^<]*)(</TD>|$),<TD class="\1">\2\3,g'
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3840 }
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3841 dt_rowhack() {
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3842 # From: <TR>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3843 # ....
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3844 # <TD>rowclass=foo</TD>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3845 # </TR>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3846 # To: <TR class="foo">....<TD>foo</TD></TR>
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3847 sed -e '
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3848 /^<TR>/ {
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3849 :loop
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3850 s/\n//
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3851 N
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3852 /<\/TR>/ {
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3853 s/\n//
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3854 s,^<TR>\(.*\)<TD\([^>]*\)>rowclass=\(.*\)\(</TD></TR>\),<TR class="\3">\1<TD\2>\3\4,
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3855 n
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3856 }
400
0a5fdb619325 $p produces duplicated final line on gsed(fixed)
HIROSE Yuuji <yuuji@gentei.org>
parents: 398
diff changeset
3857 $q
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3858 b loop
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3859 }'
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3860 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3861 dumptable() {
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3862 # $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
3863 # 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
3864 # $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
3865 # 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
3866 ### 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
3867 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
3868 if [ -n "$VIEW" ]; then
362
955cd7b517d3 Anchor of link-to-bottom expands from `W' to `EW'
HIROSE Yuuji <yuuji@gentei.org>
parents: 361
diff changeset
3869 dvlink=" <a href=\"$myname?$VIEW+\\2\\3\">VI</a><a href=\"$myname?$VIEW+\\2#bottom\">EW</a>"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3870 fi
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3871 sqlfile=$tmpd/dump.sql
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3872 : > $sqlfile # ensure to be empty
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3873 printf '.mode html\n.header 1\n' > $sqlfile
1004
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3874 # $DT_CHLD=ChildTable:BindColumn (eg. article:blogid)
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3875 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
3876 _t=${DT_CHLD%:*} _i=${DT_CHLD#*:}
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3877 cat<<-EOF >> $sqlfile
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3878 -- presql
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3879 CREATE TEMPORARY TABLE IF NOT EXISTS myacclog AS
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3880 SELECT * FROM acclog WHERE user='$user' and tbl='$2';
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3881 EOF
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3882 # Speed up counting of new articles
1004
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3883 dt_count=${DT_COUNT:+"CREATE TEMPORARY VIEW _dtcount AS
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3884 SELECT a.id $_i, $DT_COUNT, coalesce(cnt2, 0) cnt2
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3885 FROM (SELECT DISTINCT id FROM _target) a
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3886 LEFT JOIN
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3887 (SELECT blogid,$DT_COUNT,count($DT_COUNT) cnt2
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3888 FROM $_t
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3889 WHERE $DT_COUNT = '$DT_COUNT_BY'
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3890 GROUP BY $_i,$DT_COUNT) b
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3891 ON a.id=b.$_i
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3892 ;"}
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3893 cat<<-EOF >> $sqlfile
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3894 -- presql2
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3895 DROP TABLE IF EXISTS _counts;
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3896 CREATE TEMPORARY TABLE _counts AS
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3897 SELECT $_i, count($_i) cnt
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3898 FROM $_t GROUP BY $_i;
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3899 /* Prepare NEW count table */
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3900 CREATE TEMPORARY TABLE _target AS
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3901 SELECT b.rowid trowid, b.id
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3902 FROM "$2" b JOIN "$2_s" s
566
2d1d651aa1f2 $DT_SQL handling fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 565
diff changeset
3903 ON b.id=s.id AND s.key='owner'
2d1d651aa1f2 $DT_SQL handling fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 565
diff changeset
3904 ${DT_QOWNER:+ AND s.val=$DT_QOWNER};
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3905
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3906 DROP TABLE IF EXISTS _children;
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3907 CREATE TEMPORARY TABLE _children AS
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3908 SELECT a.trowid trowid, $_i, a.id, s.val ctime
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3909 FROM (SELECT t.trowid, t.id $_i, a.id
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3910 FROM _target t LEFT JOIN "$_t" a ON t.id=a.$_i) a
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3911 LEFT JOIN ${_t}_s s ON a.id=s.id AND s.key='ctime';
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3912
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3913 DROP TABLE IF EXISTS _news;
569
81b5ec847687 Turn off debug sql logging
HIROSE Yuuji <yuuji@gentei.org>
parents: 568
diff changeset
3914 DROP VIEW IF EXISTS _news;
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3915
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3916 -- CREATE TEMPORARY TABLE _news($_i, newcnt);
569
81b5ec847687 Turn off debug sql logging
HIROSE Yuuji <yuuji@gentei.org>
parents: 568
diff changeset
3917 -- INSERT INTO _news
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
3918 /* **COMPARE** the efficiency of TEMP-TABLE and VIEW !!! */
569
81b5ec847687 Turn off debug sql logging
HIROSE Yuuji <yuuji@gentei.org>
parents: 568
diff changeset
3919 CREATE TEMPORARY VIEW _news AS
81b5ec847687 Turn off debug sql logging
HIROSE Yuuji <yuuji@gentei.org>
parents: 568
diff changeset
3920 SELECT a.id $_i, coalesce(newcnt, 0) newcnt
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3921 FROM (SELECT DISTINCT id FROM _target)
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3922 a LEFT JOIN
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3923 (SELECT $_i, count(ctime) newcnt
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3924 FROM _children x
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3925 WHERE ctime > coalesce((SELECT time from myacclog
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3926 WHERE tblrowid=x.trowid),
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3927 '1970-01-01')
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3928 GROUP BY $_i) b
569
81b5ec847687 Turn off debug sql logging
HIROSE Yuuji <yuuji@gentei.org>
parents: 568
diff changeset
3929 ON a.id=b.$_i;
1004
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3930 $dt_count
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3931 EOF
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3932 cntall="(coalesce((select cnt from _counts where $_i=a.id), 0))"
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3933 cntnew="(SELECT newcnt FROM _news where $_i=a.id)"
1004
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3934 cntmine=${DT_COUNT:+"(SELECT cnt2 FROM _dtcount WHERE $_i=a.id)"}
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3935 cnt="$cntnew as '新着', $cntall as '総数', "
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3936 cnt=$cnt${DT_COUNT:+"$cntmine as '$DT_COUNT_HEADER',"}
70d9e8f1a85a Show user's post count in the blog table of group home
HIROSE Yuuji <yuuji@gentei.org>
parents: 1003
diff changeset
3937 dt_class=" td2r td3r td4r dumpblogs"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3938 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
3939 # 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
3940 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
3941 pk=`gettblpkey $2`
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3942 substr=${dumpcollen:+"substr(%s, 0, $dumpcollen)"}
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3943 substr=${substr:-%s}
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3944 for col in ${3:-`gettbl_s_cols $2`}; do
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3945 valvar=val
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3946 fromtbl=b
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3947 if gettblcols "$2" | grep -w "$col" >/dev/null 2>&1; then
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3948 # If $col belongs to master table
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3949 fromtbl=a; col=${col#a.}
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3950 fi
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3951 case $col in
60
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3952 gecos) scols="$scols${scols:+, }${col#}"
9f4e85181d40 Add new articles digest
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
3953 continue ;; # built-in column name
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3954 *:*) as=${col#*:} # as can be 稼動状態:frozen=凍結中
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3955 col=${col%%:*} # stage:稼動状態:frozen=凍結中 -> stage
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3956 case "$as" in
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3957 *:*=*) cnd=${as#*:}
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3958 h=${cnd%%=*} v=${cnd#*=}
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3959 h=`sqlquotestr "$h"`
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3960 v=`sqlquotestr "$v"`
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3961 if [ x"$fromtbl" = x"b" ]; then
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3962 valvar="CASE val WHEN $h THEN $v END"
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3963 else
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3964 valvar="$h"
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3965 fi
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3966 as=${as%%:*} ;;
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3967 esac
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3968 ;;
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3969 *) as=${col} ;;
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
3970 esac
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 396
diff changeset
3971 ss=`printf "$substr" "$valvar"`
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3972 if [ x"$fromtbl" = x"b" ]; then
905
5acef432b1de TD-class delimiter changed to :::
HIROSE Yuuji <yuuji@gentei.org>
parents: 897
diff changeset
3973 eav=$eav${eav:+,}" \"$as$asdelim\"||coalesce(max(case key when '$col' then $ss end), '') as $as"
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3974 else
905
5acef432b1de TD-class delimiter changed to :::
HIROSE Yuuji <yuuji@gentei.org>
parents: 897
diff changeset
3975 eav=$eav${eav:+,}" \"$as$asdelim\"||$ss as $as"
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3976 fi
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
3977 scols="$scols${scols:+, }${fromtbl}.$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
3978 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
3979 #case author when '$user' then a.rowid else '---' end as ID,
566
2d1d651aa1f2 $DT_SQL handling fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 565
diff changeset
3980 if [ -n "$DT_SQL" ]; then
565
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3981 echo "$DT_SQL"
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3982 else
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3983 cat<<-EOF
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3984 SELECT a.rowid as LINK, $cnt $scols
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3985 FROM $2 a LEFT JOIN
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3986 (SELECT $pk,$eav,
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3987 max(CASE key
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3988 WHEN 'owner'
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3989 THEN (SELECT gecos FROM gecoses WHERE name=val) END)
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3990 as gecos
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3991 FROM ${2}_s c GROUP BY $pk)
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3992 b ON a.$pk=b.$pk $4;
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3993 EOF
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3994 fi >> $sqlfile
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3995 ## err dt:SQL="`echo \"$presql$presql2$sql\"|tr -d '\n'`"
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3996 sqlog<<-EOF
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3997 *** SQL-file: $sqlfile ***
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3998 `cat $sqlfile`
b87e1cbf3491 Make it faster to count all/new articles in group home.
HIROSE Yuuji <yuuji@gentei.org>
parents: 562
diff changeset
3999 EOF
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
4000 printf '.mode list\n.header 0\n' >> $sqlfile
889
5843755e3b30 The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents: 888
diff changeset
4001 cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)\(#[0-9a-fxs]*\)*</TD>,\1$elink$dvlink</TD>," | dt_colhack | dt_rowhack
200
ffc676bd8277 Protect div.dumptable from div.fold
HIROSE Yuuji <yuuji@gentei.org>
parents: 196
diff changeset
4002 <div> <!-- for folding by check button (s4-funcs.sh:dumptable()) -->
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4003 <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
4004 <table class="b$dt_class">
568
3cb5c360e1bf Try to speed up user-home summary construction.
HIROSE Yuuji <yuuji@gentei.org>
parents: 567
diff changeset
4005 `query ".read $sqlfile"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4006 </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
4007 </div> <!-- dumptable -->
200
ffc676bd8277 Protect div.dumptable from div.fold
HIROSE Yuuji <yuuji@gentei.org>
parents: 196
diff changeset
4008 </div> <!-- for folding by check button (s4-funcs.sh:dumptable()) -->
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4009 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
4010 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4011
1027
f389a311a8d4 Rename function name
HIROSE Yuuji <yuuji@gentei.org>
parents: 1026
diff changeset
4012 clean_orphaned() {
758
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4013 # This shoud be done by foreign_key rules, but some db lack them
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4014 query<<-EOF
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4015 -- Find blogs that have no parent
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4016 WITH orphanedblog AS (
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4017 SELECT blog.id,val FROM blog JOIN blog_s bs
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4018 ON blog.id=bs.id AND key='owner'
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4019 WHERE val NOT IN (SELECT gname FROM grp)
812
31df689bad63 Oops, WITH clause error.
HIROSE Yuuji <yuuji@gentei.org>
parents: 810
diff changeset
4020 AND val NOT IN (SELECT name FROM user)
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4021 ) -- Remove them
758
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4022 DELETE FROM blog WHERE id IN (SELECT id FROM orphanedblog);
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4023
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4024 -- Find articles that have no parent blog
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4025 WITH orphanedarticle AS (
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4026 SELECT id FROM article
812
31df689bad63 Oops, WITH clause error.
HIROSE Yuuji <yuuji@gentei.org>
parents: 810
diff changeset
4027 WHERE blogid NOT IN (SELECT id FROM blog)
791
567980314463 World and Migration structures refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 789
diff changeset
4028 ) -- Remove them
758
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4029 DELETE FROM article WHERE id IN (SELECT id FROM orphanedarticle);
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4030 EOF
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4031 }
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4032
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4033 clearcachedir() (
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4034 td=`getcachedir "$1"`
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4035 err td=$td: ls- `ls $td`
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4036 if [ -w "$td/image.1" ]; then
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4037 err Removing td=$td
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4038 rm -fr $td/ # Clear icon-image cache!
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4039 fi
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4040 )
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4041
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4042 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
4043 # 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
4044 # $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
4045 # Using $user and $session
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4046 # Return value:
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4047 # 0: Stored successfully
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4048 # 1: Insufficient fillings
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4049 # 2: No permission to modify the record
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4050 # 3: Invalid rowid
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4051 # 4: SUCCESS to delete
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4052 # 5: Stop deletion for lack of confirm check
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4053 # 6: Password length too short
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4054 # 7: Password mismatch
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4055 # 8: Old password incorrect
730
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4056 # 9: Duplicated post
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4057 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
4058 if [ ! -e $1 ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
4059 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
4060 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
4061 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
4062 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
4063 tbl=${tbl##*/}
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 1
diff changeset
4064 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
4065 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
4066 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
4067 elif [ x"$tbl" = x"grp" ]; then
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
4068 sql="select gname from $tbl where rowid=$rowid;"
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
4069 ##err p2t:grp:q $sql
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 435
diff changeset
4070 isgrpowner "$user" "`query $sql`" && rowowner=$user
585
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4071 elif [ x"$tbl" = x"blog" ]; then
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4072 # Check if owner in blog_s
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4073 blogowner=`getvalbyid blog owner "$rowid"`
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4074 if isgrpowner "$user" "$blogowner"; then
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4075 rowowner=$user
951
41032d34324d Keep original author even if group admin edits heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 950
diff changeset
4076 origauthor=`getvalbyid blog author $rowid`
41032d34324d Keep original author even if group admin edits heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 950
diff changeset
4077 if [ -n "$origauthor" -a x"$user" != x"$origauthor" ];
41032d34324d Keep original author even if group admin edits heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 950
diff changeset
4078 then # Keep original author
41032d34324d Keep original author even if group admin edits heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 950
diff changeset
4079 setpar author string "$origauthor" # if differs from $user
41032d34324d Keep original author even if group admin edits heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 950
diff changeset
4080 fi # 2021-11-06 suggd.by Ruri
585
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4081 else
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4082 rowowner=`query "SELECT author FROM $tbl WHERE rowid=$rowid;"`
dfa90fbc05bd Group admin can edit any blog attributes.
HIROSE Yuuji <yuuji@gentei.org>
parents: 581
diff changeset
4083 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
4084 else
394
f095e97066c5 Remove "SELECT owner"
HIROSE Yuuji <yuuji@gentei.org>
parents: 393
diff changeset
4085 # 2016-12-05 There's no owner column in $tbl (need confirmation)
f095e97066c5 Remove "SELECT owner"
HIROSE Yuuji <yuuji@gentei.org>
parents: 393
diff changeset
4086 rowowner=`query "SELECT author FROM $tbl WHERE rowid=$rowid;"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4087 fi
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
4088 ### 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
4089 if [ x"$user" != x"$rowowner" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
4090 echo "他人のレコードはいじれないの" | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4091 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
4092 elif [ -z "$rowowner" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
4093 echo "指定したレコードはないみたい" | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4094 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
4095 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
4096 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
4097 # 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
4098 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
4099 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
4100 query "delete from $tbl where rowid=$rowid;"
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4101 clearcachedir "$tbl/$rowid"
758
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4102 if [ x"$tbl" = x"grp" -o x"$tbl" = x"blog" ]; then
1027
f389a311a8d4 Rename function name
HIROSE Yuuji <yuuji@gentei.org>
parents: 1026
diff changeset
4103 clean_orphaned
758
369602864de8 Clean-up code to remove orphaned blogs and articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 757
diff changeset
4104 fi
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4105 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
4106 else
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
4107 echo "消去確認のチェックがないので消さなかったの..." | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 79
diff changeset
4108 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
4109 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
4110 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
4111 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4112
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4113 ts=${tbl}_s tm=${tbl}_m val="" pval="" formaster=""
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4114 if [ -n "$rowid" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4115 # Update of existing record
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4116 for col in `gettblcols $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4117 val=`getparquote $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4118 [ -z "$val" ] && continue
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4119 ## err query "update $tbl set $col=$val where rowid=$rowid"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4120 ## XX: THIS IS DIRTY hack to ensure non-foreign key in blog_s
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4121 sql="update $tbl set $col=$val where rowid=$rowid;"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4122 if [ x"$tbl" = x"grp" -a x"$col" = x"gname" \
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4123 -o x"tbl" = x"user" -a x"$col" = x"name" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4124 ## User name cannot be changed with interface provided with this
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4125 ## script. But we offer the trigger to change owner user
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4126 ## of blog_s table.
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4127 #err "select quote($col) from $tbl where rowid=$rowid;"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4128 old=`query "select quote($col) from $tbl where rowid=$rowid;"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4129 cat<<-EOF | query
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
4130 -- Here we cannot use BEGIN-COMMIT because groupupdate()
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
4131 -- should use EXCLUSIVE transaction outside of this.
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
4132 SAVEPOINT par2table;
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
4133 $sql
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
4134 update blog_s set val=$val
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
4135 where key='owner' and val=$old;
382
7b1c44bf12e8 Add feature of cloning a group
HIROSE Yuuji <yuuji@gentei.org>
parents: 378
diff changeset
4136 RELEASE SAVEPOINT par2table;
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
4137 EOF
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4138 ## XX: DIRTY Hack Ends here
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4139 ## We should keep blog's owner as a single column which has
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4140 ## foreign key constraint with primary key of grp/user.
635
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4141 else
180
59bd085848ec Group name change affects to blog owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 179
diff changeset
4142 query "$sql"
635
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4143 fi
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4144 done
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4145 # Then, set up $pval for further insertion of tbl_s and tbl_m
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4146 for col in `gettblpkey $tbl`; do
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4147 val=`query "select $col from $tbl where rowid=$rowid;"|sed -e 's/\"/\"\"/g'`
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4148 pval="$pval${pval:+, }\"$val\""
ae37fefb7a2b Adjust indentations
HIROSE Yuuji <yuuji@gentei.org>
parents: 630
diff changeset
4149 done
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4150 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4151 # New entry
730
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4152 # XXX: WORK-AROUND FOR SOME STUPID BROWSER
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4153 # Avoid empty repost of article.
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4154 if [ x"$tbl" = x"article" ]; then
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4155 # If rowid is empty and ID exists in article-table, that is REPOST!
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4156 aid=`getpar id`
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4157 xaid=`query "SELECT id FROM $tbl WHERE id='$aid';"`
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4158 if [ -n "$xaid" ]; then
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4159 # REPOST of article
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4160 html p <<-EOF
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4161 書き込み直後のリロードなので上書きを回避します。
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4162 最新記事は末尾の「再読み込み」ボタンから見てください。
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4163 EOF
731
33df7d50532e Empty-repost workaround in EDIT mode added
HIROSE Yuuji <yuuji@gentei.org>
parents: 730
diff changeset
4164 err "Repost aid=$aid Browser=[$HTTP_USER_AGENT] user=$user"
730
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4165 return 9 # STOP Duplicated posting
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4166 fi
2c0c25fc9f68 Workaround for reposting from resuming browsers
HIROSE Yuuji <yuuji@gentei.org>
parents: 726
diff changeset
4167 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4168 # Generate values() for primary keys
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4169 for col in `gettblpkey $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4170 # Genuine primary keys for _m and _s
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4171 val=`getvalquote $tbl $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4172 [ -z "$val" ] && continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4173 pval="$pval${pval:+, }$val"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4174 done
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4175 ##err pval=$pval
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4176 for col in `gettblfkey $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4177 # args for values() to insertion into master table
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4178 val=`getvalquote $tbl $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4179 [ -z "$val" ] && continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4180 formaster=$formaster"${formaster:+, }$val"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4181 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4182 formaster="$pval${formaster:+, }$formaster"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4183 ## err formaster=$formaster
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4184 if [ -z "$formaster" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4185 echo "項目を全て埋めてください" | html pre
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4186 return 1
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4187 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4188 ## err "replace into $tbl values($formaster);"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4189 query "replace into $tbl values($formaster);"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4190 ## Insertion to master table, done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4191 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
4192
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4193 transaction=$tmpd/sqlfile.sql; touch $transaction
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4194 for kt in s m; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4195 tb2=${tbl}_$kt
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4196 for col in `gettbl_${kt}_cols $tbl`; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4197 ptype=`getpartype $col "limit 1"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4198
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4199 # First, check update of existing entries in _m
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4200 if [ $kt = m ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4201 # sessID|address.1.22|string|Somewhere-x.y.z
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4202 sql=""
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4203 ##err dots from query "select var from par where var like '$col.%';"
836
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4204 for v in `query "select var from par where var like '$col.%' AND sessid='$session';"`; do
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4205 # v=address.1.22
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4206 st_rowid=${v##*.}
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4207 origcol=${v%%.*} # original column derived from
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4208 ##err Updating for $v st_rowid=$st_rowid, partype=`getpartype $v`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4209 ##case `getpartype $v` in
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4210 ## err CASE `gettbl_coltype $tbl/$origcol` in
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4211 ## err edit flag = `getpar action.$v`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4212 case `getpar action.$v` in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4213 rm)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4214 if [ x`getpar confirm.$v` = x"yes" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4215 newsql="delete from $tb2"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4216 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4217 echo "削除確認未チェック" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4218 fi ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4219 edit)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4220 case `gettbl_coltype $tbl/$origcol` in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4221 image|document|binary)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4222 file=$tmpd/`getparfilename $v`
731
33df7d50532e Empty-repost workaround in EDIT mode added
HIROSE Yuuji <yuuji@gentei.org>
parents: 730
diff changeset
4223 if [ ! -s "$file" ]; then # Maybe stupid REPOST
33df7d50532e Empty-repost workaround in EDIT mode added
HIROSE Yuuji <yuuji@gentei.org>
parents: 730
diff changeset
4224 err "Empty REPOST by [$HTTP_USER_AGENT] user=$user"
33df7d50532e Empty-repost workaround in EDIT mode added
HIROSE Yuuji <yuuji@gentei.org>
parents: 730
diff changeset
4225 continue
33df7d50532e Empty-repost workaround in EDIT mode added
HIROSE Yuuji <yuuji@gentei.org>
parents: 730
diff changeset
4226 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4227 ## err type=file=$file
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4228 [ -z "$file" ] && continue
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
4229 bn=`sqlquotestr "${file##*/}"`
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4230 bin="X'"$(hexize "$file")"'"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4231 ct=`file --mime-type - < "$file" |cut -d' ' -f2`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4232 type=\"file:$ct\"
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
4233 newsql="update $tb2 set val=$bn, type=$type, bin=$bin"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4234 cachedir=`getcachedir "$tbl/$rowid"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4235 err getcache tbl/rowid=$tbl/$rowid, rm -r $cachedir
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4236 rm -rf $cachedir
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4237 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4238 *)
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4239 newsql="update $tb2 set val=(select val from par where var \
836
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4240 like '$col.%.$st_rowid' AND sessid='$session')"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4241 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4242 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4243 ;;
836
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4244 mv)
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4245 # regularize filename and strip directory part
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4246 newname=`getpar mv.$v|tr -d '":;#<>?^%$!'|tr -d "'"|tr ' ' _`
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4247 newname=`basename $newname`
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4248 oldname=`query "SELECT val FROM $tb2 WHERE rowid=$st_rowid;"`
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4249 oldext=`expr "$oldname" : '.*\.\(.*\)'`
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4250 newext=`expr "$newname" : '.*\.\(.*\)'`
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4251 err "p2t(mv): oldname=$oldname $oldext -> newname($v)=$newname $newext"
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4252 if [ -n "$newname" -a x"$oldext" = x"$newext" ];
836
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4253 then
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4254 newsql="UPDATE $tb2 SET val='$newname'"
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4255 else
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4256 html p<<-EOF
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4257 $newname は取り扱えないファイル名です。
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4258 空白を含まない名前にして下さい。
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4259 拡張子の変更もできません。
836
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4260 EOF
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4261 continue
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4262 fi
b3516ee2bb4d Filename renaming added to article EDIT
HIROSE Yuuji <yuuji@gentei.org>
parents: 833
diff changeset
4263 ;;
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4264 *) # maybe "keep", do not modify value
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4265 continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4266 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4267 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4268 # err newsql=$newsql
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4269 sql=$sql$nl"$newsql where rowid=$st_rowid;"
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4270 clearcachedir "$tbl/$rowid"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4271 done
124
9742dbee5cba Call large query with SQL script in par2table() - at edit
HIROSE Yuuji <yuuji@gentei.org>
parents: 123
diff changeset
4272
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4273 if [ x"$bin" = x"NULL" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4274 ## err repl:normal sql=`echo $sql`
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4275 if [ -n "$transaction" ]; then
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4276 cat<<-EOF >> $transaction
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4277 $sql
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4278 DELETE FROM $tb2 WHERE type='string' AND val='';
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4279 EOF
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4280 else
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4281 query "$sql
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4282 delete from $tb2 where type='string' and val='';"
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4283 ## err repl:normal done
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4284 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4285 else
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4286 # Binary update line is TOO LONG to pipelining
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4287 sqlfile="$tmpd/sqlf.$$"
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4288 if [ -n "$transaction" ]; then
994
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4289 cat<<-EOF >> $transaction
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4290 $sql
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4291 EOF
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4292 else
994
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4293 cat<<-EOF > $sqlfile
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4294 $sql
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4295 EOF
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4296 query ".read $sqlfile"
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4297 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4298 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4299 # Rest of kt==m: set multiple mode
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4300 nr=`getparcount $col`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4301 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4302 nr=1 # for kt==s, number of records is 1
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4303 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
4304
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4305 i=0
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4306 while [ $i -lt $nr ]; do
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4307 limit="limit 1 offset $i"
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4308 i=$((i+1)) # increase beforehand against continue
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4309 val=`getvalquote $tbl $col "$limit"`
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4310 ##XXX [ -z "$val" -o x"$val" = x'""' -o x"$val" = x"NULL" ] && continue
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4311 [ -z "$val" -o x"$val" = x'""' ] && continue
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4312 ## err $col=$val
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4313 bin=NULL
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4314 ## err partype$col=`getpartype $col "$limit"`
837
a6462eea48be Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 836
diff changeset
4315 ptype=`getpartype $col "$limit"` # partype should be obtained each time
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4316 case $ptype in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4317 file) file=$tmpd/`getparfilename $col "$limit"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4318 ## err parfile-$col=$file
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4319 [ -z "$file" ] && continue
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4320 bin="X'"$(hexize "$file")"'"
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4321 ct=`file --mime-type - < "$file"|cut -d' ' -f2`
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4322 type=\"file:$ct\" ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4323 "*"*) continue ;; # foreign table
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4324 *) type=\"string\" ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4325 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4326 case `gettbl_coltype $tbl/$col` in
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4327 [Cc][Hh][Ee][Cc][Kk][Bb][Oo][Xx]|[Tt][Ee][Xx][Tt])
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4328 test x"$val" = x"NULL" && val="''"
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4329 ;;
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4330 password) # special care for password
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4331 # name={password,pswd1,pswd2}
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4332 p1=`getpar pswd1 "$limit"`
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4333 if [ -z "$p1" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4334 continue # SKIP password setting, if p1 is empty
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4335 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4336 pswd=`getpar pswd "$limit"` p2=`getpar pswd2 "$limit"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4337 ## err pswd=$pswd
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4338 if pwcheck "$pswd"; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4339 if [ x"$p1" = x"$p2" ]; then
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4340 case "$p1" in
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4341 ??????????*) ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4342 *) echo "パスワードは10字以上にしてください。" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4343 return 6;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4344 esac
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4345 val="\"`echo $p1|mypwhash`\""
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4346 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4347 echo "2つの新パスワード不一致" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4348 return 7
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4349 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4350 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4351 echo "旧パスワード違います" | html p
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4352 return 8
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4353 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4354 fi
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4355 ;;
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4356 esac
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4357 ## err p2t: "replace into $tb2 values($pval, \"$col\", $type, $val, bin...);"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4358 #query "replace into $tb2 values($pval, \"$col\", $type, $val, $bin);"
953
93c38e425c85 Do not insert null new record.
HIROSE Yuuji <yuuji@gentei.org>
parents: 952
diff changeset
4359 if [ x"$val" = x"NULL" -a x"$bin" = x"NULL" ]; then
93c38e425c85 Do not insert null new record.
HIROSE Yuuji <yuuji@gentei.org>
parents: 952
diff changeset
4360 continue # Do not insert completely NULL record 2021-11-08
93c38e425c85 Do not insert null new record.
HIROSE Yuuji <yuuji@gentei.org>
parents: 952
diff changeset
4361 fi
93c38e425c85 Do not insert null new record.
HIROSE Yuuji <yuuji@gentei.org>
parents: 952
diff changeset
4362 sql="REPLACE into $tb2 values($pval, \"$col\", $type, $val, $bin);"
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4363 if [ x"$bin" = x"NULL" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4364 ## err Normal-query: `echo $sql`
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4365 if [ -n "$transaction" ]; then
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4366 printf '%s' "$sql" >> $transaction
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4367 else
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4368 query "$sql"
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4369 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4370 else
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4371 sqlfile="$tmpd/query.$$"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4372 ## err sqlfile=`ls -lF $sqlfile`
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4373 if [ -n "$transaction" ]; then
994
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4374 cat<<-EOF >> $transaction
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4375 $sql
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4376 EOF
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4377 else
994
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4378 cat<<-EOF >> $sqlfile
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4379 $sql
f0a62a22e33c FIX: Too long SQL including binary data put via heredocs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 988
diff changeset
4380 EOF
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4381 query ".read $sqlfile"
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4382 fi
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4383 fi
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4384 ## err p2t done
285
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4385 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4386 done
e87d6bc1e62a Remove old function and unneccesary subshelling
HIROSE Yuuji <yuuji@gentei.org>
parents: 284
diff changeset
4387 done
636
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4388 [ -n "$transaction" -a -s "$transaction" ] && cat <<-EOF | query
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4389 -- We cannot use transaction here, because groupupdate may use it.
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4390 SAVEPOINT pa2table_insert;
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4391 .read $transaction
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4392 RELEASE SAVEPOINT pa2table_insert;
b73ef3fd0e19 Table update done in 1 .read outside of shell loop.
HIROSE Yuuji <yuuji@gentei.org>
parents: 635
diff changeset
4393 EOF
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
4394 rc=$?
887
8229c75e9f94 Ensure user_s update
HIROSE Yuuji <yuuji@gentei.org>
parents: 886
diff changeset
4395 [ $rc -eq 0 -a x"$tbl" = x"user" ] && flag_profupdate
752
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
4396 ## err "Table:$tbl update done "
c22e71dc8d9b Base of annex feature added
HIROSE Yuuji <yuuji@gentei.org>
parents: 732
diff changeset
4397 return $rc
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4398 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4399 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
4400 # $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
4401 # $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
4402 # If $GF_VIEWONLY set and nonNull, output values without form
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 218
diff changeset
4403 # If $GF_ARGS set, use it as content-strings in the form
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4404 # 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
4405 # 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
4406 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
4407 if [ ! -e "$1" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
4408 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
4409 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
4410 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
4411 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
4412 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
4413 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
4414 ###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
4415 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
4416 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
4417 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
4418 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
4419 if [ -z "$rec" ]; then
61
8b2cf4d9ba00 Use html()
HIROSE Yuuji <yuuji@gentei.org>
parents: 60
diff changeset
4420 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
4421 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
4422 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
4423 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
4424 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
4425 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
4426 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
4427 <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
4428 <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
4429 fi
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4430 # Image Cache dir
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4431 ## err genform: getcache=$2/$rowid
77
10bd684f07d2 Argument for getcache fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 76
diff changeset
4432 td=`getcachedir "$2/$rowid"`
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4433 while IFS=: read -r prompt name keytype type args; do
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4434 [ -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
4435 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
4436 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
4437 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
4438 # err genform2a: Seeking for "$2.$name, type=$type"
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
4439 rawval=`getvalbyid $2 $name $rowid $td`
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4440 val=`printf '%s\n' "$rawval"|htmlescape`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4441 ## err genform3a: getvalbyid $2 $name $rowid $td
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4442 ## err genform3b: val="[$val]" type="$type"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4443 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
4444 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
4445 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
4446 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
4447 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
4448 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
4449 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
4450 if [ -s $td/$name.count -a -n "$val" ]; then
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4451 form=`$cgiform $name $td`
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4452 val=$(printf '%s\n' "$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
4453 while read fn; do
208
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
4454 echo "<tr><td>`cat $td/$fn|htmlescape|hreflink`
36b6354de5cb Profile form should escape entities. Apply ^href conversion to Profile
HIROSE Yuuji <yuuji@gentei.org>
parents: 207
diff changeset
4455 </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
4456 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
4457 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
4458 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
4459 #form="<input name=\"$name\" value=\"$val\" type=\"$type\"$sp$args>$nl"
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4460
361
34076e5a4018 Should not htmlescape at calling cgi_type*
HIROSE Yuuji <yuuji@gentei.org>
parents: 359
diff changeset
4461 form=`cgi_$type $name "$rawval" "$args"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4462 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
4463 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4464 [Rr][Aa][Dd][Ii][Oo])
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
4465 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
4466 form="`echo $args|sed -e \
100
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
4467 \"s,\([^ =][^=]*\)=\([^= ][^= ]*\),$fh value=\\"\2\\">\1</label>,g\"`"
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
4468 ;;
8dc950197939 "radio" and "checkbox"
HIROSE Yuuji <yuuji@gentei.org>
parents: 83
diff changeset
4469 [Cc][Hh][Ee][Cc][Kk][Bb][Oo][Xx])
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4470 checked=${val:+ checked}
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4471 form="<label><input type=\"checkbox\" name=\"$name\" value=\"${args#*=}\"$checked>${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
4472 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4473 [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
4474 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
4475 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
4476 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
4477 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
4478 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
4479 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
4480 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
4481 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
4482 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4483 [Ii][Mm][Aa][Gg][Ee]|[Dd][Oo][Cc][Uu][Mm][Ee][Nn][Tt]|[Bb]inary)
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4484 if [ -s $td/$name.count ]; then
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4485 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
4486 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
4487 hrfb="$myname?showattc+$2_m"
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 319
diff changeset
4488 val=$(echo "$rawval" \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4489 | while read fn; do
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4490 data=`percenthex "$td/$fn"`
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4491 #ct=`cat $td/$fn.content-type`
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4492 ct=`file --mime-type - < "$td/$fn"|cut -d' ' -f2`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4493 ri=`cat "$td/$fn.rowid"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4494 ## err fn=$fn, name=$name, ri=$ri; ls -lF "$td/" 1>&3
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4495 #imgsrc="<img src=\"data:$ct,$data\">"
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
4496 #echo "<a href=\"$hrfb+$ri\">$imgsrc</a><br>"
472
38bf8d300b12 For slower connection, it's better to use img-link over data:
HIROSE Yuuji <yuuji@gentei.org>
parents: 471
diff changeset
4497 iconhref2 "$td/$fn" "$hrfb+$ri" ""
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4498 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
4499 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
4500 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
4501 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
4502 if [ -n "$val" ]; then
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4503 imgs=$(echo "$rawval"\
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4504 |while read fn;do
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4505 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
4506 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
4507 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
4508 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
4509 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
4510 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
4511 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
4512 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
4513 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
4514 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4515 [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
4516 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
4517 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
4518 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
4519 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
4520 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
4521 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4522 [Aa][Uu][Tt][Hh][Oo][Rr])
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
4523 [ -n "$GF_VIEWONLY" ] && continue
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4524 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
4525 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
4526 [Oo][Ww][Nn][Ee][Rr])
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
4527 [ -n "$GF_VIEWONLY" ] && continue
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4528 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
4529 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
4530 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
4531 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
4532 [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
4533 # 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
4534 #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
4535 [ -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
4536 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
4537 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4538 [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
4539 [ -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
4540 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
4541 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
4542 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4543 [Ss][Ee][Rr][Ii][Aa][Ll]|[Ss][Tt][Aa][Mm][Pp])
391
554dc6669027 Icon cache'ing refined
HIROSE Yuuji <yuuji@gentei.org>
parents: 390
diff changeset
4544 [ -n "$GF_VIEWONLY" ] && continue
127
c17964aa7715 Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents: 124
diff changeset
4545 if [ -z "$rowid" ]; then
268
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 267
diff changeset
4546 val=`genserial`
127
c17964aa7715 Do not reset serial number when rowid given
HIROSE Yuuji <yuuji@gentei.org>
parents: 124
diff changeset
4547 fi
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 65
diff changeset
4548 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
4549 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
4550 [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
4551 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
4552 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4553 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
4554 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
4555 ;;
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4556 "*"*)
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4557 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
4558 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
4559 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
4560 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
4561 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
4562 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
4563 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
4564 :
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4565 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
4566 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
4567 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
4568 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
4569 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
4570 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
4571 # enctype="multipart/form-data"
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4572 cat<<-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
4573 <form action="${GF_ACTION:-$myname}" method="POST" enctype="multipart/form-data">
942
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4574 EOF
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4575 test -n "$rowid" && printf '%s\n' "$rm" # Workaround for utf8 buggy NetBSD sh
5d70fa029f8d Support MathJax rendering
HIROSE Yuuji <yuuji@gentei.org>
parents: 941
diff changeset
4576 cat<<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
4577 <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
4578 $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
4579 </table>$hiddens
13
f2204bd941d5 periodic
HIROSE Yuuji <yuuji@gentei.org>
parents: 11
diff changeset
4580 ${GF_STAGE:+`cgi_hidden stage $GF_STAGE`}
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 6
diff changeset
4581 ${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
4582 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
4583 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
4584 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
4585 <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
4586 <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
4587 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
4588 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
4589 cat<<EOF
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 218
diff changeset
4590 $GF_ARGS</form>
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4591 $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
4592 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
4593 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4594 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
4595 # $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
4596 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
4597 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4598 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
4599 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
4600 }
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4601 showattc() {
350
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4602 # $1=table_m $2=rowid &optional $3=RawFlag
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4603 ## err \$1=$1 \$2=$2 \$3=$3
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4604 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
4605 contenttype; echo
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4606 echo "このファイルは管理者のみしか見られません" | html p
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4607 putfooter; exit
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4608 fi
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4609 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
4610 # tmpfiles=$tmpfiles"${tmpfiles+ }$idir"
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4611 bin=$idir/$myname-$$.bin
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4612 sql="select quote(bin) from $1 where rowid='$2';"
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4613 ## 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
4614 sq $db "$sql" | unhexize > $bin
326
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4615 tv=`query "select type||'//'||val from $1 where rowid='$2';"`
d19e85a72a29 Allow spaces and special characters in filenames(tentative).
HIROSE Yuuji <yuuji@gentei.org>
parents: 322
diff changeset
4616 type=${tv%//*} fn=${tv#*//}
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4617 ## err tv=$tv type=$type fn=$fn, tp2=${tv%\|*}
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4618 ct=${type#file:}
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4619 case $ct in # all text/* changed to text/plain
896
920818b41cd2 Application/{csv,json} forcibly handled as text/plain
HIROSE Yuuji <yuuji@gentei.org>
parents: 895
diff changeset
4620 text/*|application/csv|application/json)
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4621 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
4622 case $charset in
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4623 ASCII*) charset="" ;;
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4624 esac
350
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4625 if [ -z "$3" ]; then
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4626 ct="text/html${charset:+; charset=$charset}"
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4627 link="?showattc+$1+$2+raw"
395
3d82052c3cd3 Do htmlescape() for euc-jp string and restore to original charset
HIROSE Yuuji <yuuji@gentei.org>
parents: 394
diff changeset
4628 nkf -e $bin | htmlescape | nkf --oc="$charset" \
350
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4629 | sed 's,^,<span></span>,' \
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4630 | _m4 -D_TITLE_="$fn" -D_CONTENT_TYPE_="$ct" \
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4631 -D_LINK_="$link" \
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4632 -D_BODY_="syscmd(\`cat')" $layout/pretty.m4.txt
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4633 exit $?
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4634 fi
a6ff48595a4d Add link to raw format of text file
HIROSE Yuuji <yuuji@gentei.org>
parents: 347
diff changeset
4635 ct="text/plain${charset:+; charset=$charset}"
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4636 ;;
995
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
4637 video/*)
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
4638 if [ -z "$3" ]; then
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
4639 _m4 -D_TITLE_="$fn" \
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
4640 -D_SRC_="?showattc+$1+$2+raw" $layout/videoplay.m4.html
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
4641 exit $?
9a54ad622318 Remove superfluous To:
HIROSE Yuuji <yuuji@gentei.org>
parents: 994
diff changeset
4642 fi
68
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4643 esac
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4644 contenttype "$ct"
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4645 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
4646 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
4647 #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
4648 cat $bin
7380bcf19078 Show attachment file size; Move showattc to s4-funcs.sh.
HIROSE Yuuji <yuuji@gentei.org>
parents: 67
diff changeset
4649 }
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4650 #
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4651 # Some default stupid handler on CGI values
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4652 #
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4653 default_storedb() {
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4654 # ARG: $1=table-def-file
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4655 # RET: $tbl=table-name, $col=mail-column, $cols=columns
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4656 tbl=`basename $1`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4657 tbl=${tbl%.def}
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4658 cols="`grep :text $1|cut -d: -f2`"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4659 col=`echo "$cols"|head -1`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4660 vcol=`getpar $col`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4661 err default0: \$1=$1 col=$col cols="[$cols]" vcol=$vcol
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4662 if [ -n "$vcol" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4663 par2table $1
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4664 else
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4665 return 2 # No insertion occurred
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4666 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4667 }
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4668
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4669 default_view() { # $1=def-file
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4670 ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4671 ## DT_VIEW="edittable+$tbl" dumptable html $tbl "name memo file" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4672 default_storedb "$@"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4673 query "select rowid from $tbl order by rowid desc;" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4674 | while read rowid; do
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4675 viewtable $1 $tbl $rowid
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4676 done | _m4 -D_TITLE_="$tbl" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4677 -D_FORM_="`genform $1`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4678 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4679 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4680 }
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4681 default_viewtext() { # $1=def-file
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4682 ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4683 default_storedb "$@"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4684 DT_VIEW="viewtable+$tbl" dumptable html $tbl "name memo file" \
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4685 | _m4 -D_TITLE_="$tbl" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4686 -D_FORM_="`genform $1`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4687 -D_DUMPTABLE_="syscmd(cat)" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4688 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4689 }
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4690 default_smail() {
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4691 default_storedb "$@"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4692 if [ $? -eq 2 ]; then
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4693 _m4 -D_TITLE_="入力" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4694 -D_FORM_="`genform $1`" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4695 -D_DUMPTABLE_="" \
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4696 $layout/html.m4.html $layout/form+dump.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4697 return
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4698 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4699 cond=""
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4700 for pk in `gettblpkey $tbl`; do
431
703346e6e7de Group names should be quoted into one argument
HIROSE Yuuji <yuuji@gentei.org>
parents: 428
diff changeset
4701 pv=$(sqlquote "$(getpar $pk)")
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4702 cond="$cond${cond:+ and }$pk=$pv"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4703 done
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4704 sql="select rowid from $tbl where $cond;"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4705 rowid=`query "$sql"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4706 ## err smail1 - "$sql" "-> rowid=$rowid"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4707
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4708 while IFS=: read prompt name keytype type args; do # Read from $1
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4709 val=`getpar $name`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4710 if [ -n "$val" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4711 text="$text
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4712 $prompt
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4713 $name=$val
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4714 ---------------------------------------------------------"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4715 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4716 case "$type" in
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4717 image|document|file)
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4718 fn="`getvalbyid $tbl $name $rowid $tmpd`"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4719 fns=$(echo "$fn"|while read fn; do
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4720 err mv $tmpd/$fn.orig $tmpd/$fn
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4721 mv $tmpd/$fn.orig $tmpd/$fn
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4722 rm $tmpd/$fn.rowid # Remove cache flag
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4723 ## err "`ls $tmpd/$fn`"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4724 echo $fn
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4725 done)
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4726 files="$files $fns"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4727 ;;
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4728 esac
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4729 done < $1
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
4730 ## err FILES=$files "`ls -lF $tmpd`"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4731 subj="from ${REMOTE_ADDR}"
102
7cdaac365897 s/$URL/$url/
HIROSE Yuuji <yuuji@gentei.org>
parents: 101
diff changeset
4732 (echo "$url"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4733 echo "への書き込みがありました。"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4734 echo "------"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4735 echo "$text"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4736 ) | (cd $tmpd &&
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4737 err LS="`ls -lF`" &&
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4738 $mydir/sendmultipart.sh -t "$admin" -s "$subj" $files)
187
7dc0918ce321 Add PIPE to handled signals
HIROSE Yuuji <yuuji@gentei.org>
parents: 182
diff changeset
4739 _m4 -D_TITLE_="入力完了" $layout/html.m4.html
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4740 echo "以下の内容で送信しました。" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4741 viewtable $1 $tbl \
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4742 `query "select rowid from $tbl order by rowid desc limit 1;"`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4743 echo "戻る" | html a "href=\"?\""
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 77
diff changeset
4744 }

yatex.org