Mercurial > hgrepos > hgweb.cgi > skipweb
annotate mackey/academy/add.rb @ 2849:a222fe462b1b
merge
author | ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp> |
---|---|
date | Tue, 01 Dec 2015 19:07:02 +0900 |
parents | 2ee6e6efc0dd |
children |
rev | line source |
---|---|
2403
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
1 #!/usr/bin/env ruby |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
2 # coding: euc-jp |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
3 require 'rubygems' |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
4 require 'pg' |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
5 require 'cgi' |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
6 c = CGI.new(:accept_charset => "euc-jp") |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
7 print"Content-type: text/html; charset=euc-jp\n\n" |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
8 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
9 number = c["id"] |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
10 pswd = c["pass"] |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
11 namae = c["name"] |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
12 sx = c["sex"] |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
13 check = 0 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
14 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
15 begin |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
16 conn = PGconn.connect('broy.e.koeki-u.ac.jp','','','','c112085','mackeyacademy','l3nl3q1u') |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
17 a = "select id from userdata" |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
18 ip = conn.exec(a) |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
19 ip.each do |row| |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
20 if number == row["id"] |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
21 check = 1 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
22 end |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
23 end |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
24 if check == 0 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
25 q = "insert into userdata (id, password, name, sex, level, exp, quest) values ('#{number}', '#{pswd}', '#{namae}', '#{sx}', '1', '0', '0')" |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
26 export = conn.exec(q) |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
27 end |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
28 end |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
29 print"<html> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
30 <head> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
31 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=euc-jp\"> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
32 <title>ユーザー登録</title> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
33 <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\"> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
34 </head> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
35 <body>\n" |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
36 if check == 0 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
37 print"<h1>登録完了</h1> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
38 <a href=\"login.html\"> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
39 <button class=\"css3button\">ログイン</button>\n" |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
40 elsif check == 1 |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
41 print"<h1>Error</h1> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
42 <p>既にIDが使われています</p> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
43 <a href=\"add.html\"> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
44 <button class=\"css3button\">もう一度</button>\n" |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
45 end |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
46 print"</a> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
47 </body> |
2ee6e6efc0dd
Mackey academy added
MASAHIRO Suzuki <c112085@roy.e.koeki-u.ac.jp>
parents:
diff
changeset
|
48 </html>\n" |