s4
changeset 68:7380bcf19078
Show attachment file size; Move showattc to s4-funcs.sh.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 31 Jul 2015 10:35:04 +0900 |
parents | 3b70f847277e |
children | d10f98c2b192 |
files | s4-blog.sh s4-funcs.sh s4.cgi |
diffstat | 3 files changed, 37 insertions(+), 30 deletions(-) [+] |
line diff
1.1 --- a/s4-blog.sh Fri Jul 31 10:04:14 2015 +0900 1.2 +++ b/s4-blog.sh Fri Jul 31 10:35:04 2015 +0900 1.3 @@ -157,9 +157,10 @@ 1.4 1.5 #data=`percenthex $td/$fn` 1.6 #ct=`cat $td/$fn.content-type` 1.7 + sz=`cat $td/$fn.size` 1.8 ri=`cat $td/$fn.rowid` 1.9 err fn=$fn ct=$ct ri=$ri; ls -lF $td/ 1>&3 1.10 - iconhref $td/$fn "$hrfb+$ri" "$fn" "$fn" 1.11 + iconhref $td/$fn "$hrfb+$ri" "$fn" "$fn($sz)" 1.12 done) 1.13 imgs=`echo "$imgs"|tr -d '\n'` # kill newlines for sed 1.14 fi
2.1 --- a/s4-funcs.sh Fri Jul 31 10:04:14 2015 +0900 2.2 +++ b/s4-funcs.sh Fri Jul 31 10:35:04 2015 +0900 2.3 @@ -555,6 +555,7 @@ 2.4 EOF 2.5 ## err i=$i - file=$file rowid=`cat $td/$fn.rowid` 2.6 ln $td/$fn.rowid $file.rowid 2>&3 # for convenience 2.7 + ls -lh $file | awk '{print $5"B"}' > $file.size 2.8 case $type in 2.9 *:[Ii]mage*) mogrify -geometry $thumbxy $file ;; 2.10 ### ここのアイコンを増やしたい 2.11 @@ -2181,3 +2182,34 @@ 2.12 -D_DUMPTABLE_="syscmd(cat)" \ 2.13 $layout/html.m4.html $layout/form+dump.m4.html 2.14 } 2.15 +showattc() { 2.16 + # $1=table_m $2=rowid $3=val 2.17 + if ! isfilereadable $user $1 $2; then 2.18 + contenttype; echo 2.19 + echo "このファイルは管理者のみしか見られません" | html p 2.20 + putfooter; exit 2.21 + fi 2.22 + idir=`umask 002; mktempd` || exit 1 2.23 + # tmpfiles=$tmpfiles"${tmpfiles+ }$idir" 2.24 + bin=$idir/$myname-$$.bin 2.25 + sql="select quote(bin) from $1 where rowid='$2';" 2.26 + sq $db "$sql" | unhexize > $bin 2.27 + tv=`query "select type,val from $1 where rowid='$2';"` 2.28 + type=${tv%\|*} fn=${tv#*\|} 2.29 + err tv=$tv type=$type fn=$fn, tp2=${tv%\|*} 2.30 + ct=${type#file:} 2.31 + case $ct in # all text/* changed to text/plain 2.32 + text/*) 2.33 + charset=`nkf -g $bin|cut -d' ' -f1` 2.34 + case $charset in 2.35 + ASCII*) charset="" ;; 2.36 + esac 2.37 + ct="text/plain${charset:+; charset=$charset}" 2.38 + ;; 2.39 + esac 2.40 + contenttype "$ct" 2.41 + echo "Content-Disposition: filename=\"$fn\"" 2.42 + echo "Content-Length: " `cat $bin | wc -c`; echo 2.43 + #echo "Content-Type: " ${type#file:}; echo 2.44 + cat $bin 2.45 +}
3.1 --- a/s4.cgi Fri Jul 31 10:04:14 2015 +0900 3.2 +++ b/s4.cgi Fri Jul 31 10:35:04 2015 +0900 3.3 @@ -158,7 +158,7 @@ 3.4 echo "無効な指定です。普通のアクセスならここに来ないはず。"|html p 3.5 fi 3.6 ;; 3.7 - "blog") 3.8 + "blog") # $2=grpID 3.9 contenttype; echo 3.10 . ./s4-blog.sh 3.11 blog_addentry $2 3.12 @@ -282,34 +282,8 @@ 3.13 ;; 3.14 "showattc") 3.15 # $2=table_m $3=rowid $4=val 3.16 - if ! isfilereadable $user $2 $3; then 3.17 - contenttype; echo 3.18 - echo "このファイルは管理者のみしか見られません" | html p 3.19 - putfooter; exit 3.20 - fi 3.21 - idir=`umask 002; mktempd` || exit 1 3.22 - # tmpfiles=$tmpfiles"${tmpfiles+ }$idir" 3.23 - bin=$idir/$myname-$$.bin 3.24 - sql="select quote(bin) from $2 where rowid='$3';" 3.25 - sq $db "$sql" | unhexize > $bin 3.26 - tv=`query "select type,val from $2 where rowid='$3';"` 3.27 - type=${tv%\|*} fn=${tv#*\|} 3.28 - err tv=$tv type=$type fn=$fn, tp2=${tv%\|*} 3.29 - ct=${type#file:} 3.30 - case $ct in # all text/* changed to text/plain 3.31 - text/*) 3.32 - charset=`nkf -g $bin|cut -d' ' -f1` 3.33 - case $charset in 3.34 - ASCII*) charset="" ;; 3.35 - esac 3.36 - ct="text/plain${charset:+; charset=$charset}" 3.37 - ;; 3.38 - esac 3.39 - contenttype "$ct" 3.40 - echo "Content-Disposition: filename=\"$fn\"" 3.41 - echo "Content-Length: " `cat $bin | wc -c`; echo 3.42 - #echo "Content-Type: " ${type#file:}; echo 3.43 - cat $bin 3.44 + shift 3.45 + showattc "$@" 3.46 exit 0 3.47 ;; 3.48 "gallery")