author | Dan |
Thu, 26 Jun 2008 20:59:23 -0400 | |
changeset 297 | 4f0f987717c6 |
parent 267 | 105457df35e5 |
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.'; |
|
267 | 126 |
window._unloadmsg = message; |
127 |
window.onbeforeunload = function(e) |
|
128 |
{ |
|
129 |
if ( !e ) |
|
130 |
e = window.event; |
|
131 |
e.returnValue = window._unloadmsg; |
|
132 |
} |
|
1 | 133 |
} |
134 |
||
135 |
function enableUnload() |
|
136 |
{ |
|
267 | 137 |
window._unloadmsg = null; |
138 |
window.onbeforeunload = null; |
|
1 | 139 |
} |
140 |
||
141 |
/** |
|
142 |
* Gets the highest z-index of all divs in the document |
|
143 |
* @return integer |
|
144 |
*/ |
|
145 |
function getHighestZ() |
|
146 |
{ |
|
147 |
z = 0; |
|
148 |
var divs = document.getElementsByTagName('div'); |
|
149 |
for(var i = 0; i < divs.length; i++) |
|
150 |
{ |
|
151 |
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex; |
|
152 |
} |
|
153 |
return z; |
|
154 |
} |
|
155 |
||
156 |
function isKeyPressed(event) |
|
157 |
{ |
|
158 |
if (event.shiftKey==1) |
|
159 |
{ |
|
160 |
shift = true; |
|
161 |
} |
|
162 |
else |
|
163 |
{ |
|
164 |
shift = false; |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
function moveDiv(div, newparent) |
|
169 |
{ |
|
170 |
var backup = div; |
|
171 |
var oldparent = div.parentNode; |
|
172 |
oldparent.removeChild(div); |
|
173 |
newparent.appendChild(backup); |
|
174 |
} |
|
175 |
||
176 |
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;} |
|
177 |
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=/";} |
|
178 |
function eraseCookie(name) {createCookie(name,"",-1);} |
|
179 |
||
180 |
var busyBannerID; |
|
181 |
function goBusy(msg) |
|
182 |
{ |
|
183 |
if(!msg) msg = 'Please wait...'; |
|
184 |
body = document.getElementsByTagName('body'); |
|
185 |
body = body[0]; |
|
186 |
body.style.cursor = 'wait'; |
|
187 |
busyBannerID = bannerOn(msg); |
|
188 |
} |
|
189 |
||
190 |
function unBusy() |
|
191 |
{ |
|
192 |
body = document.getElementsByTagName('body'); |
|
193 |
body = body[0]; |
|
194 |
body.style.cursor = 'default'; |
|
195 |
bannerOff(busyBannerID); |
|
196 |
} |
|
197 |
||
198 |
function setAjaxLoading() |
|
199 |
{ |
|
200 |
if ( document.getElementById('ajaxloadicon') ) |
|
201 |
{ |
|
188
63fddf1335d9
Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
parents:
172
diff
changeset
|
202 |
document.getElementById('ajaxloadicon').src=ajax_load_icon; |
1 | 203 |
} |
204 |
} |
|
205 |
||
206 |
function unsetAjaxLoading() |
|
207 |
{ |
|
208 |
if ( document.getElementById('ajaxloadicon') ) |
|
209 |
{ |
|
210 |
document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif'; |
|
211 |
} |
|
212 |
} |
|
213 |
||
214 |
/* |
|
215 |
* Search boxes |
|
216 |
*/ |
|
217 |
||
218 |
function buildSearchBoxes() |
|
219 |
{ |
|
220 |
var divs = document.getElementsByTagName('*'); |
|
221 |
var boxes = new Array(); |
|
222 |
for ( var i = 0; i < divs.length; i++ ) |
|
223 |
{ |
|
224 |
if ( divs[i].className) |
|
225 |
{ |
|
226 |
if ( divs[i].className.substr(0, 9) == 'searchbox' ) |
|
227 |
{ |
|
228 |
boxes.push(divs[i]); |
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 |
for ( var i = 0; i < boxes.length; i++ ) |
|
233 |
{ |
|
234 |
if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) ) |
|
235 |
{ |
|
236 |
var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/); |
|
237 |
width = parseInt(width[1]); |
|
238 |
} |
|
239 |
else |
|
240 |
{ |
|
241 |
var width = 120; |
|
242 |
} |
|
243 |
createSearchBox(boxes[i], width); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
function createSearchBox(parent, width) |
|
248 |
{ |
|
249 |
if ( typeof(parent) != 'object') |
|
250 |
{ |
|
251 |
alert('BUG: createSearchBox(): parent is not an object'); |
|
252 |
return false; |
|
253 |
} |
|
254 |
//parent.style.padding = '0px'; |
|
255 |
//parent.style.textAlign = 'center'; |
|
256 |
parent.style.width = width + 'px'; |
|
257 |
var submit = document.createElement('div'); |
|
258 |
submit.onclick = function() { searchFormSubmit(this); }; |
|
259 |
submit.className = 'js-search-submit'; |
|
260 |
var input = document.createElement('input'); |
|
261 |
input.className = 'js-search-box'; |
|
262 |
input.value = 'Search'; |
|
263 |
input.name = 'q'; |
|
264 |
input.style.width = ( width - 28 ) + 'px'; |
|
265 |
input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; }; |
|
266 |
input.onblur = function() { if ( this.value == '' ) this.value = 'Search'; }; |
|
267 |
parent.appendChild(input); |
|
268 |
var off = fetch_offset(input); |
|
269 |
var top = off['top'] + 'px'; |
|
270 |
var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px'; |
|
271 |
submit.style.top = top; |
|
272 |
submit.style.left = left; |
|
273 |
parent.appendChild(submit); |
|
274 |
} |
|
275 |
||
276 |
function searchFormSubmit(obj) |
|
277 |
{ |
|
278 |
var input = obj.previousSibling; |
|
279 |
if ( input.value == 'Search' || input.value == '' ) |
|
280 |
return false; |
|
281 |
var p = obj; |
|
282 |
while(true) |
|
283 |
{ |
|
284 |
p = p.parentNode; |
|
285 |
if ( !p ) |
|
286 |
break; |
|
287 |
if ( typeof(p.tagName) != 'string' ) |
|
288 |
break; |
|
289 |
else if ( p.tagName.toLowerCase() == 'form' ) |
|
290 |
{ |
|
291 |
p.submit(); |
|
292 |
} |
|
293 |
else if ( p.tagName.toLowerCase() == 'body' ) |
|
294 |
{ |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
||
300 |
/* |
|
301 |
* AJAX login box (experimental) |
|
302 |
*/ |
|
303 |
||
304 |
var ajax_auth_prompt_cache = false; |
|
305 |
var ajax_auth_mb_cache = false; |
|
306 |
var ajax_auth_level_cache = false; |
|
170
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
|
307 |
var ajax_auth_error_string = false; |
1 | 308 |
|
309 |
function ajaxPromptAdminAuth(call_on_ok, level) |
|
310 |
{ |
|
311 |
if ( typeof(call_on_ok) == 'function' ) |
|
312 |
{ |
|
313 |
ajax_auth_prompt_cache = call_on_ok; |
|
314 |
} |
|
315 |
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
|
316 |
level = USER_LEVEL_MEMBER; |
1 | 317 |
ajax_auth_level_cache = level; |
318 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
319 |
<p>Fetching an encryption key...</p> \ |
|
320 |
<p><small>Not working? Use the <a href="'+makeUrlNS('Special', 'Login/' + title)+'">alternate login form</a>.</p> \ |
|
321 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
|
322 |
</div>'; |
|
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
|
323 |
var title = ( level > USER_LEVEL_MEMBER ) ? 'You are requesting a sensitive operation.' : 'Please enter your username and password to continue.'; |
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
|
324 |
ajax_auth_mb_cache = new messagebox(MB_OKCANCEL|MB_ICONLOCK, title, loading_win); |
1 | 325 |
ajax_auth_mb_cache.onbeforeclick['OK'] = ajaxValidateLogin; |
326 |
ajaxAuthLoginInnerSetup(); |
|
327 |
} |
|
328 |
||
329 |
function ajaxAuthLoginInnerSetup() |
|
330 |
{ |
|
224
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
331 |
// 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:
188
diff
changeset
|
332 |
var _ = new Image(32, 32); |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
333 |
_.src = scriptPath + "/images/good.gif"; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
334 |
|
1 | 335 |
ajaxGet(makeUrlNS('Special', 'Login', 'act=getkey'), function() { |
336 |
if ( ajax.readyState == 4 ) |
|
337 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
338 |
var response = String(ajax.responseText); |
1 | 339 |
if ( response.substr(0,1) != '{' ) |
340 |
{ |
|
259
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:
254
diff
changeset
|
341 |
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:
254
diff
changeset
|
342 |
ajax_auth_mb_cache.destroy(); |
1 | 343 |
return false; |
344 |
} |
|
345 |
response = parseJSON(response); |
|
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
|
346 |
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
|
347 |
var form_html = ''; |
172 | 348 |
var shown_error = false; |
170
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
|
349 |
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
|
350 |
{ |
172 | 351 |
shown_error = true; |
352 |
form_html += '<div class="error-box-mini" id="ajax_auth_error">' + ajax_auth_error_string + '</div>'; |
|
170
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
|
353 |
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
|
354 |
} |
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
|
355 |
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
|
356 |
{ |
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
|
357 |
form_html += 'Please re-enter your login details, to verify your identity.<br /><br />'; |
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
|
358 |
} |
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
|
359 |
form_html += ' \ |
254
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:
238
diff
changeset
|
360 |
<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:
238
diff
changeset
|
361 |
<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:
238
diff
changeset
|
362 |
<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:
238
diff
changeset
|
363 |
<td>Username:</td><td><input name="username" tabindex="1" id="ajaxlogin_user" type="text" size="25" /> \ |
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:
238
diff
changeset
|
364 |
</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:
238
diff
changeset
|
365 |
<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:
238
diff
changeset
|
366 |
<td>Password:</td><td><input name="password" tabindex="2" id="ajaxlogin_pass" type="password" size="25" /> \ |
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:
238
diff
changeset
|
367 |
</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:
238
diff
changeset
|
368 |
<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:
238
diff
changeset
|
369 |
<td colspan="2" style="text-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:
238
diff
changeset
|
370 |
<br /><small>Trouble logging in? Try the <a href="'+makeUrlNS('Special', 'Login/' + title, 'level=' + level)+'">full login form</a>.<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
|
371 |
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
|
372 |
{ |
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
|
373 |
form_html += ' \ |
254
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:
238
diff
changeset
|
374 |
Did you <a href="'+makeUrlNS('Special', 'PasswordReset')+'">forget your password</a>?<br /> \ |
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:
238
diff
changeset
|
375 |
Maybe you need to <a href="'+makeUrlNS('Special', 'Register')+'">create an account</a>.</small>'; |
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
|
376 |
} |
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 |
form_html += ' \ |
254
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:
238
diff
changeset
|
378 |
</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:
238
diff
changeset
|
379 |
</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:
238
diff
changeset
|
380 |
</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:
238
diff
changeset
|
381 |
<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:
238
diff
changeset
|
382 |
<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:
238
diff
changeset
|
383 |
</form>'; |
1 | 384 |
ajax_auth_mb_cache.updateContent(form_html); |
385 |
$('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
|
386 |
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
|
387 |
{ |
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
|
388 |
$('ajaxlogin_user').object.value = response.username; |
254
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:
238
diff
changeset
|
389 |
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:
238
diff
changeset
|
390 |
{ |
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:
238
diff
changeset
|
391 |
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:
238
diff
changeset
|
392 |
} |
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:
238
diff
changeset
|
393 |
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:
238
diff
changeset
|
394 |
{ |
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:
238
diff
changeset
|
395 |
$('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:
238
diff
changeset
|
396 |
} |
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
|
397 |
} |
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
|
398 |
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
|
399 |
{ |
254
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:
238
diff
changeset
|
400 |
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:
238
diff
changeset
|
401 |
{ |
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:
238
diff
changeset
|
402 |
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:
238
diff
changeset
|
403 |
} |
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:
238
diff
changeset
|
404 |
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:
238
diff
changeset
|
405 |
{ |
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:
238
diff
changeset
|
406 |
$('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:
238
diff
changeset
|
407 |
} |
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
|
408 |
} |
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
parents:
1
diff
changeset
|
409 |
$('ajaxlogin_pass').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); }; |
254
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:
238
diff
changeset
|
410 |
$('ajaxlogin_pass').object.onkeypress = function(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:
238
diff
changeset
|
411 |
{ |
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:
238
diff
changeset
|
412 |
// 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:
238
diff
changeset
|
413 |
|
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:
238
diff
changeset
|
414 |
// 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:
238
diff
changeset
|
415 |
// 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:
238
diff
changeset
|
416 |
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:
238
diff
changeset
|
417 |
{ |
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:
238
diff
changeset
|
418 |
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:
238
diff
changeset
|
419 |
} |
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:
238
diff
changeset
|
420 |
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:
238
diff
changeset
|
421 |
{ |
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:
238
diff
changeset
|
422 |
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:
238
diff
changeset
|
423 |
} |
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:
238
diff
changeset
|
424 |
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:
238
diff
changeset
|
425 |
{ |
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:
238
diff
changeset
|
426 |
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:
238
diff
changeset
|
427 |
} |
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:
238
diff
changeset
|
428 |
}; |
172 | 429 |
/* |
430 |
## This causes the background image to disappear under Fx 2 |
|
431 |
if ( shown_error ) |
|
432 |
{ |
|
433 |
// fade to #FFF4F4 |
|
434 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 1000, from: '#FFF4F4', to: '#805600', restoreColor: '#805600', finish: function() |
|
435 |
{ |
|
436 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 3000, from: '#805600', to: '#FFF4F4', restoreColor: '#FFF4F4'}); |
|
437 |
fader.start(); |
|
438 |
}}); |
|
439 |
fader.start(); |
|
440 |
} |
|
441 |
*/ |
|
1 | 442 |
} |
443 |
}); |
|
444 |
} |
|
445 |
||
446 |
function ajaxValidateLogin() |
|
447 |
{ |
|
448 |
var username,password,auth_enabled,crypt_key,crypt_data,challenge_salt,challenge_data; |
|
449 |
username = document.getElementById('ajaxlogin_user'); |
|
450 |
if ( !username ) |
|
451 |
return false; |
|
452 |
username = document.getElementById('ajaxlogin_user').value; |
|
453 |
password = document.getElementById('ajaxlogin_pass').value; |
|
454 |
auth_enabled = false; |
|
455 |
||
456 |
disableJSONExts(); |
|
457 |
||
458 |
// |
|
459 |
// Encryption test |
|
460 |
// |
|
461 |
||
462 |
var str = ''; |
|
463 |
for(i=0;i<keySizeInBits/4;i++) |
|
464 |
{ |
|
465 |
str+='0'; |
|
466 |
} |
|
467 |
str = hexToByteArray(str); |
|
468 |
var ct = rijndaelEncrypt(str, str, 'ECB'); |
|
469 |
ct = byteArrayToHex(ct); |
|
470 |
var v; |
|
471 |
switch(keySizeInBits) |
|
472 |
{ |
|
473 |
case 128: |
|
474 |
v = '66e94bd4ef8a2c3b884cfa59ca342b2e'; |
|
475 |
break; |
|
476 |
case 192: |
|
477 |
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7'; |
|
478 |
break; |
|
479 |
case 256: |
|
480 |
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087'; |
|
481 |
break; |
|
482 |
} |
|
483 |
auth_enabled = ( ct == v && md5_vm_test() ); |
|
484 |
if ( !auth_enabled ) |
|
485 |
{ |
|
486 |
alert('Login error: encryption sanity check failed\n'); |
|
487 |
return true; |
|
488 |
} |
|
489 |
||
490 |
crypt_key = document.getElementById('ajaxlogin_crypt_key').value; |
|
491 |
challenge_salt = document.getElementById('ajaxlogin_crypt_challenge').value; |
|
492 |
||
493 |
var crypt_key_md5 = hex_md5(crypt_key); |
|
494 |
||
495 |
challenge_data = hex_md5(password + challenge_salt) + challenge_salt; |
|
496 |
||
497 |
password = stringToByteArray(password); |
|
498 |
crypt_key = hexToByteArray(crypt_key); |
|
499 |
||
500 |
crypt_data = rijndaelEncrypt(password, crypt_key, 'ECB'); |
|
501 |
crypt_data = byteArrayToHex(crypt_data); |
|
502 |
||
503 |
var json_data = { |
|
504 |
'username' : username, |
|
505 |
'crypt_key' : crypt_key_md5, |
|
506 |
'challenge' : challenge_data, |
|
507 |
'crypt_data' : crypt_data, |
|
508 |
'level' : ajax_auth_level_cache |
|
509 |
}; |
|
510 |
||
511 |
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
|
512 |
json_data = encodeURIComponent(json_data); |
1 | 513 |
|
514 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
515 |
<p>Logging in...</p> \ |
|
516 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
|
517 |
</div>'; |
|
518 |
||
519 |
ajax_auth_mb_cache.updateContent(loading_win); |
|
520 |
||
521 |
ajaxPost(makeUrlNS('Special', 'Login', 'act=ajaxlogin'), 'params=' + json_data, function() { |
|
522 |
if ( ajax.readyState == 4 ) |
|
523 |
{ |
|
524 |
var response = ajax.responseText; |
|
525 |
if ( response.substr(0,1) != '{' ) |
|
526 |
{ |
|
527 |
alert('Invalid JSON response from server: ' + response); |
|
528 |
ajaxAuthLoginInnerSetup(); |
|
529 |
return false; |
|
530 |
} |
|
531 |
response = parseJSON(response); |
|
532 |
switch(response.result) |
|
533 |
{ |
|
534 |
case 'success': |
|
224
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
535 |
var success_win = '<div align="center" style="text-align: center;"> \ |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
536 |
<p>Success.</p> \ |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
537 |
<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:
188
diff
changeset
|
538 |
</div>'; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
539 |
ajax_auth_mb_cache.updateContent(success_win); |
1 | 540 |
if ( typeof(ajax_auth_prompt_cache) == 'function' ) |
541 |
{ |
|
542 |
ajax_auth_prompt_cache(response.key); |
|
543 |
} |
|
544 |
break; |
|
545 |
case 'success_reset': |
|
546 |
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?'); |
|
547 |
if ( conf ) |
|
548 |
{ |
|
549 |
var url = makeUrlNS('Special', 'PasswordReset/stage2/' + response.user_id + '/' + response.temppass); |
|
550 |
window.location = url; |
|
551 |
} |
|
552 |
else |
|
553 |
{ |
|
554 |
ajaxAuthLoginInnerSetup(); |
|
555 |
} |
|
556 |
break; |
|
557 |
case 'error': |
|
170
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
|
558 |
if ( response.error == 'The username and/or password is incorrect.' ) |
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
|
559 |
{ |
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
|
560 |
ajax_auth_error_string = response.error; |
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
|
561 |
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
|
562 |
document.getElementById('messageBox').style.backgroundColor = '#C0C0C0'; |
171
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:
170
diff
changeset
|
563 |
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:
170
diff
changeset
|
564 |
new Spry.Effect.Shake(mb_parent, {duration: 1500}).start(); |
170
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
|
565 |
setTimeout("document.getElementById('messageBox').style.backgroundColor = '#FFF'; ajaxAuthLoginInnerSetup();", 2500); |
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
|
566 |
} |
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
|
567 |
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
|
568 |
{ |
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
|
569 |
alert(response.error); |
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
|
570 |
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
|
571 |
} |
1 | 572 |
break; |
573 |
default: |
|
574 |
alert(ajax.responseText); |
|
575 |
break; |
|
576 |
} |
|
577 |
} |
|
578 |
}); |
|
579 |
||
580 |
return true; |
|
581 |
||
582 |
} |
|
583 |
||
584 |
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ |
|
585 |
function sprintf() |
|
586 |
{ |
|
587 |
if (!arguments || arguments.length < 1 || !RegExp) |
|
588 |
{ |
|
589 |
return; |
|
590 |
} |
|
591 |
var str = arguments[0]; |
|
592 |
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; |
|
593 |
var a = b = [], numSubstitutions = 0, numMatches = 0; |
|
594 |
while (a = re.exec(str)) |
|
595 |
{ |
|
596 |
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; |
|
597 |
var pPrecision = a[5], pType = a[6], rightPart = a[7]; |
|
598 |
||
599 |
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); |
|
600 |
||
601 |
numMatches++; |
|
602 |
if (pType == '%') |
|
603 |
{ |
|
604 |
subst = '%'; |
|
605 |
} |
|
606 |
else |
|
607 |
{ |
|
608 |
numSubstitutions++; |
|
609 |
if (numSubstitutions >= arguments.length) |
|
610 |
{ |
|
611 |
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); |
|
612 |
} |
|
613 |
var param = arguments[numSubstitutions]; |
|
614 |
var pad = ''; |
|
615 |
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); |
|
616 |
else if (pPad) pad = pPad; |
|
617 |
var justifyRight = true; |
|
618 |
if (pJustify && pJustify === "-") justifyRight = false; |
|
619 |
var minLength = -1; |
|
620 |
if (pMinLength) minLength = parseInt(pMinLength); |
|
621 |
var precision = -1; |
|
622 |
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); |
|
623 |
var subst = param; |
|
624 |
if (pType == 'b') subst = parseInt(param).toString(2); |
|
625 |
else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); |
|
626 |
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; |
|
627 |
else if (pType == 'u') subst = Math.abs(param); |
|
628 |
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); |
|
629 |
else if (pType == 'o') subst = parseInt(param).toString(8); |
|
630 |
else if (pType == 's') subst = param; |
|
631 |
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); |
|
632 |
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); |
|
633 |
} |
|
634 |
str = leftpart + subst + rightPart; |
|
635 |
} |
|
636 |
return str; |
|
637 |
} |
|
638 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
639 |
/** |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
640 |
* 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
|
641 |
* @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
|
642 |
* @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
|
643 |
* @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
|
644 |
*/ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
645 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
646 |
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
|
647 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
648 |
try |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
649 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
650 |
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
|
651 |
parent.appendChild(baby); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
652 |
else |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
653 |
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
|
654 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
655 |
catch(e) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
656 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
657 |
alert(e.toString()); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
658 |
if ( window.console ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
659 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
660 |
// Firebug support |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
661 |
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
|
662 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
663 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
664 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
665 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
666 |
/** |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
667 |
* 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
|
668 |
* @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
|
669 |
* @return bool |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
670 |
*/ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
671 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
672 |
function validateEmail(email) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
673 |
{ |
238
f948557af068
Add warning in installer for PHP < 5.2.0; hopefully fix validation of e-mail addresses with dashes
Dan
parents:
224
diff
changeset
|
674 |
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
|
675 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
676 |