#!./exu -- Collect Micro-Economy Vote and e-mail it to RDS -- In the HTML form: -- method="POST" action="cgi-bin/economy.exu" -- Set the permission of this .exu file to chmod 755 include wildcard.e include get.e constant TRUE = 1, FALSE = 0 constant TITLE = 1, AUTHOR = 2, MONEY = 3 constant emailaddress = "rds@RapidEuphoria.com", fromemailaddress = "economy@RapidEuphoria.com" function hex_char(integer c) -- is c a valid hex character? return find(c, "0123456789ABCDEFabcdef") end function function hex_val(integer c) -- return value of a hex character if c >= 'A' and c <= 'F' then return 10 + c - 'A' elsif c >= 'a' and c <= 'f' then return 10 + c - 'a' else return c - '0' end if end function function parse_input(sequence s) -- crack the syntax sent from Web browser: aaa=bbb&ccc=ddd&... -- Convert to {{"aaa", "bbb"}, {"ccc", "ddd"}, ...} left-right pairs integer i, c sequence word_pairs, left_word, right_word word_pairs = {} i = 1 s &= {0,0,0} -- end markers while s[i] != 0 do left_word = "" while 1 do -- build left word c = s[i] if c = '=' or c = '&' or c = 0 then exit end if if c = '%' and hex_char(s[i+1]) and hex_char(s[i+2]) then c = 16 * hex_val(s[i+1]) + hex_val(s[i+2]) i += 2 elsif c = '+' then c = ' ' end if left_word &= c i += 1 end while i += 1 right_word = "" while 1 do -- build right word c = s[i] if c = '&' or c = 0 then exit end if if c = '%' and hex_char(s[i+1]) and hex_char(s[i+2]) then c = 16 * hex_val(s[i+1]) + hex_val(s[i+2]) i += 2 elsif c = '+' then c = ' ' end if right_word &= c i += 1 end while i += 1 word_pairs = append(word_pairs, {left_word, right_word}) end while return word_pairs end function procedure print_HTMLheader() -- Start of HTML output to user puts(1, "Content-type: text/html\n\n") puts(1, "
\n") puts(1, msg) puts(1, "