hotspotlogin 1.2.2 → 1.3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +41 -0
- data/README.rdoc +11 -4
- data/i18n/en.yml +31 -0
- data/i18n/it.yml +30 -0
- data/lib/hotspotlogin/app.rb +40 -25
- data/lib/hotspotlogin/constants.rb +1 -1
- data/lib/hotspotlogin/extensions/string.rb +12 -3
- data/public/hotspotlogin/css/default.css +55 -21
- data/views/_login_form.erb +13 -6
- data/views/hotspotlogin.erb +22 -16
- data/{public/hotspotlogin/js/UserStatus.js → views/js/UserStatus.js.erb} +77 -44
- data/views/layout.erb +3 -1
- metadata +37 -7
data/Changelog
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
* 1.3.0 (2011-09-29)
|
2
|
+
* Italian and English localization based on R18n
|
3
|
+
* some mobile-friendliness (without special layouts or device detection)
|
4
|
+
* improved JS code for user stats
|
5
|
+
|
6
|
+
* 1.2.2 (2011-08-08)
|
7
|
+
* Fix logo link and links style
|
8
|
+
|
9
|
+
* 1.2.1 (2011-08-08)
|
10
|
+
* Fix command line options
|
11
|
+
|
12
|
+
* 1.2.0 (2011-08-08)
|
13
|
+
* --logo-link
|
14
|
+
* --my-url ("My Account" link w/ dynamic replacement of the actual username)
|
15
|
+
|
16
|
+
* 1.1.0 (2011-08-03)
|
17
|
+
* --signup-url
|
18
|
+
|
19
|
+
* 1.0.2 (2010-12-08)
|
20
|
+
* Display Reply-Message properly
|
21
|
+
* fix serious encoding issues
|
22
|
+
* use Rack instead of ERB utils for escaping
|
23
|
+
|
24
|
+
* 1.0.1 (2010-11-17)
|
25
|
+
* Urgent bugfix -- handle config['logo'] == nil (TypeError)
|
26
|
+
|
27
|
+
* 1.0.0 (2010-11-16)
|
28
|
+
* Major rewrite based on CoovaChilli JSON API (coova.org/CoovaChilli/JSON).
|
29
|
+
* tested with CoovaChilli 1.2.5, and IE7, FF3, Epiphany/WebKit
|
30
|
+
* uses JavaScript and popups, your browser must support/allow them
|
31
|
+
* periodic auto-refresh of accounting data to the end user, including
|
32
|
+
downstream and upstream network traffic
|
33
|
+
* supports Session and Idle Timeout, showing relevant info if applicable,
|
34
|
+
and refreshing info when user is disconnected
|
35
|
+
* view customization, with Your Org logo, custom text, etc.
|
36
|
+
* some legacy code still around, sorry
|
37
|
+
|
38
|
+
* 0.1.2 (2010-11-08)
|
39
|
+
* Become session leader when forking/daemonizing.
|
40
|
+
* this is to avoid trapping terminal interrupts from a parent console
|
41
|
+
process, etc.
|
data/README.rdoc
CHANGED
@@ -7,8 +7,8 @@ hotspotlogin.cgi used with ChilliSpot and compatible Network Access
|
|
7
7
|
Controllers to provide a Captive Portal environment.
|
8
8
|
|
9
9
|
This release features displaying of detailed accounting info for the end user,
|
10
|
-
and
|
11
|
-
JSON interface.
|
10
|
+
Italian and English localization (based on R18n) and is strongly based on
|
11
|
+
CoovaChilli Network Access Controller and its JSON interface.
|
12
12
|
|
13
13
|
* http://github.com/gderosa/hotspotlogin.rb
|
14
14
|
|
@@ -71,15 +71,22 @@ All this options may be put into the YAML config file specified by --conf
|
|
71
71
|
|
72
72
|
See also chilli.conf(5) manual page.
|
73
73
|
|
74
|
+
==== CoovaChilli configuration
|
75
|
+
|
76
|
+
If hotspotlogin.rb listens, say, at 192.168.100.100:4990, CoovaChilli must be
|
77
|
+
configured to redirect user to http://192.168.100.100:4990/hotspotlogin
|
78
|
+
(+uamserver+ parameter). Also +uamsecret+ must match in Chilli and hotspotlogin
|
79
|
+
configuration.
|
80
|
+
|
74
81
|
==== Unix Signals
|
75
82
|
|
76
83
|
USR1 sync/update log file (flush buffered I/O)
|
77
|
-
|
84
|
+
|
78
85
|
== LICENSE:
|
79
86
|
|
80
87
|
(The MIT License)
|
81
88
|
|
82
|
-
Copyright (c) 2010 Guido De Rosa (guido.derosa*vemarsas.it)
|
89
|
+
Copyright (c) 2010, 2011 Guido De Rosa (guido.derosa*vemarsas.it)
|
83
90
|
|
84
91
|
Permission is hereby granted, free of charge, to any person obtaining
|
85
92
|
a copy of this software and associated documentation files (the
|
data/i18n/en.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
login:
|
2
|
+
"you!": sign in
|
3
|
+
result:
|
4
|
+
success: "logged in to HotSpot"
|
5
|
+
failed: "HotSpot login failed"
|
6
|
+
logoff: "logged out from HotSpot"
|
7
|
+
already: "already logged in to HotSpot"
|
8
|
+
notyet: "logged out from HotSpot"
|
9
|
+
logging_into: "logging into HotSpot"
|
10
|
+
none: "what do you want here?"
|
11
|
+
signup:
|
12
|
+
"you!": sign up
|
13
|
+
account:
|
14
|
+
dont_have:
|
15
|
+
you: "don”t have an account"
|
16
|
+
username:
|
17
|
+
short: login
|
18
|
+
long: username
|
19
|
+
logout: logout
|
20
|
+
refresh: refresh
|
21
|
+
my: my account
|
22
|
+
status:
|
23
|
+
username: username
|
24
|
+
client_state: client state
|
25
|
+
session_time: session time
|
26
|
+
session_time_left: session time left
|
27
|
+
idle_time_timeout: idle time/timeout
|
28
|
+
download_traffic: download
|
29
|
+
upload_traffic: upload
|
30
|
+
auto_updated_every: auto updated every
|
31
|
+
|
data/i18n/it.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
login:
|
2
|
+
"you!": accedi
|
3
|
+
result:
|
4
|
+
success: "accesso effettuato"
|
5
|
+
failed: "autenticazione fallita"
|
6
|
+
logoff: "disconnesso dall’HotSpot"
|
7
|
+
already: "già connesso all’HotSpot"
|
8
|
+
notyet: "accedi all’HotSpot"
|
9
|
+
logging_into: "accesso in corso"
|
10
|
+
none: "uhm..."
|
11
|
+
signup:
|
12
|
+
"you!": registrati
|
13
|
+
account:
|
14
|
+
dont_have:
|
15
|
+
you: non hai un account
|
16
|
+
username:
|
17
|
+
short: utente
|
18
|
+
long: nome utente
|
19
|
+
logout: esci
|
20
|
+
refresh: aggiorna
|
21
|
+
my: gestisci account
|
22
|
+
status:
|
23
|
+
username: utente
|
24
|
+
client_state: stato
|
25
|
+
session_time: durata sessione
|
26
|
+
session_time_left: tempo rimanente
|
27
|
+
idle_time_timeout: "inattività/(max)"
|
28
|
+
download_traffic: download
|
29
|
+
upload_traffic: upload
|
30
|
+
auto_updated_every: "aggiornato automaticam. ogni"
|
data/lib/hotspotlogin/app.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'facets/string'
|
2
3
|
require 'sinatra/base'
|
4
|
+
require 'sinatra/r18n'
|
3
5
|
require 'erb'
|
4
6
|
|
5
7
|
require 'hotspotlogin/constants'
|
@@ -16,6 +18,8 @@ module HotSpotLogin
|
|
16
18
|
set :port, HotSpotLogin.config['port']
|
17
19
|
set :logging, HotSpotLogin.config['log-http']
|
18
20
|
|
21
|
+
register Sinatra::R18n
|
22
|
+
|
19
23
|
#set :run, false
|
20
24
|
|
21
25
|
result, titel, headline, bodytext = '', '', '', ''
|
@@ -64,7 +68,7 @@ module HotSpotLogin
|
|
64
68
|
# setup of "conditional" HTTPS reverse proxies
|
65
69
|
|
66
70
|
get '/' do
|
67
|
-
redirect
|
71
|
+
redirect "/hotspotlogin?#{request.query_string}"
|
68
72
|
end
|
69
73
|
|
70
74
|
get '/hotspotlogin/favicon.ico' do
|
@@ -92,6 +96,11 @@ module HotSpotLogin
|
|
92
96
|
not_found
|
93
97
|
end
|
94
98
|
end
|
99
|
+
|
100
|
+
get '/hotspotlogin/js/UserStatus.js' do
|
101
|
+
content_type 'text/javascript'
|
102
|
+
erb :"js/UserStatus.js", :layout => false # localized strings...
|
103
|
+
end
|
95
104
|
|
96
105
|
get '/hotspotlogin/?' do
|
97
106
|
if HotSpotLogin.config['uamsecret'] and
|
@@ -103,7 +112,9 @@ module HotSpotLogin
|
|
103
112
|
userpassword = HotSpotLogin.config['userpassword']
|
104
113
|
|
105
114
|
# attempt to login
|
106
|
-
if params['login'] == 'login'
|
115
|
+
if params['login'] # == 'login'
|
116
|
+
# So you can put whichever text you want in submit button
|
117
|
+
# as in <input type="submit" name="login" value="MyText"...
|
107
118
|
hexchal = Array[params['chal']].pack('H32')
|
108
119
|
if uamsecret
|
109
120
|
newchal =
|
@@ -116,8 +127,8 @@ module HotSpotLogin
|
|
116
127
|
# bitwise XOR between (binary) Strings (operator ^)
|
117
128
|
# implemented in extensions/
|
118
129
|
pappassword = (newpwd ^ newchal).unpack('H32').join
|
119
|
-
titel =
|
120
|
-
|
130
|
+
titel = headline = t.login.result.logging_into.uppercase + '...'
|
131
|
+
# 'Logging in to HotSpot'
|
121
132
|
|
122
133
|
#if uamsecret and userpassword
|
123
134
|
if userpassword # PAP
|
@@ -133,41 +144,45 @@ module HotSpotLogin
|
|
133
144
|
end
|
134
145
|
elsif params['res'] == 'success'
|
135
146
|
result = Result::SUCCESS
|
136
|
-
titel =
|
137
|
-
|
138
|
-
bodytext = 'Welcome'
|
147
|
+
titel = headline = t.login.result.success.uppercase
|
148
|
+
# 'Logged in to HotSpot'
|
149
|
+
bodytext = 'Welcome' # used?
|
139
150
|
elsif params['res'] == 'failed'
|
140
151
|
result = Result::FAILED
|
141
|
-
titel =
|
142
|
-
|
152
|
+
titel = headline = t.login.result.failed.uppercase
|
153
|
+
# 'HotSpot Login Failed'
|
143
154
|
elsif params['res'] == 'logoff'
|
144
155
|
result = Result::LOGOFF
|
145
|
-
titel =
|
146
|
-
|
156
|
+
titel = headline = t.login.result.logoff.uppercase
|
157
|
+
# 'Logged out from HotSpot'
|
147
158
|
elsif params['res'] == 'already'
|
148
159
|
result = Result::ALREADY
|
149
|
-
titel =
|
150
|
-
|
160
|
+
titel = headline = t.login.result.already.uppercase
|
161
|
+
# 'Already logged in to HotSpot'
|
151
162
|
elsif params['res'] == 'notyet'
|
152
163
|
result = Result::NOTYET
|
153
|
-
titel =
|
154
|
-
|
164
|
+
titel = headline = t.login.result.notyet.uppercase
|
165
|
+
# 'Logged out from HotSpot'
|
155
166
|
elsif params['res'] == 'popup1'
|
156
167
|
result = Result::PopUp::LOGGING_IN
|
157
|
-
titel =
|
158
|
-
|
168
|
+
titel = t.login.result.logging_into.uppercase + '...'
|
169
|
+
# 'Logging into HotSpot'
|
170
|
+
headline = t.login.result.success.uppercase
|
171
|
+
# 'Logged in to HotSpot'
|
159
172
|
elsif params['res'] == 'popup2'
|
160
173
|
result = Result::PopUp::LOGGED_IN
|
161
|
-
titel =
|
162
|
-
|
174
|
+
titel = headline = t.login.result.success.uppercase
|
175
|
+
# 'Logged in to HotSpot'
|
163
176
|
elsif params['res'] == 'popup3'
|
164
|
-
result= Result::PopUp::LOGGED_OUT
|
165
|
-
titel =
|
166
|
-
|
167
|
-
|
177
|
+
result = Result::PopUp::LOGGED_OUT
|
178
|
+
titel = headline = t.login.result.logoff.uppercase
|
179
|
+
# 'Logged out from HotSpot'
|
180
|
+
|
181
|
+
elsif params['res'] == '' or !params['res'] # Not a form request nor a redirect..
|
168
182
|
result = Result::NONE
|
169
|
-
titel = 'What do you want here?'
|
170
|
-
headline =
|
183
|
+
titel = t.login.result.none.uppercase # 'What do you want here?'
|
184
|
+
headline = t.login.result.failed.uppercase
|
185
|
+
# 'HotSpot Login Failed'
|
171
186
|
end
|
172
187
|
|
173
188
|
logoext = nil
|
@@ -1,5 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'facets/string'
|
2
|
+
|
3
|
+
class String
|
4
|
+
|
5
|
+
# Escape single quote for use in generated JavaScript
|
6
|
+
def escape_js
|
7
|
+
gsub("'", "\\\\'")
|
8
|
+
end
|
9
|
+
|
10
|
+
=begin # use Facets implementation instead
|
11
|
+
# Bitwise XOR, behaves like in Perl or PHP
|
3
12
|
def ^(other)
|
4
13
|
# treat as a raw/binary sequence of bytes
|
5
14
|
s1 = self.force_encoding 'ASCII-8BIT'
|
@@ -13,6 +22,6 @@ class String
|
|
13
22
|
end
|
14
23
|
return bytes_result.map{|b| b.chr}.join
|
15
24
|
end
|
25
|
+
=end
|
16
26
|
end
|
17
27
|
|
18
|
-
|
@@ -1,27 +1,30 @@
|
|
1
1
|
body {
|
2
|
-
font-
|
2
|
+
font-family: sans-serif;
|
3
|
+
margin: 1em auto;
|
4
|
+
padding: 0 0.75em;
|
3
5
|
}
|
4
6
|
h1, h2 {
|
5
7
|
text-align: center;
|
6
|
-
font-family: sans-serif;
|
7
8
|
}
|
8
9
|
h1 {
|
9
|
-
font-size: 160%;
|
10
10
|
margin: 0.1ex 0;
|
11
11
|
}
|
12
|
-
|
13
|
-
font-
|
12
|
+
h1#custom-headline {
|
13
|
+
font-style: italic;
|
14
|
+
font-weight: normal;
|
15
|
+
}
|
16
|
+
h2#headline {
|
17
|
+
font-size: 110%;
|
14
18
|
margin-top: 0.1ex;
|
15
|
-
margin-bottom: 0.
|
19
|
+
margin-bottom: 0.1em;
|
16
20
|
font-style: italic;
|
17
21
|
}
|
18
22
|
#powered-by {
|
19
23
|
text-align: right;
|
20
24
|
font-style: italic;
|
21
|
-
margin-right:
|
25
|
+
margin-right: 2em;
|
22
26
|
margin-bottom: 1ex;
|
23
|
-
font-
|
24
|
-
font-size:smaller;
|
27
|
+
font-size:70%;
|
25
28
|
}
|
26
29
|
#logo-container {
|
27
30
|
text-align: center;
|
@@ -43,35 +46,41 @@ h2 {
|
|
43
46
|
}
|
44
47
|
#logInLogOut-container {
|
45
48
|
padding: 0;
|
46
|
-
margin: 0.5em 0;
|
49
|
+
margin: 0 0 0.5em 0;
|
47
50
|
text-align: center;
|
51
|
+
line-height: 1.6em;
|
48
52
|
}
|
49
53
|
#logInLogOut-container a {
|
50
|
-
margin: 0 0.
|
54
|
+
margin: 0 0.5ex;
|
55
|
+
white-space: nowrap;
|
51
56
|
}
|
52
57
|
#status-container {
|
53
58
|
text-align: center;
|
54
|
-
margin: 0 0 1em 0;
|
55
59
|
}
|
56
60
|
#status-table {
|
57
|
-
|
58
|
-
|
59
|
-
padding: 0.5ex;
|
61
|
+
font-size: 90%;
|
62
|
+
margin: 0.5em auto;
|
60
63
|
}
|
61
64
|
#status-table th {
|
62
65
|
text-align: left;
|
66
|
+
text-transform: capitalize;
|
63
67
|
}
|
64
68
|
#status-table td {
|
65
69
|
text-align: right;
|
66
70
|
}
|
71
|
+
#status-table th, #status-table td {
|
72
|
+
background: #eef;
|
73
|
+
}
|
67
74
|
#status-table th.optinfo {
|
68
|
-
font-size:
|
75
|
+
font-size: 90%;
|
69
76
|
font-style: italic;
|
70
77
|
}
|
71
78
|
#submit-container {
|
79
|
+
text-align: left;
|
72
80
|
}
|
73
81
|
#submit-container button, #submit-container input[type="submit"] {
|
74
|
-
width: 5em;
|
82
|
+
width: 4.5em;
|
83
|
+
margin-top: 0.3em;
|
75
84
|
}
|
76
85
|
#custom-text {
|
77
86
|
font-size: 94%;
|
@@ -79,8 +88,33 @@ h2 {
|
|
79
88
|
margin-bottom: 1.5em;
|
80
89
|
}
|
81
90
|
#custom-footer {
|
82
|
-
margin-top:
|
83
|
-
font-size:
|
84
|
-
|
85
|
-
|
91
|
+
margin-top: 2.6em;
|
92
|
+
font-size: 90%;
|
93
|
+
}
|
94
|
+
|
95
|
+
/* button, input[type="submit"] {
|
96
|
+
background: white;
|
97
|
+
} */
|
98
|
+
|
99
|
+
#signup-container{
|
100
|
+
font-style:italic;
|
101
|
+
font-weight: normal;
|
102
|
+
margin-top:0.2em;
|
103
|
+
}
|
104
|
+
|
105
|
+
a#signup {
|
106
|
+
border: none;
|
107
|
+
color: white;
|
108
|
+
background: #77f;
|
109
|
+
padding: 0 0.2em 0.1em 0.2em;
|
110
|
+
font-style:normal;
|
111
|
+
}
|
112
|
+
|
113
|
+
a#signup {
|
114
|
+
text-decoration: none;
|
115
|
+
margin-left: 0.2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
a img {
|
119
|
+
border: none;
|
86
120
|
}
|
data/views/_login_form.erb
CHANGED
@@ -6,16 +6,23 @@
|
|
6
6
|
<table>
|
7
7
|
<tbody>
|
8
8
|
<tr>
|
9
|
-
<th scope="row"
|
10
|
-
<td><input type="text" name="UserName" size="
|
9
|
+
<th scope="row"><%= t.username.short.capitalize %>:</td>
|
10
|
+
<td><input type="text" name="UserName" size="16" maxlength="255"></td>
|
11
11
|
</tr>
|
12
12
|
<tr>
|
13
13
|
<th scope="row">Password:</td>
|
14
|
-
<td><input type="password" name="Password" size="
|
14
|
+
<td><input type="password" name="Password" size="16" maxlength="255"></td>
|
15
|
+
</tr>
|
16
|
+
<tr> <!-- yeah, it's horrible -->
|
17
|
+
<td colspan="2" id="submit-container">
|
18
|
+
<input type="submit" name="login" value="<%= t.login.you!.capitalize %>">
|
19
|
+
</td>
|
15
20
|
</tr>
|
16
21
|
</tbody>
|
17
22
|
</table>
|
18
|
-
<div id="submit-container">
|
19
|
-
<input type="submit" name="login" value="login"><% if signup_url =~ /\S/ %> OR <a href="<%= signup_url %>" target="_blank">Signup!</a><% end %>
|
20
|
-
</div>
|
21
23
|
</form>
|
24
|
+
<% if signup_url =~ /\S/ %><span id="signup-container">
|
25
|
+
<%= t.account.dont_have.you.capitalize %>?
|
26
|
+
<a id="signup" href="<%= signup_url %>" target="_blank"><%= t.signup.you!.capitalize %>!</a>
|
27
|
+
</span><% end %>
|
28
|
+
|
data/views/hotspotlogin.erb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
<%
|
2
|
+
require 'facets/string'
|
3
|
+
require 'sinatra/r18n'
|
2
4
|
require 'hotspotlogin/app/helpers'
|
3
5
|
%>
|
4
6
|
|
@@ -8,17 +10,18 @@
|
|
8
10
|
-->
|
9
11
|
|
10
12
|
<% if custom_headline %>
|
11
|
-
<h1><%= custom_headline %></h1>
|
13
|
+
<h1 id="custom-headline"><%= custom_headline %></h1>
|
12
14
|
<% end %>
|
13
15
|
<% if logoext %>
|
14
16
|
<div id="logo-container">
|
15
|
-
<% if logo_link =~ /\S/ %><a href="<%= logo_link %>" target="_blank"><% end %>
|
17
|
+
<% if logo_link =~ /\S/ %><a class="img" href="<%= logo_link %>" target="_blank"><% end %>
|
16
18
|
<img src="/hotspotlogin/logo<%= logoext %>"/>
|
17
19
|
<% if logo_link =~ /\S/ %></a><% end %>
|
18
20
|
</div>
|
19
21
|
<% end %>
|
20
22
|
|
21
23
|
<h2 id="headline"><%= titel %></h2>
|
24
|
+
|
22
25
|
<div id="Reply-Message">
|
23
26
|
<% if params['reply'] %>
|
24
27
|
<%= Rack::Utils::escape_html params['reply'] %>
|
@@ -34,14 +37,14 @@
|
|
34
37
|
<div id="logInLogOut-container">
|
35
38
|
<a
|
36
39
|
id="logInLogOut"
|
37
|
-
href="http://<%= uamip %>:<%= uamport %>/logoff"
|
38
|
-
<a href="#" onClick="javascript:chilliController.refresh();"
|
40
|
+
href="http://<%= uamip %>:<%= uamport %>/logoff"><%= t.logout.titlecase %></a>
|
41
|
+
<a href="#logInLogOut-container" onClick="javascript:chilliController.refresh();"><%= t.refresh.titlecase %></a>
|
39
42
|
<a
|
40
43
|
id="myAccount"
|
41
44
|
href=""
|
42
45
|
target="_blank"
|
43
46
|
style="display:none;"
|
44
|
-
|
47
|
+
><%= t.my.titlecase %></a>
|
45
48
|
</div>
|
46
49
|
<% elsif [2, 5, 3, 13].include? result %>
|
47
50
|
<div id="form-container">
|
@@ -66,36 +69,39 @@
|
|
66
69
|
<div id="status-container">
|
67
70
|
<table id="status-table">
|
68
71
|
<tbody>
|
72
|
+
<%
|
73
|
+
# Yeah, do not use Ruby String methods, instead use CSS text-transform...
|
74
|
+
%>
|
69
75
|
<tr id="userName:row">
|
70
|
-
<th scope="row"
|
76
|
+
<th scope="row"><%= t.status.username %></th>
|
71
77
|
<td id="userName"></td>
|
72
78
|
<tr id="clientState:row">
|
73
|
-
<th scope="row"
|
79
|
+
<th scope="row"><%= t.status.client_state %></th>
|
74
80
|
<td id="clientState"></td>
|
75
81
|
</tr>
|
76
82
|
<tr id="sessionTime:row">
|
77
|
-
<th scope="row"
|
83
|
+
<th scope="row"><%= t.status.session_time %></th>
|
78
84
|
<td id="sessionTime"></td>
|
79
85
|
</tr>
|
80
86
|
<tr id="sessionTimeLeft:row">
|
81
|
-
<th scope="row"
|
87
|
+
<th scope="row"><%= t.status.session_time_left %></th>
|
82
88
|
<td id="sessionTimeLeft"></th>
|
83
89
|
</tr>
|
84
|
-
|
85
|
-
|
90
|
+
<!-- nobody really cares... -->
|
91
|
+
<tr id="idleTimeout:row" style="display:none;">
|
92
|
+
<th scope="row"><%= t.status.idle_time_timeout %></th>
|
86
93
|
<td id="idleTimeout"></th>
|
87
94
|
</tr>
|
88
95
|
<tr id="download:row">
|
89
|
-
<th scope="row"
|
96
|
+
<th scope="row"><%= t.status.download_traffic %></th>
|
90
97
|
<td id="download"></td>
|
91
98
|
</tr>
|
92
99
|
<tr id="upload:row">
|
93
|
-
<th scope="row"
|
100
|
+
<th scope="row"><%= t.status.upload_traffic %></th>
|
94
101
|
<td id="upload"></td>
|
95
102
|
</tr>
|
96
|
-
<tr id="interval:row">
|
97
|
-
<
|
98
|
-
<td id="interval"></td>
|
103
|
+
<tr id="interval:row" style="font-size:95%">
|
104
|
+
<td style="background:transparent; text-align:right" colspan="2" class="optinfo"><span style="font-style:italic; margin-left:0.8em;"><%= t.status.auto_updated_every.uppercase %>:</span> <span style="" id="interval"></td>
|
99
105
|
</tr>
|
100
106
|
</tbody>
|
101
107
|
</table>
|
@@ -1,3 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
require 'facets/string'
|
3
|
+
require 'sinatra/r18n'
|
4
|
+
require 'hotspotlogin/extensions/string'
|
5
|
+
%>
|
1
6
|
// Requires ChilliLibrary.js
|
2
7
|
// See: http://www.coova.org/CoovaChilli/JSON
|
3
8
|
//
|
@@ -53,6 +58,21 @@ chilliController.scheduleIdleTimeoutAutorefresh = function() {
|
|
53
58
|
}
|
54
59
|
}
|
55
60
|
|
61
|
+
chilliController.formatBytesShort = function( b , zeroReturn ) {
|
62
|
+
return chilliController.formatBytes( b , zeroReturn ).
|
63
|
+
replace('Bytes', 'B' ).
|
64
|
+
replace('Kilobytes', 'KB').
|
65
|
+
replace('Megabytes', 'MB').
|
66
|
+
replace('Gigabytes', 'GB');
|
67
|
+
}
|
68
|
+
|
69
|
+
chilliController.refreshAndLogoff = function() {
|
70
|
+
chilliController.refresh();
|
71
|
+
setTimeout('chilliController.logoff()', 250); // a delay is necessary...
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
|
56
76
|
function showUserStatus(h) {
|
57
77
|
|
58
78
|
// Utility functions and objects
|
@@ -113,10 +133,10 @@ function showUserStatus(h) {
|
|
113
133
|
txt = null;
|
114
134
|
switch(clientState) {
|
115
135
|
case chilliController.stateCodes.NOT_AUTH:
|
116
|
-
txt = '
|
136
|
+
txt = '<%= t.login.result.logoff.uppercase.escape_js %>';
|
117
137
|
break;
|
118
138
|
case chilliController.stateCodes.AUTH:
|
119
|
-
txt = '
|
139
|
+
txt = '<%= t.login.result.success.uppercase.escape_js %>';
|
120
140
|
break;
|
121
141
|
}
|
122
142
|
if (txt) {
|
@@ -132,12 +152,13 @@ function showUserStatus(h) {
|
|
132
152
|
switch(clientState) {
|
133
153
|
case chilliController.stateCodes.NOT_AUTH:
|
134
154
|
e.setAttribute('href', loginURL());
|
135
|
-
e.innerHTML = '
|
155
|
+
e.innerHTML = '<%= t.login.you!.uppercase.escape_js %>';
|
136
156
|
break;
|
137
157
|
case chilliController.stateCodes.AUTH:
|
138
|
-
e.setAttribute('href', '#');
|
139
|
-
e.onclick = chilliController.logoff;
|
140
|
-
e.
|
158
|
+
e.setAttribute('href', '#headline');
|
159
|
+
// e.onclick = chilliController.logoff;
|
160
|
+
e.onclick = chilliController.refreshAndLogoff;
|
161
|
+
e.innerHTML = '<%= t.logout.uppercase.escape_js %>';
|
141
162
|
break;
|
142
163
|
}
|
143
164
|
}
|
@@ -176,6 +197,8 @@ function showUserStatus(h) {
|
|
176
197
|
var download_e = document.getElementById('download');
|
177
198
|
var upload_e = document.getElementById('upload');
|
178
199
|
var interval_e = document.getElementById('interval');
|
200
|
+
var interval_row_e = document.getElementById('interval:row');
|
201
|
+
|
179
202
|
if (userName_e) {
|
180
203
|
userName_e.innerHTML = (
|
181
204
|
chilliController.session.userName
|
@@ -186,56 +209,67 @@ function showUserStatus(h) {
|
|
186
209
|
formatStateCode(chilliController.clientState)
|
187
210
|
);
|
188
211
|
}
|
212
|
+
|
189
213
|
//if (chilliController.terminateCause) {
|
190
214
|
// document.getElementById('terminateCause').innerHTML = (
|
191
215
|
// chilliController.terminateCause
|
192
216
|
// )
|
193
217
|
//}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
)
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
218
|
+
|
219
|
+
// So at logoff session stats are preserved :)
|
220
|
+
if (chilliController.clientState == chilliController.stateCodes.AUTH) {
|
221
|
+
|
222
|
+
if (sessionTime_e) {
|
223
|
+
document.getElementById('sessionTime').innerHTML = (
|
224
|
+
chilliController.formatTime(
|
225
|
+
chilliController.accounting.sessionTime, '0')
|
226
|
+
);
|
227
|
+
}
|
228
|
+
if (sessionTimeLeft_e) {
|
229
|
+
if (chilliController.session.sessionTimeout) {
|
230
|
+
document.getElementById('sessionTimeLeft').innerHTML = (
|
231
|
+
chilliController.formatTime(chilliController.sessionTimeLeft(), 0)
|
232
|
+
);
|
233
|
+
document.getElementById('sessionTimeLeft:row').style.display = '';
|
234
|
+
} else {
|
235
|
+
document.getElementById('sessionTimeLeft').innerHTML = ''
|
236
|
+
}
|
237
|
+
}
|
238
|
+
if (chilliController.session.idleTimeout) {
|
239
|
+
document.getElementById('idleTimeout').innerHTML = (
|
240
|
+
chilliController.formatTime(chilliController.accounting.idleTime) +
|
241
|
+
' / ' +
|
242
|
+
chilliController.formatTime(chilliController.session.idleTimeout)
|
243
|
+
);
|
244
|
+
// document.getElementById('idleTimeout:row').style.display = '';
|
245
|
+
// nobody really cares...
|
246
|
+
}
|
247
|
+
var download_bytes =
|
248
|
+
chilliController.accounting.inputOctets +
|
249
|
+
Math.pow(2, 32) * chilliController.accounting.inputGigawords;
|
250
|
+
var upload_bytes =
|
251
|
+
chilliController.accounting.outputOctets +
|
252
|
+
Math.pow(2, 32) * chilliController.accounting.outputGigawords;
|
253
|
+
if (download_e) {
|
254
|
+
download_e.innerHTML = (
|
255
|
+
chilliController.formatBytesShort(download_bytes, 0)
|
256
|
+
);
|
257
|
+
}
|
258
|
+
if (upload_e) {
|
259
|
+
upload_e.innerHTML = (
|
260
|
+
chilliController.formatBytesShort(upload_bytes, 0)
|
204
261
|
);
|
205
|
-
document.getElementById('sessionTimeLeft:row').style.display = '';
|
206
|
-
} else {
|
207
|
-
document.getElementById('sessionTimeLeft').innerHTML = ''
|
208
262
|
}
|
209
263
|
}
|
210
|
-
|
211
|
-
document.getElementById('idleTimeout').innerHTML = (
|
212
|
-
chilliController.formatTime(chilliController.accounting.idleTime) +
|
213
|
-
' / ' +
|
214
|
-
chilliController.formatTime(chilliController.session.idleTimeout)
|
215
|
-
);
|
216
|
-
document.getElementById('idleTimeout:row').style.display = '';
|
217
|
-
}
|
218
|
-
var download_bytes =
|
219
|
-
chilliController.accounting.inputOctets +
|
220
|
-
Math.pow(2, 32) * chilliController.accounting.inputGigawords;
|
221
|
-
var upload_bytes =
|
222
|
-
chilliController.accounting.outputOctets +
|
223
|
-
Math.pow(2, 32) * chilliController.accounting.outputGigawords;
|
224
|
-
if (download_e) {
|
225
|
-
download_e.innerHTML = (
|
226
|
-
chilliController.formatBytes(download_bytes, 0)
|
227
|
-
);
|
228
|
-
}
|
229
|
-
if (upload_e) {
|
230
|
-
upload_e.innerHTML = (
|
231
|
-
chilliController.formatBytes(upload_bytes, 0)
|
232
|
-
);
|
233
|
-
}
|
264
|
+
|
234
265
|
if (interval_e) {
|
235
266
|
interval_e.innerHTML = (
|
236
267
|
chilliController.formatTime(chilliController.interval, 0)
|
237
268
|
);
|
238
269
|
}
|
270
|
+
if (chilliController.clientState == chilliController.stateCodes.NOT_AUTH) {
|
271
|
+
interval_row_e.style.display = 'none';
|
272
|
+
}
|
239
273
|
|
240
274
|
chilliController.scheduleSessionTimeoutAutorefresh();
|
241
275
|
chilliController.scheduleIdleTimeoutAutorefresh();
|
@@ -248,4 +282,3 @@ function showUserStatus(h) {
|
|
248
282
|
|
249
283
|
|
250
284
|
}
|
251
|
-
|
data/views/layout.erb
CHANGED
@@ -13,9 +13,11 @@
|
|
13
13
|
<meta http-equiv="Cache-control" content="no-cache">
|
14
14
|
<meta http-equiv="Pragma" content="no-cache">
|
15
15
|
|
16
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
17
|
+
|
16
18
|
<script language="JavaScript"> // legacy stuff from hotspotlogin.cgi/php
|
17
19
|
var width = 560; // popup
|
18
|
-
var height =
|
20
|
+
var height = 600; // popup
|
19
21
|
var blur = 0;
|
20
22
|
var starttime = new Date();
|
21
23
|
var startclock = starttime.getTime();
|
metadata
CHANGED
@@ -4,9 +4,10 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 1.3.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Guido De Rosa
|
@@ -14,11 +15,11 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-09-29 00:00:00 +00:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
+
name: facets
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
@@ -31,7 +32,7 @@ dependencies:
|
|
31
32
|
type: :runtime
|
32
33
|
version_requirements: *id001
|
33
34
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
35
|
+
name: sinatra
|
35
36
|
prerelease: false
|
36
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
38
|
none: false
|
@@ -43,6 +44,32 @@ dependencies:
|
|
43
44
|
version: "0"
|
44
45
|
type: :runtime
|
45
46
|
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rack
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: sinatra-r18n
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
type: :runtime
|
72
|
+
version_requirements: *id004
|
46
73
|
description: Traditionally, a PHP or Perl/CGI web page has been used to login unauthenticated users to a Network Access Controller like ChilliSpot; this hotspotlogin implementation is based on Sinatra instead, and relies heavily on the CoovaChilli JSON interface.
|
47
74
|
email: guido.derosa@vemarsas.it
|
48
75
|
executables:
|
@@ -52,10 +79,13 @@ extensions: []
|
|
52
79
|
extra_rdoc_files:
|
53
80
|
- README.rdoc
|
54
81
|
files:
|
82
|
+
- Changelog
|
55
83
|
- README.rdoc
|
56
84
|
- bin/hotspotlogin
|
57
85
|
- examples/hotspotlogin.conf.yaml
|
58
86
|
- examples/etc/lighttpd/lighttpd.conf
|
87
|
+
- i18n/en.yml
|
88
|
+
- i18n/it.yml
|
59
89
|
- lib/hotspotlogin.rb
|
60
90
|
- lib/hotspotlogin/app.rb
|
61
91
|
- lib/hotspotlogin/app/helpers.rb
|
@@ -64,7 +94,7 @@ files:
|
|
64
94
|
- lib/hotspotlogin/extensions/string.rb
|
65
95
|
- public/hotspotlogin/css/default.css
|
66
96
|
- public/hotspotlogin/js/ChilliLibrary.js
|
67
|
-
-
|
97
|
+
- views/js/UserStatus.js.erb
|
68
98
|
- views/layout.erb
|
69
99
|
- views/hotspotlogin.erb
|
70
100
|
- views/404.erb
|