function jail_menu() { global $jname; $str = <<<EOF <a href="javascript:location.reload(true)">[ Refresh Page ]</a> | <a href="jconfig.php?jname={$jname}">[ Config ]</a> | EOF; $res = cbsd_cmd('env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd imghelper header=0'); if ($res['retval'] != 0) { if (!empty($res['error_message'])) { echo $res['error_message']; } exit(1); } $lst = explode("\n", $res['message']); $n = 0; if (!empty($lst)) { foreach ($lst as $item) { $str .= <<<EOF <a href="img_helper_cfg.php?jname={$jname}&helper={$item}">[ {$item} ]</a> | EOF; } } echo $str; echo "<hr>"; }
function updateNetInfo($post) { $keys = array('nic', 'ip4', 'mask4', 'gw4', 'ip6', 'mask6', 'gw6'); $arr = array(); $arr[] = 'nic="' . $post['iface'] . '"'; foreach ($post as $key => $val) { if (in_array($key, $keys)) { if (!empty($val)) { $arr[] = $key . '="' . $val . '"'; } } } $txt = join(' ', $arr); $myCMD = CBSD_CMD . " wb_netcfg mode=update " . $txt; echo $myCMD; //$buf=htmlentities( shell_exec($myCMD) ); $res = cbsd_cmd($myCMD); $buf = $res['message']; $arr = explode(PHP_EOL, trim($buf)); // print_r($arr); // exit; }
{ $tpl = ''; switch ($el) { case 'inputbox': $tpl = '<div class="form-field"><input type="text" name="${param}" value="${value}" ${attr}${required} /><span class="small">${desc}</span></div>'; break; case 'delimer': $tpl = '<h1>${desc}</h1>'; break; } return $tpl; } function setButtons($arr = array()) { echo '<div class="buttons"><input type="button" value="Apply" /> <input type="button" value="Cancel" /></div>'; } } if ($mode == "install") { echo "INSTALL"; # $res=cbsd_cmd('env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd task owner=cbsdweb autoflush=2 mode=new env NOCOLOR=1 /usr/local/bin/cbsd imghelper module=$hlper jname=$jname inter=0'); $res = cbsd_cmd("env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd task owner=cbsdweb mode=new env NOCOLOR=1 /usr/local/bin/cbsd imghelper module={$helper} jname={$jname} inter=0"); exit(0); } $jail_form = $workdir . "/jails-system/" . $jname . "/helpers/" . $helper . ".sqlite"; if (file_exists($jail_form)) { $form = new Forms($helper); $form->generate(); //$form->setButtons(array('apply','cancel')); } else { echo "Module not installed for {$jname}. Please <a href='/img_helper_cfg.php?jname={$jname}&mode=install&helper={$helper}'>install module</a>"; }
<?php define('CBSD_CMD', 'env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd '); echo '<pre>'; print_r(cbsd_cmd('jstart inter=0 jname=jail17')); function cbsd_cmd($cmd) { $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'r')); //echo self::CBSD_CMD.' '.$cmd;exit; $process = proc_open(CBSD_CMD . $cmd, $descriptorspec, $pipes, null, null); $error = false; $error_message = ''; if (is_resource($process)) { $buf = stream_get_contents($pipes[1]); fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); $return_value = proc_close($process); if ($return_value != 0) { $error = true; $error_message = $buf; } return array('cmd' => $cmd, 'retval' => $return_value, 'error' => $error, 'error_message' => $error_message); } }