ruby-web 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. data/ChangeLog +474 -0
  2. data/INSTALL.txt +9 -0
  3. data/InstalledFiles +180 -0
  4. data/LICENSE.txt +74 -0
  5. data/Rakefile +529 -0
  6. data/TODO +65 -0
  7. data/doc/additional.xml +149 -0
  8. data/doc/core.xml +652 -0
  9. data/doc/credits/index.xml +52 -0
  10. data/doc/credits/php.contributors.xml +118 -0
  11. data/doc/credits/php.language-snippets.ent +622 -0
  12. data/doc/install/index.xml +136 -0
  13. data/doc/install/mac/index.xml +21 -0
  14. data/doc/install/ruby-web.install.rb.instructions.xml +7 -0
  15. data/doc/install/unix/index.xml +46 -0
  16. data/doc/install/win/apache1.xml +166 -0
  17. data/doc/install/win/apache2.xml +141 -0
  18. data/doc/install/win/iis.xml +162 -0
  19. data/doc/install/win/index.xml +24 -0
  20. data/doc/install/win/installer.xml +31 -0
  21. data/doc/install/win/manual.xml +43 -0
  22. data/doc/manual.xml +69 -0
  23. data/doc/old/apache_cgi.txt +23 -0
  24. data/doc/old/fastcgi.txt +23 -0
  25. data/doc/old/mod_ruby.txt +21 -0
  26. data/doc/old/snippets.rdoc +183 -0
  27. data/doc/old/webrick.txt +23 -0
  28. data/doc/old/windows_cgi.txt +9 -0
  29. data/doc/tutorial.xml +14 -0
  30. data/doc/xsl/manual-multi.xsl +10 -0
  31. data/doc/xsl/manual-pdf.xsl +6 -0
  32. data/doc/xsl/manual-single.xsl +6 -0
  33. data/doc/xsl/manual.css +22 -0
  34. data/install.rb +1022 -0
  35. data/lib/formatter.rb +314 -0
  36. data/lib/html-parser.rb +429 -0
  37. data/lib/htmlrepair.rb +113 -0
  38. data/lib/htmlsplit.rb +842 -0
  39. data/lib/sgml-parser.rb +332 -0
  40. data/lib/web.rb +68 -0
  41. data/lib/web/assertinclude.rb +129 -0
  42. data/lib/web/config.rb +50 -0
  43. data/lib/web/connection.rb +1070 -0
  44. data/lib/web/convenience.rb +154 -0
  45. data/lib/web/formreader.rb +318 -0
  46. data/lib/web/htmlparser/html-parser.rb +429 -0
  47. data/lib/web/htmlparser/sgml-parser.rb +332 -0
  48. data/lib/web/htmltools/element.rb +296 -0
  49. data/lib/web/htmltools/stparser.rb +276 -0
  50. data/lib/web/htmltools/tags.rb +286 -0
  51. data/lib/web/htmltools/tree.rb +139 -0
  52. data/lib/web/htmltools/xmltree.rb +160 -0
  53. data/lib/web/htmltools/xpath.rb +71 -0
  54. data/lib/web/info.rb +63 -0
  55. data/lib/web/load.rb +210 -0
  56. data/lib/web/mime.rb +87 -0
  57. data/lib/web/phprb.rb +340 -0
  58. data/lib/web/resources/test/cookie.rb +33 -0
  59. data/lib/web/resources/test/counter.rb +20 -0
  60. data/lib/web/resources/test/multipart.rb +14 -0
  61. data/lib/web/resources/test/redirect.rb +8 -0
  62. data/lib/web/resources/test/stock.rb +33 -0
  63. data/lib/web/sapi/apache.rb +129 -0
  64. data/lib/web/sapi/fastcgi.rb +22 -0
  65. data/lib/web/sapi/install/apache.rb +180 -0
  66. data/lib/web/sapi/install/iis.rb +93 -0
  67. data/lib/web/sapi/install/macosx.rb +90 -0
  68. data/lib/web/sapi/webrick.rb +86 -0
  69. data/lib/web/session.rb +83 -0
  70. data/lib/web/shim/cgi.rb +129 -0
  71. data/lib/web/shim/rails.rb +175 -0
  72. data/lib/web/stringio.rb +78 -0
  73. data/lib/web/strscanparser.rb +24 -0
  74. data/lib/web/tagparser.rb +96 -0
  75. data/lib/web/testing.rb +666 -0
  76. data/lib/web/traceoutput.rb +75 -0
  77. data/lib/web/unit.rb +56 -0
  78. data/lib/web/upload.rb +59 -0
  79. data/lib/web/validate.rb +52 -0
  80. data/lib/web/wiki.rb +557 -0
  81. data/lib/web/wiki/linker.rb +72 -0
  82. data/lib/web/wiki/page.rb +201 -0
  83. data/lib/webunit.rb +27 -0
  84. data/lib/webunit/assert.rb +152 -0
  85. data/lib/webunit/converter.rb +154 -0
  86. data/lib/webunit/cookie.rb +118 -0
  87. data/lib/webunit/domwalker.rb +185 -0
  88. data/lib/webunit/exception.rb +14 -0
  89. data/lib/webunit/form.rb +116 -0
  90. data/lib/webunit/frame.rb +37 -0
  91. data/lib/webunit/htmlelem.rb +122 -0
  92. data/lib/webunit/image.rb +26 -0
  93. data/lib/webunit/jscript.rb +31 -0
  94. data/lib/webunit/link.rb +33 -0
  95. data/lib/webunit/params.rb +321 -0
  96. data/lib/webunit/parser.rb +229 -0
  97. data/lib/webunit/response.rb +464 -0
  98. data/lib/webunit/runtest.rb +41 -0
  99. data/lib/webunit/table.rb +148 -0
  100. data/lib/webunit/testcase.rb +45 -0
  101. data/lib/webunit/ui/cui/testrunner.rb +50 -0
  102. data/lib/webunit/utils.rb +68 -0
  103. data/lib/webunit/webunit.rb +28 -0
  104. data/test/dev/action.rb +83 -0
  105. data/test/dev/forms.rb +104 -0
  106. data/test/dev/forms2.rb +104 -0
  107. data/test/dev/parser.rb +17 -0
  108. data/test/dev/scripts/dump.rb +24 -0
  109. data/test/dev/scripts/makedist.rb +62 -0
  110. data/test/dev/scripts/uri.rb +41 -0
  111. data/test/dev/scripts/uri/common.rb +432 -0
  112. data/test/dev/scripts/uri/ftp.rb +149 -0
  113. data/test/dev/scripts/uri/generic.rb +1106 -0
  114. data/test/dev/scripts/uri/http.rb +76 -0
  115. data/test/dev/scripts/uri/https.rb +26 -0
  116. data/test/dev/scripts/uri/ldap.rb +238 -0
  117. data/test/dev/scripts/uri/mailto.rb +260 -0
  118. data/test/dev/scripts/urireg.rb +174 -0
  119. data/test/dev/simpledispatcher.rb +156 -0
  120. data/test/dev/test.action.rb +146 -0
  121. data/test/dev/test.formreader.rb +463 -0
  122. data/test/dev/test.simpledispatcher.rb +186 -0
  123. data/test/dev/webunit/conv/digit-0.rb +21 -0
  124. data/test/dev/webunit/conv/digit-1.rb +17 -0
  125. data/test/dev/webunit/conv/digit.rb +23 -0
  126. data/test/dev/webunit/conv/test_digit-0.rb +16 -0
  127. data/test/dev/webunit/conv/test_digit-1.rb +19 -0
  128. data/test/dev/webunit/conv/test_digit.rb +26 -0
  129. data/test/dev/webunit/conv/test_digit_view-0.rb +76 -0
  130. data/test/dev/webunit/conv/test_digit_view-1.rb +102 -0
  131. data/test/dev/webunit/conv/test_digit_view.rb +134 -0
  132. data/test/installation/htdocs/cgi_test.rb +296 -0
  133. data/test/installation/htdocs/test_install.rb +4 -0
  134. data/test/installation/runwebtest.rb +5 -0
  135. data/test/installation/test_cookie.rb +128 -0
  136. data/test/installation/test_form.rb +47 -0
  137. data/test/installation/test_multipart.rb +51 -0
  138. data/test/installation/test_request.rb +24 -0
  139. data/test/installation/test_response.rb +35 -0
  140. data/test/unit/htdocs/cookie.rb +32 -0
  141. data/test/unit/htdocs/multipart.rb +28 -0
  142. data/test/unit/htdocs/redirect.rb +12 -0
  143. data/test/unit/htdocs/simple.rb +13 -0
  144. data/test/unit/htdocs/stock.rb +33 -0
  145. data/test/unit/test_assert.rb +162 -0
  146. data/test/unit/test_cookie.rb +114 -0
  147. data/test/unit/test_domwalker.rb +77 -0
  148. data/test/unit/test_form.rb +42 -0
  149. data/test/unit/test_frame.rb +40 -0
  150. data/test/unit/test_htmlelem.rb +74 -0
  151. data/test/unit/test_image.rb +45 -0
  152. data/test/unit/test_jscript.rb +57 -0
  153. data/test/unit/test_link.rb +85 -0
  154. data/test/unit/test_multipart.rb +51 -0
  155. data/test/unit/test_params.rb +210 -0
  156. data/test/unit/test_parser.rb +53 -0
  157. data/test/unit/test_response.rb +150 -0
  158. data/test/unit/test_table.rb +70 -0
  159. data/test/unit/test_utils.rb +106 -0
  160. data/test/unit/test_webunit.rb +28 -0
  161. data/test/web/mod_ruby_stub.rb +39 -0
  162. data/test/web/test.assertinclude.rb +109 -0
  163. data/test/web/test.buffer.rb +182 -0
  164. data/test/web/test.code.loader.rb +78 -0
  165. data/test/web/test.config.rb +31 -0
  166. data/test/web/test.error.handling.rb +91 -0
  167. data/test/web/test.formreader-2.0.rb +352 -0
  168. data/test/web/test.load.rb +125 -0
  169. data/test/web/test.mime-type.rb +23 -0
  170. data/test/web/test.narf.cgi.rb +106 -0
  171. data/test/web/test.phprb.rb +239 -0
  172. data/test/web/test.request.rb +368 -0
  173. data/test/web/test.response.rb +637 -0
  174. data/test/web/test.ruby-web.rb +10 -0
  175. data/test/web/test.session.rb +50 -0
  176. data/test/web/test.shim.cgi.rb +96 -0
  177. data/test/web/test.tagparser.rb +65 -0
  178. data/test/web/test.template2.rb +297 -0
  179. data/test/web/test.testing2.rb +318 -0
  180. data/test/web/test.upload.rb +45 -0
  181. data/test/web/test.validate.rb +46 -0
  182. data/test/web/test.web.test.rb +495 -0
  183. data/test/wiki/test.history.rb +297 -0
  184. data/test/wiki/test.illustration_page.rb +287 -0
  185. data/test/wiki/test.linker.rb +197 -0
  186. data/test/wiki/test.tarpit.rb +56 -0
  187. data/test/wiki/test.wiki.rb +300 -0
  188. data/test/wikitestroot/admin.rb +7 -0
  189. data/test/wikitestroot/wiki.rb +6 -0
  190. metadata +234 -0
@@ -0,0 +1,33 @@
1
+ if Web.key?( 'key' ) && Web['key'] != '' && Web.key?( 'value' )
2
+ Web.set_cookie( Web['key'], Web['value'] )
3
+ end
4
+
5
+ print '<html><head><title>WebUnit::Cookies</title></head>'
6
+ print '<body><h1>WebUnit::Cookies</h1><table border=1>'
7
+
8
+ print Web.cookie.keys.collect{|key|
9
+ if key == ''
10
+ nil
11
+ else
12
+ "<tr><td>#{key}</td><td>#{Web.cookie[key]}</td></tr>"
13
+ end
14
+ }.compact.to_s
15
+
16
+ print '</table><br>'
17
+
18
+ print 'Params<table border=1>'
19
+
20
+ print Web.keys.collect{|key|
21
+ "<tr><td>#{key}</td><td>#{Web[key]}</td></tr>"
22
+ }.to_s
23
+
24
+ print '</table>'
25
+
26
+ print "<form>"
27
+ print '<input type="hidden" name="test" value="cookie.rb">'
28
+ print 'key = <input type="text" name="key" value="" size="20"><br>'
29
+ print 'value = <input type="text" name="value" value="" size="20"><br>'
30
+ print '<input type="submit">'
31
+
32
+ print '</body></html>'
33
+
@@ -0,0 +1,20 @@
1
+ unless Object.respond_to? :rbw_count
2
+ class Object
3
+ @@rbw_count = nil
4
+ def Object::rbw_count
5
+ @@rbw_count
6
+ end
7
+ def Object::rbw_count= other
8
+ @@rbw_count = other
9
+ end
10
+ end
11
+ end
12
+
13
+ if (Web::key? "count")
14
+ Object::rbw_count = Web["count"].to_i
15
+ else
16
+ Object::rbw_count ||= 0
17
+ Object::rbw_count += 1
18
+ end
19
+
20
+ Web::puts "<html><head><title>Count: #{Object::rbw_count}</title></head></html>"
@@ -0,0 +1,14 @@
1
+ begin
2
+ print '<h1>result</h1>'
3
+ print Web::info_fileinfo( Web['file1']) + '<hr>'
4
+ print Web::info_fileinfo( Web['file2']) + '<hr>'
5
+ print '<table border>'
6
+ %w!text1 text2 checkbox1 radio1 radio2 textarea1 textarea2 select1 select2!.each { |k|
7
+ print "<tr><td>#{k}</td><td>#{Web[k]}</td></tr>"
8
+ }
9
+ print '</table>'
10
+ rescue Exception
11
+ print 'error:'
12
+ print $!.to_s
13
+ end
14
+
@@ -0,0 +1,8 @@
1
+ if Web.key?( 'redirect' )
2
+ Web.set_redirect Web['redirect']
3
+ else
4
+ puts( "<html><body>",
5
+ "Use test=redirect&redirect=http://... <br>",
6
+ "<b>" + Web::html_encode( ENV['QUERY_STRING'] || '' ) + "</b>",
7
+ "</body></html>" )
8
+ end
@@ -0,0 +1,33 @@
1
+ if false
2
+ stock = ''
3
+
4
+ tempfile = "/tmp/ruby-web.info.test.txt"
5
+
6
+ if Web.key?( 'clear' )
7
+ File::delete( tempfile ) if File::exist?( tempfile )
8
+ else
9
+ if Web.key?( 'name' ) && Web.key?( 'title' )
10
+ open( tempfile, "a" ){ |f|
11
+ f.puts "#{ Web.multiple_params['name'][0] },#{ Web.multiple_params['title'][0] }"
12
+ }
13
+ end
14
+ if File::exist?( tempfile )
15
+ open( tempfile ).each do |line|
16
+ line.chop!
17
+ stock << "<input type=\"text\" name=\"name\" value=\"#{ line.split( ',' )[0] }\">"
18
+ stock << "<input type=\"text\" name=\"title\" value=\"#{ line.split( ',' )[1] }\">"
19
+ stock << "<br>\n"
20
+ end
21
+ end
22
+ end
23
+
24
+ print "<html><head><title>stock.cgi</title></head><body>"
25
+ print "<form method='POST'>"
26
+ print "<input type=\"hidden\" name=\"test\" value=\"stock.rb\">"
27
+ print "<input type=\"text\" name=\"name\">"
28
+ print "<input type=\"text\" name=\"title\">"
29
+ print "<input type=\"submit\" value=\"add\">"
30
+ print "<br>\n"
31
+ print stock
32
+ print "</form></body></html>"
33
+ end
@@ -0,0 +1,129 @@
1
+ =begin
2
+
3
+ = extended from apache/ruby-run.rb
4
+
5
+ Copyright (C) 2001 Shugo Maeda <shugo@modruby.net>
6
+ All rights reserved.
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions
10
+ are met:
11
+ 1. Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ 2. Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
+ SUCH DAMAGE.
28
+
29
+ =end
30
+
31
+ require "singleton"
32
+ require 'web'
33
+
34
+ module Web
35
+ class ModRubyConnection < Connection
36
+ def initialize( options = {} )
37
+ options[:env] = {}
38
+ ENV.each{|k,v|
39
+ options[:env][k] = v
40
+ }
41
+ Apache::request.headers_in.each{ |k,v|
42
+ options[:env][k] = v
43
+ }
44
+
45
+ super( options )
46
+ end
47
+
48
+ def send_header_implementation
49
+ Apache::request.status_line = header['Status'].first.split.shift
50
+ Apache::request.content_type = header['Content-Type'].first
51
+ Apache::request.content_encoding = (header['Content-Encoding'] || [ ]).first
52
+
53
+ header.delete( "Status" )
54
+ header.delete( "Content-Type" )
55
+ header.delete( "Content-Encoding" )
56
+
57
+ if (header["Set-Cookie"])
58
+ header["Set-Cookie"].each{ |cookie|
59
+ Apache::request.headers_out.add( "Set-Cookie", cookie )
60
+ }
61
+ header.delete( "Set-Cookie" )
62
+ end
63
+
64
+ header.each{ |k,v|
65
+ Apache::request.headers_out[k] = v.last
66
+ }
67
+
68
+ Apache::request.send_http_header
69
+ end
70
+ end
71
+ end
72
+
73
+
74
+ module Web
75
+ # === Overview
76
+ # Web::RubyRun executes ruby-web scripts in Apache under mod_ruby.
77
+ # It is a modified version of mod_ruby's Apache::RubyRun
78
+ #
79
+ # == Example of httpd.conf
80
+ #
81
+ # RubyRequire web/sapi/apache
82
+ # <Location /ruby>
83
+ # SetHandler ruby-object
84
+ # RubyHandler Web::RubyRun.instance
85
+ # </Location>
86
+ class RubyRun
87
+ include Singleton
88
+
89
+ def handler(r)
90
+ status = check_request(r)
91
+ return status if status != Apache::OK
92
+ filename = setup(r)
93
+ Web::open do
94
+ Web::load(filename)
95
+ end
96
+ return Apache::OK
97
+ end
98
+
99
+ private
100
+
101
+ def check_request(r)
102
+ if r.method_number == Apache::M_OPTIONS
103
+ r.allowed |= (1 << Apache::M_GET)
104
+ r.allowed |= (1 << Apache::M_POST)
105
+ return Apache::DECLINED
106
+ end
107
+ if r.finfo.mode == 0
108
+ return Apache::NOT_FOUND
109
+ end
110
+ if r.allow_options & Apache::OPT_EXECCGI == 0
111
+ r.log_reason("Options ExecCGI is off in this directory", r.filename)
112
+ return Apache::FORBIDDEN
113
+ end
114
+ unless r.finfo.executable?
115
+ r.log_reason("file permissions deny server execution", r.filename)
116
+ return Apache::FORBIDDEN
117
+ end
118
+ return Apache::OK
119
+ end
120
+
121
+ def setup(r)
122
+ r.setup_cgi_env
123
+ filename = r.filename.dup
124
+ filename.untaint
125
+ Apache.chdir_file(filename)
126
+ return filename
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,22 @@
1
+ require 'web'
2
+
3
+ module Web
4
+ class FastCGIConnection < Connection
5
+ def initialize( options = {} )
6
+ fcgi = options[:fcgi]
7
+
8
+ options[:out] = fcgi.out
9
+ options[:raw_post_data] = fcgi.in
10
+ options[:env] = fcgi.env
11
+
12
+ super( options )
13
+ end
14
+
15
+ def close
16
+ super()
17
+ options[:fcgi].finish if options[:fcgi]
18
+ options[:fcgi] = nil
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,180 @@
1
+ module Web
2
+ module Install
3
+ class Apache
4
+ require 'fileutils'
5
+ include FileUtils
6
+
7
+ def Apache::install( install_dir, httpd_conf )
8
+ self.new(install_dir, httpd_conf).install
9
+ end
10
+
11
+ attr_accessor :install_dir, :httpd_conf
12
+ def initialize( install_dir, httpd_conf )
13
+ @install_dir = install_dir
14
+ @httpd_conf = httpd_conf
15
+ end
16
+
17
+ def apache_root
18
+ File.dirname( File.dirname( httpd_conf ) )
19
+ end
20
+
21
+ def apache
22
+ [apache_root + "/Apache.exe",
23
+ apache_root + "/bin/Apache.exe" ].find do |f|
24
+ File.exists? f
25
+ end
26
+ end
27
+
28
+ def test_config_cmd
29
+ apache + " -t" if apache
30
+ end
31
+
32
+ def version
33
+ case apache
34
+ when apache_root + "/Apache.exe"
35
+ 1
36
+ when apache_root + "/bin/Apache.exe"
37
+ 2
38
+ end
39
+ end
40
+
41
+ def backup
42
+ "#{httpd_conf}.ruby-web.backup.#{Time::now::strftime('%Y.%m.%d') }"
43
+ end
44
+
45
+ def temp
46
+ "#{httpd_conf}.ruby-web.temp"
47
+ end
48
+
49
+ def ruby_conf
50
+ unless @ruby_conf
51
+ @ruby_conf = Array.new
52
+ @ruby_conf.push "AddHandler cgi-script .rb .rhtml"
53
+ end
54
+ @ruby_conf
55
+ end
56
+
57
+ def install
58
+ puts "******************************************",
59
+ "* Installing .rhtml and .rb mappings *",
60
+ "* for Apache *",
61
+ "******************************************"
62
+
63
+ new_conf = ''
64
+ lines = File.open( httpd_conf, "r" ) {|f| f.read }
65
+ lines.each do |line|
66
+ if line =~ /index.html/ && ! line =~ /index.rhtml/
67
+ line.gsub!(/index.html/,'index.html index.php')
68
+ end
69
+ if line =~ /AddHandler cgi-script.*(\.rb|\.rhtml)/
70
+ ruby_conf.delete_at(0)
71
+ end
72
+ new_conf += line + "\n"
73
+ end
74
+
75
+ cp( httpd_conf, backup )
76
+
77
+ config_file_changed = false
78
+
79
+ if ruby_conf.empty?
80
+ # apparently there is nothing to do...
81
+ else
82
+ new_conf += "\n\n################# Ruby Web ###################\n"
83
+ new_conf += ruby_conf.join "\n"
84
+
85
+ File.open(temp, "w") do |f|
86
+ f.write new_conf
87
+ end
88
+
89
+ cp( temp, httpd_conf )
90
+
91
+ config_file_changed = true
92
+
93
+ # ----------- Restart Apache ------------
94
+ unless system(test_config_cmd)
95
+ puts("[ruby-web #{$0}]: Unable that the Apache webserver is running correcly with the new module and the configuration file changes using the '#{test_config_cmd}' command. Ruby-Web itself has been installed sucessfully, but it has not been activated. Your old #{httpd_conf} file is untouched...")
96
+ puts "[ruby-web #{$0}]: The modified config file is available in '#{temp}' so you can examine it and try to activate Ruby-Web"
97
+
98
+ cp( backup, conf )
99
+ else
100
+ # restart apache
101
+ system('net stop apache')
102
+ system('net start apache')
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+
110
+ if __FILE__ == $0
111
+ begin
112
+ Web::Install::Apache::install( *ARGV )
113
+ rescue Exception
114
+ puts $!
115
+ puts $!.backtrace
116
+ sleep
117
+ end
118
+ end
119
+
120
+ __END__
121
+
122
+ <?php
123
+
124
+ $lines = file($HTTPD_CONF);
125
+ foreach($lines as $k => $v) {
126
+ if (strpos($v,'index.html') !== false) {
127
+ if (strpos($v,'index.php') == false) {
128
+ $lines[$k] = str_replace('index.html','index.html index.php',$v);
129
+ }
130
+ }
131
+
132
+ if (preg_match('/LoadModule\s+php4_module/i',$v)) {
133
+ $lines[$k] = $insarr[0];
134
+ $insarr[0] = '';
135
+ }
136
+
137
+ if (preg_match('/AddModule\s+mod_php4.c/i',$v)) {
138
+ $lines[$k] = $insarr[1];
139
+ $insarr[1] = '';
140
+ }
141
+
142
+ if (preg_match('/AddType application\/x-httpd-php \.php/i',$v)) {
143
+ $lines[$k] = $insarr[2];
144
+ $insarr[2] = '';
145
+ }
146
+
147
+ if (preg_match('/^\s*DocumentRoot\s+(.*)/',$v,$rootarr)) {
148
+ $root = $rootarr[1];
149
+ if (substr($root,0,1) == '"') $root = trim(substr($root,1));
150
+ if (substr($root,strlen($root)-1) == '"') $root = substr($root,0,strlen($root)-1);
151
+ if (substr($root,strlen($root)-1) == '/') $root = substr($root,0,strlen($root)-1);
152
+ if (substr($root,strlen($root)-1) == '\\') $root = substr($root,0,strlen($root)-1);
153
+ }
154
+ }
155
+
156
+ if ($insarr[0] != '') $lines[] = "\r\n\r\n################# PHP ###################\r\n";
157
+ foreach($insarr as $v) $lines[] = $v;
158
+
159
+ $f = fopen($HTTPD_CONF,'w');
160
+ if ($f) {
161
+ foreach($lines as $v) fwrite($f,$v);
162
+ fclose($f);
163
+ }
164
+
165
+ system('net stop apache');
166
+ system('net start apache');
167
+ sleep(2);
168
+
169
+ ------------------------------
170
+ error_reporting(E_ALL);
171
+ if (sizeof($argv) <= 2) return;
172
+
173
+ if (!$HTTPD_CONF) return;
174
+
175
+ $insarr[] = "LoadModule php4_module $MAINDIR\\php\\php4apache.dll\r\n";
176
+ $insarr[] = "AddModule mod_php4.c\r\n";
177
+ $insarr[] = "AddType application/x-httpd-php .php\r\n";
178
+
179
+
180
+ ?>