Name: Anonymous 2013-01-22 17:39
#!/bin/bash
# posix sh is for virgins
cool(){
tput setaf 2 ; echo -n ">>> " ; tput sgr0 ; echo -e -n "$*"
}
nah(){
tput setaf 1 ; echo -n ">>> " ; tput sgr0 ; echo -e -n "$*"
}
cool "This script requres the ncurses library to function!\n"
cool "----------------------------------------------------\n"
cool "Welcome to the cool BBCode decompiler! Decompile yo-\n"
cool "ur favourite BBCode with this handy Bash script! It \n"
cool "is super easy and takes no time at all! \n"
cool "----------------------------------------------------\n"
cool "This script is licensed under the BSD license, which\n"
cool "means you may use it for commercial work! Impress y-\n"
cool "our friends with this script and make it your own!!!\n"
make_a_temp_file(){
cash_cheque=`mktemp`
money_order=`mktemp`
}
[[ -f "$1" ]] || nah "404!\n"
make_a_temp_file
cat "$1" > "$cash_cheque"
prepare_cod(){
cat "$cash_cheque" | sed 's/<blockquote>/--- BEGIN SOURCE CODE ---/g' > "$money_order" && cool "Replacing starting tags!\n"
cat "$money_order" | sed 's/<\/blockquote>/--- END SOURCE CODE ---/g' > "$cash_cheque" && cool "Replacing ending tags!\n"
cat "$cash_cheque" | sed 's/<p>/-- BEGIN PARAGRAPH --/g' > "$money_order" && cool "Replacing paragraph tags (part 1/2)!\n"
cat "$money_order" | sed 's/<\/p>/--END PARAGRAPH --/g' > "$cash_cheque" && cool "Replacing paragraph tags (part 2/2)!\n"
cat "$cash_cheque" | sed 's/<br\/>//g' > "$money_order" && cool "Replacing line butts!\n"
cat "$money_order" | sed -e 's/<sup>/\[sup\]/g' -e 's/<\/sup>/\[\/sup\]/g' > "$cash_cheque" && cool "Replacing super scripts\n"
cat "$cash_cheque" | sed -e 's/<sub>/\[sub\]/g' -e 's/<\/sub>/\[\/sub\]/g' > "$money_order" && cool "Replacing sub script text\n"
cat "$money_order" | sed -e 's/<b>/\[b\]/g' -e 's/<i>/\[i\]/g' -e 's/<u>/\[u\]/g' -e 's/<\/b>/\[\/b\]/g' -e 's/<\/i>/\[\/i\]/g' -e 's/<\/u>/\[\/u\]/g' > "$cash_cheque"
cat "$cash_cheque" | sed -e 's/<code>/\[code\]/g' -e 's/<\/code>/\[\/code\]/g' > "$money_order"
}
prepare_cod
cat "$cash_cheque"
# cat "$money_order"
rm "$cash_cheque"
rm "$money_order"and here's the bb src m working with:
<blockquote>
<p>
As <code>esr</code> so eloquently puts it in <u>How To Become A Hacker</u><sup>[1]</sup>:<br/>
<span class='quote'>The problem with screen names or handles deserves some amplification. Concealing your identity behind a handle is a juvenile and silly behavior characteristic of crackers, warez d00dz, and other lower life forms. <b>Hackers don't do this; they're proud of what they do and want it associated with their <i>real</i> names.</b> So if you have a handle, drop it. In the hacker culture it will only mark you as a loser.</span><br/>
<br/>
So if you guys and girls want to get respect as programmers, you'd better use your real names from here on out.<br/>
<br/>
<span class='eop'>[sub]</span>________________________________________<br/>
<sup>[1]</sup> - <a rel="nofollow" href="http://www.catb.org/~esr/faqs/hacker-howto.html#style" target='_blank'>http://www.catb.org/~esr/faqs/hacker-howto.html#style</a><span class='ecl'>[/sup]</span>
</p>
</blockquote>