#!/usr/bin/env ruby =begin るびろぐ 2 ランキング表示 CGI "RubyRogue2Score" $Revision: 1.6 $ Copyright(C) 2004-2006 Atzm WATANABE, all rights reserved. Destributed under the GNU General Public License version 2 or later. =end require "postgres" require "kconv" require "cgi-lib" ### begin パラメータ # Web サイト関係 $PAGE_TITLE = "RubyRogue2 Score Ranking" $SITE_URI = "http://" $CSS_URI = "" $SCRIPT_NAME = "rubyrogue2score.rb" $ENCODING = "EUC-JP" # or Shift_JIS or ISO-2022-JP $HTML_HEADER = <<-end
死屍累々。
end # 検索エントリ関係 $SEARCH_DEFAULT = "戦没者の検索" $SD_FORE_COLOR = "black" $SD_HIDE_COLOR = "gray" # フォーム名等 $FORM = "form" $SORT = "sort" $LINES = "lines" $NAME = "name" # PostgreSQL デーモン関係 $PG_HOST = nil $PG_PORT = nil $PG_OPT = nil $PG_TTY = nil $PG_DBNAME = "postgres" $PG_LOGIN = "postgres" $PG_PASSWD = nil # 出力する DB のカラム名とテーブルのカラム名の対応 $COLUMNS = [ ["score", "金塊"], ["maxcavelevel", "階"], ["name", "名前"], ["died_of", "断末魔"], ["maxhp", "体力"], ["weapon", "武器"], ["armor", "防具"], ["left_ring", "指輪(左)"], ["right_ring", "指輪(右)"], ["maxstr", "強さ"], ["level", "レベル"], ["kill", "倒した敵"], ] # 出力する行数とドロップダウンリスト内文字列の対応 (all は予約語とする) $LIMITS = [["10", "トップ10"], ["50", "トップ50"], ["100", "トップ100"], ["all", "全て"]] ### end パラメータ if $ENCODING == "EUC-JP" $CONV = Kconv.method(:toeuc) elsif $ENCODING == "Shift_JIS" $CONV = Kconv.method(:tosjis) else $CONV = Kconv.method(:tojis) end def parse_args =begin 引数文字列の汚染チェックと整形 =end input = CGI.new sort = input[$SORT] lines = input[$LINES] name = input[$NAME] # ORDER BY の汚染回避 @sort = $COLUMNS[0][0] if $COLUMNS.transpose[0].include?( sort ) @sort = sort end # LIMIT の汚染回避 @limit = "limit 10" lims = $LIMITS.transpose index = lims[0].index( lines ) if index if lines == "all" @limit = "" else @limit = "limit #{lims[0][index]}" end end # WHERE の汚染回避 begin name = name.gsub( /['\\]/, "" ) rescue end @name = "" if name and name != "" and name != $SEARCH_DEFAULT @name = "where name = '#{name}'" end end def print_header =begin 共通のドキュメントヘッダを出力 =end sort_by = "" $COLUMNS.each do | key, name | sort_by << " \n" end sort_by.chomp! limits = "" $LIMITS.each do | key, name | limits << " \n" end limits.chomp! puts <<-end Content-type: text/html; charset=#{$ENCODING}
Generated by RubyRogue2Score: $Revision: 1.6 $
Distributed under the GNU Genetal Public License version 2 or later.
#{val} | " rescue NameError puts "NameError: DBカラム名を確認して下さい | " end end puts "