Mercurial > hgrepos > hgweb.cgi > skipweb
view oasis2015/accountcheck.rb @ 3037:8b4783e846f6
fishing part7
author | SUZUKI Naoyuki <c111086@g.koeki-u.ac.jp> |
---|---|
date | Tue, 15 Dec 2015 19:21:54 +0900 |
parents | 9de92588aa9f |
children |
line wrap: on
line source
#!/usr/bin/env ruby22 # -*- coding: utf-8 -*- require 'sqlite3' require 'kconv' require 'cgi' c = CGI.new(:tag_maker => "html5", :accept_charest => "UTF-8") db = SQLite3::Database.new("sql/main.sq3") sql = "insert into test values(?, ?, ?, ?, ?, ?, ?, ?, ?)" toi = "insert into toi values (?, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)" item = "insert into goods values (?, 0, 0, 0, 0, 0, 0)" name = c["name"] cle1 = "CREATE TABLE IF NOT EXISTS test(id, name, cal, age, sex, aria, exp, pt, lv)" cle2 = "CREATE TABLE IF NOT EXISTS toi(id, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10)" cle3 = "CREATE TABLE IF NOT EXISTS goods(id, g1, g2, g3, g4, g5, g6)" cle4 = "CREATE TABLE IF NOT EXISTS time(cd, now, id)" cle5 = "CREATE TABLE IF NOT EXISTS num(cd, id)" cle6 = "CREATE TABLE IF NOT EXISTS pass(id, pass, name)" ins4 = 'insert into time values(?, 61, "n")' ins5 = 'insert into num values("aa",0)' ins6 = 'insert into pass values(?, ?, ?)' num = "select id from num where cd = ?" numup = "update num set id = ? where cd = ?" db.execute(cle1) db.execute(cle2) db.execute(cle3) db.execute(cle4) db.execute(cle5) db.execute(cle6) if name == "createman789789789" db.execute(ins4, "a") db.execute(ins4, "b") db.execute(ins4, "c") db.execute(ins4, "d") db.execute(ins4, "e") db.execute(ins4, "f") db.execute(ins4, "g") db.execute(ins4, "h") db.execute(ins4, "i") db.execute(ins4, "j") db.execute(ins5) end name = c["name"] namae = "#{name}" cal = c["cal"] age = c["age"] sex = c["sex"] aria = c["aria"] id = c.cookies["id"][0] pass = c.cookies["pass"][0] if id == nil # srand # id = rand(1000) number = db.execute(num, "aa") id = number[0][0].to_i + 1 exp = 0 pt = 0 lv = 1 cd = "aa" if pass == nil pass = id end db.execute(ins6, id, pass, name) db.execute(sql, id, name, cal, age, sex, aria, exp, pt, lv) db.execute(toi, id) db.execute(item, id) db.execute(numup, id, cd) end # srand(id.to_i) # id2 = rand(1000000) id2 = pass expires = "SAT, 2 Apr 2016 00:00:00 GMT" printf("Content-type: text/html; charset=UTF-8 Set-Cookie:id=%s ;expires=%s Set-Cookie:pass=%s ;expires=%s\n\n", id, expires, id2, expires) printf(<<_EOS_, name, id.to_i) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="format-detection" content="telephone=no"> <link media="only screen and (max-device-width:480px)" href="smart.css" type="text/css" rel="stylesheet" /> <link media="screen and (min-device-width:481px)" href="profeel.css" type="text/css" rel="stylesheet" /> <link rel="shortcut icon" href="./img/cabage.png"/> <title>Registering Account</title> </head> <body> <h1>さかたっち</h1> <h2>登録が完了しました!</h2> <p>ようこそ_ %s _さん!</p> <p>あなたのIDは%04dです!</p> <div class="f1"><a href="prof.rb"><div class="lets"><span>始めよう!</span></div></a></div> <form method="POST" type="text"> </form> </body></html> _EOS_ if name == "createman987987987" `rm sql/main.sq3` # `touch sql/main.sq3` # `chmod a+w sql/main.sq3` end