57 lines
1.4 KiB
Bash
Executable File
57 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
domainprefix="https://paste.megumin.tech/"
|
|
|
|
if [[ ${post_data[paste]} ]]; then
|
|
filepath=$(mktemp -p $pwd XXX)
|
|
filename=$(basename $filepath)
|
|
if [[ ${post_data[public]} == "on" ]]; then
|
|
echo $filename >> $pwd/list
|
|
fi
|
|
if session_verify ${cookies[sh_session]}; then
|
|
echo "$filename:$(session_get_username ${cookies[sh_session]})" >> storage/pastes
|
|
fi
|
|
echo -e $(echo "${post_data[paste]}" | sed -E 's/\+/ /g;s/\%/\\x/g') > $filepath
|
|
meta[redirect]="$domainprefix$filename"
|
|
fi
|
|
|
|
source templates/head.sh
|
|
|
|
echo "<body>
|
|
|
|
<form method='post'>
|
|
<input type='submit' value='Send!'>
|
|
<input type='checkbox' name='public'>
|
|
<label for='public'>Public?</label><br>
|
|
<textarea name='paste' rows='25' cols='80'></textarea>
|
|
</form>
|
|
"
|
|
|
|
if session_verify ${cookies[sh_session]}; then
|
|
echo "<h3>Your pastes:</h3>"
|
|
pastes=$(grep -E "$(session_get_username ${cookies[sh_session]})\$" storage/pastes)
|
|
if [[ $pastes != '' ]]; then
|
|
echo "<ol>"
|
|
for i in $pastes; do
|
|
IFS=':'
|
|
array=($i)
|
|
echo "<li><a href='${array[0]}'>${array[0]}</a></li>"
|
|
done
|
|
echo "</ol>"
|
|
else
|
|
echo "You currently do not have any pastes."
|
|
fi
|
|
else
|
|
echo "If you log in, we'll be able to show you your paste history here :)"
|
|
fi
|
|
|
|
echo "<h3>Latest public pastes:</h3><ol>"
|
|
public=$(tac $pwd/list | head -n 10)
|
|
|
|
IFS=$'\n'
|
|
for i in $public; do
|
|
echo "<li><a href='$domainprefix$i'>$i</a></li>"
|
|
done
|
|
unset IFS
|
|
echo "</li>"
|
|
|