#!/usr/local/bin/ruby =begin $Id: photoxp.cgi,v 1.3 2004/11/07 08:54:35 noguchi Exp $ PhotoXP - Photographic eXPerience Bulletin Board System Copyright (C) 2002-2004 Shingo NOGUCHI This is free software with ABSOLUTELY NO WARRANTY. This file is part of PhotoXP. PhotoXP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =end $:.push(File::dirname(ENV['SCRIPT_FILENAME']||'.')+'/lib') require 'erb' require 'cgi' require './config' require 'photoxp/pcgi' require 'photoxp/util' require 'photoxp/action' require 'photoxp/error' require 'photoxp/logger' module PhotoXP class Main attr_reader :cgi, :response, :header def initialize @cgi = CGI.new('html4Tr') end def execute action_id = @cgi.get_param('action', 'index') action_class = Action::load_action(action_id) action = action_class.new(self) action.execute @header = @cgi.header(action.header) @response = action.response $access_log.log("%s: %s", @cgi.get_param('board'), @cgi.get_param('action')) end end $access_log = Logger.new(LOG_DIR+"/access.log") $error_log = Logger.new(LOG_DIR+"/error.log") # $trace_log = Logger.new(LOG_DIR+"/trace.log") begin photoxp = Main.new photoxp.execute print photoxp.header print photoxp.response if $DEBUG t = Process.times cgi = photoxp.cgi print "
\n"
      print "times=#{t.utime}/#{t.stime}/#{t.cutime}/#{t.cstime}\n"
      print "cgi.params[]=\n"
      cgi.params.keys.each {|k|
        v = cgi.get_param(k)
	print "    #{k}=#{v}\n"
      }
      print "cgi.cookies[]=\n"
      cgi.cookies.values.each {|c|
        print "    #{c}\n"
      }
      print "ENV[]=\n"
      ENV.each {|k,v|
        print "    #{k}=#{v}\n"
      }
      print "
" end rescue => e $error_log.exception(e, "Exception: "); print "Content-Type: text/html; charset=euc-jp\r\n\r\n" print "\n" print "PhotoXP - エラー\n" print "\n" print "

PhotoXP: エラーが発生しました。

\n" print "戻る" print "

\n" if $DEBUG cb = e.backtrace print "

\n"
      print "#{cb.shift}: #{CGI::escapeHTML(e.message)}\n"
      cb.each{|c|
        print "    from #{CGI::escapeHTML(c)}\n"
      }
      print "
\n" end print "\n" end end