2010-12-25 23:17:30 +01:00
|
|
|
{
|
|
|
|
"name" : "logout",
|
|
|
|
|
|
|
|
"info" : {
|
|
|
|
"syntax" : "logout",
|
|
|
|
"brief" : "End the current user session",
|
|
|
|
},
|
|
|
|
|
|
|
|
"action" : function ( arg )
|
|
|
|
{
|
|
|
|
var out = '';
|
|
|
|
|
2010-12-29 21:32:43 +01:00
|
|
|
if ( !shell.has_users )
|
|
|
|
{
|
|
|
|
return "Users module not enabled<br/>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-25 23:17:30 +01:00
|
|
|
if ( shell.user == shell.json.user )
|
|
|
|
{
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
shell.user = shell.json.user;
|
|
|
|
document.cookie = '';
|
2010-12-26 18:08:43 +01:00
|
|
|
|
|
|
|
var users_php = window.location.href;
|
|
|
|
users_php = users_php.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/users.php' );
|
|
|
|
params = 'action=logout';
|
|
|
|
|
|
|
|
var http = new XMLHttpRequest();
|
|
|
|
http.open ( "POST", users_php, true );
|
|
|
|
http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
|
|
|
|
http.setRequestHeader( "Content-length", params.length );
|
|
|
|
http.setRequestHeader( "Connection", "close" );
|
2010-12-29 21:32:43 +01:00
|
|
|
|
|
|
|
http.onreadystatechange = function ()
|
|
|
|
{
|
|
|
|
if ( http.readyState == 4 && http.status == 200 )
|
|
|
|
{
|
|
|
|
var files_config = window.location.href;
|
|
|
|
files_config = files_config.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/files.php' );
|
|
|
|
|
|
|
|
var http2 = new XMLHttpRequest();
|
|
|
|
http2.open ( "GET", files_config, true );
|
|
|
|
|
|
|
|
http2.onreadystatechange = function ()
|
|
|
|
{
|
|
|
|
if ( http2.readyState == 4 && http2.status == 200 )
|
|
|
|
{
|
|
|
|
shell.files = eval ( '(' + http2.responseText + ')' );
|
2010-12-30 03:27:26 +01:00
|
|
|
|
|
|
|
// Remove duplicates
|
|
|
|
var tmp = new Array();
|
|
|
|
|
|
|
|
for ( var i in shell.files )
|
|
|
|
{
|
|
|
|
var contains = false;
|
|
|
|
|
|
|
|
for ( var j=0; j < tmp.length && !contains; j++ )
|
|
|
|
{
|
|
|
|
if ( shell.files[i].path == tmp[j].path )
|
|
|
|
{
|
|
|
|
contains = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !contains )
|
|
|
|
{
|
|
|
|
tmp.push ( shell.files[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shell.files = tmp;
|
2010-12-29 21:32:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
http2.send ( null );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-26 18:08:43 +01:00
|
|
|
http.send ( params );
|
2010-12-25 23:17:30 +01:00
|
|
|
return out;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|