All pastes #14877 Raw Edit

Something

public text v1 · immutable
#14877 ·published 2005-06-17 17:15 UTC
rendered paste body
#!/bin/bash
echo "Content-Type: text/html"
echo                                                                 
echo '<html>'
echo '<head>'
echo '        <title>DAFCA License Creator</title>'
echo '<link rel="STYLESHEET" type="text/css" href="../style.css">'
echo '</head>'
echo
echo '<body>'
inputs=$(cat -)

if [[ -n $inputs ]]; then
	echo $inputs | /var/www/cgi-bin/create.pl
fi



file="/var/www/html/license/database.txt"

## read each line of database file into line[]:

#echo -n 'Parsing Database...'

let linecount=0
let fieldcount=0

grablines () {
	while read line[$linecount]; do
		(( linecount++ ))
	done
}

grablines < $file




## read each word of the last line into field[]:

(( linecount=0 ))
for current in "${line[@]}"; do

IFS=\|
(( fieldcount=0 ))
unset field
	for word in ${line[(( linecount ))]}; do
		field[$fieldcount]="$word"
		(( fieldcount++ ))
	done

	if [[ -n "${field[0]}" ]]; then
		option[$linecount]="${field[0]} - ${field[20]}"
		(( linecount++ ))
	fi
done

echo 
echo '<div class="header" style="width: 788px; height: 609px">'
echo '        <img align=right src="../images/header_right.jpg" width="256" height="67" alt="" border="0" hspace=0><img src="../images/header_left.gif" width="336" height="67" alt="" border="0"><br clear=all><div class="menu">'
echo '                <a'
echo 'class="menubar" href="../license/license.htm">Create New</a>'
echo '<a class="menubar" href="/cgi-bin/edit.pl">View Database</a>'
echo '<a class="selected" href="/cgi-bin/post-license.sh">Generate Key</a>'
echo '</div>'
echo '                                                                                                                                '
echo '<table cellpadding=0 cellspacing=0 border=0>'
echo '        <tr>'
echo '                <td valign=top>'
echo '<div class="sidebartop">'
echo '        <img align=right src="../images/sidebar_top.gif" width="9" height="13" alt="" border="0"></div>'
echo '                                                                                                                                '
echo '                                                                                                                                '
echo '<div class="sidebarbottom">'
echo '        <img align=right src="../images/sidebar_bottom.gif" width="9" height="13" alt="" border="0"></div>'
echo '</td>'
echo '                <td valign=top><div class="bodytext">'
echo '<h1>Generate License Key</h1>'
echo '                                                                                                                                '
echo '<FORM action=/cgi-bin/keygen.sh method=POST>'
echo '        <p>License Company <select name="" size="1">'
let optioncount=0
for list in "${option[@]}"; do
	if [[ ! $optioncount = 0 ]]; then
		echo "                <option selected>${option[$optioncount]}</option>"
	fi
	(( optioncount++))
done
echo '                </select>'
echo '        '
echo '        <p><input type="submit" value="Submit"></p>'
echo '</form>'
echo '<p>&nbsp;</p>'
echo '                                                                                                                                '
echo '</div></td>'
echo '        </tr>'
echo '        <tr>'
echo '                <td valign=top>'
echo '&nbsp;</td>'
echo '                <td valign=top>&nbsp;</td>'
echo '        </tr>'
echo '</table>'
echo '                                                                                                                                '
echo '                                                                                                                                '
echo '                                                                                                                                '
echo '</div>'
echo '</div><br>'
echo '</body>'
echo '</html>'