|
<? |
|
require_once("secrets.inc.php"); |
|
require_once("cjdns.inc.php"); |
|
|
|
$cjdns = new cjdns; |
|
$cjdns->connect(); |
|
if(isset($_REQUEST['action'])) { |
|
if(isset($_REQUEST['args'])) { |
|
# echo json_encode($cjdns->call($_REQUEST['action'], json_decode($_REQUEST['args'], TRUE))); |
|
echo print_r($cjdns->call($_REQUEST['action'], json_decode($_REQUEST['args'], TRUE))); |
|
} else { |
|
echo json_encode($cjdns->call($_REQUEST['action'])); |
|
} |
|
} else { |
|
$tabsnav = ""; |
|
$tabscontent = ""; |
|
$active = TRUE; |
|
foreach($cjdns->functionlist() as $function => $args) { |
|
if($function != "isDct") { |
|
if($active) { |
|
$tabsnav .= " <li class=\"active\"><a href=\"#$function\" data-toggle=\"tab\">$function</a></li>\n"; |
|
$tabscontent .= "<div class=\"tab-pane active\" id=\"$function\">\n"; |
|
$active = FALSE; |
|
} else { |
|
$tabsnav .= " <li><a href=\"#$function\" data-toggle=\"tab\">$function</a></li>\n"; |
|
$tabscontent .= "<div class=\"tab-pane\" id=\"$function\">\n"; |
|
} |
|
$tabscontent .= " <form class=\"form-horizontal\" action=\"index.php\" method=\"POST\" id=\"$function-form\" onsubmit=\"cjdnsadmin('$function',this,event)\">\n"; |
|
foreach($args as $arg=>$info) { |
|
if($arg != "isDct") { |
|
$required = ""; |
|
if($info['required'] == 1) { |
|
$required = "<font color=\"#FF0000\">*</font>"; |
|
} |
|
$tabscontent .= " <div class=\"control-group\">\n"; |
|
$tabscontent .= " <label class=\"control-label\" for=\"$arg\">".$arg.$required."</label>\n"; |
|
$tabscontent .= " <div class=\"controls\">\n"; |
|
$tabscontent .= " <input type=\"text\" class=\"input\" placeholder=\"".$info['type']."\" name=\"$arg\" id=\"$arg\"/>\n"; |
|
$tabscontent .= " </div>\n"; |
|
$tabscontent .= " </div>\n"; |
|
} |
|
} |
|
$tabscontent .= " <div class=\"form-actions\">\n"; |
|
$tabscontent .= " <button class=\"btn btn-success\">Execute</button>\n"; |
|
$tabscontent .= " <button class=\"btn\">Reset</button>\n"; |
|
$tabscontent .= " </div>\n"; |
|
$tabscontent .= " </form>\n"; |
|
$tabscontent .= " <div id=\"$function-output\" class=\"well\" style=\"display: none\"></div>\n"; |
|
$tabscontent .= "</div>\n"; |
|
} |
|
} ?><html> |
|
<head> |
|
<title>CJDNS GUI</title> |
|
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> |
|
<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet"> |
|
</head> |
|
<body> |
|
<br /><br /> |
|
<div class="content"> |
|
<div class="tabbable tabs-left span10"> |
|
<? |
|
echo "<ul class=\"nav nav-tabs\" id=\"functions\">\n".$tabsnav."</ul>\n"; |
|
echo "<div class=\"tab-content\">\n".$tabscontent."</div>\n"; |
|
?> |
|
</div> |
|
</div> |
|
<script src="bootstrap/js/jquery.js" type="text/javascript"></script> |
|
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script> |
|
<script src="bootstrap/js/bootstrap-tabs.js" type="text/javascript"></script> |
|
<script type="text/javascript">var functions = <? echo json_encode($cjdns->functionlist()); ?></script> |
|
<script src="js/gui.js" type="text/javascript"></script> |
|
</body> |
|
</html><? |
|
} |
|
|
|
$cjdns->disconnect(); |
|
|
|
?> |