diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/lug/lugs.rb |
Initial commit
Diffstat (limited to 'support/lug/lugs.rb')
-rwxr-xr-x | support/lug/lugs.rb | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/support/lug/lugs.rb b/support/lug/lugs.rb new file mode 100755 index 0000000000..06b4370097 --- /dev/null +++ b/support/lug/lugs.rb @@ -0,0 +1,110 @@ +#!/usr/bin/env ruby +# encoding: UTF-8 +require 'cgi' +require 'erb' +require 'open-uri' +require 'date' +require 'resolv' + + +# admins to be informed, one per line: +ADMINS = %w{ + wybo@dekkerdocumenten.nl +} + +RESPONSE = <<EOF +Content-type: text/html + +<%= open(CALLERDIR+"../1blok1e.inc") { |f| f.read } %> +<%= open(CALLERDIR+"../1blok2e.inc") { |f| f.read } %> +<h1>TeX user groups around the world</h1> +<% if errmess.empty? %> + <h2>Thank you for your support of the LUG database</h2> + Your corrections will be sent to <%= ADMINS[0] %> for handling. +<% else %> + <h3>Sorry, you did not correctly enter the required fields:</h3><br> + <font color="red"> + <%= errmess.join("<br>") %> + </font><p> + <form>Please try again by going + <input type="button" value="Back" onClick="history.go(-1);return true;"> + </form> +<% end %> +<hr noshade> +</td></tr></table></td></tr></table> +<%= open(CALLERDIR+"../1blok4e.inc") { |f| f.read } %> <%= DateTime.now %> +</p></div></body></html> +EOF + +MESS = <<EOF +password=<%= q['password'] %> +submitemail=<%= q['submitemail'] %> +addr=<%= q['addr'] %> +bacc=<%= q['bacc'] %> +baddr=<%= q['baddr'] %> +bank=<%= q['bank'] %> +bcode=<%= q['bcode'] %> +brout=<%= q['brout'] %> +code=<%= q['code'] %> +editor=<%= q['editor'] %> +eemail=<%= q['eemail'] %> +email=<%= q['email'] %> +faddr=<%= q['faddr'] %> +femail=<%= q['femail'] %> +ffax=<%= q['ffax'] %> +fname=<%= q['fname'] %> +fphone=<%= q['fphone'] %> +fpos=<%= q['fpos'] %> +full=<%= q['full'] %> +gaddr=<%= q['gaddr'] %> +gemail=<%= q['gemail'] %> +gfax=<%= q['gfax'] %> +gname=<%= q['gname'] %> +gphone=<%= q['gphone'] %> +gpos=<%= q['gpos'] %> +lang=<%= q['lang'] %> +list=<%= q['list'] %> +members=<%= q['members'] %> +paddr=<%= q['paddr'] %> +pemail=<%= q['pemail'] %> +pfax=<%= q['pfax'] %> +pname=<%= q['pname'] %> +pphone=<%= q['pphone'] %> +ppos=<%= q['ppos'] %> +publ=<%= q['publ'] %> +short=<%= q['short'] %> +subscr=<%= q['subscr'] %> +www=<%= q['www'] %> +country=<%= q['country'] %> +EOF + +def validate_email_domain(email) + return false unless email =~ /\@(.*)/ + Resolv::DNS.open do |dns| + @mx = dns.getresources($1, Resolv::DNS::Resource::IN::MX) + end + @mx.size > 0 ? true : false +end + +def mail(message,to,code) + m = open("|/usr/bin/mail -s '===LUG correction for #{code}===' #{to}",'w') + m.puts message + m.close +end + +q = CGI.new + +CALLERDIR=ENV['HTTP_REFERER'].sub(/[^\/]*$/,'') + +errmess = [] +q['password'] == 'kjwb' || + errmess.push("You typed the wrong (or no) password") +validate_email_domain(q['submitemail']) || + errmess.push("You must enter a valid email addres") + +message = ERB.new(RESPONSE).result +print message + +exit unless errmess.empty? +message = ERB.new(MESS).result.gsub(/\r\n/,"\n ").strip +ADMINS.each { |m| mail(message,m,q['code']) } |