# You should have received a copy of the GNU Affero General Public License
# along with Busy. If not, see <http://www.gnu.org/licenses/>.
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
- if (echo "${line}" | egrep -xq 'user=.+'); then
- user="$(echo "${line}" |cut -d= -f2- |sed 's/+/ /g;s/%/\\x/g')"
- user=$(echo -e "${user}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)
- elif (echo "${line}" | egrep -xq 'pass=.+'); then
- pass="$(echo "${line}" |cut -d= -f2- |sed 's/+/ /g;s/%/\\x/g')"
- pass=$(echo -e "${pass}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g')
- fi
-done
-fi
+$ACL_WIKIEDIT || echo "Location: //${HTTP_HOST}/?p=Error&i=noaccess\n\n"
+$ACL_WIKIEDIT || exit 0
-echo -n "Location: https://${user}:${pass}@${HTTP_HOST}/session.cgi?${QUERY_STRING}\n\n"
+page="$(echo -E "$_GET[\"p\"]" |egrep -Ex 'Wiki')"
+edit="$(echo -E "$_GET[\"e\"]" |egrep -Ex '[0-9]{10}_[0-9]{3}(_[0-9]{1,4})?')"
+
+case "$page" in
+ Wiki) [ -f "$_DATA/Wiki/${edit}" ] && echo "${USER}:$(($(date +%s)+600))" >"$_DATA/Wiki/${edit}.lock"
+ echo -n "Location: //${HTTP_HOST}/?p=Wiki&e=$edit\n\n"
+ ;;
+ *) echo -n "Location: //${HTTP_HOST}/?p=Error&r=input&$page\n\n"
+ exit 0
+ ;;
+esac