#!/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 = < <%= open(CALLERDIR+"../1blok2e.inc") { |f| f.read } %>

TeX user groups around the world

<% if errmess.empty? %>

Thank you for your support of the LUG database

Your corrections will be sent to <%= ADMINS[0] %> for handling. <% else %>

Sorry, you did not correctly enter the required fields:


<%= errmess.join("
") %>

Please try again by going
<% end %>
<%= open(CALLERDIR+"../1blok4e.inc") { |f| f.read } %> <%= DateTime.now %>

EOF MESS = < 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']) }