Wiki2Go 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/Wiki2GoServer.rb +11 -0
- data/bin/Wiki2Go_make_site.rb +10 -0
- data/bin/Wiki2Go_make_wiki.rb +10 -0
- data/bin/Wiki2Go_update_site.rb +10 -0
- data/lib/Web2Go/CGIRequest.rb +99 -0
- data/lib/Web2Go/CGIResponse.rb +64 -0
- data/lib/Web2Go/ERB_Interpreter.rb +47 -0
- data/lib/Web2Go/MockCookie.rb +17 -0
- data/lib/Web2Go/MockRequest.rb +131 -0
- data/lib/Web2Go/MockResponse.rb +35 -0
- data/lib/Web2Go/Web2Go.rb +0 -0
- data/lib/Web2Go/WebrickRequest.rb +124 -0
- data/lib/Web2Go/WebrickResponse.rb +50 -0
- data/lib/Wiki2Go.rb +2 -0
- data/lib/Wiki2Go/BlackList.rb +52 -0
- data/lib/Wiki2Go/DotGraphics.rb +69 -0
- data/lib/Wiki2Go/FileStorage.rb +267 -0
- data/lib/Wiki2Go/GreyList.rb +88 -0
- data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +4743 -0
- data/lib/Wiki2Go/Install/config/passwords +1 -0
- data/lib/Wiki2Go/Install/make_site.rb +515 -0
- data/lib/Wiki2Go/Install/site/error.html +77 -0
- data/lib/Wiki2Go/Install/site/html/admin.css +135 -0
- data/lib/Wiki2Go/Install/site/html/xml.gif +0 -0
- data/lib/Wiki2Go/Install/site/robots.txt +13 -0
- data/lib/Wiki2Go/Install/site/style.css +135 -0
- data/lib/Wiki2Go/Install/templates/admin.htm +48 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/admin.txt +1 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/greylist.txt +72 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +67 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/regenerate.txt +26 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/removespam.txt +19 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/update.txt +13 -0
- data/lib/Wiki2Go/Install/templates/edit.htm +74 -0
- data/lib/Wiki2Go/Install/templates/pagelist.htm +82 -0
- data/lib/Wiki2Go/Install/templates/rss.xml +11 -0
- data/lib/Wiki2Go/Install/templates/versionlist.htm +84 -0
- data/lib/Wiki2Go/Install/templates/view.htm +72 -0
- data/lib/Wiki2Go/Install/wiki/style.css +135 -0
- data/lib/Wiki2Go/Page.rb +69 -0
- data/lib/Wiki2Go/PrivateWikiConfig.rb +27 -0
- data/lib/Wiki2Go/PublicWikiConfig.rb +52 -0
- data/lib/Wiki2Go/ReadWriteWikiConfig.rb +23 -0
- data/lib/Wiki2Go/Server.rb +94 -0
- data/lib/Wiki2Go/SpamFilter.rb +95 -0
- data/lib/Wiki2Go/UrlFinder.rb +26 -0
- data/lib/Wiki2Go/Web.rb +185 -0
- data/lib/Wiki2Go/WebrickServlet.rb +211 -0
- data/lib/Wiki2Go/WhiteList.rb +29 -0
- data/lib/Wiki2Go/Wiki2Go.rb +274 -0
- data/lib/Wiki2Go/Wiki2GoConfig.rb +144 -0
- data/lib/Wiki2Go/Wiki2GoServlet.rb +197 -0
- data/lib/Wiki2Go/WikiFormatter.rb +597 -0
- data/lib/Wiki2Go/WikiLogFile.rb +43 -0
- data/lib/Wiki2Go/cgi/changes.rb +20 -0
- data/lib/Wiki2Go/cgi/display.rb +20 -0
- data/lib/Wiki2Go/cgi/edit.rb +20 -0
- data/lib/Wiki2Go/cgi/redirect.rb +20 -0
- data/lib/Wiki2Go/cgi/save.rb +20 -0
- data/lib/Wiki2Go/cgi/search.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/admin.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/generate_static.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/removespam.rb +20 -0
- data/lib/Wiki2Go/cgi/upload.rb +20 -0
- data/lib/Wiki2Go/cgi/versions.rb +20 -0
- data/lib/Wiki2Go/cgi/view.rb +20 -0
- metadata +113 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module Web2Go
|
4
|
+
|
5
|
+
class CGIFile
|
6
|
+
|
7
|
+
attr_reader :content
|
8
|
+
attr_reader :filename
|
9
|
+
|
10
|
+
def initialize(file)
|
11
|
+
@file = file
|
12
|
+
@content = file.read
|
13
|
+
@filename = file.original_filename
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
class CGIRequest
|
19
|
+
|
20
|
+
attr_reader :server_variable
|
21
|
+
attr_reader :params
|
22
|
+
|
23
|
+
def initialize(cgi)
|
24
|
+
@cgi = cgi
|
25
|
+
@server_variable = ENV
|
26
|
+
@params = @cgi.params
|
27
|
+
end
|
28
|
+
|
29
|
+
def path
|
30
|
+
@server_variable['PATH_INFO']
|
31
|
+
end
|
32
|
+
|
33
|
+
def host
|
34
|
+
@server_variable['SERVER_NAME']
|
35
|
+
end
|
36
|
+
|
37
|
+
def port
|
38
|
+
@server_variable['SERVER_PORT']
|
39
|
+
end
|
40
|
+
|
41
|
+
def user
|
42
|
+
@user ||= find_user
|
43
|
+
@user
|
44
|
+
end
|
45
|
+
|
46
|
+
def authenticated
|
47
|
+
@server_variable.has_key?("AUTH_TYPE")
|
48
|
+
end
|
49
|
+
|
50
|
+
def parameter(name,default_value=nil)
|
51
|
+
value = @params[name]
|
52
|
+
if value.nil? || value.length < 1 then
|
53
|
+
return default_value
|
54
|
+
else
|
55
|
+
return value[0]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def uploaded_file(name,pos=0)
|
60
|
+
file = @params[name]
|
61
|
+
if !file.nil? then
|
62
|
+
return CGIFile.new(file[pos])
|
63
|
+
end
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def cookie(name)
|
68
|
+
if @cgi.cookies.has_key?(name) then
|
69
|
+
return @cgi.cookies[name]
|
70
|
+
else
|
71
|
+
return nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def cookies
|
76
|
+
@cgi.cookies
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def find_user
|
82
|
+
user = @server_variable['REMOTE_USER']
|
83
|
+
if user.nil? or user.empty? then
|
84
|
+
user = @server_variable['REMOTE_ADDR']
|
85
|
+
begin
|
86
|
+
addr = Resolv.getname(user)
|
87
|
+
if !addr.nil? and !addr.empty? then
|
88
|
+
user = addr
|
89
|
+
end
|
90
|
+
rescue
|
91
|
+
end
|
92
|
+
end
|
93
|
+
user
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module Web2Go
|
4
|
+
|
5
|
+
class CGIResponse
|
6
|
+
|
7
|
+
attr_accessor :content_type
|
8
|
+
|
9
|
+
def initialize(cgi)
|
10
|
+
@cgi = cgi
|
11
|
+
@content_type = 'text/html'
|
12
|
+
@redirect = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def redirect_to=(redirect_url)
|
16
|
+
@redirect = redirect_url
|
17
|
+
end
|
18
|
+
|
19
|
+
def body=(content)
|
20
|
+
options = Hash.new
|
21
|
+
options['type'] = @content_type
|
22
|
+
|
23
|
+
if @cgi.cookies.length > 0 then
|
24
|
+
options['cookie'] = @cgi.cookies
|
25
|
+
end
|
26
|
+
if !@redirect.nil? then
|
27
|
+
options['Status'] = '302 Moved'
|
28
|
+
options[ 'location'] = @redirect
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
@cgi.out(options) do
|
33
|
+
content
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_cookie(cookie)
|
39
|
+
@cgi.cookies[cookie.name] = cookie
|
40
|
+
end
|
41
|
+
|
42
|
+
def cookies
|
43
|
+
@cgi.cookies
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_cookie(name,value,domain=nil,path=nil,expires=nil)
|
47
|
+
cookie = CGI::Cookie.new(name,value)
|
48
|
+
cookie.expires = expires unless expires.nil?
|
49
|
+
cookie.domain = domain unless domain.nil?
|
50
|
+
cookie.path = path unless path.nil?
|
51
|
+
set_cookie(cookie)
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_cookies(cookies)
|
55
|
+
# cookies.each do |cookie|
|
56
|
+
# set_cookie(cookie)
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require 'erb'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Web2Go
|
6
|
+
|
7
|
+
# ERB_Interpreter manages the execution of ERB scripts
|
8
|
+
# See eRuby and ERB class in stdlib
|
9
|
+
class ERB_Interpreter
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@evaluation_context = OpenStruct.new
|
13
|
+
end
|
14
|
+
|
15
|
+
# Add a named field to the evaluation context
|
16
|
+
# Can be accessed from within script as erb.name
|
17
|
+
def add_parameter(name,value)
|
18
|
+
@evaluation_context.send(name+'=',value)
|
19
|
+
end
|
20
|
+
|
21
|
+
# add a member variable to the evaluation context
|
22
|
+
# Can be accessed from within script as @name
|
23
|
+
def add_field(name,value)
|
24
|
+
instance_variable_set(name,value)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Execute an ERB script and return the resulting string
|
29
|
+
def execute(script,params=nil)
|
30
|
+
|
31
|
+
parser = ERB.new(script)
|
32
|
+
|
33
|
+
if !params.nil? then
|
34
|
+
params.each { |key,value| add_parameter(key,value) }
|
35
|
+
end
|
36
|
+
|
37
|
+
erb = @evaluation_context
|
38
|
+
# for compatibility with previous usage of ERB in Wiki2Go
|
39
|
+
current = @evaluation_context
|
40
|
+
|
41
|
+
parser.result(binding)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Web2Go
|
2
|
+
|
3
|
+
|
4
|
+
class MockCookie
|
5
|
+
attr_reader :name
|
6
|
+
attr_reader :value
|
7
|
+
attr_reader :domain
|
8
|
+
attr_reader :expires
|
9
|
+
|
10
|
+
def initialize(name,value,domain,expires)
|
11
|
+
@name = name
|
12
|
+
@value = value
|
13
|
+
@domain = domain
|
14
|
+
@expires = expires
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
require 'uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
require 'Web2Go/MockCookie'
|
6
|
+
|
7
|
+
module Web2Go
|
8
|
+
|
9
|
+
class MockFile
|
10
|
+
attr_reader :filename
|
11
|
+
attr_reader :content
|
12
|
+
|
13
|
+
def initialize(filename,content=nil)
|
14
|
+
@filename = filename
|
15
|
+
if content.nil? then
|
16
|
+
File.open(filename,"r") do |f|
|
17
|
+
content = f.read
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@content = content
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class MockRequest
|
25
|
+
|
26
|
+
#Request interface
|
27
|
+
attr_reader :server_variable
|
28
|
+
attr_reader :params
|
29
|
+
attr_accessor :user
|
30
|
+
attr_accessor :authenticated
|
31
|
+
attr_accessor :cookies
|
32
|
+
|
33
|
+
def initialize(url = 'http://localhost/',env=ENV)
|
34
|
+
@server_variable = get_server_variables(url)
|
35
|
+
@server_variable.update( env)
|
36
|
+
|
37
|
+
@params = CGI::parse(server_variable['QUERY_STRING'])
|
38
|
+
@user = env['REMOTE_USER'] || env['USER'] || env['USERNAME']
|
39
|
+
@authenticated = env.has_key?('AUTH_TYPE')
|
40
|
+
@uploaded_files = {}
|
41
|
+
@cookies = {}
|
42
|
+
end
|
43
|
+
|
44
|
+
def path
|
45
|
+
@server_variable['PATH_INFO']
|
46
|
+
end
|
47
|
+
|
48
|
+
def host
|
49
|
+
@server_variable['SERVER_NAME']
|
50
|
+
end
|
51
|
+
|
52
|
+
def port
|
53
|
+
@server_variable['SERVER_PORT']
|
54
|
+
end
|
55
|
+
|
56
|
+
def parameter(name,default_value=nil)
|
57
|
+
value = @params[name]
|
58
|
+
if value.nil? then
|
59
|
+
return default_value
|
60
|
+
else
|
61
|
+
return value[0]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def uploaded_file(name,pos=0)
|
66
|
+
file = @uploaded_files[name]
|
67
|
+
if !file.nil? then
|
68
|
+
return file[pos]
|
69
|
+
end
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def cookie(name)
|
74
|
+
return @cookies[name]
|
75
|
+
end
|
76
|
+
|
77
|
+
#Mock manipulation
|
78
|
+
def add_parameter(name,value)
|
79
|
+
if @params.has_key?(name) then
|
80
|
+
@params[name].push(value)
|
81
|
+
else
|
82
|
+
@params[name] = [ value ]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def upload_file(name,filename,content=nil)
|
87
|
+
file = MockFile.new(filename,content)
|
88
|
+
if @uploaded_files.has_key?(name) then
|
89
|
+
@uploaded_files[name].push(file)
|
90
|
+
else
|
91
|
+
@uploaded_files[name] = [ file ]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def add_cookie(name,value,domain=nil,expires=nil)
|
96
|
+
@cookies[name] = MockCookie.new(name,value,domain,expires)
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def get_server_variables(url)
|
102
|
+
vars = Hash.new
|
103
|
+
uri = URI::parse(url)
|
104
|
+
vars['SERVER_NAME'] = uri.host
|
105
|
+
vars['SERVER_PORT'] = uri.port
|
106
|
+
vars['SCRIPT_NAME'], vars['PATH_INFO'] = split_script_and_path(clean(uri.path))
|
107
|
+
vars['QUERY_STRING'] = uri.query || ''
|
108
|
+
vars
|
109
|
+
end
|
110
|
+
|
111
|
+
def split_script_and_path(path)
|
112
|
+
if path =~ /\// then
|
113
|
+
path =~ /^([^\/]+)\/(.*)$/
|
114
|
+
return $1,$2
|
115
|
+
else
|
116
|
+
return path,""
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
def clean(path)
|
122
|
+
if path.nil? then
|
123
|
+
return ""
|
124
|
+
else
|
125
|
+
return path.squeeze('/').gsub(/^\//,'').gsub(/\/$/,'')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
require 'uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Web2Go
|
6
|
+
|
7
|
+
class MockResponse
|
8
|
+
|
9
|
+
attr_accessor :body
|
10
|
+
attr_accessor :content_type
|
11
|
+
attr_accessor :redirect_to
|
12
|
+
attr_accessor :cookies
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@content_type = 'text/html'
|
16
|
+
@cookies = { }
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_cookie(cookie)
|
20
|
+
@cookies[cookie.name] = cookie
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_cookie(name,value,domain=nil,expires=nil)
|
24
|
+
@cookies[name] = MockCookie.new(name,value,domain,expires)
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_cookies(cookies)
|
28
|
+
cookies.each do |cookie|
|
29
|
+
set_cookie(cookie)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|