aritcaptcha 1.5.0 → 1.7.0
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.
- data/VERSION +1 -1
- data/aritcaptcha.gemspec +2 -1
- data/lib/aritcaptcha/aritcaptcha_helper.rb +9 -5
- data/lib/aritcaptcha/articaptcha_verify.rb +16 -0
- data/lib/aritcaptcha.rb +1 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
data/aritcaptcha.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{aritcaptcha}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Guilherme Nascimento"]
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"aritcaptcha.gemspec",
|
27
27
|
"lib/aritcaptcha.rb",
|
28
28
|
"lib/aritcaptcha/aritcaptcha_helper.rb",
|
29
|
+
"lib/aritcaptcha/articaptcha_verify.rb",
|
29
30
|
"lib/aritcaptcha/calculation.rb",
|
30
31
|
"spec/aritcaptcha_helper_spec.rb",
|
31
32
|
"spec/aritcaptcha_spec.rb",
|
@@ -9,18 +9,22 @@ module Aritcaptcha
|
|
9
9
|
OPERATIONS = [ADD, SUB, DIV, MUL]
|
10
10
|
|
11
11
|
def aritcaptcha_tag(options={})
|
12
|
+
equation_key = Time.now.to_i
|
12
13
|
number1 = options[:one] || 50
|
13
14
|
number2 = options[:two] || 50
|
14
15
|
operation = options[:op] || OPERATIONS[rand(OPERATIONS.size)]
|
15
16
|
|
16
17
|
equation, result = Aritcaptcha::Calculation.generate_calculation number1, number2, operation
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
|
19
|
+
session[:equation] = [equation_key, eval(equation)]
|
20
|
+
|
21
|
+
if options[:html]
|
22
|
+
html_options = options[:html].inject([]){|dump, pair| dump << "#{pair[0]}=\"#{pair[1]}\""}
|
23
|
+
html_options.join(" ")
|
24
|
+
end
|
22
25
|
|
23
26
|
html = "#{equation} = <input type='text' name='equation' #{html_options} />"
|
27
|
+
html << %{<input type="hidden" name="equation_key" value="#{equation_key}" />\n}
|
24
28
|
html
|
25
29
|
end
|
26
30
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Aritcaptcha
|
2
|
+
|
3
|
+
module AritcaptchaVerify
|
4
|
+
SOLV_KEY = 0
|
5
|
+
SOLV = 1
|
6
|
+
|
7
|
+
def verify_articaptcha(params)
|
8
|
+
puts params[:equation_key]
|
9
|
+
puts params[:equation]
|
10
|
+
if (solv_key = params[:equation_key]) and (solv = params[:equation])
|
11
|
+
return (session[:equation] and session[:equation][SOLV_KEY] == solv_key.to_i and session[:equation][SOLV] == solv.to_i)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/aritcaptcha.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aritcaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 7
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Guilherme Nascimento
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- aritcaptcha.gemspec
|
54
54
|
- lib/aritcaptcha.rb
|
55
55
|
- lib/aritcaptcha/aritcaptcha_helper.rb
|
56
|
+
- lib/aritcaptcha/articaptcha_verify.rb
|
56
57
|
- lib/aritcaptcha/calculation.rb
|
57
58
|
- spec/aritcaptcha_helper_spec.rb
|
58
59
|
- spec/aritcaptcha_spec.rb
|