Skip to content

Commit

Permalink
Added command module, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
noccy80 committed Dec 16, 2016
1 parent c59e36a commit e68e53a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ function config_write() {

$items = $root->createChild("items");
foreach ($_CONFIG['items'] as $item) {
$opts = array_map(function ($opt) { return $opt->name; }, $_MODULES[$item[0]]->opts);
$conf = $items->createChild($item[0]);
$conf->setValue($item[1]);
$opts = array_map(function ($opt) { return $opt->name; }, $_MODULES[$item[1]]->opts);
$conf = $items->createChild($item[1]);
$conf->setValue($item[0]);
foreach ($item[2] as $k=>$v) {
if (in_array($k,$opts)) {
$conf->setAttribute($k,$v);
Expand Down Expand Up @@ -99,7 +99,7 @@ function config_item_edit($name, array $attr) {
global $_CONFIG;
$filtered = [];
foreach ($_CONFIG['items'] as $item) {
if ($item[1]==$name) {
if ($item[0]==$name) {
$item[2] = array_merge($item[2],$attr);
}
$filtered[] = $item;
Expand Down
19 changes: 19 additions & 0 deletions modules/command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

define("COMMAND_CLASS", "class");
define("COMMAND_EXEC", "exec");

function _command(array $opts) {
$attr = [
'class' => $opts[COMMAND_CLASS]
];
if (($exec = $opts[COMMAND_EXEC])) {
$output = trim(exec($exec));
} else {
$output = null;
}
return panel($output, $attr, 'command');
}
module("command", "Execute a command and display the output");
option("exec",COMMAND_EXEC,OPT_TYPE_STRING,"Command to execute","");
option("class",COMMAND_CLASS,OPT_TYPE_STRING,"The class to use","system");

0 comments on commit e68e53a

Please sign in to comment.