Mercurial > hgrepos > hgweb.cgi > skipweb
view archive/program/6hour/kuchikomi.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/6hour/kuchikomi.rb@ca7dc3493900 |
children |
line wrap: on
line source
#!/usr/bin/env ruby # coding: euc-jp # $KCODE = 'e' # 日本語コードの定義 require 'cgi' # CGI を使いますという宣言 c = CGI.new(:accept_charset => "EUC-JP") print("Content-type: text/html; charset=EUC-JP\n\n") # 日本語コードの定義 # CGIスクリプトから受け取った変数の対を、rbで使う変数に代入 kuchikomi = c["info"] hos = c["byoin"] adress = c["jusho"] hito = c["toukousya"] ku = Hash.new jusho = [] sha = [] komi = [] a = 0 if /(\S+):(\S+)/=~hos # $1 = 病院名 # $2 = 住所 name = $1 adress = $2 end if kuchikomi == "" || hito == "" || /,/=~kuchikomi || /,/=~hito || /^M/=~kuchikomi print("<html>\n") # HTMLの規定 print("<head>\n") # HTMLの設定 print("<link rel=\"stylesheet\" type=\"text/css\" href=\"kensaku.css\">\n") # cssの設定 print("<title>エラー</title>\n") # <title>の表示 print("<link rel=\"shortcut icon\" href=\"smile.png\">") # アイコン print("</head>\n") # HTMLの設定(閉) print("<body>\n") # HTMLの表示部分 print("<h1>エラー</h1>\n") print("<h2>未入力項目または , を使用している項目があります。<br>登録をやり直して下さい。</h2>\n") print("<a href=\"http://roy/~c110127/6hour/hospital.html\">検索画面へ戻る</a>\n") print("<a href=\"http://roy/~c110067/6hour/kansei.html\">最短0.6秒TOP</a>\n") print("<a href=\"http://roy/~c110127/6hour/\">最長6時間TOP</a>\n") # リンクの表示 print("<p>最長 6 時間</p>\n") # <p>の表示 print("</body>\n") # HTMLの表示部分(閉) print("</html>\n") # HTMLの規定(閉) else # 正常に登録された場合 open("kuchi.txt","a")do |kaku| kaku.printf("%s,%s,%s,%s\n",name,adress,kuchikomi,hito) end i = 0 open("kuchi.txt","r:euc-jp")do |yomu| while line = yomu.gets if /([^,]+),([^,]+),([^,]+),([^,]+)/=~line # $1 = 病院名 # $2 = 住所 # $3 = くちこみ # $4 = 投稿者 ku[i] = $1,$2,$3,$4 i += 1 end end end # p ku print("<html>\n") # HTMLの規定 print("<head>\n") # HTMLの設定 print("<link rel=\"stylesheet\" type=\"text/css\" href=\"kuchikomi.css\">\n") # cssの設定 print("<title>くちこみ</title>\n") # <title>の表示 print("<link rel=\"shortcut icon\" href=\"smile.png\">") # アイコン print("</head>\n") # HTMLの設定(閉) print("<body>\n") # HTMLの表示部分 print("<h1>くちこみ投稿完了<sub><img class=\"head\" src=\"chara2.png\" width=\"80\" height=\"100\" alt=\"FUCHO\"></img></sub></h1>\n") # p ku[13][1] print("<div class=\"center\">\n") printf("<h2>%s</h2>\n",name) print("<h3>くちこみ情報</h3>\n") print("<p>\n") for i in ku.keys.sort if ku[i][1] == adress printf("・%s 投稿者%sさん<br>\n",ku[i][2],ku[i][3]) end # i += 1 end print("</p>\n") print("</div>\n") print("<p>") print("<a href=\"http://roy/~c110127/6hour/hospital.html\">検索画面へ戻る</a>\n") print("<a href=\"http://roy/~c110067/6hour/kansei.html\">最短0.6秒TOP</a>\n") print("<a href=\"http://roy/~c110127/6hour/\">最長6時間TOP</a></p>\n") print("<p>最長 6 時間</p>\n") # <p>の表示 print("</body>\n") # HTMLの表示部分(閉) print("</html>\n") # HTMLの規定(閉) end