Skip to content

Commit bd8fe4b

Browse files
committed
added welcome message with intial [init] command when not logged in
1 parent 8883ac2 commit bd8fe4b

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

commandline/index.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
$command = (isset($_GET["command"]) and $_GET["command"]!="") ? trim($_GET["command"]) : null;
88
if($command!=null){
9-
lCommand::addToStack($command);
10-
}
11-
if(!lConnection::isAuthorized()){
12-
lCommand::addToStackIfNotExists("login");
9+
if($command=="init"){
10+
if(!lConnection::isAuthorized()) lCommand::write("welcome to the php command line. please login via the command \"login\"");
11+
}else{
12+
lCommand::addToStack($command);
13+
}
1314
}
1415

1516
lCommand::performNextCommand();

commandline/library/lCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static function performNextCommand(){
4848
$args = array_slice($splits, 1);
4949

5050
// call command
51+
if($command=="") return;
5152
if(lConnection::isAuthorized() or $program=="login"){
5253
if(file_exists("programms/$program/init.php")){
5354
require_once("programms/$program/init.php");

commandline/programms/login/init.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function loginMain($args, $command){
1919
lCommand::write("welcome, ".$username);
2020
}else{
2121
lCommand::write("not authorized");
22-
lCommand::addToStack("login");
23-
lCommand::performNextCommand();
22+
// lCommand::addToStack("login");
23+
// lCommand::performNextCommand();
2424
}
2525
}
2626
}

index.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class CommandLine{
6363
}
6464
}
6565
static sendCommand(command){
66+
console.log(command);
6667
CommandLine.commandhistory.unshift(command);
6768
let xhttp = new XMLHttpRequest();
6869
xhttp.onreadystatechange = function() {
@@ -72,7 +73,7 @@ class CommandLine{
7273
CommandLine.print(answer["return"]);
7374
}
7475
};
75-
xhttp.open("GET", "commandline/?command="+encodeURI(command), true);
76+
xhttp.open("GET", "commandline/?command="+encodeURIComponent(command), true);
7677
xhttp.send();
7778
}
7879
static print(content){
@@ -87,6 +88,7 @@ class CommandLine{
8788
}
8889
CommandLine.commandhistory = [];
8990
CommandLine.historyindex = -1;
91+
CommandLine.sendCommand("init");
9092
</script>
9193
</head>
9294
<body onclick="document.getElementsByTagName('textarea')[0].focus();">

0 commit comments

Comments
 (0)