author | Dan |
Wed, 26 Dec 2007 00:37:26 -0500 | |
changeset 334 | c72b545f1304 |
parent 326 | ab66d6d1f1f4 |
child 335 | 67bd3121a12e |
permissions | -rw-r--r-- |
1 | 1 |
// Some additional DHTML functions |
2 |
||
3 |
function fetch_offset(obj) { |
|
4 |
var left_offset = obj.offsetLeft; |
|
5 |
var top_offset = obj.offsetTop; |
|
6 |
while ((obj = obj.offsetParent) != null) { |
|
7 |
left_offset += obj.offsetLeft; |
|
8 |
top_offset += obj.offsetTop; |
|
9 |
} |
|
10 |
return { 'left' : left_offset, 'top' : top_offset }; |
|
11 |
} |
|
12 |
||
13 |
function fetch_dimensions(o) { |
|
14 |
var w = o.offsetWidth; |
|
15 |
var h = o.offsetHeight; |
|
16 |
return { 'w' : w, 'h' : h }; |
|
17 |
} |
|
18 |
||
19 |
function findParentForm(o) |
|
20 |
{ |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
21 |
if ( o.tagName == 'FORM' ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
22 |
return o; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
23 |
while(true) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
24 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
25 |
o = o.parentNode; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
26 |
if ( !o ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
27 |
return false; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
28 |
if ( o.tagName == 'FORM' ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
29 |
return o; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
30 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
31 |
return false; |
1 | 32 |
} |
33 |
||
34 |
function ajaxReverseDNS(o, text) |
|
35 |
{ |
|
36 |
if(text) var ipaddr = text; |
|
37 |
else var ipaddr = o.innerHTML; |
|
38 |
rDnsObj = o; |
|
39 |
rDnsBannerObj = bannerOn('Retrieving reverse DNS info...'); |
|
40 |
ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function() { |
|
41 |
if(ajax.readyState == 4) |
|
42 |
{ |
|
43 |
off = fetch_offset(rDnsObj); |
|
44 |
dim = fetch_dimensions(rDnsObj); |
|
45 |
right = off['left'] + dim['w']; |
|
46 |
top = off['top'] + dim['h']; |
|
47 |
var thediv = document.createElement('div'); |
|
48 |
thediv.className = 'info-box'; |
|
49 |
thediv.style.margin = '0'; |
|
50 |
thediv.style.position = 'absolute'; |
|
51 |
thediv.style.top = top + 'px'; |
|
52 |
thediv.style.display = 'none'; |
|
53 |
thediv.style.zIndex = getHighestZ() + 2; |
|
54 |
thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000); |
|
55 |
thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>'; |
|
56 |
var body = document.getElementsByTagName('body'); |
|
57 |
body = body[0]; |
|
58 |
bannerOff(rDnsBannerObj); |
|
59 |
body.appendChild(thediv); |
|
60 |
thediv.style.display = 'block'; |
|
61 |
left = fetch_dimensions(thediv); |
|
62 |
thediv.style.display = 'none'; |
|
63 |
left = right - left['w']; |
|
64 |
thediv.style.left = left + 'px'; |
|
65 |
thediv.style.display = 'block'; |
|
66 |
fadeInfoBoxes(); |
|
67 |
} |
|
68 |
}); |
|
69 |
} |
|
70 |
||
71 |
function bannerOn(text) |
|
72 |
{ |
|
73 |
darken(true); |
|
74 |
var thediv = document.createElement('div'); |
|
75 |
thediv.className = 'mdg-comment'; |
|
76 |
thediv.style.padding = '0'; |
|
77 |
thediv.style.marginLeft = '0'; |
|
78 |
thediv.style.position = 'absolute'; |
|
79 |
thediv.style.display = 'none'; |
|
80 |
thediv.style.padding = '4px'; |
|
81 |
thediv.style.fontSize = '14pt'; |
|
82 |
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000); |
|
83 |
thediv.innerHTML = text; |
|
84 |
||
85 |
var body = document.getElementsByTagName('body'); |
|
86 |
body = body[0]; |
|
87 |
body.appendChild(thediv); |
|
88 |
body.style.cursor = 'wait'; |
|
89 |
||
90 |
thediv.style.display = 'block'; |
|
91 |
dim = fetch_dimensions(thediv); |
|
92 |
thediv.style.display = 'none'; |
|
93 |
bdim = { 'w' : getWidth(), 'h' : getHeight() }; |
|
94 |
so = getScrollOffset(); |
|
95 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
96 |
var left = (bdim['w'] / 2) - ( dim['w'] / 2 ); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
97 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
98 |
var top = (bdim['h'] / 2); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
99 |
top = top - ( dim['h'] / 2 ); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
100 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
101 |
top = top + so; |
1 | 102 |
|
103 |
thediv.style.top = top + 'px'; |
|
104 |
thediv.style.left = left + 'px'; |
|
105 |
||
106 |
thediv.style.display = 'block'; |
|
107 |
||
108 |
return thediv.id; |
|
109 |
} |
|
110 |
||
111 |
function bannerOff(id) |
|
112 |
{ |
|
113 |
e = document.getElementById(id); |
|
114 |
if(!e) return; |
|
115 |
e.innerHTML = ''; |
|
116 |
e.style.display = 'none'; |
|
117 |
var body = document.getElementsByTagName('body'); |
|
118 |
body = body[0]; |
|
119 |
body.style.cursor = 'default'; |
|
120 |
enlighten(true); |
|
121 |
} |
|
122 |
||
123 |
function disableUnload(message) |
|
124 |
{ |
|
125 |
if(typeof message != 'string') message = 'You may want to save your changes first.'; |
|
126 |
var body = document.getElementsByTagName('body'); |
|
127 |
body = body[0]; |
|
128 |
body.onbeforeunload='return unescape(\''+escape(message)+'\')'; |
|
129 |
} |
|
130 |
||
131 |
function enableUnload() |
|
132 |
{ |
|
133 |
var body = document.getElementsByTagName('body'); |
|
134 |
body = body[0]; |
|
135 |
body.onbeforeunload = null; |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* Gets the highest z-index of all divs in the document |
|
140 |
* @return integer |
|
141 |
*/ |
|
142 |
function getHighestZ() |
|
143 |
{ |
|
144 |
z = 0; |
|
145 |
var divs = document.getElementsByTagName('div'); |
|
146 |
for(var i = 0; i < divs.length; i++) |
|
147 |
{ |
|
148 |
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex; |
|
149 |
} |
|
150 |
return z; |
|
151 |
} |
|
152 |
||
153 |
function isKeyPressed(event) |
|
154 |
{ |
|
155 |
if (event.shiftKey==1) |
|
156 |
{ |
|
157 |
shift = true; |
|
158 |
} |
|
159 |
else |
|
160 |
{ |
|
161 |
shift = false; |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
function moveDiv(div, newparent) |
|
166 |
{ |
|
167 |
var backup = div; |
|
168 |
var oldparent = div.parentNode; |
|
169 |
oldparent.removeChild(div); |
|
170 |
newparent.appendChild(backup); |
|
171 |
} |
|
172 |
||
173 |
function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;} |
|
174 |
function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";} |
|
175 |
function eraseCookie(name) {createCookie(name,"",-1);} |
|
176 |
||
177 |
var busyBannerID; |
|
178 |
function goBusy(msg) |
|
179 |
{ |
|
180 |
if(!msg) msg = 'Please wait...'; |
|
181 |
body = document.getElementsByTagName('body'); |
|
182 |
body = body[0]; |
|
183 |
body.style.cursor = 'wait'; |
|
184 |
busyBannerID = bannerOn(msg); |
|
185 |
} |
|
186 |
||
187 |
function unBusy() |
|
188 |
{ |
|
189 |
body = document.getElementsByTagName('body'); |
|
190 |
body = body[0]; |
|
191 |
body.style.cursor = 'default'; |
|
192 |
bannerOff(busyBannerID); |
|
193 |
} |
|
194 |
||
195 |
function setAjaxLoading() |
|
196 |
{ |
|
197 |
if ( document.getElementById('ajaxloadicon') ) |
|
198 |
{ |
|
200
63fddf1335d9
Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
parents:
176
diff
changeset
|
199 |
document.getElementById('ajaxloadicon').src=ajax_load_icon; |
1 | 200 |
} |
201 |
} |
|
202 |
||
203 |
function unsetAjaxLoading() |
|
204 |
{ |
|
205 |
if ( document.getElementById('ajaxloadicon') ) |
|
206 |
{ |
|
207 |
document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif'; |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
/* |
|
212 |
* Search boxes |
|
213 |
*/ |
|
214 |
||
215 |
function buildSearchBoxes() |
|
216 |
{ |
|
217 |
var divs = document.getElementsByTagName('*'); |
|
218 |
var boxes = new Array(); |
|
219 |
for ( var i = 0; i < divs.length; i++ ) |
|
220 |
{ |
|
221 |
if ( divs[i].className) |
|
222 |
{ |
|
223 |
if ( divs[i].className.substr(0, 9) == 'searchbox' ) |
|
224 |
{ |
|
225 |
boxes.push(divs[i]); |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
for ( var i = 0; i < boxes.length; i++ ) |
|
230 |
{ |
|
231 |
if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) ) |
|
232 |
{ |
|
233 |
var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/); |
|
234 |
width = parseInt(width[1]); |
|
235 |
} |
|
236 |
else |
|
237 |
{ |
|
238 |
var width = 120; |
|
239 |
} |
|
240 |
createSearchBox(boxes[i], width); |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
function createSearchBox(parent, width) |
|
245 |
{ |
|
246 |
if ( typeof(parent) != 'object') |
|
247 |
{ |
|
248 |
alert('BUG: createSearchBox(): parent is not an object'); |
|
249 |
return false; |
|
250 |
} |
|
251 |
//parent.style.padding = '0px'; |
|
252 |
//parent.style.textAlign = 'center'; |
|
253 |
parent.style.width = width + 'px'; |
|
254 |
var submit = document.createElement('div'); |
|
255 |
submit.onclick = function() { searchFormSubmit(this); }; |
|
256 |
submit.className = 'js-search-submit'; |
|
257 |
var input = document.createElement('input'); |
|
258 |
input.className = 'js-search-box'; |
|
259 |
input.value = 'Search'; |
|
260 |
input.name = 'q'; |
|
261 |
input.style.width = ( width - 28 ) + 'px'; |
|
262 |
input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; }; |
|
263 |
input.onblur = function() { if ( this.value == '' ) this.value = 'Search'; }; |
|
264 |
parent.appendChild(input); |
|
265 |
var off = fetch_offset(input); |
|
266 |
var top = off['top'] + 'px'; |
|
267 |
var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px'; |
|
268 |
submit.style.top = top; |
|
269 |
submit.style.left = left; |
|
270 |
parent.appendChild(submit); |
|
271 |
} |
|
272 |
||
273 |
function searchFormSubmit(obj) |
|
274 |
{ |
|
275 |
var input = obj.previousSibling; |
|
276 |
if ( input.value == 'Search' || input.value == '' ) |
|
277 |
return false; |
|
278 |
var p = obj; |
|
279 |
while(true) |
|
280 |
{ |
|
281 |
p = p.parentNode; |
|
282 |
if ( !p ) |
|
283 |
break; |
|
284 |
if ( typeof(p.tagName) != 'string' ) |
|
285 |
break; |
|
286 |
else if ( p.tagName.toLowerCase() == 'form' ) |
|
287 |
{ |
|
288 |
p.submit(); |
|
289 |
} |
|
290 |
else if ( p.tagName.toLowerCase() == 'body' ) |
|
291 |
{ |
|
292 |
break; |
|
293 |
} |
|
294 |
} |
|
295 |
} |
|
296 |
||
297 |
/* |
|
298 |
* AJAX login box (experimental) |
|
299 |
*/ |
|
300 |
||
301 |
var ajax_auth_prompt_cache = false; |
|
302 |
var ajax_auth_mb_cache = false; |
|
303 |
var ajax_auth_level_cache = false; |
|
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
304 |
var ajax_auth_error_string = false; |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
305 |
var ajax_auth_show_captcha = false; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
306 |
|
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
307 |
function ajaxAuthErrorToString($data) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
308 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
309 |
var $errstring = $data.error; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
310 |
// this was literally copied straight from the PHP code. |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
311 |
switch($data.error) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
312 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
313 |
case 'key_not_found': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
314 |
$errstring = $lang.get('user_err_key_not_found'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
315 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
316 |
case 'key_wrong_length': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
317 |
$errstring = $lang.get('user_err_key_wrong_length'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
318 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
319 |
case 'too_big_for_britches': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
320 |
$errstring = $lang.get('user_err_too_big_for_britches'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
321 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
322 |
case 'invalid_credentials': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
323 |
$errstring = $lang.get('user_err_invalid_credentials'); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
324 |
var subst = { |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
325 |
lockout_fails: $data.lockout_fails, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
326 |
lockout_threshold: $data.lockout_threshold, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
327 |
lockout_duration: $data.lockout_duration |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
328 |
} |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
329 |
if ( $data.lockout_policy == 'lockout' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
330 |
{ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
331 |
$errstring += $lang.get('user_err_invalid_credentials_lockout', subst); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
332 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
333 |
else if ( $data.lockout_policy == 'captcha' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
334 |
{ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
335 |
$errstring += $lang.get('user_err_invalid_credentials_lockout_captcha', subst); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
336 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
337 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
338 |
case 'backend_fail': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
339 |
$errstring = $lang.get('user_err_backend_fail'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
340 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
341 |
case 'locked_out': |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
342 |
$attempts = parseInt($data['lockout_fails']); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
343 |
if ( $attempts > $data['lockout_threshold']) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
344 |
$attempts = $data['lockout_threshold']; |
182
c69730750be3
Fixed the security hole (really, I'm a moron - used $failed > $threshold instead of $failed >= $threashold) and patched up some...erm... math issues
Dan
parents:
179
diff
changeset
|
345 |
$time_rem = $data.time_rem; |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
346 |
$s = ( $time_rem == 1 ) ? '' : $lang.get('meta_plural'); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
347 |
|
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
348 |
var subst = { |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
349 |
lockout_threshold: $data.lockout_threshold, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
350 |
time_rem: $time_rem, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
351 |
plural: $s, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
352 |
captcha_blurb: ( $data.lockout_policy == 'captcha' ? $lang.get('user_err_locked_out_captcha_blurb') : '' ) |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
353 |
} |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
354 |
|
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
355 |
$errstring = $lang.get('user_err_locked_out', subst); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
356 |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
357 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
358 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
359 |
return $errstring; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
360 |
} |
1 | 361 |
|
362 |
function ajaxPromptAdminAuth(call_on_ok, level) |
|
363 |
{ |
|
364 |
if ( typeof(call_on_ok) == 'function' ) |
|
365 |
{ |
|
366 |
ajax_auth_prompt_cache = call_on_ok; |
|
367 |
} |
|
368 |
if ( !level ) |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
369 |
level = USER_LEVEL_MEMBER; |
1 | 370 |
ajax_auth_level_cache = level; |
371 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
372 |
<p>' + $lang.get('user_login_ajax_fetching_key') + '</p> \ |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
373 |
<p><small>' + $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title) }) + '</p> \ |
1 | 374 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
375 |
</div>'; |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
376 |
var title = ( level > USER_LEVEL_MEMBER ) ? $lang.get('user_login_ajax_prompt_title_elev') : $lang.get('user_login_ajax_prompt_title'); |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
377 |
ajax_auth_mb_cache = new messagebox(MB_OKCANCEL|MB_ICONLOCK, title, loading_win); |
1 | 378 |
ajax_auth_mb_cache.onbeforeclick['OK'] = ajaxValidateLogin; |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
379 |
ajax_auth_mb_cache.onbeforeclick['Cancel'] = function() |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
380 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
381 |
if ( document.getElementById('autoCaptcha') ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
382 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
383 |
var to = fly_out_top(document.getElementById('autoCaptcha'), false, true); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
384 |
setTimeout(function() { |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
385 |
var d = document.getElementById('autoCaptcha'); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
386 |
d.parentNode.removeChild(d); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
387 |
}, to); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
388 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
389 |
} |
1 | 390 |
ajaxAuthLoginInnerSetup(); |
391 |
} |
|
392 |
||
393 |
function ajaxAuthLoginInnerSetup() |
|
394 |
{ |
|
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
395 |
// let's hope this gets the image cached |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
396 |
var _ = new Image(32, 32); |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
397 |
_.src = scriptPath + "/images/good.gif"; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
398 |
|
1 | 399 |
ajaxGet(makeUrlNS('Special', 'Login', 'act=getkey'), function() { |
400 |
if ( ajax.readyState == 4 ) |
|
401 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
402 |
var response = String(ajax.responseText); |
1 | 403 |
if ( response.substr(0,1) != '{' ) |
404 |
{ |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
315
diff
changeset
|
405 |
handle_invalid_json(response); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
315
diff
changeset
|
406 |
ajax_auth_mb_cache.destroy(); |
1 | 407 |
return false; |
408 |
} |
|
409 |
response = parseJSON(response); |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
410 |
var disable_controls = false; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
411 |
if ( response.locked_out && !ajax_auth_error_string ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
412 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
413 |
response.error = 'locked_out'; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
414 |
ajax_auth_error_string = ajaxAuthErrorToString(response); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
415 |
if ( response.lockout_policy == 'captcha' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
416 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
417 |
ajax_auth_show_captcha = response.captcha; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
418 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
419 |
else |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
420 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
421 |
disable_controls = true; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
422 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
423 |
} |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
424 |
var level = ajax_auth_level_cache; |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
425 |
var form_html = ''; |
176 | 426 |
var shown_error = false; |
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
427 |
if ( ajax_auth_error_string ) |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
428 |
{ |
176 | 429 |
shown_error = true; |
430 |
form_html += '<div class="error-box-mini" id="ajax_auth_error">' + ajax_auth_error_string + '</div>'; |
|
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
431 |
ajax_auth_error_string = false; |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
432 |
} |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
433 |
else if ( level > USER_LEVEL_MEMBER ) |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
434 |
{ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
435 |
form_html += $lang.get('user_login_ajax_prompt_body_elev') + '<br /><br />'; |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
436 |
} |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
437 |
if ( ajax_auth_show_captcha ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
438 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
439 |
var captcha_html = ' \ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
440 |
<tr> \ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
441 |
<td>' + $lang.get('user_login_field_captcha') + ':</td> \ |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
442 |
<td><input type="hidden" id="ajaxlogin_captcha_hash" value="' + ajax_auth_show_captcha + '" /><input type="text" tabindex="3" size="25" id="ajaxlogin_captcha_code" /> \ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
443 |
</tr>'; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
444 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
445 |
else |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
446 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
447 |
var captcha_html = ''; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
448 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
449 |
var disableme = ( disable_controls ) ? 'disabled="disabled" ' : ''; |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
450 |
form_html += ' \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
451 |
<form action="#" onsubmit="ajaxValidateLogin(); return false;" name="ajax_login_form"> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
452 |
<table border="0" align="center"> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
453 |
<tr> \ |
326 | 454 |
<td>' + $lang.get('user_login_field_username') + ':</td><td><input tabindex="1" id="ajaxlogin_user" type="text" ' + disableme + 'size="25" /> \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
455 |
</tr> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
456 |
<tr> \ |
326 | 457 |
<td>' + $lang.get('user_login_field_password') + ':</td><td><input tabindex="2" id="ajaxlogin_pass" type="password" ' + disableme + 'size="25" /> \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
458 |
</tr> \ |
326 | 459 |
' + captcha_html + ' \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
460 |
<tr> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
461 |
<td colspan="2" style="text-align: center;"> \ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
462 |
<small>' + $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title, 'level=' + level) }) + '<br />'; |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
463 |
if ( level <= USER_LEVEL_MEMBER ) |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
464 |
{ |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
465 |
form_html += ' \ |
326 | 466 |
' + $lang.get('user_login_ajax_link_forgotpass', { forgotpass_link: makeUrlNS('Special', 'PasswordReset') }) + '<br /> \ |
467 |
' + $lang.get('user_login_createaccount_blurb', { reg_link: makeUrlNS('Special', 'Register') }); |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
468 |
} |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
469 |
form_html += '</small> \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
470 |
</td> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
471 |
</tr> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
472 |
</table> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
473 |
<input type="hidden" id="ajaxlogin_crypt_key" value="' + response.key + '" /> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
474 |
<input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
475 |
</form>'; |
1 | 476 |
ajax_auth_mb_cache.updateContent(form_html); |
477 |
$('messageBox').object.nextSibling.firstChild.tabindex = '3'; |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
478 |
if ( typeof(response.username) == 'string' ) |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
479 |
{ |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
480 |
$('ajaxlogin_user').object.value = response.username; |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
481 |
if ( IE ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
482 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
483 |
setTimeout("document.forms['ajax_login_form'].password.focus();", 200); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
484 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
485 |
else |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
486 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
487 |
$('ajaxlogin_pass').object.focus(); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
488 |
} |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
489 |
} |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
490 |
else |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
491 |
{ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
492 |
if ( IE ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
493 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
494 |
setTimeout("document.forms['ajax_login_form'].username.focus();", 200); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
495 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
496 |
else |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
497 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
498 |
$('ajaxlogin_user').object.focus(); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
499 |
} |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
500 |
} |
326 | 501 |
var enter_obj = ( ajax_auth_show_captcha ) ? 'ajaxlogin_captcha_code' : 'ajaxlogin_pass'; |
502 |
$(enter_obj).object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); }; |
|
503 |
$(enter_obj).object.onkeypress = function(e) |
|
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
504 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
505 |
// Trigger a form submit when the password field is focused and the user presses enter |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
506 |
|
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
507 |
// IE doesn't give us an event object when it should - check window.event. If that |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
508 |
// still fails, give up. |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
509 |
if ( !e ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
510 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
511 |
e = window.event; |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
512 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
513 |
if ( !e && IE ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
514 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
515 |
return true; |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
516 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
517 |
if ( e.keyCode == 13 ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
518 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
519 |
ajaxValidateLogin(); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
520 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
521 |
}; |
176 | 522 |
/* |
523 |
## This causes the background image to disappear under Fx 2 |
|
524 |
if ( shown_error ) |
|
525 |
{ |
|
526 |
// fade to #FFF4F4 |
|
527 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 1000, from: '#FFF4F4', to: '#805600', restoreColor: '#805600', finish: function() |
|
528 |
{ |
|
529 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 3000, from: '#805600', to: '#FFF4F4', restoreColor: '#FFF4F4'}); |
|
530 |
fader.start(); |
|
531 |
}}); |
|
532 |
fader.start(); |
|
533 |
} |
|
534 |
*/ |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
535 |
if ( ajax_auth_show_captcha ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
536 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
537 |
ajaxShowCaptcha(ajax_auth_show_captcha); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
538 |
ajax_auth_show_captcha = false; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
539 |
} |
1 | 540 |
} |
541 |
}); |
|
542 |
} |
|
543 |
||
544 |
function ajaxValidateLogin() |
|
545 |
{ |
|
546 |
var username,password,auth_enabled,crypt_key,crypt_data,challenge_salt,challenge_data; |
|
547 |
username = document.getElementById('ajaxlogin_user'); |
|
548 |
if ( !username ) |
|
549 |
return false; |
|
550 |
username = document.getElementById('ajaxlogin_user').value; |
|
551 |
password = document.getElementById('ajaxlogin_pass').value; |
|
552 |
auth_enabled = false; |
|
553 |
||
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
554 |
if ( document.getElementById('autoCaptcha') ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
555 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
556 |
var to = fly_out_top(document.getElementById('autoCaptcha'), false, true); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
557 |
setTimeout(function() { |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
558 |
var d = document.getElementById('autoCaptcha'); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
559 |
d.parentNode.removeChild(d); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
560 |
}, to); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
561 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
562 |
|
1 | 563 |
disableJSONExts(); |
564 |
||
565 |
// |
|
566 |
// Encryption test |
|
567 |
// |
|
568 |
||
569 |
var str = ''; |
|
570 |
for(i=0;i<keySizeInBits/4;i++) |
|
571 |
{ |
|
572 |
str+='0'; |
|
573 |
} |
|
574 |
str = hexToByteArray(str); |
|
575 |
var ct = rijndaelEncrypt(str, str, 'ECB'); |
|
576 |
ct = byteArrayToHex(ct); |
|
577 |
var v; |
|
578 |
switch(keySizeInBits) |
|
579 |
{ |
|
580 |
case 128: |
|
581 |
v = '66e94bd4ef8a2c3b884cfa59ca342b2e'; |
|
582 |
break; |
|
583 |
case 192: |
|
584 |
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7'; |
|
585 |
break; |
|
586 |
case 256: |
|
587 |
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087'; |
|
588 |
break; |
|
589 |
} |
|
590 |
auth_enabled = ( ct == v && md5_vm_test() ); |
|
591 |
if ( !auth_enabled ) |
|
592 |
{ |
|
593 |
alert('Login error: encryption sanity check failed\n'); |
|
594 |
return true; |
|
595 |
} |
|
596 |
||
597 |
crypt_key = document.getElementById('ajaxlogin_crypt_key').value; |
|
598 |
challenge_salt = document.getElementById('ajaxlogin_crypt_challenge').value; |
|
599 |
||
600 |
var crypt_key_md5 = hex_md5(crypt_key); |
|
601 |
||
602 |
challenge_data = hex_md5(password + challenge_salt) + challenge_salt; |
|
603 |
||
604 |
password = stringToByteArray(password); |
|
605 |
crypt_key = hexToByteArray(crypt_key); |
|
606 |
||
607 |
crypt_data = rijndaelEncrypt(password, crypt_key, 'ECB'); |
|
608 |
crypt_data = byteArrayToHex(crypt_data); |
|
609 |
||
610 |
var json_data = { |
|
611 |
'username' : username, |
|
612 |
'crypt_key' : crypt_key_md5, |
|
613 |
'challenge' : challenge_data, |
|
614 |
'crypt_data' : crypt_data, |
|
615 |
'level' : ajax_auth_level_cache |
|
616 |
}; |
|
617 |
||
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
618 |
if ( document.getElementById('ajaxlogin_captcha_hash') ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
619 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
620 |
json_data.captcha_hash = document.getElementById('ajaxlogin_captcha_hash').value; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
621 |
json_data.captcha_code = document.getElementById('ajaxlogin_captcha_code').value; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
622 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
623 |
|
1 | 624 |
json_data = toJSONString(json_data); |
135
c5dbad7ec2d0
Enano should now fully support UTF-8 usernames; newly registered users are now granted automatic edit access to their user pages (admins can still use protection on the page)
Dan
parents:
133
diff
changeset
|
625 |
json_data = encodeURIComponent(json_data); |
1 | 626 |
|
627 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
628 |
<p>' + $lang.get('user_login_ajax_loggingin') + '</p> \ |
1 | 629 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
630 |
</div>'; |
|
631 |
||
632 |
ajax_auth_mb_cache.updateContent(loading_win); |
|
633 |
||
634 |
ajaxPost(makeUrlNS('Special', 'Login', 'act=ajaxlogin'), 'params=' + json_data, function() { |
|
635 |
if ( ajax.readyState == 4 ) |
|
636 |
{ |
|
637 |
var response = ajax.responseText; |
|
638 |
if ( response.substr(0,1) != '{' ) |
|
639 |
{ |
|
640 |
alert('Invalid JSON response from server: ' + response); |
|
641 |
ajaxAuthLoginInnerSetup(); |
|
642 |
return false; |
|
643 |
} |
|
644 |
response = parseJSON(response); |
|
645 |
switch(response.result) |
|
646 |
{ |
|
647 |
case 'success': |
|
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
648 |
var success_win = '<div align="center" style="text-align: center;"> \ |
304 | 649 |
<p>' + $lang.get('user_login_success_short') + '</p> \ |
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
650 |
<p><img alt=" " src="'+scriptPath+'/images/good.gif" /></p> \ |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
651 |
</div>'; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
652 |
ajax_auth_mb_cache.updateContent(success_win); |
1 | 653 |
if ( typeof(ajax_auth_prompt_cache) == 'function' ) |
654 |
{ |
|
655 |
ajax_auth_prompt_cache(response.key); |
|
656 |
} |
|
657 |
break; |
|
658 |
case 'success_reset': |
|
659 |
var conf = confirm('You have logged in using a temporary password. Before you can log in, you must finish resetting your password. Do you want to reset your real password now?'); |
|
660 |
if ( conf ) |
|
661 |
{ |
|
662 |
var url = makeUrlNS('Special', 'PasswordReset/stage2/' + response.user_id + '/' + response.temppass); |
|
663 |
window.location = url; |
|
664 |
} |
|
665 |
else |
|
666 |
{ |
|
667 |
ajaxAuthLoginInnerSetup(); |
|
668 |
} |
|
669 |
break; |
|
670 |
case 'error': |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
671 |
if ( response.data.error == 'invalid_credentials' || response.data.error == 'locked_out' ) |
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
672 |
{ |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
673 |
ajax_auth_error_string = ajaxAuthErrorToString(response.data); |
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
674 |
mb_current_obj.updateContent(''); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
675 |
document.getElementById('messageBox').style.backgroundColor = '#C0C0C0'; |
175
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
174
diff
changeset
|
676 |
var mb_parent = document.getElementById('messageBox').parentNode; |
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
174
diff
changeset
|
677 |
new Spry.Effect.Shake(mb_parent, {duration: 1500}).start(); |
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
678 |
setTimeout("document.getElementById('messageBox').style.backgroundColor = '#FFF'; ajaxAuthLoginInnerSetup();", 2500); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
679 |
|
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
680 |
if ( response.data.lockout_policy == 'captcha' && response.data.error == 'locked_out' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
681 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
682 |
ajax_auth_show_captcha = response.captcha; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
683 |
} |
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
684 |
} |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
685 |
else |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
686 |
{ |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
687 |
ajax_auth_error_string = ajaxAuthErrorToString(response.data); |
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
688 |
ajaxAuthLoginInnerSetup(); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
689 |
} |
1 | 690 |
break; |
691 |
default: |
|
692 |
alert(ajax.responseText); |
|
693 |
break; |
|
694 |
} |
|
695 |
} |
|
696 |
}); |
|
697 |
||
698 |
return true; |
|
699 |
||
700 |
} |
|
701 |
||
702 |
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ |
|
703 |
function sprintf() |
|
704 |
{ |
|
705 |
if (!arguments || arguments.length < 1 || !RegExp) |
|
706 |
{ |
|
707 |
return; |
|
708 |
} |
|
709 |
var str = arguments[0]; |
|
710 |
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; |
|
711 |
var a = b = [], numSubstitutions = 0, numMatches = 0; |
|
712 |
while (a = re.exec(str)) |
|
713 |
{ |
|
714 |
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; |
|
715 |
var pPrecision = a[5], pType = a[6], rightPart = a[7]; |
|
716 |
||
717 |
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); |
|
718 |
||
719 |
numMatches++; |
|
720 |
if (pType == '%') |
|
721 |
{ |
|
722 |
subst = '%'; |
|
723 |
} |
|
724 |
else |
|
725 |
{ |
|
726 |
numSubstitutions++; |
|
727 |
if (numSubstitutions >= arguments.length) |
|
728 |
{ |
|
729 |
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); |
|
730 |
} |
|
731 |
var param = arguments[numSubstitutions]; |
|
732 |
var pad = ''; |
|
733 |
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); |
|
734 |
else if (pPad) pad = pPad; |
|
735 |
var justifyRight = true; |
|
736 |
if (pJustify && pJustify === "-") justifyRight = false; |
|
737 |
var minLength = -1; |
|
738 |
if (pMinLength) minLength = parseInt(pMinLength); |
|
739 |
var precision = -1; |
|
740 |
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); |
|
741 |
var subst = param; |
|
742 |
if (pType == 'b') subst = parseInt(param).toString(2); |
|
743 |
else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); |
|
744 |
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; |
|
745 |
else if (pType == 'u') subst = Math.abs(param); |
|
746 |
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); |
|
747 |
else if (pType == 'o') subst = parseInt(param).toString(8); |
|
748 |
else if (pType == 's') subst = param; |
|
749 |
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); |
|
750 |
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); |
|
751 |
} |
|
752 |
str = leftpart + subst + rightPart; |
|
753 |
} |
|
754 |
return str; |
|
755 |
} |
|
756 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
757 |
/** |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
758 |
* Insert a DOM object _after_ the specified child. |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
759 |
* @param object Parent node |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
760 |
* @param object Node to insert |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
761 |
* @param object Node to insert after |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
762 |
*/ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
763 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
764 |
function insertAfter(parent, baby, bigsister) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
765 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
766 |
try |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
767 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
768 |
if ( parent.childNodes[parent.childNodes.length-1] == bigsister ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
769 |
parent.appendChild(baby); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
770 |
else |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
771 |
parent.insertBefore(baby, bigsister.nextSibling); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
772 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
773 |
catch(e) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
774 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
775 |
alert(e.toString()); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
776 |
if ( window.console ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
777 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
778 |
// Firebug support |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
779 |
window.console.warn(e); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
780 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
781 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
782 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
783 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
784 |
/** |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
785 |
* Validates an e-mail address. |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
786 |
* @param string E-mail address |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
787 |
* @return bool |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
788 |
*/ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
789 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
790 |
function validateEmail(email) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
791 |
{ |
295
f948557af068
Add warning in installer for PHP < 5.2.0; hopefully fix validation of e-mail addresses with dashes
Dan
parents:
281
diff
changeset
|
792 |
return ( email.match(/^(?:[\w\d_-]+\.?)+@((?:(?:[\w\d_-]\-?)+\.)+\w{2,4}|localhost)$/) ) ? true : false; |
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
793 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
794 |
|
334
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
795 |
/** |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
796 |
* Equivalent of PHP's time() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
797 |
* @return int |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
798 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
799 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
800 |
function unix_time() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
801 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
802 |
return parseInt((new Date()).getTime()/1000); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
803 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
804 |