49 lines
1.2 KiB
Bash
49 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
title=$(cat ${post_multipart[2]} | sed -s 's/<//g;s/://g' | tr -d '\n\r')
|
|
msg=$(cat ${post_multipart[3]} | sed -E 's/<//g;s/$/<br>/g;s/://g' | tr -d '\n\r')
|
|
img=${post_multipart[4]}
|
|
img_name=$(basename ${post_multipart[4]})
|
|
rel=$(cat ${post_multipart[0]} | sed -E 's/<//g;s/\r//g')
|
|
|
|
if [[ $title == '' && $rel == '' ]]; then
|
|
echo "Empty title?"
|
|
return 1
|
|
fi
|
|
|
|
if [[ $(file --mime-type -b $img) == "image/"* ]]; then
|
|
mv "$img" "$pwd/i/$img_name"
|
|
img_copied_url="i/$img_name"
|
|
elif [[ $rel == 'new' ]]; then
|
|
echo "No image?"
|
|
return 1
|
|
elif [[ $msg == '<br>' ]]; then
|
|
echo "Post something!"
|
|
return 1
|
|
fi
|
|
|
|
if session_verify ${cookies[sh_session]}; then
|
|
username=$(session_get_username ${cookies[sh_session]})
|
|
else
|
|
username='Anon'
|
|
fi
|
|
|
|
if [[ $rel == *"new"* ]]; then
|
|
rel=$(($(ls storage/threads/ | wc -l)+1))
|
|
touch "storage/threads/$rel"
|
|
fi
|
|
|
|
if [[ -f "storage/threads/$rel" ]]; then
|
|
echo "$username:$title:$msg:$img_name" | sed -E "s/\r//g" >> "storage/threads/$rel"
|
|
else
|
|
echo "No such thread!!"
|
|
return 1
|
|
fi
|
|
|
|
meta[redirect]="thread.shs?id=$rel"
|
|
|
|
source templates/head.sh
|
|
|
|
echo "Submitted succesfully.<br>
|
|
<a href='thread.shs?id=$rel'>Click here if you're not redirected</a>"
|