Mercurial > hgrepos > hgweb.cgi > skipweb
view mackey/academy/ans.rb @ 2581:1db4ed79727a
beerฃฒ
author | ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp> |
---|---|
date | Sun, 26 Jul 2015 13:03:56 +0900 |
parents | 2ee6e6efc0dd |
children |
line wrap: on
line source
#!/usr/bin/ruby # coding: utf-8 require 'cgi' c = CGI.new(:accept_charset => "utf-8") print "Content-type: text/html; charset=utf-8\n\n" check = c["answer"] quiznum = c["dat"] srand number=rand(1060) num = 0 damage = "" quiz = "" ansone = "" anstwo = "" ansthi = "" ansfou = "" anstrue = "" open("data.txt", "r:utf-8") do |list| while line = list.gets if /(\d+),(\S+),(\S+),(\S+),(\S+),(\S+),(\d)/ =~ line if quiznum.to_i == $1.to_i if check.to_i == $7.to_i damage = "ๆปๆๆๅ๏ผ" else damage = "ๆปๆๅคฑๆ!" end end if number.to_i == $1.to_i num = $1.to_i quiz = $2.to_s ansone = $3.to_s anstwo = $4.to_s ansthi = $5.to_s ansfou = $6.to_s anstrue = $7.to_i end end end end printf("<html> <head> <title>ใใฟใฎใใใใใ ใ!</title> <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\"> </head> <body> <h1>ใใฟใฎใใใใใ ใ</h1> <h2>#{damage}</h2> <p>No.#{number}</p> <div class=\"main\"> <div> <img border=\"1\" src=\"maou.png\" width=\"480\" height=\"320\" alt=\"ใพใใใฎใใใใฃใฝใใ\" title=\"ใพใใ\"> <h2>ๅ้ก</h2> <p>%s</p> <form method=\"POST\" action=\"ans.rb\"> <button class=\"css3button\" type=\"submit\" name=\"answer\" value=\"1\">%s</bu\ tton> <button class=\"css3button\" type=\"submit\" name=\"answer\" value=\"2\">%s</bu\ tton> <button class=\"css3button\" type=\"submit\" name=\"answer\" value=\"3\">%s<br></bu\ tton> <button class=\"css3button\" type=\"submit\" name=\"answer\" value=\"4\">%s<br></bu\ tton> <input type=\"hidden\" name=\"dat\" value=\"%d\"> </form> </div> </div> </body> </html>", quiz, ansone, anstwo, ansthi, ansfou, num)