function page()
{
    $cf = new dnsmasq();
    $page = CurrentPageName();
    $sys = new systeminfos();
    $sys->array_interfaces[null] = '{select}';
    $sys->array_tcp_addr[null] = '{select}';
    $interfaces = Field_array_Hash($sys->array_interfaces, 'interfaces', null);
    $tcpaddr = Field_array_Hash($sys->array_tcp_addr, 'listen_addresses', null);
    $html = "\n<p>{dnsmasq_intro_settings}</p>\n<form name='ffm1'>\n<table style='width:100%'>\n<input type='hidden' name='SaveConf1' value='yes'>\n<tr>\n<td align='right' valign='top' class=bottom style='font-weight:bold' class=bottom>{domain-needed}:</td>\n<td align='left' valign='top' class=bottom class=bottom >" . Field_key_checkbox_img('domain-needed', $cf->main_array["domain-needed"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{domain-needed_text}</td>\n</tr>\n<tr>\n<td align='right' valign='top' class=bottom style='font-weight:bold' class=bottom>{expand-hosts}:</td>\n<td align='left' valign='top' class=bottom class=bottom >" . Field_key_checkbox_img('expand-hosts', $cf->main_array["expand-hosts"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{expand-hosts_text}</td>\n</tr>\n\n\n<tr>\n<td align='right' valign='top' class=bottom style='font-weight:bold'>{bogus-priv}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('bogus-priv', $cf->main_array["bogus-priv"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{bogus-priv_text}</td>\n</tr>\n<tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold'>{filterwin2k}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('filterwin2k', $cf->main_array["filterwin2k"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{filterwin2k_text}</td>\n</tr>\n<tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold'>{strict-order}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('strict-order', $cf->main_array["strict-order"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{strict-order_text}</td>\n</tr>\n\n<tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold'>{no-resolv}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('no-resolv', $cf->main_array["no-resolv"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{no-resolv_text}</td>\n</tr>\n<tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold'>{no-negcache}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('no-negcache', $cf->main_array["no-negcache"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{no-negcache_text}</td>\n</tr>\n\n\n\n<tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold'>{no-poll}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('no-poll', $cf->main_array["no-poll"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{no-poll_text}</td>\n</tr>\n\n<tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold'>{log-queries}:</td>\n<td align='left' valign='top' class=bottom>" . Field_key_checkbox_img('log-queries', $cf->main_array["log-queries"], '{enable_disable}') . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{log-queries_text}</td>\n</tr>\n\n\n\n</table>\n\n<table style='width:100%'>\n</tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold' nowrap>{resolv-file}:</td>\n<td align='left' valign='top' class=bottom>" . Field_text('resolv-file', $cf->main_array["resolv-file"]) . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{resolv-file_text}</td>\n</tr>\n</tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold' nowrap>{cache-size}:</td>\n<td align='left' valign='top' class=bottom>" . Field_text('cache-size', $cf->main_array["cache-size"]) . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{cache-size_text}</td>\n</tr>\n\n</tr>\n<td align='right' valign='top' class=bottom valign='top' class=bottom style='font-weight:bold' nowrap>{dnsmasq_domain}:</td>\n<td align='left' valign='top' class=bottom>" . Field_text('domain', $cf->main_array["domain"]) . "</td>\n<td align='left' valign='top' class=bottom style='font-size:9px'>{dnsmasq_domain_text}</td>\n</tr>\n\n</tr>\n<td colspan=3 align='right'><input type='button' value='{edit}&nbsp;&raquo;' OnClick=\"javascript:ParseForm('ffm1','{$page}',true);\"></td>\n</tr>\n</table>\n</form>\n\n<H4>{dnmasq_interface}</H4>\n<p>{dnmasq_interface_text}</p>\n<form name='ffm2'>\n<table style='width:130px'><tr><td>{$interfaces}&nbsp;</td><td><input type='button' value='{add}&nbsp;&raquo;' OnClick=\"javascript:ParseForm('ffm2','{$page}',true);InterfacesReload()\" style='margin:0px;'></td></tr></table>\n</form>\n<div id='dnmasq_interface'>" . LoadInterfaces() . "</div>\n\n\n<H4>{dnsmasq_listen_address}</H4>\n<p>{dnsmasq_listen_address_text}</p>\n<form name='ffm21'>\n<table style='width:170px'><tr><td>{$tcpaddr}&nbsp;</td><td><input type='button' value='{add}&nbsp;&raquo;' OnClick=\"javascript:ParseForm('ffm21','{$page}',true);ListentAddressesReload()\" style='margin:0px;'></td></tr></table>\n</form>\n<div id='dnsmasq_listen_address'>" . LoadListenAddress() . "</div>\n\n\n\n<H4>{dnsmasq_address}</h4>\n<p>{dnsmasq_address_text}</p>\n<center>\n<form name='ffm3'>\n<table style='width:100%'>\n<tr>\n\t<td nowrap><strong>{domain_or_server}</strong></td>\n\t<td>" . Field_text('address_server') . "</td>\n\t<td nowrap><strong>{ip}</strong>\n\t<td>" . Field_text('address_ip') . "</td>\n\t<td><input type='button' value='{add}&nbsp;&raquo;' OnClick=\"javascript:ParseForm('ffm3','{$page}',true);addressesReload();\"></td>\n\t</tr>\n\t</table>\n\t</center>\n</form>\n<div id='array_addresses'>" . Loadaddresses() . "</div>\n";
    $JS["JS"][] = 'js/dnsmasq.js';
    $tpl = new template_users('{dnsmasq_settings}', $html, 0, 0, 0, 0, $JS);
    echo $tpl->web_page;
}
Esempio n. 2
0
function page()
{
    $cf = new dnsmasq();
    $page = CurrentPageName();
    $tpl = new templates();
    $sys = new systeminfos();
    $sys->array_interfaces[null] = '{select}';
    $sys->array_tcp_addr[null] = '{select}';
    $interfaces = Field_array_Hash($sys->array_interfaces, 'interfaces', null, "style:font-size:14px;padding:3px;");
    $tcpaddr = Field_array_Hash($sys->array_tcp_addr, 'listen_addresses', null, "style:font-size:14px;padding:3px;");
    $sock = new sockets();
    $EnableDNSMASQ = $sock->GET_INFO("EnableDNSMASQ");
    if (!is_numeric($EnableDNSMASQ)) {
        $EnableDNSMASQ = 1;
    }
    $EnableDNSMASQLDAPDB = $sock->GET_INFO("EnableDNSMASQLDAPDB");
    if (!is_numeric($EnableDNSMASQLDAPDB)) {
        $EnableDNSMASQLDAPDB = 0;
    }
    $f[] = "domain-needed";
    $f[] = "expand-hosts";
    $f[] = "bogus-priv";
    $f[] = "filterwin2k";
    $f[] = "strict-order";
    $f[] = "no-resolv";
    $f[] = "no-negcache";
    $f[] = "no-poll";
    $f[] = "log-queries";
    while (list($index, $key) = each($f)) {
        if ($cf->main_array[$key] == "yes") {
            $cf->main_array[$key] = 1;
        } else {
            $cf->main_array[$key] = 0;
        }
        $js[] = "if(document.getElementById('{$key}').checked){XHR.appendData('{$key}','yes');\t}else{XHR.appendData('{$key}','no');}";
    }
    // kill -USR1 17226
    $html = "\n<table style='width:100%'>\n<tr>\n<td width=1% valign='top'><div id='get-status'></div></td>\n<td width=99% valign='top'>\n<div class=explain id='dnsmaskrool'>{dnsmasq_intro_settings}</div>\n<div style='text-align:right'>\n\t" . imgtootltip("refresh-24.png", "{refresh}", "LoadAjax('get-status','{$page}?get-status=yes');") . "\n</div>\n</td>\n</tr>\n</table>\n<table style='width:100%' class=form>\n<tr>\n\t<td align='right' valign='top' class=legend>{EnableDNSMASQ}:</td>\n\t<td align='left' valign='top'>" . Field_checkbox("EnableDNSMASQ", 1, $EnableDNSMASQ, "EnableDNSMASQSave()") . "</td>\n\t<td align='left' valign='top'  width=1%>" . help_icon("{EnableDNSMASQ_explain}") . "</td>\n</tr>\n<tr>\n\t<td align='right' valign='top' class=legend>{EnableDNSMASQLDAPDB}:</td>\n\t<td align='left' valign='top'>" . Field_checkbox("EnableDNSMASQLDAPDB", 1, $EnableDNSMASQLDAPDB, "EnableDNSMASQSave()") . "</td>\n\t<td align='left' valign='top'  width=1%>" . help_icon("{EnableDNSMASQLDAPDB_explain}") . "</td>\n</tr>\n</table>\n\n<div id='ffm1'></div>\n\n<div style='font-size:16px'>{interface}</div>\n<div class=explain>{dnmasq_interface_text}</div>\n<form name='ffm2'>\n<center>\n<table style='width:130px'>\n\t<tr><td valign='middle'>{$interfaces}</td>\n\t<td valign='middle'>" . button("{add}", "ParseForm('ffm2','{$page}',true);InterfacesReload()") . "</td>\n\t</tr>\n</table>\n</center>\n</form>\n<div id='dnmasq_interface'>" . LoadInterfaces() . "</div>\n\n<p>&nbsp;</p>\n<div style='font-size:16px'>{dnsmasq_listen_address}</div>\n<div class=explain>{dnsmasq_listen_address_text}</div>\n\n<form name='ffm21'>\n<center>\n<table style='width:170px'>\n\t<tr>\n\t\t<td>{$tcpaddr}</td>\n\t\t<td>" . button("{add}", "ParseForm('ffm21','{$page}',true);ListentAddressesReload()") . "</td>\n\t</tr>\n</table>\n</center>\n</form>\n<div id='dnsmasq_listen_address'>" . LoadListenAddress() . "</div>\n\n\n\n\n\n\n<script>\n\n\tvar x_SaveDNSMASQMainConf= function (obj) {\n\t\tvar tempvalue=obj.responseText;\n\t\tif(tempvalue.length>3){alert(tempvalue);}\t\n\t\tRefreshMainForm();\n\t}\n\n\tfunction SaveDNSMASQMainConf(){\n\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('resolv-file',document.getElementById('resolv-file').value);\n\t\tXHR.appendData('cache-size',document.getElementById('cache-size').value);\n\t\tXHR.appendData('domain',document.getElementById('dnsmasq-domain').value);\n\t\tXHR.appendData('SaveConf1','yes');\t\t\n\t\t" . @implode("\n", $js) . "\n\t\tAnimateDiv('ffm1');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveDNSMASQMainConf);\n\t\t\n\t\n\t}\n\n\n\tvar x_EnableDNSMASQSaveBack= function (obj) {\n\t\tRefreshTab('main_config_dnsmasq');\n\t\tvar tempvalue=obj.responseText;\n\t\tif(tempvalue.length>3){alert(tempvalue);}\t\n\t\tLoadjs('dnsmasq.index.php');\n\t\t\n\t}\t\t\n\t\n\tfunction EnableDNSMASQSave(key){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('EnableDNSMASQ').checked){XHR.appendData('EnableDNSMASQ',1);\t}else{XHR.appendData('EnableDNSMASQ',0);}\n\t\tif(document.getElementById('EnableDNSMASQLDAPDB').checked){XHR.appendData('EnableDNSMASQLDAPDB',1);\t}else{XHR.appendData('EnableDNSMASQLDAPDB',0);}\n\t\tAnimateDiv('dnsmaskrool');\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_EnableDNSMASQSaveBack);\n\t}\n\n\tfunction RefreshMainForm(){\n\t\tLoadAjax('ffm1','{$page}?ffm1=yes');\n\t}\n\t\n\t\n\tLoadAjax('get-status','{$page}?get-status=yes');\n\t\n</script>\n\n";
    echo $tpl->_ENGINE_parse_body($html);
}
Esempio n. 3
0
function page(){

	$cf=new dnsmasq();
	$page=CurrentPageName();
	$tpl=new templates();
	$sys=new systeminfos();
	$sys->array_interfaces[null]='{select}';
	$sys->array_tcp_addr[null]='{select}';
	$interfaces=Field_array_Hash($sys->array_interfaces,'interfaces',null,"style:font-size:14px;padding:3px;");
	$tcpaddr=Field_array_Hash($sys->array_tcp_addr,'listen_addresses',null,"style:font-size:14px;padding:3px;");
	$sock=new sockets();
	$EnableDNSMASQ=$sock->GET_INFO("EnableDNSMASQ");
	if(!is_numeric($EnableDNSMASQ)){$EnableDNSMASQ=1;}
	// kill -USR1 17226
$html="
<table style='width:100%'>
<tr>
<td width=1% valign='top'><div id='get-status'></div></td>
<td width=99% valign='top'>
<div class=explain id='dnsmaskrool'>{dnsmasq_intro_settings}</div>
</td>
</tr>
</table>
<table style='width:100%' class=form>
<tr>
	<td align='right' valign='top' class=legend>{EnableDNSMASQ}:</td>
	<td align='left' valign='top'>". Field_checkbox("EnableDNSMASQ",1,$EnableDNSMASQ,"EnableDNSMASQSave()")."</td>
	<td align='left' valign='top'  width=1%>". help_icon("{EnableDNSMASQ_explain}")."</td>
</tr>
</table>

<form name='ffm1'>
<table style='width:100%' class=form>
<input type='hidden' name='SaveConf1' value='yes'>

<tr>
	<td align='right' valign='top' class=legend>{domain-needed}:</td>
	<td align='left' valign='top'>" . Field_key_checkbox_img('domain-needed',$cf->main_array["domain-needed"],'{enable_disable}')."</td>
	<td align='left' valign='top'  width=1%>". help_icon("{domain-needed_text}")."</td>
</tr>
<tr>
<td align='right' valign='top' class=legend>{expand-hosts}:</td>
<td align='left' valign='top'   >" . Field_key_checkbox_img('expand-hosts',$cf->main_array["expand-hosts"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{expand-hosts_text}")."</td>
</tr>


<tr>
<td align='right' valign='top' class=legend>{bogus-priv}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('bogus-priv',$cf->main_array["bogus-priv"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{bogus-priv_text}")."</td>
</tr>
<tr>
<td align='right' valign='top'  valign='top'  class=legend>{filterwin2k}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('filterwin2k',$cf->main_array["filterwin2k"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{filterwin2k_text}")."</td>
</tr>
<tr>
<td align='right' valign='top'  valign='top'  class=legend>{strict-order}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('strict-order',$cf->main_array["strict-order"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{strict-order_text}")."</td>
</tr>

<tr>
<td align='right' valign='top'  valign='top' class=legend >{no-resolv}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('no-resolv',$cf->main_array["no-resolv"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{no-resolv_text}")."</td>
</tr>
<tr>
<td align='right' valign='top'  valign='top'  class=legend>{no-negcache}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('no-negcache',$cf->main_array["no-negcache"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{no-negcache_text}")."</td>
</tr>



<tr>
<td align='right' valign='top'  valign='top'  class=legend>{no-poll}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('no-poll',$cf->main_array["no-poll"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{no-poll_text}")."</td>
</tr>

<tr>
<td align='right' valign='top'  valign='top'  class=legend>{log-queries}:</td>
<td align='left' valign='top' >" . Field_key_checkbox_img('log-queries',$cf->main_array["log-queries"],'{enable_disable}')."</td>
<td align='left' valign='top'  width=1%>". help_icon("{log-queries_text}")."</td>
</tr>



</table>

<table style='width:100%'>
</tr>
<td align='right' valign='top'  valign='top'   nowrap class=legend>{resolv-file}:</td>
<td align='left' valign='top' >" . Field_text('resolv-file',$cf->main_array["resolv-file"],"font-size:13px;padding:3px;")."</td>
<td align='left' valign='top'  >". help_icon("{resolv-file_text}")."</td>
</tr>
</tr>
<td align='right' valign='top'  valign='top'   nowrap class=legend>{cache-size}:</td>
<td align='left' valign='top' >" . Field_text('cache-size',$cf->main_array["cache-size"],"font-size:13px;padding:3px;width:70px")."</td>
<td align='left' valign='top'  >". help_icon("{cache-size_text}")."</td>
</tr>

</tr>
<td align='right' valign='top'  valign='top'   nowrap class=legend>{domain}:</td>
<td align='left' valign='top' >" . Field_text('domain',$cf->main_array["domain"],"font-size:13px;padding:3px;")."</td>
<td align='left' valign='top'  >". help_icon("{dnsmasq_domain_explain}")."</td>
</tr>

</tr>
<td colspan=3 align='right'><hr>". button("{apply}","ParseForm('ffm1','$page',true);")."</td>
</tr>
</table>
</form>

<div style='font-size:16px'>{interface}</div>
<div class=explain>{dnmasq_interface_text}</div>
<form name='ffm2'>
<center>
<table style='width:130px'>
	<tr><td valign='middle'>$interfaces</td>
	<td valign='middle'>". button("{add}","ParseForm('ffm2','$page',true);InterfacesReload()")."</td>
	</tr>
</table>
</center>
</form>
<div id='dnmasq_interface'>" . LoadInterfaces() . "</div>

<p>&nbsp;</p>
<div style='font-size:16px'>{dnsmasq_listen_address}</div>
<div class=explain>{dnsmasq_listen_address_text}</div>
<form name='ffm21'>
<center>
<table style='width:170px'>
	<tr>
		<td>$tcpaddr</td>
		<td>". button("{add}","ParseForm('ffm21','$page',true);ListentAddressesReload()")."</td>
	</tr>
</table>
</center>
</form>
<div id='dnsmasq_listen_address'>" . LoadListenAddress() . "</div>






<script>

	var x_EnableDNSMASQSaveBack= function (obj) {
		RefreshTab('main_config_dnsmasq');
		var tempvalue=obj.responseText;
		if(tempvalue.length>0){alert(tempvalue);}	
		
	}		
	
	function EnableDNSMASQSave(key){
		var XHR = new XHRConnection();
		if(document.getElementById('EnableDNSMASQ').checked){
			XHR.appendData('EnableDNSMASQ',1);	
		}else{
			XHR.appendData('EnableDNSMASQ',0);	
		}
		document.getElementById('dnsmaskrool').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';
		XHR.sendAndLoad('$page', 'GET',x_EnableDNSMASQSaveBack);
	}	
	
	
	LoadAjax('get-status','$page?get-status=yes');
	
</script>

";
	
echo $tpl->_ENGINE_parse_body($html);
	
}