changeset 2597:fb460649240b

acc
author ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp>
date Thu, 22 Oct 2015 20:55:45 +0900
parents 11e291bdd90a
children e1e651b656a6
files opencampus2015/#accountcheck.rb# opencampus2015/.#accountcheck.rb opencampus2015/accountcheck.rb opencampus2015/index.html opencampus2015/prof.rb
diffstat 5 files changed, 163 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/opencampus2015/#accountcheck.rb#	Thu Oct 22 20:55:45 2015 +0900
@@ -0,0 +1,145 @@
+#!/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"]
+pswd = c["pswd"]
+cle1 = "CREATE TABLE IF NOT EXISTS test(id, name, cal, age, sex, pswd, 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)"
+
+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"
+
+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)
+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)
+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
+  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
+  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, 24 Oct 2015 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/opencampus2015/.#accountcheck.rb	Thu Oct 22 20:55:45 2015 +0900
@@ -0,0 +1,1 @@
+c113007@roy.e.koeki-u.ac.jp.20783
\ No newline at end of file
--- a/opencampus2015/accountcheck.rb	Thu Oct 22 18:40:12 2015 +0900
+++ b/opencampus2015/accountcheck.rb	Thu Oct 22 20:55:45 2015 +0900
@@ -15,14 +15,18 @@
 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)"
+pswd = c["pswd"]
+cle1 = "CREATE TABLE IF NOT EXISTS test(id, name, cal, age, sex, pswd, 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)"
 
+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"
+
 ins4 = 'insert into time values(?, 61, "n")'
 ins5 = 'insert into num values("aa",0)'
 ins6 = 'insert into pass values(?, ?, ?)'
@@ -31,10 +35,12 @@
 
 db.execute(cle1)
 db.execute(cle2)
-db.execute(cle3)
+#db.execute(cle3)
 db.execute(cle4)
 db.execute(cle5)
 db.execute(cle6)
+db.execute(cle7)
+db.execute(cle8)
 if name == "createman789789789"
 db.execute(ins4, "a")
 db.execute(ins4, "b")
--- a/opencampus2015/index.html	Thu Oct 22 18:40:12 2015 +0900
+++ b/opencampus2015/index.html	Thu Oct 22 20:55:45 2015 +0900
@@ -18,12 +18,13 @@
 </head>
 
 <body>
-<h1>ほげほげ!</h1><h2>~公益大に入学しよう~</h2>
-<p>キャラクターを登録しよう!</p>
+<h1>Miyazac Quest</h1><h2>~魔王駿を倒せ~</h2>
+<p>ユーザ登録</p>
 
 <form method="POST" action="./accountcheck.rb">
 <table>
-<tr><td>名前</td><td><input name="name" type="text" size="15"  placeholder="名前"></td></tr>
+<tr><td>名前</td><td><input name="name" type="text" size="15" placeholder="名前"></td></tr>
+<tr><td>パスワード</td><td><input name="pswd" type="text" size="15" placeholder="0000"></td></tr>
 <tr><td>性別</td><td><select name="sex">
          <option value="B">男
          <option value="G">女
@@ -37,18 +38,10 @@
          <option>50代
          <option>60代以上
         </select></td></tr>
-<tr><td>出身地</td><td><select name="aria">
-         <option>酒田市内
-         <option>山形県内 
-         <option>県外 
-         </select></td></tr>
 <tr><td>キャラ</td><td><select name="cal">
-           <option value="snake">へび
-	   <option value="inu">いぬ
-           <option value="sisip">シシップ
+           <option value="snake">スネーク
            <option value="kamon">カモン
-           <option value="boy">男の子
-           <option value="girl">女の子
+	   <option value="medama">目玉
         </select></td></tr>
 <tr><td></td><td><input type="submit" value="登録する!"></td></tr>
 </table>
--- a/opencampus2015/prof.rb	Thu Oct 22 18:40:12 2015 +0900
+++ b/opencampus2015/prof.rb	Thu Oct 22 20:55:45 2015 +0900
@@ -302,7 +302,7 @@
 
 <body>
 <header><p>%s</p></header>
-<h1>ほげほげ</h1>
+<h1>Miyazac quest</h1>
 <h2>%s</h2>
 
 <div class="cal">
@@ -325,7 +325,7 @@
 <p>こうえきポイント:%dp</p>
 <table><tr><td>
 <form method="POST" action="gohan.rb">
-<label><input type="checkbox" name="hdn">ごはんをあげる!<div><br>
+<label><input type="checkbox" name="hdn">宿屋<div><br>
 <label><input type="radio" name="gohan" value="g1">%s:2pt<img src=%s width="16" height="16"></label><br>
 <label><input type="radio" name="gohan" value="g2">%s:5pt<img src=%s width="16" height="16"></label><br>
 %s
@@ -339,10 +339,6 @@
 
 </form>
 </td></tr></table>
-
-
-
-<address>skip&#x40;xxxx.co.jp</address>
 <footer></footer>
 </body>
 </html>

yatex.org