spiderfw 0.6.29 → 0.6.30
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.
- checksums.yaml +7 -0
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/apps/core/admin/controllers/admin_controller.rb +1 -1
- data/apps/core/admin/public/css/sass/admin.css +14 -14
- data/apps/core/admin/public/sass/admin.scss +2 -1
- data/apps/core/admin/views/admin.layout.shtml +1 -1
- data/apps/core/auth/controllers/mixins/auth_helper.rb +1 -1
- data/apps/core/components/assets.rb +6 -3
- data/apps/core/components/public/js/jquery/jquery-1.8.3.js +6 -0
- data/apps/core/components/public/js/jquery/jquery-1.8.3.min.js +183 -0
- data/apps/core/components/widgets/admin/admin.rb +2 -2
- data/apps/core/components/widgets/confirm/confirm.rb +2 -2
- data/apps/core/components/widgets/list/plugins/exportable/exportable_list.rb +0 -1
- data/apps/messenger/backends/sms/skebby.rb +61 -0
- data/apps/messenger/config/options.rb +6 -0
- data/apps/messenger/lib/backends/skebby.rb +106 -0
- data/apps/messenger/messenger.rb +5 -3
- data/apps/messenger/models/email.rb +1 -1
- data/apps/worker/lib/runner.rb +5 -1
- data/lib/spiderfw/controller/controller.rb +5 -1
- data/lib/spiderfw/controller/mixins/http_mixin.rb +6 -1
- data/lib/spiderfw/model/condition.rb +4 -4
- data/lib/spiderfw/model/mappers/hash_mapper.rb +1 -1
- data/lib/spiderfw/model/storage/db/adapters/mysql.rb +7 -3
- data/lib/spiderfw/model/storage/db/adapters/oracle.rb +4 -0
- data/lib/spiderfw/model/storage/db/db_storage.rb +4 -0
- data/lib/spiderfw/site.rb +5 -0
- metadata +29 -134
@@ -5,8 +5,8 @@ module Spider; module Components
|
|
5
5
|
is_attr_accessor :actions
|
6
6
|
is_attribute :cancel_param
|
7
7
|
is_attribute :ok_param
|
8
|
-
is_attribute :cancel_text, :default =>
|
9
|
-
is_attribute :ok_text, :default =>
|
8
|
+
is_attribute :cancel_text, :default => Proc.new{ _('Cancel') }
|
9
|
+
is_attribute :ok_text, :default => Proc.new{ _('Ok') }
|
10
10
|
|
11
11
|
|
12
12
|
def prepare
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'apps/messenger/lib/sms_backend'
|
2
|
+
require 'apps/messenger/lib/backends/skebby'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
|
8
|
+
module Spider; module Messenger; module Backends; module SMS
|
9
|
+
|
10
|
+
module Skebby
|
11
|
+
include Messenger::SMSBackend
|
12
|
+
|
13
|
+
|
14
|
+
def self.send_message(msg)
|
15
|
+
Spider.logger.debug("**Sending SMS with skebby**")
|
16
|
+
username = Spider.conf.get('messenger.skebby.username')
|
17
|
+
password = Spider.conf.get('messenger.skebby.password')
|
18
|
+
from = Spider.conf.get('messenger.skebby.from')
|
19
|
+
to = []
|
20
|
+
to << msg.to.gsub("+","");
|
21
|
+
text = msg.text
|
22
|
+
gw = Spider::Messenger::Skebby::SkebbyGatewaySendSMS.new(username, password)
|
23
|
+
|
24
|
+
#controllo il credito
|
25
|
+
credito_presente = gw.getCredit()
|
26
|
+
if credito_presente
|
27
|
+
|
28
|
+
#Invio SMS Basic
|
29
|
+
#result = gw.sendSMS('send_sms_basic', 'Hi Mike, how are you? By John', recipients )
|
30
|
+
|
31
|
+
#Invio SMS Classic con mittente personalizzato di tipo numerico
|
32
|
+
#result = gw.sendSMS('send_sms_classic', 'Hi Mike, how are you', recipients, { :senderNumber => '393471234567' } )
|
33
|
+
|
34
|
+
#Invio SMS Classic con notifica(report) con mittente personalizzato di tipo alfanumerico - Invio SMS Classic Plus
|
35
|
+
#result = gw.sendSMS('send_sms_classic_report', 'Hi Mike, how are you', recipients, { :senderString => 'Jhon' } )
|
36
|
+
|
37
|
+
#Invio SMS Classic con notifica(report) con mittente personalizzato di tipo numerico - Invio SMS Classic Plus
|
38
|
+
#result = gw.sendSMS('send_sms_classic_report', 'Hi Mike, how are you', recipients, { :senderNumber => '393471234567' } )
|
39
|
+
|
40
|
+
#Invio SMS Classic con mittente personalizzato di tipo alfanumerico
|
41
|
+
result = gw.sendSMS('send_sms_classic', text, to, { :senderString => from, :charset => 'UTF-8' } )
|
42
|
+
if result
|
43
|
+
gw.printResponse
|
44
|
+
else
|
45
|
+
raise "Errore nell'invio degli sms."
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise "Il credito e insufficiente per mandare sms."
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
end; end; end; end
|
@@ -45,4 +45,10 @@ module Spider
|
|
45
45
|
:type => String
|
46
46
|
config_option 'messenger.mobyt.from', _("From parameter for the Mobyt service"),
|
47
47
|
:type => String
|
48
|
+
config_option 'messenger.skebby.username', _("Username for the Skebby service"),
|
49
|
+
:type => String
|
50
|
+
config_option 'messenger.skebby.password', _("Password for the Skebby service"),
|
51
|
+
:type => String
|
52
|
+
config_option 'messenger.skebby.from', _("From parameter for the Skebby service"),
|
53
|
+
:type => String
|
48
54
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'net/http'
|
3
|
+
require 'iconv'
|
4
|
+
|
5
|
+
module Spider::Messenger
|
6
|
+
|
7
|
+
module Skebby
|
8
|
+
|
9
|
+
class SkebbyGatewaySendSMS
|
10
|
+
|
11
|
+
def initialize(username = '', password = '')
|
12
|
+
@url = 'http://gateway.skebby.it/api/send/smseasy/advanced/http.php'
|
13
|
+
|
14
|
+
@parameters = {
|
15
|
+
'username' => username,
|
16
|
+
'password' => password,
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def sendSMS(method, text, recipients, options = {})
|
21
|
+
unless recipients.kind_of?(Array)
|
22
|
+
raise("recipients must be an array")
|
23
|
+
end
|
24
|
+
|
25
|
+
@parameters['method'] = method
|
26
|
+
@parameters['text'] = text
|
27
|
+
|
28
|
+
@parameters["recipients[]"] = recipients
|
29
|
+
|
30
|
+
unless options[:senderNumber].nil?
|
31
|
+
@parameters['sender_number'] = options[:senderNumber]
|
32
|
+
end
|
33
|
+
|
34
|
+
unless options[:senderString].nil?
|
35
|
+
@parameters['sender_string'] = options[:senderString]
|
36
|
+
end
|
37
|
+
|
38
|
+
unless options[:charset].nil?
|
39
|
+
@parameters['charset'] = options[:charset]
|
40
|
+
end
|
41
|
+
|
42
|
+
#@parameters.each {|key, value| puts "#{key} is #{value}" }
|
43
|
+
|
44
|
+
@response = Net::HTTP.post_form(URI(@url), @parameters)
|
45
|
+
if @response.message == "OK"
|
46
|
+
true
|
47
|
+
else
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def getCredit()
|
54
|
+
|
55
|
+
@parameters['method'] = 'get_credit'
|
56
|
+
|
57
|
+
@response = Net::HTTP.post_form(URI(@url), @parameters)
|
58
|
+
if @response.message == "OK"
|
59
|
+
true
|
60
|
+
else
|
61
|
+
false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def getResponse
|
66
|
+
result = {}
|
67
|
+
@response.body.split('&').each do |res|
|
68
|
+
if res != ''
|
69
|
+
temp = res.split('=')
|
70
|
+
if temp.size > 1
|
71
|
+
result[temp[0]] = temp[1]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
return result
|
76
|
+
end
|
77
|
+
|
78
|
+
def printResponse
|
79
|
+
result = self.getResponse
|
80
|
+
if result.has_key?('status') and result['status'] == 'success'
|
81
|
+
Spider.logger.debug "Sms mandato con successo a #{@parameters['recipients[]']}"
|
82
|
+
# result.each do |key,value|
|
83
|
+
# Spider.logger.debug "\t#{key} => #{CGI::unescape(value)}"
|
84
|
+
# end
|
85
|
+
true
|
86
|
+
else
|
87
|
+
# ------------------------------------------------------------------
|
88
|
+
# Controlla la documentazione completa all'indirizzo http:#www.skebby.it/business/index/send-docs/
|
89
|
+
# ------------------------------------------------------------------
|
90
|
+
# Per i possibili errori si veda http:#www.skebby.it/business/index/send-docs/#errorCodesSection
|
91
|
+
# ATTENZIONE: in caso di errore Non si deve riprovare l'invio, trattandosi di errori bloccanti
|
92
|
+
# ------------------------------------------------------------------
|
93
|
+
Spider.logger.debug "Error, trace is:"
|
94
|
+
result.each do |key,value|
|
95
|
+
Spider.logger.debug "\t#{key} => #{CGI::unescape(value)}"
|
96
|
+
end
|
97
|
+
false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/apps/messenger/messenger.rb
CHANGED
@@ -59,7 +59,9 @@ module Spider
|
|
59
59
|
return false if mutex.locked?
|
60
60
|
model = Spider::Messenger.const_get(self.queues[queue][:model])
|
61
61
|
lock_file = "#{self.lock_file}_#{queue}"
|
62
|
-
now = DateTime.now
|
62
|
+
#now = DateTime.now
|
63
|
+
#aggiungo un minuto al now per mandare message tra un minuto e non andare nel passato se sta finendo il minuto
|
64
|
+
now =(DateTime.now+((1.0/24)/60))
|
63
65
|
mutex.synchronize do
|
64
66
|
FileUtils.touch(lock_file)
|
65
67
|
File.open(lock_file, 'r'){ |f| return false unless f.flock File::LOCK_EX | File::LOCK_NB }
|
@@ -127,7 +129,7 @@ module Spider
|
|
127
129
|
msg = Email.new(
|
128
130
|
:from => from, :to => to, :headers => headers, :body => body
|
129
131
|
)
|
130
|
-
msg.next_try = params[:send_from] || DateTime.now
|
132
|
+
msg.next_try = params[:send_from] || (DateTime.now+((1.0/24)/60))
|
131
133
|
msg.save
|
132
134
|
return msg
|
133
135
|
end
|
@@ -136,7 +138,7 @@ module Spider
|
|
136
138
|
msg = SMS.new(
|
137
139
|
:to => to, :text => text, :sender_name => sender_name
|
138
140
|
)
|
139
|
-
msg.next_try = params[:send_from] || DateTime.now
|
141
|
+
msg.next_try = params[:send_from] || (DateTime.now+((1.0/24)/60))
|
140
142
|
msg.save
|
141
143
|
return msg
|
142
144
|
end
|
@@ -8,7 +8,7 @@ module Spider; module Messenger
|
|
8
8
|
element :to, String, :label => _("To")
|
9
9
|
element :headers, Text, :label => _("Headers")
|
10
10
|
element :subject, String, :label => _("Subject"), :computed_from => [:headers]
|
11
|
-
element :body, Text, :label => _("Body")
|
11
|
+
element :body, Text, :label => _("Body"), :length => 100000000 #mette un campo longtext
|
12
12
|
|
13
13
|
queue :email
|
14
14
|
|
data/apps/worker/lib/runner.rb
CHANGED
@@ -6,7 +6,11 @@ module Spider; module Worker
|
|
6
6
|
class Runner
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
|
9
|
+
if Gem.loaded_specs['rufus-scheduler'].version.to_s < "3.0.0"
|
10
|
+
@scheduler = Rufus::Scheduler.start_new
|
11
|
+
else
|
12
|
+
@scheduler = Rufus::Scheduler.new
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def stop
|
@@ -251,7 +251,11 @@ module Spider
|
|
251
251
|
@is_target
|
252
252
|
end
|
253
253
|
|
254
|
-
|
254
|
+
# If the site supports SSL, returns the #https_url; otherwise, the #http_url
|
255
|
+
def self.http_s_url(action=nil)
|
256
|
+
Spider.site.http_s_url + route_path(action)
|
257
|
+
end
|
258
|
+
|
255
259
|
# The main controller's execution method. The Controller will dispatch
|
256
260
|
# to another controller if a route is set; otherwise, it will call the
|
257
261
|
# method that should be executed according to action.
|
@@ -52,7 +52,12 @@ module Spider; module ControllerMixins
|
|
52
52
|
# @return [String] the request_path prefixed with http:// and the current host.
|
53
53
|
def request_url
|
54
54
|
return request_path unless @request.env['HTTP_HOST']
|
55
|
-
'http://'+@request.env['HTTP_HOST']+request_path
|
55
|
+
#'http://'+@request.env['HTTP_HOST']+request_path vecchia versione con problemi con https
|
56
|
+
if @request.env["HTTPS"] == "on"
|
57
|
+
u = "https://#{@request.env['HTTP_HOST']}#{request_path}"
|
58
|
+
else
|
59
|
+
u = "http://#{@request.env['HTTP_HOST']}#{request_path}"
|
60
|
+
end
|
56
61
|
end
|
57
62
|
|
58
63
|
# @return [String] the request_url with query params, if any
|
@@ -48,7 +48,7 @@ module Spider; module Model
|
|
48
48
|
return c
|
49
49
|
end
|
50
50
|
|
51
|
-
@comparison_operators = %w{= > < >= <= <> like}
|
51
|
+
@comparison_operators = %w{= > < >= <= <> like ilike nlike}
|
52
52
|
@comparison_operators_regexp = @comparison_operators.inject('') do |str, op|
|
53
53
|
str += '|' unless str.empty?
|
54
54
|
str += Regexp.quote(op)
|
@@ -230,7 +230,6 @@ module Spider; module Model
|
|
230
230
|
unless field.is_a?(Spider::QueryFuncs::Function)
|
231
231
|
field = field.to_s
|
232
232
|
parts = field.split('.', 2)
|
233
|
-
debugger if parts[0].blank?
|
234
233
|
parts[0] = parts[0].to_sym
|
235
234
|
field = field.to_sym unless parts[1]
|
236
235
|
end
|
@@ -540,11 +539,12 @@ module Spider; module Model
|
|
540
539
|
@condition_context = condition_context
|
541
540
|
end
|
542
541
|
|
543
|
-
[:==, :<, :>, :<=, :>=, :like, :ilike, :not].each do |op|
|
542
|
+
[:==, :<, :>, :<=, :>=, :like, :ilike, :nlike, :not].each do |op|
|
544
543
|
define_method(op) do |val|
|
545
544
|
replace = {
|
546
545
|
:== => '=',
|
547
|
-
:not => '<>'
|
546
|
+
:not => '<>',
|
547
|
+
:nlike => 'not like'
|
548
548
|
}
|
549
549
|
if replace[op]
|
550
550
|
op = replace[op]
|
@@ -495,7 +495,9 @@ module Spider; module Model; module Storage; module Db
|
|
495
495
|
when 'String'
|
496
496
|
'VARCHAR'
|
497
497
|
when 'Spider::DataTypes::Text'
|
498
|
-
'TEXT'
|
498
|
+
return 'TEXT' if (attributes[:length].blank? || (!attributes[:length].blank? && attributes[:length] < 65536))
|
499
|
+
return 'MEDIUMTEXT' if !attributes[:length].blank? && attributes[:length] >= 65536 && attributes[:length] < 16777216
|
500
|
+
return 'LONGTEXT' if !attributes[:length].blank? && attributes[:length] >= 16777216
|
499
501
|
when 'Fixnum'
|
500
502
|
'INT'
|
501
503
|
when 'Float'
|
@@ -522,6 +524,8 @@ module Spider; module Model; module Storage; module Db
|
|
522
524
|
db_attributes[:length] = attributes[:length] || 255
|
523
525
|
when 'Fixnum'
|
524
526
|
db_attributes[:length] = 11
|
527
|
+
when 'Spider::DataTypes::Text'
|
528
|
+
db_attributes[:length] = nil
|
525
529
|
end
|
526
530
|
db_attributes[:autoincrement] = false if attributes[:autoincrement] && !attributes[:primary_key]
|
527
531
|
return db_attributes
|
@@ -554,8 +558,8 @@ module Spider; module Model; module Storage; module Db
|
|
554
558
|
end
|
555
559
|
|
556
560
|
def schema_field_varchar_equal?(current, field)
|
557
|
-
#
|
558
|
-
|
561
|
+
# modifica fatta per introduzione LONGTEXT
|
562
|
+
current[:type] == field[:type] && current[:length] == field[:attributes][:length]
|
559
563
|
end
|
560
564
|
|
561
565
|
|
@@ -214,6 +214,10 @@ module Spider; module Model; module Storage; module Db
|
|
214
214
|
comp = 'like'
|
215
215
|
key = "UPPER(#{key})"
|
216
216
|
end
|
217
|
+
if (comp.to_s.downcase == 'nlike')
|
218
|
+
comp = 'not like'
|
219
|
+
key = "UPPER(#{key})"
|
220
|
+
end
|
217
221
|
if (value.nil?)
|
218
222
|
comp = comp == '=' ? "IS" : "IS NOT"
|
219
223
|
sql = "#{key} #{comp} NULL"
|
@@ -363,6 +363,10 @@ module Spider; module Model; module Storage; module Db
|
|
363
363
|
comp = 'like'
|
364
364
|
key = "UPPER(#{key})"
|
365
365
|
end
|
366
|
+
if (comp.to_s.downcase == 'nlike')
|
367
|
+
comp = 'not like'
|
368
|
+
key = "UPPER(#{key})"
|
369
|
+
end
|
366
370
|
if (value.nil?)
|
367
371
|
comp = comp == '=' ? "IS" : "IS NOT"
|
368
372
|
sql = "#{key} #{comp} NULL"
|