Tons of multiuser fixes and improvements
This commit is contained in:
parent
bdac1ac43f
commit
519a526419
22 changed files with 838 additions and 278 deletions
14
README
14
README
|
@ -27,6 +27,9 @@ pseudo-terminal are represented in normal font, the files that links to an
|
||||||
external content is instead represented as an `executable' file (by default, in
|
external content is instead represented as an `executable' file (by default, in
|
||||||
colour green).
|
colour green).
|
||||||
|
|
||||||
|
Q.: Which is the default password for 'root' user?
|
||||||
|
A.: blash. Remember to use it only one time, then change it using the passwd command.
|
||||||
|
|
||||||
Q.: Which browsers are compatible with blash?
|
Q.: Which browsers are compatible with blash?
|
||||||
A.: So far blash has been successfully tested with the following browsers:
|
A.: So far blash has been successfully tested with the following browsers:
|
||||||
|
|
||||||
|
@ -45,11 +48,14 @@ blash. Internet Explorer is currently NOT working with blash, at least any
|
||||||
release <= 8. I'm sorry, choose a decent browser.
|
release <= 8. I'm sorry, choose a decent browser.
|
||||||
|
|
||||||
Q.: How do I add the contents for my web site in blash?
|
Q.: How do I add the contents for my web site in blash?
|
||||||
A.: Open the file blash.json. This JSON file contains the preferences for your
|
A.: Open the file system/blash.json. This JSON file contains the preferences for your
|
||||||
shell (banner, prompt style, default user, escape sequences recognized in the
|
shell (banner, prompt style, default user, escape sequences recognized in the
|
||||||
prompt string...), the commands to be used, and the array "directories". This
|
prompt string...), the commands to be used, and so on. Change this file in order to
|
||||||
array is the container of your web site data. Each element can have the
|
change the preferences of your CMS.
|
||||||
following fields:
|
|
||||||
|
The contents of your web site are held in the file system/files_json.php. Modify this
|
||||||
|
file directly using the example contents as trace for adding or removing new contents.
|
||||||
|
Each content can include the following fields:
|
||||||
|
|
||||||
- path (MANDATORY), the full absolute path that identifies that resource
|
- path (MANDATORY), the full absolute path that identifies that resource
|
||||||
- type (MANDATORY), the resource type (directory or file)
|
- type (MANDATORY), the resource type (directory or file)
|
||||||
|
|
205
blash.json
205
blash.json
|
@ -1,205 +0,0 @@
|
||||||
/**
|
|
||||||
* Sample configuration and contents
|
|
||||||
*/
|
|
||||||
|
|
||||||
{
|
|
||||||
"banner" : "blash version 0.1<br/>" +
|
|
||||||
"Copyright (C) 2010 BlackLight <blacklight@autistici.org>" +
|
|
||||||
"<br/>Licence GPLv3+: GNU GPL version 3 or later " +
|
|
||||||
"<<a class=\"bannerLink\" href=\"http://gnu.org/licences/gpl.html\" target=\"_new\">" +
|
|
||||||
"http://gnu.org/licences/gpl.html</a>><br/>" +
|
|
||||||
"Source code available at <a class=\"bannerLink\" target=\"_new\" " +
|
|
||||||
"href=\"https://github.com/BlackLight/blash\">" +
|
|
||||||
"https://github.com/BlackLight/blash</a><br/><br/>" +
|
|
||||||
"This is free software; you are free to change and " +
|
|
||||||
"redistribuite it.<br/>There is NO WARRANTY, to the " +
|
|
||||||
"extent permitted by law.<br/>" +
|
|
||||||
"Type '<span class=\"brief\">man blash</span>' for help on usage and available commands<br/><br/>",
|
|
||||||
|
|
||||||
"user" : "guest",
|
|
||||||
"machine" : "localhost",
|
|
||||||
"shellName" : "blash",
|
|
||||||
"basepath" : "/",
|
|
||||||
"promptText" : "[#{800}%n#{888}@#{800}%m#{888} %W] $ ",
|
|
||||||
"promptSequences" : [
|
|
||||||
{
|
|
||||||
"sequence" : "%n",
|
|
||||||
"default_text" : "guest",
|
|
||||||
"text" : function () {
|
|
||||||
return shell.user;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sequence" : "%m",
|
|
||||||
"default_text" : "localhost",
|
|
||||||
"text" : function () {
|
|
||||||
return shell.json.machine;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sequence" : "%W",
|
|
||||||
"default_text" : "/",
|
|
||||||
"text" : function () {
|
|
||||||
return shell.path;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"directories" : [
|
|
||||||
{
|
|
||||||
"path" : "/",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/blog",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/news",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/forum",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/tutorials",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/software",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/etc",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/home",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/home/guest",
|
|
||||||
"type" : "directory",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/home/guest/mbox",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "No new mail",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/google",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "http://www.google.com",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/blog/post1",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "This is my first post",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/blog/post2",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "This is my second post",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/blog/post3",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "This is my third post",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/etc/blashrc",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "This is the default blash configuration file",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/forum/post1",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "<b>Sent by <i>admin</i> at <i>00:00:01</i></b><br/>Welcome to the forum<br/><br/>\n" +
|
|
||||||
"<b>Sent by <i>troll</i> at <i>00:00:02</i></b><br/>lulz<br/>\n",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/forum/post2",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "<b>Sent by <i>lolcat</i> at <i>00:00:03</i></b><br/>Can I haz cheezburger?<br/>\n",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/home/guest/.blashrc",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "Custom blash configuration file",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/home/guest/mbox",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "No new mail",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/news/news1",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "Nothing new under the sun",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/software/soft1",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "/software/soft1.tar.gz",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/software/soft2",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "/software/soft2.tar.gz",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/software/soft3",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "/software/soft3.tar.gz",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/tutorials/tut1",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "/software/tut1.pdf",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/tutorials/tut2",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "/software/tut2.pdf",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/github",
|
|
||||||
"type" : "file",
|
|
||||||
"href" : "https://github.com/BlackLight/blash",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/aboutme",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "Luke, I am your father",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/contacts",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "Contact me at spam@montypython.com",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/irc",
|
|
||||||
"type" : "file",
|
|
||||||
"content" : "IRC channel at #thegame@irc.randomstuff.com",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
"commands" : [
|
|
||||||
"cat",
|
|
||||||
"cd",
|
|
||||||
"clear",
|
|
||||||
"echo",
|
|
||||||
"eval",
|
|
||||||
"find",
|
|
||||||
"logout",
|
|
||||||
"ls",
|
|
||||||
"man",
|
|
||||||
"passwd",
|
|
||||||
"pwd",
|
|
||||||
"su",
|
|
||||||
"useradd",
|
|
||||||
"whoami",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,14 +9,14 @@
|
||||||
"action" : function ( arg )
|
"action" : function ( arg )
|
||||||
{
|
{
|
||||||
var out = '';
|
var out = '';
|
||||||
|
var found = false;
|
||||||
|
var dir = shell.files;
|
||||||
|
|
||||||
if ( !arg || arg.length == 0 )
|
if ( !arg || arg.length == 0 )
|
||||||
{
|
{
|
||||||
return "Argument required<br/>\n";
|
return "Argument required<br/>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
var found = false;
|
|
||||||
var dir = shell.json.directories;
|
|
||||||
arg = shell.expandPath ( arg );
|
arg = shell.expandPath ( arg );
|
||||||
|
|
||||||
for ( var i=0; i < dir.length && !found; i++ )
|
for ( var i=0; i < dir.length && !found; i++ )
|
||||||
|
@ -39,7 +39,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
if ( !found )
|
||||||
},
|
{
|
||||||
|
arg = arg.replace ( '<', '<' );
|
||||||
|
arg = arg.replace ( '>', '>' );
|
||||||
|
return "cat: " + arg + ": No such file or directory<br/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
out = out.replace ( /<br\/>\s*$/, '' );
|
||||||
|
return out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
var found = false;
|
var found = false;
|
||||||
arg = shell.expandPath ( arg );
|
arg = shell.expandPath ( arg );
|
||||||
|
|
||||||
for ( var i=0; i < shell.json.directories.length && !found; i++ )
|
for ( var i=0; i < shell.files.length && !found; i++ )
|
||||||
{
|
{
|
||||||
if ( shell.json.directories[i].path == arg )
|
if ( shell.files[i].path == arg )
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
if ( shell.json.directories[i].type != 'directory' )
|
if ( shell.files[i].type != 'directory' )
|
||||||
{
|
{
|
||||||
return "cd: not a directory: " + arg + "<br/>\n";
|
return "cd: not a directory: " + arg + "<br/>\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
var re = new RegExp ( arg, "i" );
|
var re = new RegExp ( arg, "i" );
|
||||||
|
|
||||||
for ( var i in shell.json.directories )
|
for ( var i in shell.files )
|
||||||
{
|
{
|
||||||
var dir = shell.json.directories[i];
|
var dir = shell.files[i];
|
||||||
|
|
||||||
if ( dir.path.match ( re ))
|
if ( dir.path.match ( re ))
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
{
|
{
|
||||||
var out = '';
|
var out = '';
|
||||||
|
|
||||||
|
if ( !shell.has_users )
|
||||||
|
{
|
||||||
|
return "Users module not enabled<br/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( shell.user == shell.json.user )
|
if ( shell.user == shell.json.user )
|
||||||
{
|
{
|
||||||
return out;
|
return out;
|
||||||
|
@ -27,6 +33,29 @@
|
||||||
http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
|
http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
|
||||||
http.setRequestHeader( "Content-length", params.length );
|
http.setRequestHeader( "Content-length", params.length );
|
||||||
http.setRequestHeader( "Connection", "close" );
|
http.setRequestHeader( "Connection", "close" );
|
||||||
|
|
||||||
|
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 + ')' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
http2.send ( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
http.send ( params );
|
http.send ( params );
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
"action" : function ( arg )
|
"action" : function ( arg )
|
||||||
{
|
{
|
||||||
var dirs = new Array();
|
var dirs = new Array();
|
||||||
var out = '';
|
|
||||||
var exists = false;
|
var exists = false;
|
||||||
|
var re = null;
|
||||||
|
|
||||||
if ( !arg || arg.length == 0 )
|
if ( !arg || arg.length == 0 )
|
||||||
{
|
{
|
||||||
var re = null;
|
re = null;
|
||||||
|
arg = shell.path;
|
||||||
|
|
||||||
if ( shell.path == '/' )
|
if ( shell.path == '/' )
|
||||||
{
|
{
|
||||||
|
@ -24,14 +25,24 @@
|
||||||
}
|
}
|
||||||
} else if ( arg && arg.length > 0 ) {
|
} else if ( arg && arg.length > 0 ) {
|
||||||
arg = shell.expandPath ( arg );
|
arg = shell.expandPath ( arg );
|
||||||
var re = new RegExp ( '^' + arg + '/[^/]+$' );
|
re = new RegExp ( '^' + arg + '/[^/]+$' );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( var i=0; i < shell.json.directories.length; i++ )
|
shell.re = re;
|
||||||
{
|
return this.ls ( arg );
|
||||||
var dir = shell.json.directories[i];
|
},
|
||||||
|
|
||||||
if ( dir.path.match ( re ))
|
"ls" : function ( arg )
|
||||||
|
{
|
||||||
|
var dirs = new Array();
|
||||||
|
var out = '';
|
||||||
|
var exists = false;
|
||||||
|
|
||||||
|
for ( var i=0; i < shell.files.length; i++ )
|
||||||
|
{
|
||||||
|
var dir = shell.files[i];
|
||||||
|
|
||||||
|
if ( dir.path.match ( shell.re ))
|
||||||
{
|
{
|
||||||
exists = true;
|
exists = true;
|
||||||
dir.path.match ( /\/([^\/]+)$/ );
|
dir.path.match ( /\/([^\/]+)$/ );
|
||||||
|
@ -114,9 +125,9 @@
|
||||||
|
|
||||||
if ( !exists )
|
if ( !exists )
|
||||||
{
|
{
|
||||||
for ( var i=0; i < shell.json.directories.length; i++ )
|
for ( var i=0; i < shell.files.length; i++ )
|
||||||
{
|
{
|
||||||
var dir = shell.json.directories[i];
|
var dir = shell.files[i];
|
||||||
arg = arg.replace ( /\/+$/, '' );
|
arg = arg.replace ( /\/+$/, '' );
|
||||||
|
|
||||||
if ( dir.path.match ( arg ))
|
if ( dir.path.match ( arg ))
|
||||||
|
@ -135,9 +146,9 @@
|
||||||
(( shell.path == '/' ) ? '' : '/' ) + arg );
|
(( shell.path == '/' ) ? '' : '/' ) + arg );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( var i=0; i < shell.json.directories.length; i++ )
|
for ( var i=0; i < shell.files.length; i++ )
|
||||||
{
|
{
|
||||||
var dir = shell.json.directories[i];
|
var dir = shell.files[i];
|
||||||
|
|
||||||
if ( dir.path.match ( re ))
|
if ( dir.path.match ( re ))
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,6 +97,12 @@
|
||||||
{
|
{
|
||||||
var out = '';
|
var out = '';
|
||||||
|
|
||||||
|
if ( !shell.has_users )
|
||||||
|
{
|
||||||
|
return "Users module not enabled<br/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
shell.auto_prompt_focus = false;
|
shell.auto_prompt_focus = false;
|
||||||
shell.auto_prompt_refresh = false;
|
shell.auto_prompt_refresh = false;
|
||||||
shell.newuser = arg;
|
shell.newuser = arg;
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
{
|
{
|
||||||
var out = '';
|
var out = '';
|
||||||
|
|
||||||
|
if ( !shell.has_users )
|
||||||
|
{
|
||||||
|
return "Users module not enabled<br/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ( !arg || arg.length == 0 )
|
if ( !arg || arg.length == 0 )
|
||||||
{
|
{
|
||||||
arg = 'root';
|
arg = 'root';
|
||||||
|
@ -60,17 +65,29 @@
|
||||||
{
|
{
|
||||||
if ( http.readyState == 4 && http.status == 200 )
|
if ( http.readyState == 4 && http.status == 200 )
|
||||||
{
|
{
|
||||||
if ( http.responseText.match ( /^Successfully logged in as '(.+?)'\s+(.*)\s*$/i ))
|
if ( http.responseText.match ( /^Successfully logged in as '(.+?)'/i ))
|
||||||
{
|
{
|
||||||
var user = RegExp.$1;
|
var user = RegExp.$1;
|
||||||
var auth = RegExp.$2;
|
|
||||||
|
|
||||||
shell.user = user;
|
shell.user = user;
|
||||||
shell.cmdOut.innerHTML = "Successfully logged in as '" + user + "'";
|
|
||||||
} else {
|
var files_config = window.location.href;
|
||||||
shell.cmdOut.innerHTML = '';
|
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 + ')' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
http2.send ( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
shell.cmdOut.innerHTML = http.responseText;
|
||||||
shell.refreshPrompt ( false, false );
|
shell.refreshPrompt ( false, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,12 @@
|
||||||
{
|
{
|
||||||
var out = '';
|
var out = '';
|
||||||
|
|
||||||
|
if ( !shell.has_users )
|
||||||
|
{
|
||||||
|
return "Users module not enabled<br/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( !arg || arg.length == 0 )
|
if ( !arg || arg.length == 0 )
|
||||||
{
|
{
|
||||||
return "Usage: " + this.name + " <username><br/>\n";
|
return "Usage: " + this.name + " <username><br/>\n";
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
{
|
{
|
||||||
var out = '';
|
var out = '';
|
||||||
|
|
||||||
|
if ( !shell.has_users )
|
||||||
|
{
|
||||||
|
return "guest<br/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( arg )
|
if ( arg )
|
||||||
{
|
{
|
||||||
return "whoami: extra operand `" + arg + "'<br/>\n";
|
return "whoami: extra operand `" + arg + "'<br/>\n";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Blash - An AJAX interactive shell emulator for web browsing</title>
|
<title>Blash - An AJAX interactive shell emulator for web browsing</title>
|
||||||
<script type="text/javascript" language="javascript" src="blash.js"></script>
|
<script type="text/javascript" language="javascript" src="system/blash.js"></script>
|
||||||
<script type="text/javascript" language="javascript" src="md5.js"></script>
|
<script type="text/javascript" language="javascript" src="system/md5.js"></script>
|
||||||
<link rel="stylesheet" href="blash.css" type="text/css">
|
<link rel="stylesheet" href="blash.css" type="text/css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
Binary file not shown.
45
modules/users/files.php
Normal file
45
modules/users/files.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include '../../system/files_json.php';
|
||||||
|
include 'user_utils.php';
|
||||||
|
|
||||||
|
if ( !$files_json || strlen ( $files_json ) == 0 )
|
||||||
|
{
|
||||||
|
print "Empty JSON files content\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = json_decode ( $files_json, true );
|
||||||
|
|
||||||
|
if ( !$json )
|
||||||
|
{
|
||||||
|
print "Empty or invalid JSON files content\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "[\n";
|
||||||
|
|
||||||
|
for ( $i=0; $i < count ( $json ); $i++ )
|
||||||
|
{
|
||||||
|
$can_read = false;
|
||||||
|
$perms = getPerms ( $json[$i]['path'] );
|
||||||
|
$perms = json_decode ( $perms, true );
|
||||||
|
|
||||||
|
if ( $perms['read'] == true )
|
||||||
|
{
|
||||||
|
$keys = array_keys ( $json[$i] );
|
||||||
|
|
||||||
|
print "{\n";
|
||||||
|
|
||||||
|
foreach ( $keys as $k )
|
||||||
|
{
|
||||||
|
print '"'.$k.'": "'.$json[$i][$k].'",'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "},\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "]\n";
|
||||||
|
|
||||||
|
?>
|
208
modules/users/user_utils.php
Normal file
208
modules/users/user_utils.php
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function getUser ()
|
||||||
|
{
|
||||||
|
include 'userlist.php';
|
||||||
|
|
||||||
|
if ( isset ( $_COOKIE['username'] ) && isset ( $_COOKIE['auth'] ))
|
||||||
|
{
|
||||||
|
if ( !( $xml = new SimpleXMLElement ( $xmlcontent )))
|
||||||
|
{
|
||||||
|
return "Unable to open the users XML file\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( $i = 0; $i < count ( $xml->user ); $i++ )
|
||||||
|
{
|
||||||
|
if ( !strcasecmp ( $xml->user[$i]['name'], $_COOKIE['username'] ))
|
||||||
|
{
|
||||||
|
$auth = md5 ( $xml->user[$i]['name'] . $xml->user[$i]['pass'] );
|
||||||
|
|
||||||
|
if ( !strcasecmp ( $auth, $_COOKIE['auth'] ))
|
||||||
|
{
|
||||||
|
return $xml->user[$i]['name'];
|
||||||
|
} else {
|
||||||
|
return "guest";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "guest";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "guest";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPerms ( $resource )
|
||||||
|
{
|
||||||
|
include "../../system/files_json.php";
|
||||||
|
|
||||||
|
if ( !$files_json || strlen ( $files_json ) == 0 )
|
||||||
|
{
|
||||||
|
return '{ "message": "Empty JSON file container" }';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = getUser();
|
||||||
|
$resource = str_replace ( '"', '\"', $resource );
|
||||||
|
|
||||||
|
if ( $user == 'root' )
|
||||||
|
{
|
||||||
|
return '{ "resource" : "'.$resource.'", "read" : true, "write" : true }'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( preg_match ( '@/[^/]+/+$@', $resource ))
|
||||||
|
{
|
||||||
|
$resource = preg_replace ( '@/+$@', '', $resource );
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = json_decode ( $files_json, true );
|
||||||
|
$dir = $resource;
|
||||||
|
$response = "{ \"resource\": \"$dir\"\n";
|
||||||
|
|
||||||
|
$read_perm_found = false; // Have we found information about the read permissions of this resource?
|
||||||
|
$write_perm_found = false; // Have we found information about the write permissions of this resource?
|
||||||
|
$res_found = false; // Have we found the resource?
|
||||||
|
$can_read = false;
|
||||||
|
$can_write = false;
|
||||||
|
|
||||||
|
if ( !$json || count ( $json ) == 0 )
|
||||||
|
{
|
||||||
|
return '{ "message": "Empty JSON file" }';
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
for ( $i=0; $i < count ( $json ); $i++ )
|
||||||
|
{
|
||||||
|
if ( !strcmp ( $json[$i]['path'], $dir ))
|
||||||
|
{
|
||||||
|
$res_found = true;
|
||||||
|
|
||||||
|
if ( !$read_perm_found )
|
||||||
|
{
|
||||||
|
if ( isset ( $json[$i]['can_read'] ))
|
||||||
|
{
|
||||||
|
$read_perm_found = true;
|
||||||
|
$read = $json[$i]['can_read'];
|
||||||
|
|
||||||
|
if ( preg_match ( '/[\s,]*'.$user.'[\s,]*/', $read ))
|
||||||
|
{
|
||||||
|
$response .= ", \"read\": true\n";
|
||||||
|
$can_read = true;
|
||||||
|
} else if ( preg_match_all ( "/[\s,]?@([^\s,]+)[\s,]?/", $read, $matches )) {
|
||||||
|
for ( $j=1; $j < count ( $matches ); $j++ )
|
||||||
|
{
|
||||||
|
if ( !strcasecmp ( $matches[$j][0], "all" ))
|
||||||
|
{
|
||||||
|
$response .= ", \"read\": true\n";
|
||||||
|
$can_read = true;
|
||||||
|
} else if ( !strcasecmp ( $matches[$j], "registered" ) && $user != 'guest' ) {
|
||||||
|
$response .= ", \"read\": true\n";
|
||||||
|
$can_read = true;
|
||||||
|
} else {
|
||||||
|
if ( isset ( $json['groups'] ))
|
||||||
|
{
|
||||||
|
for ( $k=0; $k < count ( $json['groups'] ); $k++ )
|
||||||
|
{
|
||||||
|
if ( $json['groups'][$k]['name'] == $matches[$k] )
|
||||||
|
{
|
||||||
|
if ( isset ( $json['groups'][$k]['users'] ))
|
||||||
|
{
|
||||||
|
if ( preg_match ( '/[\s,]*'.$user.'[\s,]*/', $json['groups'][$k]['users'] ))
|
||||||
|
{
|
||||||
|
$can_read = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$can_read )
|
||||||
|
{
|
||||||
|
$response .= ", \"read\": false\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$write_perm_found )
|
||||||
|
{
|
||||||
|
if ( isset ( $json[$i]['can_write'] ))
|
||||||
|
{
|
||||||
|
$write_perm_found = true;
|
||||||
|
$write = $json[$i]['can_write'];
|
||||||
|
|
||||||
|
if ( preg_match ( '/[\s,]*'.$user.'[\s,]*/', $write ))
|
||||||
|
{
|
||||||
|
$response .= ", \"write\": true\n";
|
||||||
|
$can_write = true;
|
||||||
|
} else if ( preg_match_all ( "/[\s,'\"]?@([^\s,'\"]+)[\s,'\"]/", $write, $matches )) {
|
||||||
|
for ( $j=1; $j < count ( $matches ); $j++ )
|
||||||
|
{
|
||||||
|
if ( !strcasecmp ( $matches[$j], "all" ))
|
||||||
|
{
|
||||||
|
$response .= ", \"write\": true\n";
|
||||||
|
$can_write = true;
|
||||||
|
} else if ( !strcasecmp ( $matches[$j], "registered" ) && $user != 'guest' ) {
|
||||||
|
$response .= ", \"write\": true\n";
|
||||||
|
$can_write = true;
|
||||||
|
} else {
|
||||||
|
if ( isset ( $json['groups'] ))
|
||||||
|
{
|
||||||
|
for ( $k=0; $k < count ( $json['groups'] ); $k++ )
|
||||||
|
{
|
||||||
|
if ( $json['groups'][$k]['name'] == $matches[$k] )
|
||||||
|
{
|
||||||
|
if ( isset ( $json['groups'][$k]['users'] ))
|
||||||
|
{
|
||||||
|
if ( preg_match ( '/[\s,]*'.$user.'[\s,]*/', $json['groups'][$k]['users'] ))
|
||||||
|
{
|
||||||
|
$can_write = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$can_write )
|
||||||
|
{
|
||||||
|
$response .= ", \"write\": false\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$res_found )
|
||||||
|
{
|
||||||
|
return '{ "message": "Resource not found" }';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $read_perm_found && $write_perm_found )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( preg_match ( '@/[^/]+/@', $dir ))
|
||||||
|
{
|
||||||
|
$dir = preg_replace ( '@/[^/]+$@', '', $dir );
|
||||||
|
} else if ( preg_match ( '@^/[^/]+$@', $dir )) {
|
||||||
|
$dir = '/';
|
||||||
|
} else if ( $dir == '/' ) {
|
||||||
|
$dir = '';
|
||||||
|
}
|
||||||
|
} while ( strlen ( $dir ) > 0 );
|
||||||
|
|
||||||
|
$response .= "}\n";
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -3,7 +3,7 @@
|
||||||
$xmlcontent = <<<XML
|
$xmlcontent = <<<XML
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<users>
|
<users>
|
||||||
<user name="blacklight" pass="5f4dcc3b5aa765d61d8327deb882cf99" home="/home/blacklight"/></users>
|
<user name="root" pass="3c7f506040bffb0aada69cfd5b101f4b" home="/root"/><user name="blacklight" pass="5f4dcc3b5aa765d61d8327deb882cf99" home="/home/blacklight"/></users>
|
||||||
|
|
||||||
XML;
|
XML;
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include 'userlist.php';
|
include 'userlist.php';
|
||||||
|
include 'user_utils.php';
|
||||||
function getUser ()
|
|
||||||
{
|
|
||||||
include 'userlist.php';
|
|
||||||
|
|
||||||
if ( isset ( $_COOKIE['username'] ) && isset ( $_COOKIE['auth'] ))
|
|
||||||
{
|
|
||||||
if ( !( $xml = new SimpleXMLElement ( $xmlcontent )))
|
|
||||||
{
|
|
||||||
return "Unable to open the users XML file\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( $i = 0; $i < count ( $xml->user ); $i++ )
|
|
||||||
{
|
|
||||||
if ( !strcasecmp ( $xml->user[$i]['name'], $_COOKIE['username'] ))
|
|
||||||
{
|
|
||||||
$auth = md5 ( $xml->user[$i]['name'] . $xml->user[$i]['pass'] );
|
|
||||||
|
|
||||||
if ( !strcasecmp ( $auth, $_COOKIE['auth'] ))
|
|
||||||
{
|
|
||||||
return $xml->user[$i]['name'];
|
|
||||||
} else {
|
|
||||||
return "guest";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "guest";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "guest";
|
|
||||||
}
|
|
||||||
|
|
||||||
$action = $_REQUEST['action'];
|
$action = $_REQUEST['action'];
|
||||||
|
|
||||||
|
@ -90,7 +59,7 @@ switch ( $action )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite ( $fp, "<?php\n\n\$xmlcontent = <<<XML\n" . $xml->asXML() . "\nXML;\n\n?>\n" );
|
fwrite ( $fp, '<?php'."\n\n".'$xmlcontent = <<<XML'."\n" . $xml->asXML() . "\nXML;\n\n?>\n" );
|
||||||
fclose ( $fp );
|
fclose ( $fp );
|
||||||
|
|
||||||
print 'User "'.$username.' successfully added, home directory set to "/home/'.$username."\"\n";
|
print 'User "'.$username.' successfully added, home directory set to "/home/'.$username."\"\n";
|
||||||
|
@ -130,7 +99,7 @@ switch ( $action )
|
||||||
setcookie ( 'username', $xml->user[$i]['name'], 0, "/" );
|
setcookie ( 'username', $xml->user[$i]['name'], 0, "/" );
|
||||||
setcookie ( 'auth', $auth, 0, "/" );
|
setcookie ( 'auth', $auth, 0, "/" );
|
||||||
|
|
||||||
print "Successfully logged in as '$username' $auth\n";
|
print "Successfully logged in as '$username'\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +172,18 @@ switch ( $action )
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'getperms':
|
||||||
|
$res = $_REQUEST['resource'];
|
||||||
|
|
||||||
|
if ( !$res )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
print getPerms ( $res );
|
||||||
|
// var_dump ( getPerms ( $res ));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -19,6 +19,9 @@ function blash ()
|
||||||
/** Object containing the parsed JSON configuration object */
|
/** Object containing the parsed JSON configuration object */
|
||||||
this.json = {};
|
this.json = {};
|
||||||
|
|
||||||
|
/** Object containing the files in the shell */
|
||||||
|
this.files = {};
|
||||||
|
|
||||||
/** Shell window object */
|
/** Shell window object */
|
||||||
this.window = document.getElementById ( "blashWindow" );
|
this.window = document.getElementById ( "blashWindow" );
|
||||||
|
|
||||||
|
@ -57,6 +60,12 @@ function blash ()
|
||||||
|
|
||||||
/** Variable set if the focus should be automatically set to the prompt line after a command */
|
/** Variable set if the focus should be automatically set to the prompt line after a command */
|
||||||
this.auto_prompt_focus = true;
|
this.auto_prompt_focus = true;
|
||||||
|
|
||||||
|
/** Variable set if the current implementation of blash uses the user module */
|
||||||
|
this.has_users = false;
|
||||||
|
|
||||||
|
/** Path to the file containing the files directory */
|
||||||
|
this.files_json = window.location.href;
|
||||||
/**************************************/
|
/**************************************/
|
||||||
|
|
||||||
this.loadCommand = function ( cmd )
|
this.loadCommand = function ( cmd )
|
||||||
|
@ -113,7 +122,7 @@ function blash ()
|
||||||
this.prompt.focus();
|
this.prompt.focus();
|
||||||
|
|
||||||
var json_config = window.location.href;
|
var json_config = window.location.href;
|
||||||
json_config = json_config.replace ( /\/([a-zA-Z\.]+)$/, '/blash.json' );
|
json_config = json_config.replace ( /\/([a-zA-Z\.]+)$/, '/system/blash.json' );
|
||||||
|
|
||||||
var http = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
http.open ( "GET", json_config, true );
|
http.open ( "GET", json_config, true );
|
||||||
|
@ -144,6 +153,42 @@ function blash ()
|
||||||
{
|
{
|
||||||
shell.loadCommand ( shell.json.commands[i] );
|
shell.loadCommand ( shell.json.commands[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shell.has_users = false;
|
||||||
|
|
||||||
|
for ( var i=0; i < shell.json.modules.length; i++ )
|
||||||
|
{
|
||||||
|
var module = shell.json.modules[i];
|
||||||
|
|
||||||
|
if ( module.name == 'users' )
|
||||||
|
{
|
||||||
|
has_users = module.enabled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shell.files_json = window.location.href;
|
||||||
|
|
||||||
|
if ( has_users )
|
||||||
|
{
|
||||||
|
shell.files_json = shell.files_json.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/files.php' );
|
||||||
|
} else {
|
||||||
|
shell.files_json = shell.files_json.replace ( /\/([a-zA-Z\.]+)$/, '/system/files.json' );
|
||||||
|
}
|
||||||
|
|
||||||
|
var http2 = new XMLHttpRequest();
|
||||||
|
http2.open ( "GET", shell.files_json, true );
|
||||||
|
|
||||||
|
http2.onreadystatechange = function ()
|
||||||
|
{
|
||||||
|
if ( http2.readyState == 4 && http2.status == 200 )
|
||||||
|
{
|
||||||
|
shell.files = eval ( '(' + http2.responseText + ')' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
http2.send ( null );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,12 +282,15 @@ function blash ()
|
||||||
cmd_found = true;
|
cmd_found = true;
|
||||||
var out = this.commands[i].action ( arg );
|
var out = this.commands[i].action ( arg );
|
||||||
|
|
||||||
|
if ( out )
|
||||||
|
{
|
||||||
if ( out.length > 0 )
|
if ( out.length > 0 )
|
||||||
{
|
{
|
||||||
this.cmdOut.innerHTML = out;
|
this.cmdOut.innerHTML = out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !cmd_found )
|
if ( !cmd_found )
|
||||||
{
|
{
|
||||||
|
@ -345,7 +393,7 @@ function blash ()
|
||||||
var path = arg;
|
var path = arg;
|
||||||
var dirs = new Array();
|
var dirs = new Array();
|
||||||
|
|
||||||
for ( var i in this.json.directories )
|
for ( var i in this.files )
|
||||||
{
|
{
|
||||||
if ( arg.match ( /^[^\/]/ ) )
|
if ( arg.match ( /^[^\/]/ ) )
|
||||||
{
|
{
|
||||||
|
@ -355,11 +403,11 @@ function blash ()
|
||||||
|
|
||||||
var re = new RegExp ( '^' + path + '[^/]*$' );
|
var re = new RegExp ( '^' + path + '[^/]*$' );
|
||||||
|
|
||||||
if ( this.json.directories[i].path.match ( re ))
|
if ( this.files[i].path.match ( re ))
|
||||||
{
|
{
|
||||||
dirs.push ({
|
dirs.push ({
|
||||||
'name' : this.json.directories[i].path,
|
'name' : this.files[i].path,
|
||||||
'type' : this.json.directories[i].type,
|
'type' : this.files[i].type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
73
system/blash.json
Normal file
73
system/blash.json
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/**
|
||||||
|
* Sample configuration and contents
|
||||||
|
*/
|
||||||
|
|
||||||
|
{
|
||||||
|
"banner" : "blash version 0.1<br/>" +
|
||||||
|
"Copyright (C) 2010 BlackLight <blacklight@autistici.org>" +
|
||||||
|
"<br/>Licence GPLv3+: GNU GPL version 3 or later " +
|
||||||
|
"<<a class=\"bannerLink\" href=\"http://gnu.org/licences/gpl.html\" target=\"_new\">" +
|
||||||
|
"http://gnu.org/licences/gpl.html</a>><br/>" +
|
||||||
|
"Source code available at <a class=\"bannerLink\" target=\"_new\" " +
|
||||||
|
"href=\"https://github.com/BlackLight/blash\">" +
|
||||||
|
"https://github.com/BlackLight/blash</a><br/><br/>" +
|
||||||
|
"This is free software; you are free to change and " +
|
||||||
|
"redistribuite it.<br/>There is NO WARRANTY, to the " +
|
||||||
|
"extent permitted by law.<br/>" +
|
||||||
|
"Type '<span class=\"brief\">man blash</span>' for help on usage and available commands<br/><br/>",
|
||||||
|
|
||||||
|
"user" : "guest",
|
||||||
|
"machine" : "localhost",
|
||||||
|
"shellName" : "blash",
|
||||||
|
"basepath" : "/",
|
||||||
|
"promptText" : "[#{800}%n#{888}@#{800}%m#{888} %W] $ ",
|
||||||
|
"promptSequences" : [
|
||||||
|
{
|
||||||
|
"sequence" : "%n",
|
||||||
|
"default_text" : "guest",
|
||||||
|
"text" : function () {
|
||||||
|
return shell.user;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sequence" : "%m",
|
||||||
|
"default_text" : "localhost",
|
||||||
|
"text" : function () {
|
||||||
|
return shell.json.machine;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sequence" : "%W",
|
||||||
|
"default_text" : "/",
|
||||||
|
"text" : function () {
|
||||||
|
return shell.path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"modules" : [
|
||||||
|
{
|
||||||
|
"name" : "users",
|
||||||
|
"enabled" : true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"commands" : [
|
||||||
|
"cat",
|
||||||
|
"cd",
|
||||||
|
"clear",
|
||||||
|
"echo",
|
||||||
|
"eval",
|
||||||
|
"find",
|
||||||
|
"logout",
|
||||||
|
"ls",
|
||||||
|
"man",
|
||||||
|
"passwd",
|
||||||
|
"perms",
|
||||||
|
"pwd",
|
||||||
|
"su",
|
||||||
|
"useradd",
|
||||||
|
"whoami"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
158
system/files.json
Normal file
158
system/files.json
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path" : "/",
|
||||||
|
"type" : "directory",
|
||||||
|
"can_read" : "@all",
|
||||||
|
"can_write" : "root"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/news",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/forum",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/tutorials",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/etc",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest/mbox",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "No new mail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/blacklight",
|
||||||
|
"type" : "directory",
|
||||||
|
"can_read" : "blacklight",
|
||||||
|
"can_write" : "blacklight"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/blacklight/mbox",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "No new mail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/google",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "http://www.google.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog/post1",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is my first post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog/post2",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is my second post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog/post3",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is my third post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/etc/blashrc",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is the default blash configuration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/forum/post1",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "<b>Sent by <i>admin</i> at <i>00:00:01</i></b><br/>Welcome to the forum<br/><br/>\n<b>Sent by <i>troll</i> at <i>00:00:02</i></b><br/>lulz<br/>\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/forum/post2",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "<b>Sent by <i>lolcat</i> at <i>00:00:03</i></b><br/>Can I haz cheezburger?<br/>\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest/.blashrc",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Custom blash configuration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest/mbox",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "No new mail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/news/news1",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Nothing new under the sun"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software/soft1",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/soft1.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software/soft2",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/soft2.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software/soft3",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/soft3.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/tutorials/tut1",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/tut1.pdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/tutorials/tut2",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/tut2.pdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/github",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "https://github.com/BlackLight/blash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/aboutme",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Luke, I am your father"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/contacts",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Contact me at spam@montypython.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/irc",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "IRC channel at #thegame@irc.randomstuff.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/root",
|
||||||
|
"type" : "directory",
|
||||||
|
"can_read" : "root",
|
||||||
|
"can_write" : "root"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
163
system/files_json.php
Normal file
163
system/files_json.php
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$files_json = <<<JSON
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path" : "/",
|
||||||
|
"type" : "directory",
|
||||||
|
"can_read" : "@all",
|
||||||
|
"can_write" : "root"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/news",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/forum",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/tutorials",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/etc",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest",
|
||||||
|
"type" : "directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest/mbox",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "No new mail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/blacklight",
|
||||||
|
"type" : "directory",
|
||||||
|
"can_read" : "blacklight",
|
||||||
|
"can_write" : "blacklight"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/blacklight/mbox",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "No new mail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/google",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "http://www.google.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog/post1",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is my first post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog/post2",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is my second post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/blog/post3",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is my third post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/etc/blashrc",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "This is the default blash configuration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/forum/post1",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "lol"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/forum/post2",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "lol"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest/.blashrc",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Custom blash configuration file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/home/guest/mbox",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "No new mail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/news/news1",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Nothing new under the sun"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software/soft1",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/soft1.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software/soft2",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/soft2.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/software/soft3",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/soft3.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/tutorials/tut1",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/tut1.pdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/tutorials/tut2",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "/software/tut2.pdf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/github",
|
||||||
|
"type" : "file",
|
||||||
|
"href" : "https://github.com/BlackLight/blash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/aboutme",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Luke, I am your father"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/contacts",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "Contact me at spam@montypython.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/irc",
|
||||||
|
"type" : "file",
|
||||||
|
"content" : "IRC channel at #thegame@irc.randomstuff.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "/root",
|
||||||
|
"type" : "directory",
|
||||||
|
"can_read" : "root",
|
||||||
|
"can_write" : "root"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
JSON;
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in a new issue