Mercurial > hgrepos > hgweb.cgi > s4
view s4.cgi @ 59:916d81b9c4fc
Selection from group member
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 25 Jul 2015 23:00:58 +0900 |
parents | 0c26f4461d0b |
children | 666180f62a3d |
line wrap: on
line source
#!/bin/sh # 愛 PATH=/usr/local/sqlite3/bin:$PATH myname=`basename $0` mydir=`dirname $0` . $mydir/s4-funcs.sh cgiinit if [ x"$1" = x"reg" ]; then contenttype; echo regist $2 putfooter exit fi dologin #gencookie; echo case ${SERVER_SOFTWARE} in bozohttp*) # Ugly workaround for bozohttpd, which can't send # two or more arguments. set -- `echo "$@"|(IFS=+ read a b c d e f g; echo $a $b $c $d $e $f $g)` ;; esac err 1=$1 2=$2 3=$3 4=$4 stage=`getpar stage` stage=${stage:-$1} case ${stage} in # "") # contenttype; echo # m4 -D_SITE_="S System" $layout/welcome.m4.html # # echo "<pre>"; gencookie "user=$user" "skey=$skey"; echo "</pre>" # # echo "<pre>`env|sort -u`</pre>" # ;; "home"|"") contenttype; echo err HOME: just in rowid=`getpar rowid` [ -n "`getpar rowid`" ] && par2table $formdir/user.def showhome ${2:-$user} ;; # "diary") # contenttype; echo # title=`getpar title` #diary=`getpar diary` wday=`getpar wday` # [ -n "$title" ] && par2table $formdir/diary.def # m4 -D_TITLE_="$title" -D_DIARY_="$diary" \ # -D_FORM_="`genform templ/form/diary.def`" \ # -D_FORM2_="syscmd(\`genform templ/form/diary.def')" \ # -D_DUMPTABLE_="`dumptable html diary title,wday,diary`" \ # $layout/html.m4.html $layout/diary.m4.html # ;; "login") contenttype; echo myargs="" showlogin ;; "invite") contenttype; echo invite ;; "groupman") contenttype; echo gname=`getpar gname` if [ -n "$gname" ]; then #gname=${gname%%[!-A-Z0-9a-z_.!#$%^&()=:/*]*} #newgname=`echo "$gname"|tr -dc '\-0-9A-Za-z#=:/_.,'` newgname=`echo "$gname"|tr -d '\"'` newgname=$gname if [ x"$newgname" != x"$gname" ]; then err NewGNAME: gname=$newgname echo "<p>使用禁止文字を除去し $gname としました。</p>" gname=$newgname replpar gname string "$gname" fi par2table $formdir/grp.def joingrp "$gname" "$user" yes "$user" as-admin fi GF_STAGE=groupman note="<p>グループ名に使用できない文字は自動的に削除されます。</p>" m4 -D_TITLE_="グループ作成" \ -D_FORM_="$note`genform $formdir/grp.def`" \ -D_DUMPTABLE_="`DT_VIEW=grp dumptable html grp 'gname gecos:DESC mtime:TIME' 'order by b.TIME desc'`" \ $layout/html.m4.html $layout/groupman.m4.html ;; "edittable") contenttype; echo m4 -D_TITLE_="グループ編集/削除" $layout/html.m4.html edittable "$formdir/$2.def" "$2" "$3" ;; "userconf") contenttype; echo [ -n "`getpar rowid`" ] && par2table $formdir/user.def userconf ;; "groupconf") contenttype; echo [ -n "`getpar rowid`" ] && par2table $formdir/grp.def groupconf "$2" ;; "mems") contenttype; echo m4 -D_TITLE_="参加者一覧" -D_BODYCLASS_=listmember $layout/html.m4.html kwd=`getpar kwd` listmember $kwd ;; "grps") contenttype; echo m4 -D_TITLE_="グループ一覧" -D_BODYCLASS_=listgroup $layout/html.m4.html kwd=`getpar kwd` listgroup $kwd \ | m4 -D_DUMPTABLE_="syscmd(\`cat')" \ -D_TITLE_="グループ関連操作" \ -D_FORM_="<a href=\"?groupman\">新規グループ作成</a>" \ $layout/groupman.m4.html ;; "grps2") contenttype; echo m4 -D_TITLE_="グループ一覧" \ -D_FORM_="`listgroup2 $formdir/grp.def`" -D_DUMPTABLE_= \ $layout/html.m4.html \ $layout/groupman.m4.html ;; "grp") # $2=group-rowid contenttype; echo gpg=`getpar grp` grid=${2:-$gpg} grp=`getgroupbyid "$grid"` err grp: getpar-grp"(gpg)=[$grp]" ## . ./s4-blog.sh jg=`getpar joingrp` if [ -n "$jg" ]; then err jg=$jg, grp=$grp [ -n "$jg" -a -n "$grp" ] && joingrp "$grp" "$user" "$jg" "`getpar email`" fi m4 -D_TITLE_="グループ $grp" \ $layout/html.m4.html showgroup "$grid" ;; "grpaction") # $2=group-rowid contenttype; echo grid=${2:-`getpar grp`} grp=`getgroupbyid "$grid"` if [ -z "$grp" ]; then echo "<p>無効な指定です。</p>" return fi m4 -D_TITLE_="グループ $grp 個別選択操作" $layout/html.m4.html grpaction "$grid" ;; "commission") # $2=grp-rowid $3=user-rowid contenttype; echo err commission: "$@" m4 -D_TITLE_="グループ $2 管理者委任" $layout/html.m4.html shift # $1=grp-rowid $2=user-rowid if [ -n "$2" ]; then grp_reg_adm "$@" else echo "<p>無効な指定です。普通のアクセスならここに来ないはず。</p>" fi ;; "blog") contenttype; echo . ./s4-blog.sh blog_addentry $2 ;; "replyblog") contenttype; echo rowid=${2%%[!A-Z0-9a-z_]*} ## err ROWid=$rowid, '$2'=$2 . ./s4-blog.sh err blog_reply $rowid blog_reply $rowid ;; "editheading") contenttype; echo rowid=${2%%[!A-Z0-9a-z_]*} # blogrowid=${3%%[!A-Z0-9a-z_]*} if [ -z "$rowid" ]; then echo "<p>話題番号が未指定です。</p>" return fi owner=`getvalbyid blog owner $2` title=`getvalbyid blog title $2` m4 -D_TITLE_="修正" \ -D_SUBTITLE_="[$title]@$owner" -D_DIARY_="" \ -D_BLOGS_="" -D_DUMPTABLE_="" \ -D_FORM_="`GF_ACTION=\"?blog\" edittable $formdir/blog.def blog $rowid`" \ $layout/html.m4.html $layout/diary.m4.html ;; "editart") contenttype; echo rowid=${2%%[!A-Z0-9a-z_]*} blogrowid=${3%%[!A-Z0-9a-z_]*} if [ -z "$rowid" -o -z "$blogrowid" ]; then echo "<p>表示する記事番号が未指定です。</p>" return fi owner=`getvalbyid blog owner $blogrowid` title=`getvalbyid blog title $blogrowid` author=`getvalbyid article author $rowid` err EDITart: owner=$owner, author=$author if isgrpowner $user $owner; then : EDIT OK elif [ x"$owner" != x"$user" -a x"$author" != x"$user" ]; then echo "<p>本人か所有者しか編集できません.</p>" return fi aid=`query "select id from article where rowid=$rowid;"` # title=`getvalbyid blog title $2` m4 -D_TITLE_="コメントの修正" -D_DIARY_="" \ -D_FORM_="`GF_ACTION=\"?replyblog+$blogrowid#$aid\" edittable $formdir/article.def article $rowid`" \ -D_SUBTITLE_="`gecos $owner`の「$title」" \ -D_BLOGS_= -D_DUMPTABLE_= \ $layout/html.m4.html $layout/diary.m4.html ;; "lshandout") contenttype; echo rowid=${2%%[!A-Z0-9a-z_]*} if [ -z "$rowid" ]; then echo "<p>話題番号が未指定です。</p>" return fi . ./s4-blog.sh lshandout $rowid ;; "gethandout") rowid=${2%%[!A-Z0-9a-z_]*} if [ -z "$rowid" ]; then echo "<p>話題番号が未指定です。</p>" return fi . ./s4-blog.sh gethandout $rowid ;; "searchart") # $2=blogowner contenttype; echo m4 -D_TITLE_="検索結果" $layout/html.m4.html kwd=`getpar kwd` if [ -z "$kwd" ]; then echo "<p>検索語を指定してください</p>" else owner=`getpar owner` owner=${owner:-$2} echo "<h2>「$kwd」による検索結果</h2>" if [ -n "$owner" ]; then cond="where key='owner' and val='$owner'" if isuser $owner; then echo "<p>(`linkhome $owner` さんの記録からの検索)</p>" else linkhome $owner 1>&3 echo "<p>(`linkhome $owner` グループからの検索)</p>" fi fi # article_s: id=article-id, key='text', val='TEXT' # article: id=article-id, blogid=blogkd # blog: id=blog-id, author=LeaderAuthor # blog_s: id=blog-id, key='title', val='BLOG-TITLE' # WANT: blog-ROWid,article-id,val(TEXT) sql="select b.rowid||'#'||x.id as '', b.title as TITLE, substr(x.val, 0, 80) as TEXT from (select blog.rowid,blog.*,bs.val as title from blog join blog_s bs on blog.id=bs.id and bs.key='title') b join (select a.id,a.blogid,s.val from article a join article_s s on a.id=s.id where s.val like '%$kwd%') x on b.id=x.blogid where b.id in (select id from blog_s $cond);" sedopt="s,<TR><TD>\([^<]*\)</TD>,<TR><TD><a\ href=\"?replyblog+\1\">VIEW</a></TD>," cat<<EOF <table class="b searchart"> `sq -header -html $db "$sql"|sed "$sedopt"` </table> EOF fi ;; "send2mem") contenttype; echo send2grpmember ;; "showattc") # $2=table_m $3=rowid $4=val if ! isfilereadable $user $2 $3; then contenttype; echo echo "<p>このファイルは管理者のみしか見られません</p>" putfooter; exit fi idir=`umask 002; mktempd` || exit 1 # tmpfiles=$tmpfiles"${tmpfiles+ }$idir" bin=$idir/$myname-$$.bin sql="select quote(bin) from $2 where rowid='$3';" sq $db "$sql" | unhexize > $bin tv=`query "select type,val from $2 where rowid='$3';"` type=${tv%\|*} fn=${tv#*\|} err tv=$tv type=$type fn=$fn, tp2=${tv%\|*} ct=${type#file:} case $ct in # all text/* changed to text/plain text/*) charset=`nkf -g $bin|cut -d' ' -f1` case $charset in ASCII*) charset="" ;; esac ct="text/plain${charset:+; charset=$charset}" ;; esac contenttype "$ct" echo "Content-Disposition: filename=\"$fn\"" echo "Content-Length: " `cat $bin | wc -c`; echo #echo "Content-Type: " ${type#file:}; echo cat $bin exit 0 ;; "gallery") ## contenttype "Image/jpeg" sql="select quote(b) from te where a='${2:-mikan.jpg}'" idir=`umask 002; mktempd` || exit 1 # tmpfiles=$tmpfiles"${tmpfiles+ }$idir" img=$idir/$myname-$$.bin db=b.sq3 sqlite3 $db "$sql" | xxd -r -p > $img len=`cat $img | wc -c` echo "Content-Length: $len" type=`file --mime-type $img | cut -d' ' -f2` echo 'Content-type: $type'; echo cat $img ;; esac putfooter