Mercurial > hgrepos > hgweb.cgi > s4
changeset 268:138da0f3a2e5
Duplicate post by reloading or back+submit, dissolved
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 26 Jul 2016 08:24:56 +0859 |
parents | 9bfa9bda1289 |
children | 176bf3d68c7c |
files | s4-blog.sh s4-funcs.sh |
diffstat | 2 files changed, 30 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-blog.sh Mon Jul 25 22:37:17 2016 +0859 +++ b/s4-blog.sh Tue Jul 26 08:24:56 2016 +0859 @@ -196,52 +196,39 @@ # echo r=$mrid fn=$fn case "$fn" in *.[Pp][Nn][Gg]|*.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg]|*.[Gg][Ii][Ff]) - # fmt=${fn##*.} # jpg:- is slow...why + # fmt=${fn##*.} # convert - jpg:- is slow...why case "$fn" in *.[Pp][Nn][Gg]) fmt=png ;; *.[Gg][Ii][Ff]) fmt=gif ;; *) fmt=jpeg ;; esac - if false; then # This block should be removed - sq $db "SELECT hex(bin) FROM article_m WHERE rowid=$mrid" \ - | unhexize \ - | convert -define ${fmt}:size=100x100 -resize 100x100'>' - ${fmt}:- \ - | hexize \ - | sed -e 's/\(..\)/%\1/g' \ - -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \ - -e "s|\$|\">$fnb</a>|" - else - outfile=$td/$mrid-${fn%.*}.$fmt - #err fn=$fn outfile=$outfile - #err "`ls -Fa $td`" - #rm -f $outfile - # mkfifo $outfile - #err "usecache=$usecache `ls -l $outfile`" - #err tm=$tm - #err tsfile=$tsfile=`cat $tsfile` - if [ -s $outfile ] && # $outfile should be > 0 - { [ "$usecache" ] || # And usecache flag is true, or... - { [ -s "$tsfile" ] && [ x"`cat $tsfile`" = x"$tm" ] - };}; then - # err Set usecache=1 - usecache=1 # Set usecache flag on - cat<<-EOF + outfile=$td/$mrid-${fn%.*}.$fmt + #err fn=$fn outfile=$outfile + #err "usecache=$usecache `ls -l $outfile`" + #err tm=$tm + #err tsfile=$tsfile=`cat $tsfile` + if [ -s $outfile ] && # $outfile should be > 0 + { [ "$usecache" ] || # And usecache flag is true, or... + { [ -s "$tsfile" ] && [ x"`cat $tsfile`" = x"$tm" ] + };}; then + # err Set usecache=1 + usecache=1 # Set usecache flag on + cat<<-EOF <a href="$catlink+$mrid"><img src="$outfile"> $fnb</a> EOF - else - query "SELECT hex(bin) FROM article_m WHERE rowid=$mrid;" \ - | unhexize \ - | convert -define ${fmt}:size=100x100 -resize 100x100'>' \ - - ${fmt}:- \ - | tee "$outfile" \ - | hexize \ - | sed -e 's/\(..\)/%\1/g' \ - -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \ - -e "s|\$|\">$fnb</a>|" - [ -d $td ] || mkdir -p "$td" - echo $tm > $tsfile - fi + else + query "SELECT hex(bin) FROM article_m WHERE rowid=$mrid;" \ + | unhexize \ + | convert -define ${fmt}:size=100x100 -resize 100x100'>' \ + - ${fmt}:- \ + | tee "$outfile" \ + | hexize \ + | sed -e 's/\(..\)/%\1/g' \ + -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \ + -e "s|\$|\">$fnb</a>|" + [ -d $td ] || mkdir -p "$td" + echo $tm > $tsfile fi ;; *) @@ -271,6 +258,7 @@ $iswritable && cat<<-EOF <div class="blogcomment"> <input type="hidden" name="blogid" value="$id"> + <input type="hidden" name="id" value="`genserial`"> <input type="hidden" name="stage" value="replyblog"> $textform </div>
--- a/s4-funcs.sh Mon Jul 25 22:37:17 2016 +0859 +++ b/s4-funcs.sh Tue Jul 26 08:24:56 2016 +0859 @@ -953,6 +953,9 @@ # $1=columns (default: 10) dd if=/dev/urandom count=1 2>/dev/null|nkf -MB|fold -w${1:-10}|sed -n 10p } +genserial() { + echo $((($(date +%s)-1433084400)/10))c$$ +} smail() { # smail rcpts subj (file) # $SMAIL_TO <- Recipient value of To: header @@ -3069,7 +3072,7 @@ ;; [Ss][Ee][Rr][Ii][Aa][Ll]|[Ss][Tt][Aa][Mm][Pp]) if [ -z "$rowid" ]; then - val=$((($(date +%s)-1433084400)/10))c$$ + val=`genserial` fi form="<input type=\"hidden\" name=\"$name\" value=\"$val\">" prompt="" ;;