view nakamachi/retry.rb @ 462:aa75146ef679

cgimailtest
author FUJIKAWA Kosuke <c111126@g.koeki-u.ac.jp>
date Thu, 06 Feb 2014 20:57:32 +0900
parents 1032a7338ed2
children 4d98e46eee49
line wrap: on
line source

#!/usr/bin/env ruby
#coding:euc-jp

require 'cgi'
require 'kconv'

cgi = CGI.new(:accept_charset=>"EUC-JP")
print "Content-type: text/html; charset=EUC-JP\n\n"

pon = cgi["pon"].to_i
store = cgi["store"].to_i
num = cgi["num"].toeuc

n = 0
ban = Array.new
data = Hash.new

open("hoge.dat","r") do |hoge|
  while line = hoge.gets
    if /(\d+)\s+(\d+)\s+(\d+)\s+(\S+)/ =~ line
      ban[n] = $1.to_i
      data[$1.to_i] = $2.to_i,$3.to_i,$4
      n += 1
    end
  end
end

if data[ban[pon-1]][2].toeuc == num && data[ban[pon-1]][1] == store then
  printf(<<_EOS_,data[ban[pon-1]][0])
<html>
<head>
<title>OK</title>
</head>
<body>
<h1>確認しました。</h1>
<p>QRコードを再表示します</p>
<p><img src=\"qr%d.png\" alt=\"クーポン表示QRコード\"></p>
<p><a href=\"retry.html\">もどる</a></p>
</body>
</html>
_EOS_
  
else
#print(<<_EOS_)
puts"<html>
<head>
<title>Not found</title>
</head>
<body>
<h1>入力が正しくありません</h1>
<p>正しく入力してやり直してください</p>
<p><a href=\"retry.html\">もどる</a></p>
</body>
</html>
"  

end

yatex.org