Newer
Older
skip-web / program / GiveMeALiftInYourCar / login_pre.rb
@MURAKAMI Masaki MURAKAMI Masaki on 21 May 2014 3 KB Updated
#!/usr/bin/env ruby
# coding: euc-jp

require 'pg'
require 'cgi'

c = CGI.new(:tag_maker => "html4", :accept_charset => "EUC-JP")
id = c["id"].to_s
pass = c["pass"].to_s
if id == "" && pass == ""
id = c.cookies["id"][0]
pass = c.cookies["pass"][0]
end
str = CGI::rfc1123_date(Time.now + (24 * 60 * 60))
p_str = CGI::rfc1123_date(Time.now - (24 * 60 * 60))

#HTTPヘッダー
out = c["out"].to_s

if out == "ok"
print("Content-type: text/html; charset=EUC-JP 
Set-Cookie: id=#{id}; expires=#{p_str};
Set-Cookie: pass=#{pass}; expires=#{p_str}; \n\n")
id = ""
pass = ""
else
print("Content-type: text/html; charset=EUC-JP 
Set-Cookie: id=#{id}; expires=#{str};
Set-Cookie: pass=#{pass}; expires=#{str}; \n\n")
end 

vist = c["vsit"]

table = "group_works_id"
myname = "login.rb"

pghost = "localhost"
pgport = 5432
pgoptions = nil
pgtty = nil
dbname = "c112124"
dbuser = "c112124"
passwd = nil



sql = "SELECT * FROM #{table} "

conn = PGconn.connect(pghost, pgport, pgoptions, pgtty, dbname, dbuser, passwd)
tuple = conn.exec(sql)

value = []
id_list = []
x = 0

tuple.each{|line|
  value = line.values
  id_list[x] = [value[0].to_s, value[1].to_s]
  x += 1
}

tuple.clear
conn.close

#p id_list
#p id
#p pass

no = 0

id_list.each{|ids|
  if id == ids[0] && pass == ids[1] 
    printf('
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>トップページ -koeki network-</title>
<style type="text/css">
<!--

-->
</style>
<link rel="stylesheet" type="text/css" href="group.css">
</head>

<body>
<div class="base">
<h1 ><img class="kn" src="koeki-network.png" alt="300x167(14204bytes)" width="300" height="120">
</h1>
<!--
<p>
<dl>
<dt><span class="info">おしらせ</span><br></dt>
<dd>乗せてって掲示板のデータベース変更にともない、コメントの投稿日等が異る場合があります。</dd>
</dl>
</p>
--!>

<p class="user">ようこそ! <span class="user_name">%s</span>さん</p>

<!-- 利用に関して --!>
<p class="attention">
御利用の際には<a href="./TOS.html">Koeki Networkの使い方</a>をよく読んで楽しく、便利なKOEKIライフを!
</p>

<div class="bb">
<a href="db/eating_bulletin_board.rb">乗せてって掲示板</a>
<p>
同乗者を募るカーシェア掲示板です!
</p>
<a href="./">グルメデータベース</a>
<p>--- β版(スタッフ作業用) ---</p>
<a href="">その他情報報告所</a>
<p>--- 現在調整中(under construction) ---</p>
<a href="">雑談掲示板</a>
<p>--- 現在調整中(under construction) ---</p>
</div>
', id)
print"
<a class=\"cont\" href=\"http://roy/~c112075/japanet/pre.html\">もどる。</a>
<a class=\"cont\" href=\"./login.rb?out=ok\">ろぐあうと。</a>
<hr>
"
    no = 0
    break
  else
    no += 1
  end
}
if no > 0
    print'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>ログイン -koeki network-</title>
<style type="text/css">
<!--

-->
</style>
<link rel="stylesheet" type="text/css" href="group.css">
</head>

<div class="base">
<h1 ><img class="kn" src="koeki-network.png" alt="300x167(14204bytes)" width="300" height="120">
</h1>
<h2>ろぐいん</h2>
<div class="bb">
'
    if vist == "visted"
      print"<p>エラー<br>パスワードかIDが間違っています!!</p>"
    end
  printf("<form method=\"POST\" action=\"./%s\">\n", myname)
  printf'<p>
ユーザーID: <input class="mgn_2" name="id" type="text" maxlength="12"><br>
パスワード : <input class="mgn_2" name="pass" type="password" maxlength="12"><br>
<input name="vsit" type="hidden" value="visted">
<input type="submit" value="OK">
<input type="reset" value="reset"><br>
</p><hr><a href="./new-account.rb">あかうんとを作る。</a> <a href="http://roy/~c112075/japanet/pre.html">もどる。</a>
<hr>
</div>
'
end
print'
<hr>
<address>c112124&#x40;h.koeki-u.ac.jp</address>
</div>
</body>
</html>
'