From 1df6f8d8c85d0dbdaab93b9ee32c396e317cae29 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 20 Nov 2014 20:54:19 +0000 Subject: [PATCH] simplify code flow, link to edited article after return svn path=/trunk/; revision=56 --- actions/introedit.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/actions/introedit.sh b/actions/introedit.sh index d55b1b2..5f987fd 100755 --- a/actions/introedit.sh +++ b/actions/introedit.sh @@ -16,24 +16,29 @@ # along with Busy. If not, see . -info="$(echo -E "$_GET[\"i\"]" |grep -Ex 'intro|news')" +info="$(echo -E "$_GET[\"i\"]" |grep -Ex 'intro|news|[0-9]{10}_[0-9]{3}')" + +case "$info" in + news) + $ACL_ADDNEWS \ + && file="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3).news" \ + || info='' + ;; + intro) + $ACL_EDITINTRO \ + && file="intro" \ + || info='' + ;; + *) $ACL_EDITNEWS \ + && file="${info}.news" \ + || info='' +esac -if [ "$info" = "news" ]; then - $ACL_ADDNEWS || info='' -elif [ "$info" = "intro" ]; then - $ACL_EDITINTRO || info='' -elif [ -z "$info" ]; then - $ACL_EDITNEWS || info='' -fi [ -n "$info" ] || echo -n "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n" [ -n "$info" ] || exit 0 -[ "$info" = "news" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)" -[ "$info" != "intro" ] && info="${info}.news" -[ "$info" = "intro" ] && ($ACL_EDITINTRO || info='') - cgi_post -[ -z "$_POST[\"cancel\"]" ] && echo -E "$_POST[\"text\"]" >"$_DATA/Home/$info" +[ -z "$_POST[\"cancel\"]" ] && echo -E "$_POST[\"text\"]" >"$_DATA/Home/${file}" -echo -n "Location: ${HTTP_REFERER}\n\n" +echo -n "Location: ${HTTP_REFERER}#news_${info}\n\n" -- 2.39.2