File: index.fcgi

package info (click to toggle)
tdiary 5.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,852 kB
  • sloc: ruby: 22,925; xml: 325; makefile: 16; sh: 10
file content (44 lines) | stat: -rwxr-xr-x 1,008 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env ruby
#
# index.fcgi $Revision: 1.35 $
#
# Copyright (C) 2004, Akinori MUSHA
# Copyright (C) 2006, moriq
# Copyright (C) 2006-2009, Kazuhiko <kazuhiko@fdiary.net>
# You can redistribute it and/or modify it under GPL2 or any later version.
#
require 'fcgi'
# workaround untaint LOAD_PATH for rubygems library path is always tainted.
$:.each{|path| path if path.include?('fcgi') }

if FileTest::symlink?( __FILE__ ) then
	org_path = File::dirname( File::readlink( __FILE__ ) )
else
	org_path = File::dirname( __FILE__ )
end
load "#{org_path}/misc/lib/fcgi_patch.rb"

FCGI.each_cgi do |cgi|
	begin
		ENV.clear
		ENV.update(cgi.env_table)
		class << CGI; self; end.class_eval do
			define_method(:new) {|*args| cgi }
		end
		dir = File::dirname( cgi.env_table["SCRIPT_FILENAME"] || __FILE__ )
		Dir.chdir(dir) do
			load 'index.rb'
		end
	ensure
		class << CGI
			remove_method :new
		end
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End: