Mercurial > hgrepos > hgweb.cgi > skipweb
changeset 872:a6eea85ff9fe
-system
author | ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp> |
---|---|
date | Fri, 23 Oct 2015 15:41:15 +0900 |
parents | fb7551b76cdf |
children | bb9de4387ed1 |
files | opencampus2015/#accountcheck.rb# opencampus2015/.#accountcheck.rb opencampus2015/accountcheck.rb |
diffstat | 3 files changed, 47 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/opencampus2015/#accountcheck.rb# Fri Oct 23 14:43:10 2015 +0900 +++ b/opencampus2015/#accountcheck.rb# Fri Oct 23 15:41:15 2015 +0900 @@ -4,10 +4,11 @@ require 'sqlite3' require 'kconv' require 'cgi' +require 'csv' c = CGI.new(:tag_maker => "html5", :accept_charest => "UTF-8") db = SQLite3::Database.new("sql/main.sq3") - +csv = "list.csv" sql = "insert into test values(?, ?, ?, ?, ?, ?, ?, ?, ?)" @@ -24,8 +25,8 @@ cle6 = "CREATE TABLE IF NOT EXISTS pass(id, pass, name)" cle7 = "CREATE TABLE IF NOT EXISTS zukan(no, name, tah, lv2, lv3, lv4, lv5)" -cle8 = "CREATE TABLE IF NOT EXISTS box(id, i1 ,e1 ,t1 , tm2, i2 ,e2 ,t2 , tm2, i3 ,e3 ,t3 ,tm3)" -ins8 = ".import list.csv zukan" +cle8 = "CREATE TABLE IF NOT EXISTS box(id, no1, e1, t1, tm1, no2, e2, t2, tm2, no3, e3, t3, tm3)" +ins8 = "insert into box values(?,?,0,?,?,0,0,0,0,0,0,0,0)" ins4 = 'insert into time values(?, 61, "n")' ins5 = 'insert into num values("aa",0)' @@ -42,18 +43,12 @@ db.execute(cle7) db.execute(cle8) 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) -db.execute(ins8) + ("a".."j").each{|x|db.execute(ins4,x)} + db.execute(ins5) + #system `sqlite3 -separator , /sql/main.sq3 ".import list.csv zukan"` #(ins7) + CSV.foreach(csv) do |row| + db.execute("INSERT INTO zukan VALUES(?,?,?,?,?,?,?)",*row) + end end name = c["name"] @@ -63,27 +58,31 @@ sex = c["sex"] aria = c["aria"] + id = c.cookies["id"][0] pass = c.cookies["pass"][0] +no1 = db.execute("select no from zukan where name = ?",cal)[0][0] +t1 = db.execute("select tah from zukan where name = ?",cal)[0][0] + if id == nil number = db.execute(num, "aa") -begin - id = number[0][0].to_i + 1 -rescue - 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) - id = number[0][0].to_i + 1 -end + begin + id = number[0][0].to_i + 1 + rescue + ("a".."j").each{|x| db.execute(ins4,x)} + # 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) + id = number[0][0].to_i + 1 + end exp = 0 pt = 0 lv = 1 @@ -94,8 +93,9 @@ 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(item, id) db.execute(numup, id, cd) + db.execute(ins8,id,no1,t1.to_i/5,t1) end # srand(id.to_i) # id2 = rand(1000000) @@ -127,19 +127,16 @@ </head> <body> -<h1>ほげほげ</h1> -<h2>登録が完了しました!</h2> -<p>ようこそ_ %s _さん!</p> -<p>あなたのIDは%04dです!</p> +<h1>Miyazac Quest</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` +filename ='sql/main.sq3' +File.delete filename end
--- a/opencampus2015/.#accountcheck.rb Fri Oct 23 14:43:10 2015 +0900 +++ b/opencampus2015/.#accountcheck.rb Fri Oct 23 15:41:15 2015 +0900 @@ -1,1 +1,1 @@ -c113007@roy.e.koeki-u.ac.jp.20783 \ No newline at end of file +c113007@roy.e.koeki-u.ac.jp.21432 \ No newline at end of file
--- a/opencampus2015/accountcheck.rb Fri Oct 23 14:43:10 2015 +0900 +++ b/opencampus2015/accountcheck.rb Fri Oct 23 15:41:15 2015 +0900 @@ -44,11 +44,11 @@ db.execute(cle8) if name == "createman789789789" ("a".."j").each{|x|db.execute(ins4,x)} -db.execute(ins5) -#system `sqlite3 -separator , /sql/main.sq3 ".import list.csv zukan"` #(ins7) -CSV.foreach(csv) do |row| -db.execute("INSERT INTO zukan VALUES(?,?,?,?,?,?,?)",*row) -end + db.execute(ins5) + #system `sqlite3 -separator , /sql/main.sq3 ".import list.csv zukan"` #(ins7) + CSV.foreach(csv) do |row| + db.execute("INSERT INTO zukan VALUES(?,?,?,?,?,?,?)",*row) + end end name = c["name"] @@ -136,10 +136,8 @@ </form> </body></html> _EOS_ -print"#{i1},,#{t1}" - if name == "createman987987987" - `rm sql/main.sq3` -# `touch sql/main.sq3` -# `chmod a+w sql/main.sq3` +filename ='sql/main.sq3' +File.delete filename +# `rm /sql/main.sq3` end