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 wrap: on
line diff
--- a/s4-blog.sh	Fri Jul 31 10:04:14 2015 +0900
+++ b/s4-blog.sh	Fri Jul 31 10:35:04 2015 +0900
@@ -157,9 +157,10 @@
 
 		       #data=`percenthex $td/$fn`
 		       #ct=`cat $td/$fn.content-type`
+		       sz=`cat $td/$fn.size`
 		       ri=`cat $td/$fn.rowid`
 err fn=$fn ct=$ct ri=$ri; ls -lF $td/ 1>&3
-			iconhref $td/$fn "$hrfb+$ri" "$fn" "$fn"
+			iconhref $td/$fn "$hrfb+$ri" "$fn" "$fn($sz)"
 		     done)
 	imgs=`echo "$imgs"|tr -d '\n'`	# kill newlines for sed
       fi
--- a/s4-funcs.sh	Fri Jul 31 10:04:14 2015 +0900
+++ b/s4-funcs.sh	Fri Jul 31 10:35:04 2015 +0900
@@ -555,6 +555,7 @@
 EOF
 		 ## err i=$i - file=$file rowid=`cat $td/$fn.rowid`
 		 ln $td/$fn.rowid $file.rowid 2>&3 # for convenience
+		 ls -lh $file | awk '{print $5"B"}' > $file.size
 		 case $type in
 		   *:[Ii]mage*) mogrify -geometry $thumbxy $file ;;
 		   ### ここのアイコンを増やしたい
@@ -2181,3 +2182,34 @@
 	   -D_DUMPTABLE_="syscmd(cat)" \
 	   $layout/html.m4.html $layout/form+dump.m4.html
 }
+showattc() {
+  # $1=table_m $2=rowid $3=val
+  if ! isfilereadable $user $1 $2; then
+    contenttype; echo
+    echo "このファイルは管理者のみしか見られません" | html p
+    putfooter; exit
+  fi
+  idir=`umask 002; mktempd` || exit 1
+  # tmpfiles=$tmpfiles"${tmpfiles+ }$idir"
+  bin=$idir/$myname-$$.bin
+  sql="select quote(bin) from $1 where rowid='$2';"
+  sq $db "$sql" | unhexize > $bin
+  tv=`query "select type,val from $1 where rowid='$2';"`
+  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
+}
--- a/s4.cgi	Fri Jul 31 10:04:14 2015 +0900
+++ b/s4.cgi	Fri Jul 31 10:35:04 2015 +0900
@@ -158,7 +158,7 @@
       echo "無効な指定です。普通のアクセスならここに来ないはず。"|html p
     fi
     ;;
-  "blog")
+  "blog")	# $2=grpID
     contenttype; echo
     . ./s4-blog.sh
     blog_addentry $2
@@ -282,34 +282,8 @@
     ;;
   "showattc")
     # $2=table_m $3=rowid $4=val
-    if ! isfilereadable $user $2 $3; then
-      contenttype; echo
-      echo "このファイルは管理者のみしか見られません" | html 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
+    shift
+    showattc "$@"
     exit 0
    ;;
   "gallery")

yatex.org