mirror of
https://github.com/Codiad/Codiad.git
synced 2026-03-22 00:46:51 +01:00
Merge remote-tracking branch 'origin/master' into custom_splitting
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
// Enable or disable terminal
|
||||
|
||||
$terminal_enabled = false;
|
||||
|
||||
// Terminal password (Leave blank for none)
|
||||
|
||||
$terminal_password = '';
|
||||
|
||||
// Restricted and non-functional (require interactive mode) commands
|
||||
|
||||
$restricted = array('ssh','telnet');
|
||||
|
||||
?>
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('config.php');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Verify Session or Key
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
checkSession();
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Verify Terminal Enabled
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
if(!$terminal_enabled){
|
||||
exit('Terminal commands disabled');
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Init terminal path
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
if(!isset($_SESSION['terminal_path'])){
|
||||
$_SESSION['terminal_path'] = WORKSPACE . '/' . $_SESSION['project'];
|
||||
}
|
||||
|
||||
chdir($_SESSION['terminal_path']);
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Terminal Functions
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
function terminal($command,$restricted){
|
||||
|
||||
if(!function_exists('exec')){
|
||||
// Exec is not enabled, print out error
|
||||
$output = 'Command execution not possible on this system';
|
||||
$return_var = 1;
|
||||
}else{
|
||||
|
||||
// Exec is good! Run through the process!
|
||||
|
||||
$command_pop = explode(' ',$command);
|
||||
$first = $command_pop[0];
|
||||
|
||||
// Handle change directory
|
||||
if($first=='cd'){
|
||||
chdir($command_pop[1]);
|
||||
$_SESSION['terminal_path']=exec('pwd');
|
||||
}
|
||||
|
||||
// No text editors, change to 'cat' for output
|
||||
if($first=='vi' || $first=='vim' || $first=='nano'){
|
||||
$command = str_replace($first,'cat',$command);
|
||||
}
|
||||
|
||||
// Handle restricted functions
|
||||
if(in_array($first,$restricted)){
|
||||
$command = 'echo "ERROR: Command not allowed"';
|
||||
}
|
||||
|
||||
exec($command , $output , $return_var);
|
||||
$output = implode("\n" , $output);
|
||||
|
||||
return array('output' => $output , 'status' => $return_var);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$command_response = terminal(urldecode($_GET['command']),$restricted);
|
||||
|
||||
echo(htmlentities($command_response['output']));
|
||||
|
||||
?>
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('config.php');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Verify Session or Key
|
||||
@@ -16,121 +15,14 @@
|
||||
|
||||
checkSession();
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Verify Terminal Enabled
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
if(!$terminal_enabled){
|
||||
exit('<label style="padding: 50px 0 30px 0; text-align: center;">Terminal is currently disabled. Enable via /components/terminal/config.php</label><button onclick="codiad.modal.unload();">Close</button>');
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Init terminal path
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
$_SESSION['terminal_path'] = WORKSPACE . '/' . $_SESSION['project'];
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Check Terminal Password
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
$auth_fail = false;
|
||||
|
||||
if(isset($_GET['p'])){
|
||||
if(urldecode($_GET['p'])==$terminal_password){
|
||||
$_SESSION['terminal_auth'] = true;
|
||||
}else{
|
||||
$auth_fail = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($terminal_password!=''){
|
||||
if(empty($_SESSION['terminal_auth'])){
|
||||
$_SESSION['terminal_auth'] = false;
|
||||
}
|
||||
}else{
|
||||
$_SESSION['terminal_auth'] = true;
|
||||
}
|
||||
|
||||
if(!$_SESSION['terminal_auth']){
|
||||
|
||||
?>
|
||||
|
||||
<form id="terminal-auth">
|
||||
<label>Terminal Password</label>
|
||||
<input type="password" name="terminal_password">
|
||||
<button class="btn-left">Authenticate</button><button class="btn-right" onclick="codiad.modal.unload(); return false;">Close</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
$('#terminal-auth input').focus();
|
||||
// Set Terminal Width
|
||||
$('#modal').css({ 'width':'350px','margin-left':'-175px' });
|
||||
// Submit Password
|
||||
$('#terminal-auth').on('submit',function(e){
|
||||
e.preventDefault();
|
||||
$('#modal-content').load('components/terminal/dialog.php?p='+escape($('input[name="terminal_password"]').val()));
|
||||
});
|
||||
<?php if($auth_fail){ ?>
|
||||
// Show auth fail message
|
||||
codiad.message.error('Incorrect Password');
|
||||
<?php } ?>
|
||||
?>
|
||||
<style>#terminal { border: 1px solid #2b2b2b; }</style>
|
||||
<iframe id="terminal" width="100%" height="400" src="components/terminal/emulator/index.php?id=kd9kdi8nundj"></iframe>
|
||||
<button onclick="codiad.modal.unload(); return false;">Close Terminal</button>
|
||||
<script>
|
||||
$(function(){
|
||||
var wheight = $(window)
|
||||
.outerHeight() - 300;
|
||||
$('#terminal').css('height',wheight+'px');
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php }else{ ?>
|
||||
|
||||
<label>Terminal</label>
|
||||
<div id="terminal-container">
|
||||
<div id="terminal"></div>
|
||||
<input type="text" id="term-command">
|
||||
<div id="term-command-icon">>></div>
|
||||
</div>
|
||||
<button onclick="codiad.modal.unload();">Close Terminal</button>
|
||||
<script>
|
||||
|
||||
$(function(){
|
||||
|
||||
|
||||
command_history = [];
|
||||
command_counter = -1;
|
||||
history_counter = -1;
|
||||
|
||||
// Set Terminal Width
|
||||
$('#modal').css({'width':codiad.terminal.termWidth+'px','margin-left':'-'+Math.round(codiad.terminal.termWidth/2)+'px'});
|
||||
|
||||
// Set Terminal Height
|
||||
var new_height = $(window).height()-350;
|
||||
$('#terminal').css({ 'height':new_height+'px' });
|
||||
|
||||
$('#term-command').focus();
|
||||
$('#term-command').keydown(function(e){
|
||||
code = (e.keyCode ? e.keyCode : e.which);
|
||||
// Enter key - fire command
|
||||
if(code == 13){
|
||||
var command = $(this).val();
|
||||
if (command.trim() === '' || command.trim()== 'Processing...'){ return; }
|
||||
command_history[++command_counter] = command;
|
||||
history_counter = command_counter;
|
||||
codiad.terminal.runCommand(command);
|
||||
// Up arrow - traverse history (reverse)
|
||||
}else if(code == 38){
|
||||
if(history_counter>=0){
|
||||
$(this).val(command_history[history_counter--]);
|
||||
}
|
||||
// Down arrow - travers history (forward)
|
||||
} else if (code == 40) {
|
||||
if (history_counter <= command_counter) {
|
||||
$(this).val(command_history[++history_counter]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<?php } ?>
|
||||
</script>
|
||||
101
components/terminal/emulator/css/screen.css
Normal file
101
components/terminal/emulator/css/screen.css
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* PHP+JQuery Temrinal Emulator by Fluidbyte <http://www.fluidbyte.net>
|
||||
*
|
||||
* This software is released as-is with no warranty and is complete free
|
||||
* for use, modification and redistribution
|
||||
*/
|
||||
|
||||
/* RESET */
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section, summary,
|
||||
time, mark, audio, video{margin:0;padding:0;border:0;outline:0;font-size:100%;font:inherit;vertical-align:baseline;}
|
||||
a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent;}
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section{display:block;}
|
||||
body{line-height:1;}
|
||||
ol, ul{list-style:none;}
|
||||
blockquote, q{quotes:none;}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after{content:'';content:none;}
|
||||
ins{text-decoration:none;}
|
||||
del{text-decoration:line-through;}
|
||||
table{border-collapse:collapse;border-spacing:0;}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
/* WEBKIT SCROLLBARS */
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track-piece {
|
||||
background-color: #333;
|
||||
-webkit-border-radius: 0;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:vertical {
|
||||
height: 5px;
|
||||
background-color: #666;
|
||||
-webkit-border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:vertical:hover {
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:horizontal {
|
||||
width: 5px;
|
||||
background-color: #666;
|
||||
-webkit-border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:horizontal:hover {
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background-color: #2D2D2D;
|
||||
}
|
||||
|
||||
/* DOCUMENT */
|
||||
|
||||
html { width: 100%; height: 100%; overflow: hidden; }
|
||||
body { width: 100%; height: 100%; }
|
||||
|
||||
/* GLOBALS */
|
||||
|
||||
a,a:link,a:visited { cursor: pointer; }
|
||||
a:hover,a:active { }
|
||||
|
||||
.hide { display: none; }
|
||||
.clear { clear: both; }
|
||||
.right { float: right; }
|
||||
.left { float: left; }
|
||||
|
||||
/* TERMINAL */
|
||||
|
||||
#terminal { overflow: scroll; background: #1a1a1a; width: 100%; height: 100%; color: #fff; font-family: monospace; padding: 5px; line-height: 135%;
|
||||
-webkit-box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, .8);
|
||||
box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, .8);
|
||||
}
|
||||
|
||||
.command { font-weight: bold; color: #8a8af2; }
|
||||
.data { padding: 0 15px; }
|
||||
|
||||
#command, #command input { display: block; position: relative; background: #1a1a1a; color: #fff; border: none; font-family: monospace; width: 100%; }
|
||||
#command input { padding-left: 15px; }
|
||||
#command #prompt { position: absolute; z-index: 9999; font-weight: bold; }
|
||||
|
||||
#command input:focus { outline: none; }
|
||||
46
components/terminal/emulator/index.php
Normal file
46
components/terminal/emulator/index.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<!--
|
||||
/*
|
||||
* PHP+JQuery Temrinal Emulator by Fluidbyte <http://www.fluidbyte.net>
|
||||
*
|
||||
* This software is released as-is with no warranty and is complete free
|
||||
* for use, modification and redistribution
|
||||
*/
|
||||
-->
|
||||
<?php
|
||||
|
||||
require_once('../../../config.php');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Verify Session or Key
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
checkSession();
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Terminal</title>
|
||||
<link rel="stylesheet" href="css/screen.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div id="terminal">
|
||||
|
||||
<div id="output"></div>
|
||||
|
||||
<div id="command">
|
||||
<div id="prompt">></div>
|
||||
<input type="text">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="js/jquery-1.8.2.js"></script>
|
||||
<script src="js/system.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
2
components/terminal/emulator/js/jquery-1.8.2.js
vendored
Normal file
2
components/terminal/emulator/js/jquery-1.8.2.js
vendored
Normal file
File diff suppressed because one or more lines are too long
107
components/terminal/emulator/js/system.js
Normal file
107
components/terminal/emulator/js/system.js
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* PHP+JQuery Temrinal Emulator by Fluidbyte <http://www.fluidbyte.net>
|
||||
*
|
||||
* This software is released as-is with no warranty and is complete free
|
||||
* for use, modification and redistribution
|
||||
*/
|
||||
|
||||
$(function(){ terminal.init(); });
|
||||
|
||||
var terminal = {
|
||||
|
||||
// Controller
|
||||
controller : 'term.php',
|
||||
|
||||
// DOM Objects
|
||||
command : $('#command input'),
|
||||
screen : $('#terminal'),
|
||||
output : $('#terminal>#output'),
|
||||
|
||||
// Command History
|
||||
command_history : [],
|
||||
command_counter : -1,
|
||||
history_counter : -1,
|
||||
|
||||
init : function(){
|
||||
terminal.listener();
|
||||
// Start with authentication
|
||||
terminal.process_command();
|
||||
},
|
||||
|
||||
listener : function(){
|
||||
terminal.command.focus().keydown(function(e){
|
||||
var code = (e.keyCode ? e.keyCode : e.which);
|
||||
var command = terminal.get_command();
|
||||
switch(code){
|
||||
// Enter key, process command
|
||||
case 13:
|
||||
if(command=='clear'){
|
||||
terminal.clear();
|
||||
}else{
|
||||
terminal.command_history[++terminal.command_counter] = command;
|
||||
terminal.history_counter = terminal.command_counter;
|
||||
terminal.process_command();
|
||||
terminal.command.val('Processing...').focus();
|
||||
}
|
||||
break;
|
||||
// Up arrow, reverse history
|
||||
case 38:
|
||||
if(terminal.history_counter>=0){
|
||||
$(this).val(terminal.command_history[terminal.history_counter--]);
|
||||
}
|
||||
break;
|
||||
// Down arrow, forward history
|
||||
case 40:
|
||||
if (terminal.history_counter <= terminal.command_counter) {
|
||||
$(this).val(terminal.command_history[++terminal.history_counter]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
process_command : function(){
|
||||
var command = terminal.get_command();
|
||||
$.post(terminal.controller,{command:command},function(data){
|
||||
terminal.command.val('').focus();
|
||||
switch(data){
|
||||
case '[CLEAR]':
|
||||
terminal.clear();
|
||||
break;
|
||||
case '[CLOSED]':
|
||||
terminal.clear();
|
||||
terminal.process_command();
|
||||
window.parent.codiad.modal.unload();
|
||||
break;
|
||||
case '[AUTHENTICATED]':
|
||||
terminal.command_history = [];
|
||||
terminal.command_counter = -1;
|
||||
terminal.history_counter = -1;
|
||||
terminal.clear();
|
||||
break;
|
||||
case 'Enter Password:':
|
||||
terminal.clear();
|
||||
terminal.display_output('Authentication Required',data);
|
||||
terminal.command.css({'color':'#333'});
|
||||
break;
|
||||
default:
|
||||
terminal.display_output(command,data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
get_command : function(){
|
||||
return terminal.command.val();
|
||||
},
|
||||
|
||||
display_output : function(command,data){
|
||||
terminal.output.append('<pre class="command">'+command+'</pre><pre class="data">'+data+'</pre>');
|
||||
terminal.screen.scrollTop(terminal.output.height());
|
||||
},
|
||||
|
||||
clear : function(){
|
||||
terminal.output.html('');
|
||||
terminal.command.css({ 'color':'#fff' }).val('');
|
||||
}
|
||||
|
||||
};
|
||||
212
components/terminal/emulator/term.php
Normal file
212
components/terminal/emulator/term.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* PHP+JQuery Temrinal Emulator by Fluidbyte <http://www.fluidbyte.net>
|
||||
*
|
||||
* This software is released as-is with no warranty and is complete free
|
||||
* for use, modification and redistribution
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Password
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
define('PASSWORD','terminal');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Core Stuff
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../../../config.php');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Verify Session or Key
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
checkSession();
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Globals
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
define('ROOT',WORKSPACE . '/' . $_SESSION['project']);
|
||||
define('BLOCKED','ssh,telnet');
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Terminal Class
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
class Terminal{
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Properties
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
public $command = '';
|
||||
public $output = '';
|
||||
public $directory = '';
|
||||
|
||||
// Holder for commands fired by system
|
||||
public $command_exec = '';
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
public function __construct(){
|
||||
if(!isset($_SESSION['dir'])){
|
||||
if(ROOT==''){
|
||||
$this->command_exec = 'pwd';
|
||||
$this->Execute();
|
||||
$_SESSION['dir'] = $this->output;
|
||||
}else{
|
||||
$this->directory = ROOT;
|
||||
$this->ChangeDirectory();
|
||||
}
|
||||
}else{
|
||||
$this->directory = $_SESSION['dir'];
|
||||
$this->ChangeDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Primary call
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
public function Process(){
|
||||
$this->ParseCommand();
|
||||
$this->Execute();
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Parse command for special functions, blocks
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
public function ParseCommand(){
|
||||
|
||||
// Explode command
|
||||
$command_parts = explode(" ",$this->command);
|
||||
|
||||
// Handle 'cd' command
|
||||
if(in_array('cd',$command_parts)){
|
||||
$cd_key = array_search('cd', $command_parts);
|
||||
$cd_key++;
|
||||
$this->directory = $command_parts[$cd_key];
|
||||
$this->ChangeDirectory();
|
||||
// Remove from command
|
||||
$this->command = str_replace('cd '.$this->directory,'',$this->command);
|
||||
}
|
||||
|
||||
// Replace text editors with cat
|
||||
$editors = array('vi','vim','nano');
|
||||
$this->command = str_replace($editors,'cat',$this->command);
|
||||
|
||||
// Handle blocked commands
|
||||
$blocked = explode(',',BLOCKED);
|
||||
if(in_array($command_parts[0],$blocked)){
|
||||
$this->command = 'echo ERROR: Command not allowed';
|
||||
}
|
||||
|
||||
// Update exec command
|
||||
$this->command_exec = $this->command . ' 2>&1';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Chnage Directory
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
public function ChangeDirectory(){
|
||||
chdir($this->directory);
|
||||
// Store new directory
|
||||
$_SESSION['dir'] = exec('pwd');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Execute commands
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
public function Execute(){
|
||||
//system
|
||||
if(function_exists('system')){
|
||||
ob_start();
|
||||
system($this->command_exec);
|
||||
$this->output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
//passthru
|
||||
else if(function_exists('passthru')){
|
||||
ob_start();
|
||||
passthru($this->command_exec);
|
||||
$this->output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
//exec
|
||||
else if(function_exists('exec')){
|
||||
exec($this->command_exec , $this->output);
|
||||
$this->output = implode("\n" , $output);
|
||||
}
|
||||
//shell_exec
|
||||
else if(function_exists('shell_exec')){
|
||||
$this->output = shell_exec($this->command_exec);
|
||||
}
|
||||
// no support
|
||||
else{
|
||||
$this->output = 'Command execution not possible on this system';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Processing
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
$command = '';
|
||||
if(!empty($_POST['command'])){ $command = $_POST['command']; }
|
||||
|
||||
if(strtolower($command=='exit')){
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Exit
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
$_SESSION['term_auth'] = 'false';
|
||||
$output = '[CLOSED]';
|
||||
|
||||
}else if($_SESSION['term_auth']!='true'){
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Authentication
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
if($command==PASSWORD){
|
||||
$_SESSION['term_auth'] = 'true';
|
||||
$output = '[AUTHENTICATED]';
|
||||
}else{
|
||||
$output = 'Enter Password:';
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Execution
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// Split &&
|
||||
$Terminal = new Terminal();
|
||||
$output = '';
|
||||
$command = explode("&&", $command);
|
||||
foreach($command as $c){
|
||||
$Terminal->command = $c;
|
||||
$output .= $Terminal->Process();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo(htmlentities($output));
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -9,32 +9,10 @@
|
||||
|
||||
termWidth: $(window)
|
||||
.outerWidth() - 500,
|
||||
controller: 'components/terminal/controller.php',
|
||||
|
||||
open: function() {
|
||||
codiad.modal.load(this.termWidth, 'components/terminal/dialog.php');
|
||||
},
|
||||
|
||||
runCommand: function(c) {
|
||||
curTerminal = $('#terminal');
|
||||
if (c == 'clear') {
|
||||
curTerminal.html('');
|
||||
$('#term-command')
|
||||
.val('')
|
||||
.focus();
|
||||
} else {
|
||||
$('#term-command')
|
||||
.val('Processing...');
|
||||
$.get(this.controller + '?command=' + escape(c), function(data) {
|
||||
curTerminal.append('<pre class="output-command">>> ' + c + '</pre>');
|
||||
curTerminal.append('<pre class="output-data">' + data + '</pre>');
|
||||
curTerminal.scrollTop(
|
||||
curTerminal[0].scrollHeight - curTerminal.height() + 20);
|
||||
$('#term-command')
|
||||
.val('')
|
||||
.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
})(this, jQuery);
|
||||
})(this, jQuery);
|
||||
@@ -1,24 +0,0 @@
|
||||
#terminal-container { position: relative; background: #1a1a1a;
|
||||
box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, .9);
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#terminal, #term-command { background: transparent; border: none; color: #fff; font-family: monospace, sans-serif; margin: 0;
|
||||
border-radius: none;
|
||||
}
|
||||
|
||||
#terminal pre { border: none; box-shadow: none; background: none; margin: 0; padding: 0 12px; }
|
||||
.output-command { font-weight: bold; color: #7474e3; }
|
||||
.output-data { padding-bottom: 20px; }
|
||||
|
||||
#term-command { padding: 5px 0 5px 37px; }
|
||||
|
||||
#term-command-icon { position: absolute; color: #fff; font-family: monospace, sans-serif; margin: -19px 0 0 14px; }
|
||||
|
||||
#terminal:focus, #term-command:focus { border: none; outline: none; }
|
||||
|
||||
#terminal { height: 400px; line-height: 140%; overflow: scroll; }
|
||||
|
||||
#term-command, #term-command:focus { border-top: 1px dashed #666; }
|
||||
@@ -112,7 +112,7 @@
|
||||
<option value="0" <?php if(!$projects_assigned){ echo('selected="selected"'); } ?>>Access ALL Projects</option>
|
||||
<option value="1" <?php if($projects_assigned){ echo('selected="selected"'); } ?>>Only Selected Projects</option>
|
||||
</select>
|
||||
<div id="project_selector" <?php if(!$projects_assigned){ echo('style="display: none;"'); } ?>>
|
||||
<div id="project-selector" <?php if(!$projects_assigned){ echo('style="display: none;"'); } ?>>
|
||||
<table>
|
||||
<?php
|
||||
// Build list
|
||||
|
||||
@@ -134,13 +134,12 @@
|
||||
$('input:checkbox[name="project"]:checked').each(function(){
|
||||
projects.push($(this).val());
|
||||
});
|
||||
console.log(projects);
|
||||
if(accessLevel==0){ projects = 0; }
|
||||
// Check and make sure if access level not full that at least on project is selected
|
||||
if (accessLevel==1 && !projects) {
|
||||
codiad.message.error('At Least One Project Must Be Selected');
|
||||
} else {
|
||||
$.post(this.controller + '?action=project_access&username=' + username,{projects: projects}, function(data) {
|
||||
$.post(_this.controller + '?action=project_access&username=' + username,{projects: projects}, function(data) {
|
||||
var projectsResponse = codiad.jsend.parse(data);
|
||||
if (projectsResponse != 'error') {
|
||||
codiad.message.success('Account Modified');
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#project_selector { max-height: 250px; background: #404040;
|
||||
#project-selector { max-height: 250px; background: #404040;
|
||||
margin: 10px 0 5px 0;
|
||||
border-radius: 5px;
|
||||
box-shadow: inset 0px 0px 5px 0px rgba(0, 0, 0, .5);
|
||||
overflow: scroll;
|
||||
overflow: scroll;
|
||||
max-height: 200px;
|
||||
}
|
||||
|
||||
#project_selector table td { border: none; border-bottom: 1px solid #666; }
|
||||
#project_selector table tr:last-child td { border: none; }
|
||||
#project-selector table td { border: none; border-bottom: 1px solid #666; }
|
||||
#project-selector table tr:last-child td { border: none; }
|
||||
Reference in New Issue
Block a user