forked from dtouzeau/artica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnsmasq.records.settings.php
139 lines (124 loc) · 4.71 KB
/
dnsmasq.records.settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.dnsmasq.inc');
include_once('ressources/class.main_cf.inc');
$usersmenus=new usersMenus();
if($usersmenus->AsPostfixAdministrator==false){header('location:users.index.php');exit;}
if(isset($_GET["othersoptions"])){othersoptions();exit;}
if(isset($_GET["mxrecdomainfrom"])){SaveConfMx();exit;}
if(isset($_GET["mxHostsReload"])){echo Loadmxhosts();exit;}
if(isset($_GET["DnsmasqDeleteMxHost"])){DnsmasqDeleteMxHost();exit;}
if(isset($_GET["DnsMasqMxMove"])){DnsMasqMxMove();exit;}
page();
function page(){
$cf=new dnsmasq();
$page=CurrentPageName();
$html="
<H4>{others_options}</H4>
<form name='fmm1'>
<input type='hidden' name='othersoptions' value='yes'>
<center>
<table style='width:100%'>
<tr>
<td align='right' valign='top' class=bottom style='font-weight:bold' class=bottom>{localmx}:</td>
<td align='left' valign='top' class=bottom class=bottom >" . Field_key_checkbox_img('localmx',$cf->main_array["localmx"],'{enable_disable}')."</td>
<td align='left' valign='top' class=bottom style='font-size:9px'>{localmx_text}</td>
</tr>
<tr>
<td align='right' valign='top' class=bottom style='font-weight:bold' class=bottom>{selfmx}:</td>
<td align='left' valign='top' class=bottom class=bottom >" . Field_key_checkbox_img('selfmx',$cf->main_array["selfmx"],'{enable_disable}')."</td>
<td align='left' valign='top' class=bottom style='font-size:9px'>{selfmx_text}</td>
</tr>
</table>
<table style='width:100%'>
<tr>
<td nowrap>{mx-target}</td>
<td><strong>" . Field_text('mx-target',$cf->main_array["mx-target"]) . "</td>
<td style='font-size:9px'>{mx-target_text}</td>
</tr>
<tr><td colspan=3 align='right'><input type='button' OnClick=\"javasript:ParseForm('fmm1','$page',true);\" value='{edit} »'></td></tr>
</table>
</form>
</center>
<p>{dnsmasq_DNS_records_text}<br>{mxexamples}</p>
<form name='ffm1'>
<center>
<table style='width:100%'>
<td class='bottom'> </td>
<tr style='background-color:#CCCCCC'>
<td class='bottom'> </td>
<td class='bottom'><strong>{mxrecdomainfrom}</td>
<td class='bottom'><strong>{mxrecdomainto}</td>
<td class='bottom'><strong>{mxheight}</td>
<td class='bottom'> </td>
</tr>
<tr>
<td class='bottom' width='20px'> </td>
<td class='bottom' width='140px'>" . Field_text('mxrecdomainfrom') . "</td>
<td class='bottom' width='180px'>" . Field_text('mxrecdomainto') . "</td>
<td class='bottom' width='100px'>" . Field_text('mxheight') . "</td>
<td class='bottom'><input type='button' OnClick=\"javascript:ParseForm('ffm1','$page',true);mxHostsReload();\" value='{add} »'></td>
</tr>
</table>
</form>
</center>
<div id='mx_hosts'>" . Loadmxhosts() . "</div>
";
$JS["JS"][]='js/dnsmasq.js';
$tpl=new template_users('{dnsmasq_DNS_records}',$html,0,0,0,0,$JS);
echo $tpl->web_page;
}
function othersoptions(){
unset($_GET["othersoptions"]);
$conf=new dnsmasq();
while (list ($key, $line) = each ($_GET) ){
if($line<>null){
$conf->main_array[$key]=$line;
}else{unset($conf->main_array[$key]);}
}
$conf->SaveConf();
}
function SaveConfMx(){
$mxrecdomainfrom=$_GET["mxrecdomainfrom"];
$mxrecdomainto=$_GET["mxrecdomainto"];
$mxheight=$_GET["mxheight"];
if($mxrecdomainfrom==null && $mxrecdomainto==null && $mxheight==null){return null;}
$cf=new dnsmasq();
$cf->array_mxhost[]="$mxrecdomainfrom,$mxrecdomainto,$mxheight";
$cf->SaveConf();
}
function DnsmasqDeleteMxHost(){
$cf=new dnsmasq();
unset($cf->array_mxhost[$_GET["DnsmasqDeleteMxHost"]]);
$cf->SaveConf();
}
function DnsMasqMxMove(){
$cf=new dnsmasq();
$newarrar=array_move_element($cf->array_mxhost,$cf->array_mxhost[$_GET["DnsMasqMxMove"]],$_GET["move"]);
$cf->array_mxhost=$newarrar;
$cf->SaveConf();
}
function Loadmxhosts(){
$conf=new dnsmasq();
if(!is_array($conf->array_mxhost)){return null;}
$html="<center><table style='width:100%'>";
while (list ($index, $line) = each ($conf->array_mxhost) ){
$m=explode(",",$line);
$cell_up="<td width=1% class=bottom>" . imgtootltip('arrow_up.gif','{up}',"DnsMasqMxMove('$index','up')") ."</td>";
$cell_down="<td width=1% class=bottom>" . imgtootltip('arrow_down.gif','{down}',"DnsMasqMxMove('$index','down')") ."</td>";
$html=$html . "
<tr>
<td width='20px' valign='middle' class=bottom><img src='img/fw_bold.gif'><td>
<td class=bottom width='140px'>{$m[0]}</td>
<td class=bottom width='180px'>{$m[1]}</td>
<td class=bottom width='100px'>{$m[2]}</td>
$cell_up
$cell_down
<td class=bottom width='100px'>" . imgtootltip('x.gif','{delete}',"DnsmasqDeleteMxHost('$index');")."</td>
</tr>";
}
$tpl=new templates();
return $tpl->_ENGINE_parse_body($html . "</table></center>");
}