function print_jail($jail, $status) { // Get some information about this jail $sccmd = array("jail {$jail} autostart", "jail {$jail} type", "jail {$jail} tag"); $response = send_sc_query($sccmd); $jauto = $response["jail {$jail} autostart"]; $jtype = $response["jail {$jail} type"]; $jtag = $response["jail {$jail} tag"]; $jtag = substr($jtag, 8); if ($jauto == "true") { $autostatus = "Enabled"; } else { $autostatus = "Disabled"; } print "<tr>\n"; print " <td><a href=\"?p=jailinfo&jail={$jail}\" style=\"text-decoration: underline;\">{$jtag}</a></td>\n"; print " <td><a href=\"/?p=jails&autostart={$jail}\" style=\"text-decoration: underline;\">{$autostatus}</a></td>\n"; if ($status == "Running") { print " <td><a href=\"/?p=jails&toggle={$jail}&status={$status}\" style=\"color: green; text-decoration: underline;\">{$status}</a></td>\n"; } else { print " <td><a href=\"/?p=jails&toggle={$jail}&status={$status}\" style=\"color: red; text-decoration: underline;\">{$status}</a></td>\n"; } if ($status == "Running") { $dccmd = array("iocage getip4 {$jail}"); $response = send_dc_cmd($dccmd); $jip = $response["iocage getip4 {$jail}"]; print " <td>{$jip}</td>\n"; } else { print " <td></td>\n"; } print "</tr>\n"; }
$jailMsg = "Invalid jail name, no special chars allowed!"; } // Check if SSH is enabled if (!empty($_POST['sshd']) and $_POST['sshd'] == "checked") { $flags = "sshd"; $badData = true; $jailMsg = "SSH public key required!"; if (!empty($_POST['sshkey'])) { $badData = false; $sshpub = str_replace("\n", "", $_POST['sshkey']); $flags = "sshd ::::" . $sshpub . "::::"; } } if (!$badData) { $dccmd = array("iocage create {$jailname} {$flags}"); send_dc_cmd($dccmd); $showForm = false; ?> <h1>Jail Creation</h1> <br> <p>The jail, <?php echo "{$jailname}"; ?> , is queued for creation!</p><br> <a href="?p=jails">Back to Jails</a> <?php } // End of $badData } if ($showForm) { ?>
function display_jail_fstab_editor() { global $pbicdir; global $pbiorigin; global $jail; global $jailUrl; global $jailPath; // Get the jail path // Query the system for the running jail list $sccmd = array("jail {$jail} path"); $response = send_sc_query($sccmd); $jailPath = $response["jail {$jail} path"]; // Check for add action if (!empty($_POST['mount'])) { $cmd = "iocage addfstab {$jail} " . $_POST['mount']; $dccmd = array("{$cmd}"); $response = send_dc_cmd($dccmd); $adderror = $response["{$cmd}"]; } // Check for delete action if (!empty($_GET['delMnt'])) { $cmd = "iocage delfstab {$jail} " . $_POST['delMnt']; $dccmd = array("{$cmd}"); $response = send_dc_cmd($dccmd); $delerror = $response["{$cmd}"]; } // Get current fstab $cmd = "iocage getfstab {$jail} "; $dccmd = array("{$cmd}"); $response = send_dc_cmd($dccmd); $fstab = explode("\n", $response["{$cmd}"]); echo "<br>"; echo "{$adderror['0']}{$delerror['0']}"; echo "<table width=\"95%\"><tr><th></th><th></th></tr>"; echo "<form method=\"post\" action=\"?p=plugininfo&app=" . rawurlencode($pbiorigin) . "#tabs-fstab\">\n"; echo "<tr><td><input name=\"mount\" type=\"text\"></td><td><input type=\"submit\" value=\"Add\" class=\"btn-style\"></td></tr>"; echo "</form>"; // Now display the existing fstab lines if any foreach ($fstab as $mntline) { $mntarray = preg_split('/[\\s]+/', $mntline); if ($mntarray[0] == "nullfs" and "{$jailPath}{$mntarray['1']}" == "{$mntarray['2']}") { echo "<tr><td>{$mntarray['1']}</td><td><a href=\"?p=plugininfo&app=" . rawurlencode($pbiorigin) . "&delMnt=" . rawurlencode($mntarray[1]) . "#tabs-fstab\"><img src=\"images/application-exit.png\" height=32 width=32></a></td></tr>"; } } echo "</table></form>"; }
if ("{$page}" == "exportpbis") { require "pages/exportpbis.php"; exit(0); } // If we are on plugins section, make sure we have a start-end range if (stripos($page, "plugin") !== false) { if ($vimage == 1) { // Get the iocage pool $curpool = get_iocage_pool(); if (empty($curpool)) { $firstrun = true; $page = "pluginconfig"; } } else { $dccmd = array("iocage get ip4_autostart default", "iocage get ip4_autoend default"); $output = send_dc_cmd($dccmd); $ip4start = $output["iocage get ip4_autostart default"][0]; $ip4end = $output["iocage get ip4_autoend default"][0]; if (empty($ip4start) or empty($ip4end) or ($ip4start == "none" or $ip4end == "none")) { $firstrun = true; $page = "pluginconfig"; } } } // Set some globals for mobile detection $detect = new Mobile_Detect(); $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer'; $scriptVersion = $detect->getScriptVersion(); require "include/header.php"; if ($deviceType == "computer") { require "include/nav-computer.php";
function get_cfg_value($cfg) { global $pbicdir; $jail = "#system"; $jailUrl = "__system__"; $key = $cfg['key']; $default = $cfg['default']; $jid = "__system__"; // Talk to dispatcher to get config value $dccmd = array("getcfg {$pbicdir} {$jid} {$key}"); $output = send_dc_cmd($dccmd); if (!empty($output[0])) { return $output[0]; } return $default; }
function get_iocage_pool() { $dccmd = array("iocage activate"); $response = send_dc_cmd($dccmd); $rtn = explode("\n", $response["iocage activate"]); $rtn = explode(" ", $rtn[0]); return $rtn[1]; }
echo "<div id=\"status-working\"></div>"; } ?> <h1><center>Recent application actions</h1> <br> <table class="status" style="width:768px"> <tr> <th>Action</th> <th>Application</th> <th>Target</th> <th>Result</th> </tr> <?php $dccmd = array("results"); $response = send_dc_cmd($dccmd); $rarray = explode("\n", $response["results"]); // Loop through the results $rarray = array_reverse($rarray); foreach ($rarray as $res) { $results = explode(" ", $res); if (empty($results[0])) { continue; } if ($results[2] == "iocage") { echo "<tr><td>jail: {$results['3']}</td>"; echo "<td>{$results['4']}</td>"; echo "<td>{$results['5']}</td>"; echo "<td><a href=\"?p=dispatcher&log={$results['1']}\" style=\"text-decoration: underline;\">{$results['0']}</a></td></tr>"; } elseif ($results[2] == "pkgupdate") { $target = $results[3];