comparison archive/program/GiveMeALiftInYourCar/login_pre.rb @ 3645:d2d89793be14

s/syuzai/shuzai/g completely
author HIROSE Yuuji <yuuji@koeki-u.ac.jp>
date Mon, 21 May 2018 10:19:01 +0900
parents program/GiveMeALiftInYourCar/login_pre.rb@b488d0de91bf
children
comparison
equal deleted inserted replaced
3644:2e332b1abf94 3645:d2d89793be14
1 #!/usr/bin/env ruby
2 # coding: euc-jp
3
4 require 'pg'
5 require 'cgi'
6
7 c = CGI.new(:tag_maker => "html4", :accept_charset => "EUC-JP")
8 id = c["id"].to_s
9 pass = c["pass"].to_s
10 if id == "" && pass == ""
11 id = c.cookies["id"][0]
12 pass = c.cookies["pass"][0]
13 end
14 str = CGI::rfc1123_date(Time.now + (24 * 60 * 60))
15 p_str = CGI::rfc1123_date(Time.now - (24 * 60 * 60))
16
17 #HTTPヘッダー
18 out = c["out"].to_s
19
20 if out == "ok"
21 print("Content-type: text/html; charset=EUC-JP
22 Set-Cookie: id=#{id}; expires=#{p_str};
23 Set-Cookie: pass=#{pass}; expires=#{p_str}; \n\n")
24 id = ""
25 pass = ""
26 else
27 print("Content-type: text/html; charset=EUC-JP
28 Set-Cookie: id=#{id}; expires=#{str};
29 Set-Cookie: pass=#{pass}; expires=#{str}; \n\n")
30 end
31
32 vist = c["vsit"]
33
34 table = "group_works_id"
35 myname = "login.rb"
36
37 pghost = "localhost"
38 pgport = 5432
39 pgoptions = nil
40 pgtty = nil
41 dbname = "c112124"
42 dbuser = "c112124"
43 passwd = nil
44
45
46
47 sql = "SELECT * FROM #{table} "
48
49 conn = PGconn.connect(pghost, pgport, pgoptions, pgtty, dbname, dbuser, passwd)
50 tuple = conn.exec(sql)
51
52 value = []
53 id_list = []
54 x = 0
55
56 tuple.each{|line|
57 value = line.values
58 id_list[x] = [value[0].to_s, value[1].to_s]
59 x += 1
60 }
61
62 tuple.clear
63 conn.close
64
65 #p id_list
66 #p id
67 #p pass
68
69 no = 0
70
71 id_list.each{|ids|
72 if id == ids[0] && pass == ids[1]
73 printf('
74 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
75 "http://www.w3.org/TR/html4/strict.dtd">
76 <html>
77 <head>
78 <title>トップページ -koeki network-</title>
79 <style type="text/css">
80 <!--
81
82 -->
83 </style>
84 <link rel="stylesheet" type="text/css" href="group.css">
85 </head>
86
87 <body>
88 <div class="base">
89 <h1 ><img class="kn" src="koeki-network.png" alt="300x167(14204bytes)" width="300" height="120">
90 </h1>
91 <!--
92 <p>
93 <dl>
94 <dt><span class="info">おしらせ</span><br></dt>
95 <dd>乗せてって掲示板のデータベース変更にともない、コメントの投稿日等が異る場合があります。</dd>
96 </dl>
97 </p>
98 --!>
99
100 <p class="user">ようこそ! <span class="user_name">%s</span>さん</p>
101
102 <!-- 利用に関して --!>
103 <p class="attention">
104 御利用の際には<a href="./TOS.html">Koeki Networkの使い方</a>をよく読んで楽しく、便利なKOEKIライフを!
105 </p>
106
107 <div class="bb">
108 <a href="db/eating_bulletin_board.rb">乗せてって掲示板</a>
109 <p>
110 同乗者を募るカーシェア掲示板です!
111 </p>
112 <a href="./">グルメデータベース</a>
113 <p>--- β版(スタッフ作業用) ---</p>
114 <a href="">その他情報報告所</a>
115 <p>--- 現在調整中(under construction) ---</p>
116 <a href="">雑談掲示板</a>
117 <p>--- 現在調整中(under construction) ---</p>
118 </div>
119 ', id)
120 print"
121 <a class=\"cont\" href=\"http://roy/~c112075/japanet/pre.html\">もどる。</a>
122 <a class=\"cont\" href=\"./login.rb?out=ok\">ろぐあうと。</a>
123 <hr>
124 "
125 no = 0
126 break
127 else
128 no += 1
129 end
130 }
131 if no > 0
132 print'
133 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
134 "http://www.w3.org/TR/html4/strict.dtd">
135 <html>
136 <head>
137 <title>ログイン -koeki network-</title>
138 <style type="text/css">
139 <!--
140
141 -->
142 </style>
143 <link rel="stylesheet" type="text/css" href="group.css">
144 </head>
145
146 <div class="base">
147 <h1 ><img class="kn" src="koeki-network.png" alt="300x167(14204bytes)" width="300" height="120">
148 </h1>
149 <h2>ろぐいん</h2>
150 <div class="bb">
151 '
152 if vist == "visted"
153 print"<p>エラー<br>パスワードかIDが間違っています!!</p>"
154 end
155 printf("<form method=\"POST\" action=\"./%s\">\n", myname)
156 printf'<p>
157 ユーザーID: <input class="mgn_2" name="id" type="text" maxlength="12"><br>
158 パスワード : <input class="mgn_2" name="pass" type="password" maxlength="12"><br>
159 <input name="vsit" type="hidden" value="visted">
160 <input type="submit" value="OK">
161 <input type="reset" value="reset"><br>
162 </p><hr><a href="./new-account.rb">あかうんとを作る。</a> <a href="http://roy/~c112075/japanet/pre.html">もどる。</a>
163 <hr>
164 </div>
165 '
166 end
167 print'
168 <hr>
169 <address>c112124&#x40;h.koeki-u.ac.jp</address>
170 </div>
171 </body>
172 </html>
173 '
174

yatex.org