s4
changeset 462:e8bde2d9cb0b
New feature - show blog-seen time table, added
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Mon, 21 Aug 2017 20:05:37 +0859 |
parents | d7b23ad0e2e8 |
children | 4f0314630559 |
files | s4-blog.sh s4.cgi |
diffstat | 2 files changed, 64 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/s4-blog.sh Mon Aug 21 20:04:49 2017 +0859 1.2 +++ b/s4-blog.sh Mon Aug 21 20:05:37 2017 +0859 1.3 @@ -174,6 +174,7 @@ 1.4 href3="(<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"F\">ファイル取得</a>)" 1.5 fi 1.6 href4='<a href="#bottom" accesskey="b" title="B"> 末尾へ</a>' 1.7 + href5="<a href=\"?blogseen+$rowid\" accesskey=\"s\" title=\"S\"> 読刻</a>" 1.8 quizmodefile=$td/quiz; rm -f "$quizmodefile" # XXX: Global state 1.9 1.10 query<<-EOF | 1.11 @@ -192,7 +193,7 @@ 1.12 EOF 1.13 { IFS='|' read edit ctime hexhead blogtype 1.14 cat<<-EOF 1.15 - <tr><td>${edit:+$href }$ctime $blogtype $href2$href3 $href4</td></tr> 1.16 + <tr><td>${edit:+$href }$ctime $blogtype $href2$href3 $href4 $href5</td></tr> 1.17 <tr class="preface${frozen_class:+ }$frozen_class"> 1.18 <td>`echo "$hexhead"|unhexize|hreflink|minitbl`</td></tr> 1.19 </table> 1.20 @@ -634,6 +635,66 @@ 1.21 echo 1.22 cat $arc 1.23 } 1.24 +blogseen() { # $1 = blogid 1.25 + blogid=${1%%[!0-9]*} 1.26 + if [ -z "$blogid" ]; then 1.27 + echo "Invalid blog id" | html p; exit 1.28 + fi 1.29 + blog_writable "$blogid" "$user" 1.30 + rc=$? # =0: writable, $BLOG_NOTMEM bit set => not member 1.31 + if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then 1.32 + echo "メンバー以外は利用できません。" | html p; return 1.33 + fi 1.34 + owner=`getvalbyid blog owner $rowid` 1.35 + #qowner=`sqlquotestr "$owner"` 1.36 + ge=`gecos "$owner"` 1.37 + title=`getvalbyid blog title $rowid` 1.38 + _m4 -D_TITLE_="アクセス時刻" $layout/html.m4.html 1.39 + tmpf=$tmpd/header 1.40 + echo "[title]@${ge:-$owner}" > $tmpf 1.41 + warn=' class="warn"' 1.42 + cat <<-EOF 1.43 + <table class="b">' 1.44 + <tr><th>メンバー</th><th>uname</th><th>最終閲覧時刻</th></tr> 1.45 + EOF 1.46 + query <<-EOF | 1.47 + WITH grpmem as ( 1.48 + SELECT user, (SELECT gecos FROM gecoses WHERE name=user) gecos 1.49 + FROM grp_mem 1.50 + WHERE gname=(SELECT val FROM blog_s 1.51 + WHERE id=(select id from blog where rowid=16) 1.52 + AND key='owner') 1.53 + ), acctime AS ( 1.54 + SELECT user, max(time) atime 1.55 + FROM tblaccesses 1.56 + WHERE tbl='blog' AND tblrowid=16 1.57 + GROUP BY user 1.58 + ) 1.59 + SELECT g.user, 1.60 + (SELECT rowid FROM user u WHERE u.name=g.user), 1.61 + hex(gecos), 1.62 + atime 1.63 + FROM grpmem g LEFT JOIN acctime t 1.64 + ON g.user = t.user 1.65 + GROUP BY t.user 1.66 + ORDER BY atime DESC; 1.67 + EOF 1.68 + while IFS='|' read u uid hexge time; do 1.69 + td=${time:+"<td>"} # If the variable time is set, td=<td> 1.70 + td=${td:-"<td$warn>"} # else td=<td class="warn"> 1.71 + cat <<-EOF 1.72 + <tr> 1.73 + <td><a href="?home+$uid">`echo "$hexge"|unhexize|htmlescape`</a></td> 1.74 + <td>`echo ${u%%@*}|htmlescape`</td> 1.75 + $td${time:----}</td></tr> 1.76 + EOF 1.77 + done 1.78 + cat <<-EOF 1.79 + </table> 1.80 + <p><a href="?replyblog+$rowid">[$title]に戻る</a></p> 1.81 + </html> 1.82 + EOF 1.83 +} 1.84 lsmyfile() { # $1(optional)=SortBy 1.85 case "$1" in 1.86 ""|CTIME-DESC)
2.1 --- a/s4.cgi Mon Aug 21 20:04:49 2017 +0859 2.2 +++ b/s4.cgi Mon Aug 21 20:05:37 2017 +0859 2.3 @@ -79,9 +79,9 @@ 2.4 echo "Refresh: 0; $newurl"; echo 2.5 exit 0 2.6 ;; 2.7 - lshandout|lshandoutall|gethandout|gethandoutcsv|gethandoutcsv2) 2.8 + lshandout|lshandoutall|gethandout|gethandoutcsv|gethandoutcsv2|blogseen) 2.9 case "$stage" in 2.10 - lshandout*) contenttype; echo ;; 2.11 + lshandout*|blogseen*) contenttype; echo ;; 2.12 esac 2.13 rowid=${2%%[!A-Z0-9a-z_]*} 2.14 if [ -z "$rowid" ]; then