function disp_pia_daemon_box($tokens) { global $_settings; $settings = $_settings->get_settings(); $disp_body = ''; $fields = ''; //comma separate list of settings offered here $disp_body .= '<div class="box options">'; $disp_body .= '<form action="/?page=config&cmd=store_setting&cid=cnetwork" method="post">' . "\n"; $disp_body .= '<input type="hidden" name="store" value="daemon_settings">'; $disp_body .= '<h2>PIA Daemon Settings</h2>' . "\n"; $disp_body .= "<table>\n"; $fields .= 'DAEMON_ENABLED,'; $sel = array('id' => 'DAEMON_ENABLED', 'selected' => $settings['DAEMON_ENABLED'], 'onchange' => "toggle(this, 'MYVPN[0],MYVPN[1],MYVPN[2],MYVPN[3],MYVPN[4],MYVPN[5],MYVPN[6],MYVPN[7],MYVPN[8],MYVPN[9],MYVPN[10]', 'no', 'disabled', '');", array('yes', 'yes'), array('no', 'no')); $disp_body .= '<tr><td>Start after OS boot </td><td>' . build_select($sel) . '</td></tr>' . "\n"; //Failover connection selection - fix hard coded loop later $fovers = 0; $fields .= 'MYVPN,'; for ($x = 0; $x < 30; ++$x) { if (array_key_exists('MYVPN[' . $x . ']', $settings) === true) { if ($settings['DAEMON_ENABLED'] === 'no') { $ovpn = VPN_get_connections('MYVPN[' . $x . ']', array('selected' => $settings['MYVPN[' . $x . ']'], 'disabled' => '', array('', ''))); //empty array creates a space between the default selection } else { $ovpn = VPN_get_connections('MYVPN[' . $x . ']', array('selected' => $settings['MYVPN[' . $x . ']'], array('', ''))); //empty array creates a space between the default selection } $disp_body .= '<tr><td>Failover ' . $x . '</td><td>' . $ovpn . '</td></tr>' . "\n"; ++$fovers; } } if ($settings['DAEMON_ENABLED'] === 'no') { $ovpn = VPN_get_connections('MYVPN[' . $fovers . ']', array('initial' => 'empty', 'disabled' => '')); } else { $ovpn = VPN_get_connections('MYVPN[' . $fovers . ']', array('initial' => 'empty')); } $disp_body .= '<tr><td>Add Failover</td><td>' . $ovpn . '</td></tr>' . "\n"; $disp_body .= "</table>\n"; $disp_body .= '<input type="hidden" name="store_fields" value="' . rtrim($fields, ',') . '">'; $disp_body .= '<br><input type="submit" name="store settings" value="Store Settings">'; $disp_body .= '<input type="hidden" name="token" value="' . $tokens[0] . '">'; $disp_body .= '</form>'; $disp_body .= '</div>'; return $disp_body; }
/** * returns the default UI for this page * @return string string with HTML for body of this page */ function disp_default() { global $_token; global $settings; $disp_body = ''; /* show VM network and VPN overview */ //VPN control UI $disp_body .= '<noscript><p>please enable javascript to activate the advanced UI</p></noscript>'; $disp_body .= '<div id="overview_net_control">'; $disp_body .= '<h2>Network Control</h2>'; $pass = array('handle user request - establish or disconnect VPN'); $tokens = $_token->pgen($pass); $disp_body .= '<form id="frm_vpn_connection" class="inline" action="/" method="post">'; $disp_body .= '<input type="hidden" name="cmd" value="network_control">'; $disp_body .= '<table class="control_box">'; $disp_body .= '<tr>'; $disp_body .= '<td>'; $disp_body .= VPN_get_connections('vpn_connections', array('initial' => 'Connect To', 'onchange' => 'vpn_connect();')) . "\n"; // Connect VPN $disp_body .= '</td>'; $disp_body .= '<td id="ele_vpn_connect">'; $disp_body .= ' <input type="submit" name="vpn_connect" value="Connect VPN">'; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="vpn_disconnect" value="Disconnect VPN">'; $disp_body .= '</td>'; $disp_body .= '</tr>'; $disp_body .= '</table>'; $disp_body .= '<input type="hidden" name="token" value="' . $tokens[0] . '">'; $disp_body .= " </form>\n"; $pass = array('handle user request - start or stop pia-daemon'); $tokens = $_token->pgen($pass); $disp_body .= '<form class="inline" action="/" method="post">'; $disp_body .= '<input type="hidden" name="cmd" value="network_control">'; $disp_body .= '<table class="control_box">'; $disp_body .= '<tr>'; $disp_body .= '<td id="ele_daemon_lbl">PIA VPN Daemon</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="daemon_start" value="Start pia-daemon">'; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="daemon_stop" value="Stop pia-daemon">'; $disp_body .= '</td>'; $disp_body .= '</tr>'; $disp_body .= '</table>'; $disp_body .= '<input type="hidden" name="token" value="' . $tokens[0] . '">'; $disp_body .= " </form>\n"; if ($settings['SOCKS_INT_ENABLED'] == 'yes' || $settings['SOCKS_EXT_ENABLED'] == 'yes') { $pass = array('handle user request - start or restart SOCKS proxy'); $tokens = $_token->pgen($pass); $disp_body .= '<form id="frm_socks_proxy" class="inline" action="/" method="post">'; $disp_body .= '<input type="hidden" name="cmd" value="socks_proxy_control">'; $disp_body .= '<table class="control_box">'; $disp_body .= '<tr>'; $disp_body .= '<td id="ele_socks_lbl">'; $disp_body .= "SOCKS5 Proxy\n"; $disp_body .= '</td>'; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="socks_start" value="Start Proxy Server">'; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="socks_stop" value="Stop Proxy Server">'; $disp_body .= '</td>'; $disp_body .= '</tr>'; $disp_body .= '</table>'; $disp_body .= '<input type="hidden" name="token" value="' . $tokens[0] . '">'; $disp_body .= " </form>\n"; } //firewall control UI $pass = array('handle user request - start or stop the firewall'); $tokens = $_token->pgen($pass); $disp_body .= '<form class="inline" action="/" method="post">'; $disp_body .= '<input type="hidden" name="cmd" value="firewall_control">'; $disp_body .= '<table class="control_box">'; $disp_body .= '<tr>'; $disp_body .= '<td id="ele_firewall_lbl">'; $disp_body .= "Firewall\n"; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="firewall_enable" value="Restart Firewall">'; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="firewall_disable" value="Stop Forwarding">'; $disp_body .= '</td>'; $disp_body .= '</tr>'; $disp_body .= '</table>'; $disp_body .= '<input type="hidden" name="token" value="' . $tokens[0] . '">'; $disp_body .= "</form>\n"; //OS control UI $pass = array('handle user request - shutdown or reboot the OS'); $tokens = $_token->pgen($pass); $disp_body .= '<form class="inline" action="/" method="post">'; $disp_body .= '<input type="hidden" name="cmd" value="os_control">'; $disp_body .= '<table class="control_box">'; $disp_body .= '<tr>'; $disp_body .= '<td> </td><td> </td>'; //empty row to move buttons out of the way $disp_body .= '</tr>'; $disp_body .= '<tr>'; $disp_body .= '<td id="ele_os_lbl">'; $disp_body .= "Operating System\n"; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="vm_restart" value="Restart PIA-VM">'; $disp_body .= '</td>'; $disp_body .= '<td>'; $disp_body .= ' <input type="submit" name="vm_shutdown" value="Shutdown PIA-VM">'; $disp_body .= '</td>'; $disp_body .= '</tr>'; $disp_body .= '</table>'; $disp_body .= '<input type="hidden" name="token" value="' . $tokens[0] . '">'; $disp_body .= "</form>\n"; $disp_body .= "</div>\n"; /* show system status */ $disp_body .= '<div id="overview_net_status">'; $disp_body .= '<h2>System Status</h2>'; $disp_body .= '<div id="system_status">' . VM_get_status() . '</div>'; $disp_body .= "</div>\n"; $disp_body .= '<script type="text/javascript">' . 'var timr1=setInterval(function(){' . 'var _overview = new OverviewObj();' . '_overview.refresh_status();' . '_overview.clean_feedback();' . '},' . $settings['WEB_UI_REFRESH_TIME'] . ');' . 'var _overview = new OverviewObj();' . '_overview.set_js_network_control();' . '/* handle the "connect" event on the overview page */ function vpn_connect(){ var submit_form = document.getElementById(\'frm_vpn_connection\'); var ele_conn = document.createElement((\'input\')); ele_conn.setAttribute(\'type\', \'hidden\'); ele_conn.setAttribute(\'name\', \'vpn_connect\'); submit_form.appendChild(ele_conn); submit_form.submit(); }' . '</script>'; return $disp_body; }