knjrbfw 0.0.114 → 0.0.116

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.
@@ -6,24 +6,24 @@ path_to = ARGV[0]
6
6
 
7
7
  Dir.glob(File.join("**", ".svn")).each do |dir|
8
8
  newdir = path_to + "/" + dir
9
-
9
+
10
10
  #print dir + "\n"
11
11
  #print newdir + "\n"
12
-
13
- if File.exists?(newdir)
12
+
13
+ if File.exist?(newdir)
14
14
  print "Remove: " + newdir.to_s + "\n"
15
15
  FileUtils.rm_r(newdir)
16
16
  end
17
-
17
+
18
18
  begin
19
19
  #print "Move: " + dir + "\n"
20
20
  #FileUtils.mv(dir, newdir)
21
-
21
+
22
22
  print "Copy: " + dir + "\n"
23
23
  FileUtils.cp_r(dir, newdir)
24
24
  rescue => e
25
25
  print "Failed: " + e.message + "\n"
26
26
  end
27
-
27
+
28
28
  #print "\n"
29
29
  end
@@ -20,16 +20,16 @@ checks = [
20
20
  checks.each do |dir|
21
21
  dev_name = dir + "_dev"
22
22
  original_name = dir + "_original"
23
-
23
+
24
24
  if mode == "dev"
25
- if File.exists?(dir) and File.symlink?(dir)
25
+ if File.exist?(dir) and File.symlink?(dir)
26
26
  #do nothing.
27
- elsif File.exists?(dir) and !File.exists?(original_name)
27
+ elsif File.exist?(dir) and !File.exist?(original_name)
28
28
  File.rename(dir, original_name)
29
29
  File.rename(dev_name, dir)
30
30
  end
31
31
  elsif mode == "original"
32
- if File.exists?(dir) and File.exists?(original_name) and File.symlink?(dir)
32
+ if File.exist?(dir) and File.exist?(original_name) and File.symlink?(dir)
33
33
  File.rename(dir, dev_name)
34
34
  File.rename(original_name, dir)
35
35
  else
data/lib/knj/web.rb CHANGED
@@ -443,7 +443,7 @@ class Knj::Web
443
443
  raise "No value given in arguments for imageupload-input." if !args.key?(:value)
444
444
 
445
445
  path = args[:path].gsub("%value%", value.to_s).untaint
446
- if File.exists?(path)
446
+ if File.exist?(path)
447
447
  html << "<img src=\"image.rhtml?path=#{self.urlenc(path).html}&smartsize=100&rounded_corners=10&border_color=black&force=true&ts=#{Time.new.to_f}\" alt=\"Image\" />"
448
448
 
449
449
  if args[:dellink]
@@ -919,13 +919,3 @@ class Symbol
919
919
  return self.to_s.sql
920
920
  end
921
921
  end
922
-
923
- class Fixnum
924
- def sql
925
- return self.to_s.sql
926
- end
927
-
928
- def html
929
- return self.to_s.html
930
- end
931
- end
@@ -5,17 +5,17 @@
5
5
  rescue NameError
6
6
  appsrv = _kas
7
7
  end
8
-
8
+
9
9
  #Support for the PHP-version... Comes handy when converting PHP to Ruby...
10
10
  if !_get["path"]
11
11
  trans = {
12
12
  "picture" => "path"
13
13
  }
14
-
14
+
15
15
  if _get["edgesize"]
16
16
  _get["rounded_corners"] = (_get["edgesize"].to_f / 3.0).to_i
17
17
  end
18
-
18
+
19
19
  if _get["edgeborder"]
20
20
  if _get["edgeborder"].length == 6
21
21
  _get["border_color"] = "##{_get["edgeborder"]}"
@@ -23,30 +23,30 @@
23
23
  _get["border_color"] = _get["edbeborder"]
24
24
  end
25
25
  end
26
-
26
+
27
27
  if _get["edgeborder"]
28
28
  _get["border"] = 1
29
29
  end
30
-
30
+
31
31
  trans.each do |key, val|
32
32
  _get[val] = _get[key] if _get[key]
33
33
  end
34
34
  end
35
-
35
+
36
36
  #Base64-encoding of path.
37
37
  if _get["path64"]
38
38
  require "base64"
39
39
  _get["path"] = Base64.decode64(_get["path64"])
40
40
  end
41
-
41
+
42
42
  require "digest/md5"
43
43
  idstr = Digest::MD5.hexdigest("#{Process.euid}_#{_get["path"]}_#{_get["smartsize"].to_i}_#{_get["width"].to_i}_#{_get["height"].to_i}_#{_get["maxwidth"].to_i}_#{_get["maxheight"].to_i}_#{_get["rounded_corners"].to_i}_#{_get["border"].to_i}_#{_get["border_color"]}")
44
-
45
- if !_get["path"] or !File.exists?(_get["path"])
44
+
45
+ if !_get["path"] or !File.exist?(_get["path"])
46
46
  print "File does not exist: '#{_get["path"]}'.\n"
47
47
  exit
48
48
  end
49
-
49
+
50
50
  time_orig = File.mtime(_get["path"])
51
51
  tmp_write = false
52
52
  if Knj::CONFIG["webscripts_image"]
@@ -54,65 +54,65 @@
54
54
  else
55
55
  tmp_path = "#{Knj::Os.tmpdir}/knjrbfw_image_#{idstr}"
56
56
  end
57
-
58
- tmp_exists = File.exists?(tmp_path)
57
+
58
+ tmp_exists = File.exist?(tmp_path)
59
59
  tmp_write = true unless tmp_exists
60
-
60
+
61
61
  if !tmp_write and tmp_exists
62
62
  time_cache = File.mtime(tmp_path)
63
-
63
+
64
64
  if time_orig > time_cache
65
65
  tmp_write = true
66
66
  end
67
67
  end
68
-
68
+
69
69
  if _get["force"] == "true" or _get["force"] == "1"
70
70
  force = true
71
71
  else
72
72
  force = false
73
73
  end
74
-
74
+
75
75
  notchanged = false
76
-
76
+
77
77
  if _httpsession.handler.modified_since and time_cache and _httpsession.handler.modified_since.utc.to_s == time_cache.utc.to_s
78
78
  notchanged = true
79
79
  elsif _httpsession.handler.modified_since and _httpsession.handler.modified_since.utc.to_s == time_orig.utc.to_s
80
80
  notchanged = true
81
81
  end
82
-
82
+
83
83
  if notchanged and !force
84
84
  _httpsession.resp.status = 304
85
85
  exit
86
86
  end
87
-
87
+
88
88
  if tmp_write or force
89
89
  blob_cont = nil
90
-
90
+
91
91
  raise "RMagick has not been loaded. If loaded through here bugs will occur. Load in beginning of script." unless ::Kernel.const_defined?(:Magick)
92
92
  pic = Magick::Image.read(_get["path"]).first
93
-
93
+
94
94
  if !pic
95
95
  print "Could not open image from '#{_get["path"]}'."
96
96
  exit
97
97
  end
98
-
98
+
99
99
  pic.format = "png"
100
-
100
+
101
101
  pic_columns = pic.columns
102
102
  pic_rows = pic.rows
103
-
103
+
104
104
  width = pic_columns
105
105
  height = pic_rows
106
-
106
+
107
107
  height = _get["height"].to_i if _get["height"]
108
108
  width = _get["width"].to_i if _get["width"]
109
-
109
+
110
110
  if _get["width"] && !_get["height"]
111
111
  height = (pic_rows.to_f / (pic_columns.to_f / width.to_f)).to_i
112
112
  elsif _get["height"] && !_get["width"]
113
113
  width = (pic_columns.to_f / (pic_rows.to_f / height.to_f)).to_i
114
114
  end
115
-
115
+
116
116
  if _get["smartsize"]
117
117
  if pic_columns > pic_rows
118
118
  width = _get["smartsize"].to_i
@@ -122,51 +122,51 @@
122
122
  width = (pic_columns.to_f / (pic_rows.to_f / height.to_f)).to_i
123
123
  end
124
124
  end
125
-
125
+
126
126
  if _get["maxwidth"]
127
127
  maxwidth = _get["maxwidth"].to_i
128
-
128
+
129
129
  if width > maxwidth
130
130
  height = (pic_rows.to_f / (pic_columns.to_f / maxwidth.to_f)).to_i
131
131
  width = maxwidth
132
132
  end
133
133
  end
134
-
134
+
135
135
  if _get["maxheight"]
136
136
  maxheight = _get["maxheight"].to_i
137
-
137
+
138
138
  if height > maxheight
139
139
  width = (pic_columns.to_f / (pic_rows.to_f / maxheight.to_f)).to_i
140
140
  height = maxheight
141
141
  end
142
142
  end
143
-
143
+
144
144
  if _get["width"] and _get["height"]
145
145
  width = _get["width"].to_i
146
146
  height = _get["height"].to_i
147
147
  end
148
-
148
+
149
149
  if height != pic_rows or width != pic_columns
150
150
  pic = pic.resize_to_fill(width.to_i, height.to_i)
151
151
  end
152
-
152
+
153
153
  if _get["rounded_corners"]
154
154
  args = {:img => pic, :radius => _get["rounded_corners"].to_i}
155
-
155
+
156
156
  if _get["border"] and _get["border_color"]
157
157
  args[:border] = _get["border"].to_i
158
158
  args[:border_color] = _get["border_color"]
159
159
  end
160
-
160
+
161
161
  #Call rounded_corners with the proxy-hash.
162
162
  Knj::Image.rounded_corners(args)
163
163
  end
164
-
164
+
165
165
  pic.write(tmp_path) if tmp_write or force
166
166
  end
167
-
168
- raise "Picture was not written: '#{tmp_path}'." if !tmp_path || !File.exists?(tmp_path)
169
-
167
+
168
+ raise "Picture was not written: '#{tmp_path}'." if !tmp_path || !File.exist?(tmp_path)
169
+
170
170
  appsrv.header("Last-Modified", "#{time_orig.httpdate} GMT") if time_orig
171
171
  appsrv.header("Content-Type", "image/png")
172
172
  _httpsession.force_fileread(tmp_path)
@@ -5,17 +5,17 @@
5
5
  rescue NameError
6
6
  appsrv = _kas
7
7
  end
8
-
8
+
9
9
  #Support for the PHP-version... Comes handy when converting PHP to Ruby...
10
10
  if !_get["path"]
11
11
  trans = {
12
12
  "picture" => "path"
13
13
  }
14
-
14
+
15
15
  if _get["edgesize"]
16
16
  _get["rounded_corners"] = (_get["edgesize"].to_f / 3.0).to_i
17
17
  end
18
-
18
+
19
19
  if _get["edgeborder"]
20
20
  if _get["edgeborder"].length == 6
21
21
  _get["border_color"] = "##{_get["edgeborder"]}"
@@ -23,104 +23,104 @@
23
23
  _get["border_color"] = _get["edbeborder"]
24
24
  end
25
25
  end
26
-
26
+
27
27
  if _get["edgeborder"]
28
28
  _get["border"] = 1
29
29
  end
30
-
30
+
31
31
  trans.each do |key, val|
32
32
  _get[val] = _get[key] if _get[key]
33
33
  end
34
34
  end
35
-
35
+
36
36
  #Base64-encoding of path.
37
37
  if _get["path64"]
38
38
  require "base64"
39
39
  _get["path"] = Base64.decode64(_get["path64"])
40
40
  end
41
-
41
+
42
42
  require "digest/md5"
43
43
  idstr = Digest::MD5.hexdigest("#{_get["path"]}_#{_get["smartsize"].to_i}_#{_get["width"].to_i}_#{_get["height"].to_i}_#{_get["maxwidth"].to_i}_#{_get["maxheight"].to_i}_#{_get["rounded_corners"].to_i}_#{_get["border"].to_i}_#{_get["border_color"]}")
44
-
45
- if !_get["path"] or !File.exists?(_get["path"])
44
+
45
+ if !_get["path"] or !File.exist?(_get["path"])
46
46
  print "File does not exist: '#{_get["path"]}'.\n"
47
47
  exit
48
48
  end
49
-
49
+
50
50
  time_orig = File.mtime(_get["path"])
51
-
51
+
52
52
  tmp_write = false
53
53
  if Knj::CONFIG["webscripts_image"]
54
54
  tmp_path = "#{Knj::CONFIG["webscripts_image"]["tmp_path"]}/#{idstr}"
55
55
  else
56
56
  tmp_path = "#{Knj::Os.tmpdir}/knjrbfw_image_#{idstr}"
57
57
  end
58
-
59
- tmp_exists = File.exists?(tmp_path)
58
+
59
+ tmp_exists = File.exist?(tmp_path)
60
60
  tmp_write = true if !tmp_exists
61
-
61
+
62
62
  if !tmp_write and tmp_exists
63
63
  time_cache = File.mtime(tmp_path)
64
-
64
+
65
65
  if time_orig > time_cache
66
66
  tmp_write = true
67
67
  end
68
68
  end
69
-
69
+
70
70
  if _get["force"] == "true" or _get["force"] == "1"
71
71
  force = true
72
72
  else
73
73
  force = false
74
74
  end
75
-
75
+
76
76
  notchanged = false
77
-
77
+
78
78
  if _httpsession.handler.modified_since and time_cache and _httpsession.handler.modified_since.utc.to_s == time_cache.utc.to_s
79
79
  notchanged = true
80
80
  elsif _httpsession.handler.modified_since and _httpsession.handler.modified_since.utc.to_s == time_orig.utc.to_s
81
81
  notchanged = true
82
82
  end
83
-
83
+
84
84
  if notchanged and !force
85
85
  _httpsession.resp.status = 304
86
86
  exit
87
87
  end
88
-
88
+
89
89
  if tmp_write or force
90
90
  blob_cont = nil
91
-
91
+
92
92
  require "ruby_process"
93
93
  Ruby_process::Cproxy.run do |data|
94
94
  subproc = data[:subproc]
95
95
  subproc.static(:Object, :require, "rubygems")
96
96
  subproc.static(:Object, :require, "#{Knj.knjrbfw_path}/../knjrbfw.rb")
97
- subproc.static(:Object, :require, "RMagick")
97
+ subproc.static(:Object, :require, "rmagick")
98
98
  subproc.static(:Dir, :chdir, File.dirname(__FILE__))
99
-
99
+
100
100
  pic = subproc.static("Magick::Image", :read, _get["path"]).first
101
-
101
+
102
102
  if !pic
103
103
  print "Could not open image from '#{_get["path"]}'."
104
104
  exit
105
105
  end
106
-
106
+
107
107
  pic.format = "png"
108
-
108
+
109
109
  pic_columns = pic.columns.__rp_marshal
110
110
  pic_rows = pic.rows.__rp_marshal
111
-
111
+
112
112
  width = pic_columns
113
113
  height = pic_rows
114
-
114
+
115
115
  height = _get["height"].to_i if _get["height"]
116
116
  width = _get["width"].to_i if _get["width"]
117
-
117
+
118
118
  if _get["width"] && !_get["height"]
119
119
  height = (pic_rows.to_f / (pic_columns.to_f / width.to_f)).to_i
120
120
  elsif _get["height"] && !_get["width"]
121
121
  width = (pic_columns.to_f / (pic_rows.to_f / height.to_f)).to_i
122
122
  end
123
-
123
+
124
124
  if _get["smartsize"]
125
125
  if pic_columns > pic_rows
126
126
  width = _get["smartsize"].to_i
@@ -130,50 +130,50 @@
130
130
  width = (pic_columns.to_f / (pic_rows.to_f / height.to_f)).to_i
131
131
  end
132
132
  end
133
-
133
+
134
134
  if _get["maxwidth"]
135
135
  maxwidth = _get["maxwidth"].to_i
136
-
136
+
137
137
  if width > maxwidth
138
138
  height = (pic_rows.to_f / (pic_columns.to_f / maxwidth.to_f)).to_i
139
139
  width = maxwidth
140
140
  end
141
141
  end
142
-
142
+
143
143
  if _get["maxheight"]
144
144
  maxheight = _get["maxheight"].to_i
145
-
145
+
146
146
  if height > maxheight
147
147
  width = (pic_columns.to_f / (pic_rows.to_f / maxheight.to_f)).to_i
148
148
  height = maxheight
149
149
  end
150
150
  end
151
-
151
+
152
152
  if _get["width"] and _get["height"]
153
153
  width = _get["width"].to_i
154
154
  height = _get["height"].to_i
155
155
  end
156
-
156
+
157
157
  if height != pic_rows or width != pic_columns
158
158
  pic = pic.resize_to_fill(width.to_i, height.to_i)
159
159
  end
160
-
160
+
161
161
  if _get["rounded_corners"]
162
162
  args = {:img => pic, :radius => _get["rounded_corners"].to_i}
163
-
163
+
164
164
  if _get["border"] and _get["border_color"]
165
165
  args[:border] = _get["border"].to_i
166
166
  args[:border_color] = _get["border_color"]
167
167
  end
168
-
168
+
169
169
  #Call rounded_corners with the proxy-hash.
170
170
  subproc.static("Knj::Image", :rounded_corners, args)
171
171
  end
172
-
172
+
173
173
  pic.write(tmp_path) if tmp_write or force
174
174
  end
175
175
  end
176
-
176
+
177
177
  appsrv.header("Last-Modified", "#{time_orig.httpdate} GMT") if time_orig
178
178
  appsrv.header("Content-Type", "image/png")
179
179
  _httpsession.force_fileread(tmp_path)
@@ -1,15 +1,15 @@
1
1
  class Knj::Win::TightVNC
2
2
  def initialize(args)
3
3
  @args = ArrayExt.hash_sym(args)
4
-
4
+
5
5
  @args[:port] = 5900 if !@args[:port]
6
6
  @args[:port_http] = 5800 if !@args[:http_port]
7
-
7
+
8
8
  raise "No path given." if !@args[:path]
9
-
9
+
10
10
  exefile = @args[:path] + "/WinVNC.exe"
11
- raise "#{exefile} was not found." if !File.exists?(exefile)
12
-
11
+ raise "#{exefile} was not found." if !File.exist?(exefile)
12
+
13
13
  @wmi = WIN32OLE.connect("winmgmts://")
14
14
  processes = @wmi.ExecQuery("SELECT * FROM win32_process")
15
15
  ended = false
@@ -19,13 +19,13 @@ class Knj::Win::TightVNC
19
19
  ended = true
20
20
  end
21
21
  end
22
-
22
+
23
23
  sleep 1 if ended
24
-
24
+
25
25
  #print Win::Registry.get(:cur_user, 'Software\ORL\WinVNC3', 'Password', :sz).unpack('H*')[0] + "\n"
26
26
  #print ["160e9d46f26586ca"].pack('H*').unpack('H*')[0] + "\n"
27
27
  #exit
28
-
28
+
29
29
  Win::Registry.set(:cur_user, 'Software\ORL\WinVNC3', [
30
30
  ["AutoPortSelect", 1, :dword],
31
31
  ["BlankScreen", 0, :dword],
@@ -61,7 +61,7 @@ class Knj::Win::TightVNC
61
61
  ["LoopbackOnly", 0, :dword]
62
62
  ])
63
63
  #password is of this moment only 'kaspernj'.
64
-
64
+
65
65
  @wmi = WIN32OLE.connect("winmgmts://")
66
66
  processes = @wmi.ExecQuery("SELECT * FROM win32_process")
67
67
  ended = false
@@ -71,17 +71,17 @@ class Knj::Win::TightVNC
71
71
  ended = true
72
72
  end
73
73
  end
74
-
74
+
75
75
  sleep 1 if ended
76
-
76
+
77
77
  Knj::Thread.new do
78
78
  IO.popen(exefile) do |process|
79
79
  #nothing
80
80
  end
81
81
  end
82
-
82
+
83
83
  sleep 1
84
-
84
+
85
85
  @processes = @wmi.ExecQuery("SELECT * FROM win32_process")
86
86
  for process in @processes do
87
87
  if process.Name == "WinVNC.exe"
@@ -89,14 +89,14 @@ class Knj::Win::TightVNC
89
89
  break
90
90
  end
91
91
  end
92
-
92
+
93
93
  raise "Could not start WinVNC.exe." if !@process
94
-
94
+
95
95
  Kernel.at_exit do
96
96
  self.close
97
97
  end
98
98
  end
99
-
99
+
100
100
  def open?
101
101
  begin
102
102
  @process.GetOwner
@@ -105,10 +105,10 @@ class Knj::Win::TightVNC
105
105
  return false
106
106
  end
107
107
  end
108
-
108
+
109
109
  def close
110
110
  return nil if !@process
111
-
111
+
112
112
  begin
113
113
  @process.Terminate
114
114
  rescue => e
@@ -118,7 +118,7 @@ class Knj::Win::TightVNC
118
118
  raise e
119
119
  end
120
120
  end
121
-
121
+
122
122
  @process = nil
123
123
  @args = nil
124
124
  @wmi = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.114
4
+ version: 0.0.116
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Stöckel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-13 00:00:00.000000000 Z
11
+ date: 2023-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wref
@@ -399,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
399
399
  - !ruby/object:Gem::Version
400
400
  version: '0'
401
401
  requirements: []
402
- rubygems_version: 3.2.32
402
+ rubygems_version: 3.3.7
403
403
  signing_key:
404
404
  specification_version: 4
405
405
  summary: A framework with lots of stuff for Ruby.