Mercurial > hgrepos > hgweb.cgi > s4
comparison s4-funcs.sh @ 837:a6462eea48be
Multiple files upload for tablets added and file renaming fixed
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 25 Jun 2020 15:50:16 +0900 |
parents | b3516ee2bb4d |
children | de2ef47143a0 |
comparison
equal
deleted
inserted
replaced
836:b3516ee2bb4d | 837:a6462eea48be |
---|---|
61 maximagexy=1600x1600 | 61 maximagexy=1600x1600 |
62 ### maximagexy=400x400 | 62 ### maximagexy=400x400 |
63 filesize_max=$((5*1024*1024)) | 63 filesize_max=$((5*1024*1024)) |
64 filesize_max_MB="$((filesize_max/1024/1024))MB" | 64 filesize_max_MB="$((filesize_max/1024/1024))MB" |
65 file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*"' | 65 file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*"' |
66 file_accept='accept=".jpg,.jpeg,.gif,.png,.tiff,.pdf,.odt,.ods,.odp,.odg,.mp3,.mp4,.avi,.ogg,.mov,.webm,.gpx,.json,.geojson,.kml,.html,.css,.rb,.c,.txt,.zip,.xcf,.bz2,.gz,.xz,.7z,.csv,.dat"' | 66 file_accept='accept=".jpg,.jpeg,.gif,.png,.tiff,.pdf,.odt,.ods,.odp,.odg,.mp3,.mp4,.avi,.ogg,.mov,.webm,.gpx,.json,.geojson,.kml,.html,.css,.rb,.c,.h,.txt,.tex,.sty,.zip,.xcf,.bz2,.gz,.xz,.7z,.csv,.dat"' |
67 file_accept_egrep='^(text/|message/|image/|audio/|video/|application/(vnd.oasis|pdf|epub|xml|zip|[xz]-))' | 67 file_accept_egrep='^(text/|message/|image/|audio/|video/|application/(vnd.oasis|pdf|epub|xml|zip|[xz]-))' |
68 file_accept_help=" | 68 file_accept_help=" |
69 添付可能ファイル: テキスト、画像、音声、動画、ODF、PDF、 | 69 添付可能ファイル: テキスト、画像、音声、動画、ODF、PDF、 |
70 圧縮ファイル、データベースファイル | 70 圧縮ファイル、データベースファイル |
71 (いずれも ${filesize_max_MB} 以内) | 71 (いずれも ${filesize_max_MB} 以内) |
2939 fi | 2939 fi |
2940 done | 2940 done |
2941 fi | 2941 fi |
2942 subj=`getpar subject` | 2942 subj=`getpar subject` |
2943 afiles="" | 2943 afiles="" |
2944 for fn in `query "SELECT DISTINCT val FROM par WHERE var='files' AND sessid='$session';"` | 2944 for fn in `query "SELECT DISTINCT val FROM par WHERE var='image' AND sessid='$session';"` |
2945 do | 2945 do |
2946 f=$tmpd/$fn | 2946 f=$tmpd/$fn |
2947 if [ -s $f ]; then | 2947 if [ -s $f ]; then |
2948 afiles=$afiles"${afiles:+ }$f" | 2948 afiles=$afiles"${afiles:+ }$f" |
2949 fi | 2949 fi |
3142 <td>`cgi_checkbox sender yes 'checked'`<small></small> | 3142 <td>`cgi_checkbox sender yes 'checked'`<small></small> |
3143 </td></tr> | 3143 </td></tr> |
3144 <tr><td>Subject: </td><td>`cgi_text subject`</td></tr> | 3144 <tr><td>Subject: </td><td>`cgi_text subject`</td></tr> |
3145 <tr><td>追加宛先(通常空欄): </td><td>`cgi_text supprcpt ""`</td></tr> | 3145 <tr><td>追加宛先(通常空欄): </td><td>`cgi_text supprcpt ""`</td></tr> |
3146 <tr><td>ファイル添付: </td> | 3146 <tr><td>ファイル添付: </td> |
3147 <td>`cgi_file files "" "multiple $file_accept title=\"$file_accept_help\""`<br><small>文書ファイルはPDFに変換してから</small></td></tr> | 3147 <td>`cgi_file image "" "multiple $file_accept title=\"$file_accept_help\""`<br><small>文書ファイルはPDFに変換してから</small></td></tr> |
3148 </table> | 3148 </table> |
3149 <p>(下記一覧から1人以上選択していない場合は送れません`cgi_submit 確認後送信`)</p> | 3149 <p>(下記一覧から1人以上選択していない場合は送れません`cgi_submit 確認後送信`)</p> |
3150 </div> | 3150 </div> |
3151 <div>本文:`cgi_textarea text "" cols=72` | 3151 <div>本文:`cgi_textarea text "" cols=72` |
3152 </div> | 3152 </div> |
3820 WHERE blogid NOT IN (SELECT id FROM blog) | 3820 WHERE blogid NOT IN (SELECT id FROM blog) |
3821 ) -- Remove them | 3821 ) -- Remove them |
3822 DELETE FROM article WHERE id IN (SELECT id FROM orphanedarticle); | 3822 DELETE FROM article WHERE id IN (SELECT id FROM orphanedarticle); |
3823 EOF | 3823 EOF |
3824 } | 3824 } |
3825 | |
3826 clearcachedir() ( | |
3827 td=`getcachedir "$1"` | |
3828 err td=$td: ls- `ls $td` | |
3829 if [ -w "$td/image.1" ]; then | |
3830 err Removing td=$td | |
3831 rm -fr $td/ # Clear icon-image cache! | |
3832 fi | |
3833 ) | |
3834 | |
3825 par2table() ( | 3835 par2table() ( |
3826 # copy current parameters of par into destination table | 3836 # copy current parameters of par into destination table |
3827 # $1=definition-file | 3837 # $1=definition-file |
3828 # Using $user and $session | 3838 # Using $user and $session |
3829 # Return value: | 3839 # Return value: |
3874 rm=`getpar rm` cfm=`getpar confirm` | 3884 rm=`getpar rm` cfm=`getpar confirm` |
3875 # Editing existent entry | 3885 # Editing existent entry |
3876 if [ x"$rm" = x"yes" ]; then | 3886 if [ x"$rm" = x"yes" ]; then |
3877 if [ x"$rm$cfm" = x"yesyes" ]; then | 3887 if [ x"$rm$cfm" = x"yesyes" ]; then |
3878 query "delete from $tbl where rowid=$rowid;" | 3888 query "delete from $tbl where rowid=$rowid;" |
3889 clearcachedir "$tbl/$rowid" | |
3879 if [ x"$tbl" = x"grp" -o x"$tbl" = x"blog" ]; then | 3890 if [ x"$tbl" = x"grp" -o x"$tbl" = x"blog" ]; then |
3880 clean-orphaned | 3891 clean-orphaned |
3881 fi | 3892 fi |
3882 return 4 | 3893 return 4 |
3883 else | 3894 else |
4020 ;; | 4031 ;; |
4021 mv) | 4032 mv) |
4022 # regularize filename and strip directory part | 4033 # regularize filename and strip directory part |
4023 newname=`getpar mv.$v|tr -d '":;#<>?^%$!'|tr -d "'"|tr ' ' _` | 4034 newname=`getpar mv.$v|tr -d '":;#<>?^%$!'|tr -d "'"|tr ' ' _` |
4024 newname=`basename $newname` | 4035 newname=`basename $newname` |
4025 err "newname($v)=$newname" | 4036 oldname=`query "SELECT val FROM $tb2 WHERE rowid=$st_rowid;"` |
4026 newext="${newname##*.}" | 4037 oldext=`expr "$oldname" : '.*\.\(.*\)'` |
4027 if test x"$newname" != x"$newext" \ | 4038 newext=`expr "$newname" : '.*\.\(.*\)'` |
4028 && echo "${file_accept#*=}" \ | 4039 err "p2t(mv): oldname=$oldname $oldext -> newname($v)=$newname $newext" |
4029 | fgrep -w "$newext" >/dev/null 1>&2 | 4040 if [ -n "$newname" -a x"$oldext" = x"$newext" ]; |
4030 then | 4041 then |
4031 newsql="UPDATE $tb2 SET val='$newname'" | 4042 newsql="UPDATE $tb2 SET val='$newname'" |
4032 else | 4043 else |
4033 html p<<-EOF | 4044 html p<<-EOF |
4034 $newname は取り扱えないファイル名です。 | 4045 $newname は取り扱えないファイル名です。 |
4035 空白を含まない名前で拡張子を正しくつけて下さい。 | 4046 空白を含まない名前にして下さい。 |
4047 拡張子の変更もできません。 | |
4036 EOF | 4048 EOF |
4037 continue | 4049 continue |
4038 fi | 4050 fi |
4039 ;; | 4051 ;; |
4040 *) # maybe "keep", do not modify value | 4052 *) # maybe "keep", do not modify value |
4041 continue | 4053 continue |
4042 ;; | 4054 ;; |
4043 esac | 4055 esac |
4044 # err newsql=$newsql | 4056 # err newsql=$newsql |
4045 sql=$sql$nl"$newsql where rowid=$st_rowid;" | 4057 sql=$sql$nl"$newsql where rowid=$st_rowid;" |
4058 clearcachedir "$tbl/$rowid" | |
4046 done | 4059 done |
4047 | 4060 |
4048 if [ x"$bin" = x"NULL" ]; then | 4061 if [ x"$bin" = x"NULL" ]; then |
4049 ## err repl:normal sql=`echo $sql` | 4062 ## err repl:normal sql=`echo $sql` |
4050 if [ -n "$transaction" ]; then | 4063 if [ -n "$transaction" ]; then |
4080 val=`getvalquote $tbl $col "$limit"` | 4093 val=`getvalquote $tbl $col "$limit"` |
4081 [ -z "$val" -o x"$val" = x'""' -o x"$val" = x"NULL" ] && continue | 4094 [ -z "$val" -o x"$val" = x'""' -o x"$val" = x"NULL" ] && continue |
4082 ## err $col=$val | 4095 ## err $col=$val |
4083 bin=NULL | 4096 bin=NULL |
4084 ## err partype$col=`getpartype $col "$limit"` | 4097 ## err partype$col=`getpartype $col "$limit"` |
4098 ptype=`getpartype $col "$limit"` # partype should be obtained each time | |
4085 case $ptype in | 4099 case $ptype in |
4086 file) file=$tmpd/`getparfilename $col "$limit"` | 4100 file) file=$tmpd/`getparfilename $col "$limit"` |
4087 ## err parfile-$col=$file | 4101 ## err parfile-$col=$file |
4088 [ -z "$file" ] && continue | 4102 [ -z "$file" ] && continue |
4089 bin="X'"$(hexize "$file")"'" | 4103 bin="X'"$(hexize "$file")"'" |