mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
use template for dhcp page
This commit is contained in:
parent
c1f75a696a
commit
9defff1cf4
@ -132,195 +132,12 @@ function DisplayDHCPConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
echo renderTemplate("dhcp", compact(
|
||||||
<div class="row">
|
"status",
|
||||||
<div class="col-lg-12">
|
"serviceStatus",
|
||||||
<div class="panel panel-primary">
|
"RangeStart", "RangeEnd",
|
||||||
<div class="panel-heading">
|
"arrRangeLeaseTime",
|
||||||
<i class="fa fa-exchange fa-fw"></i> <?php echo _("Configure DHCP"); ?>
|
"mselected", "hselected", "dselected", "infiniteselected",
|
||||||
<span class="label pull-right service-status-<?php echo $serviceStatus ?>">dnsmasq <?php echo _($serviceStatus) ?></span>
|
"dnsmasq_state", "conf", "dhcpHost"
|
||||||
</div>
|
));
|
||||||
<!-- /.panel-heading -->
|
|
||||||
<div class="panel-body">
|
|
||||||
<p><?php $status->showMessages(); ?></p>
|
|
||||||
<form method="POST" action="?page=dhcpd_conf" class="js-dhcp-settings-form">
|
|
||||||
<?php echo CSRFTokenFieldTag() ?>
|
|
||||||
<!-- Nav tabs -->
|
|
||||||
<ul class="nav nav-tabs">
|
|
||||||
<li class="active"><a href="#server-settings" data-toggle="tab"><?php echo _("Server settings"); ?></a>
|
|
||||||
</li>
|
|
||||||
<li><a href="#static-leases" data-toggle="tab"><?php echo _("Static Leases") ?></a></li>
|
|
||||||
<li><a href="#client-list" data-toggle="tab"><?php echo _("Client list"); ?></a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<!-- Tab panes -->
|
|
||||||
<div class="tab-content">
|
|
||||||
<div class="tab-pane fade in active" id="server-settings">
|
|
||||||
<h4>DHCP server settings</h4>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="code">Interface</label>
|
|
||||||
<select class="form-control" name="interface">
|
|
||||||
<?php
|
|
||||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
|
||||||
|
|
||||||
foreach ($interfaces as $inet) {
|
|
||||||
$select = '';
|
|
||||||
if ($inet === $conf['interface']) {
|
|
||||||
$select = ' selected="selected"';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ' <option value="'.htmlspecialchars($inet, ENT_QUOTES).'"'.
|
|
||||||
$select.'>'.htmlspecialchars($inet, ENT_QUOTES).'</option>' , PHP_EOL;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="code"><?php echo _("Starting IP Address"); ?></label>
|
|
||||||
<input type="text" class="form-control"name="RangeStart" value="<?php echo htmlspecialchars($RangeStart, ENT_QUOTES); ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="code"><?php echo _("Ending IP Address"); ?></label>
|
|
||||||
<input type="text" class="form-control" name="RangeEnd" value="<?php echo htmlspecialchars($RangeEnd, ENT_QUOTES); ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-xs-2 col-sm-2">
|
|
||||||
<label for="code"><?php echo _("Lease Time"); ?></label>
|
|
||||||
<input type="text" class="form-control" name="RangeLeaseTime" value="<?php echo htmlspecialchars($arrRangeLeaseTime[1], ENT_QUOTES); ?>" />
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-2 col-sm-2">
|
|
||||||
<label for="code"><?php echo _("Interval"); ?></label>
|
|
||||||
<select name="RangeLeaseTimeUnits" class="form-control" >
|
|
||||||
<option value="m"<?php echo $mselected; ?>><?php echo _("Minute(s)"); ?></option>
|
|
||||||
<option value="h"<?php echo $hselected; ?>><?php echo _("Hour(s)"); ?></option>
|
|
||||||
<option value="d"<?php echo $dselected; ?>><?php echo _("Day(s)"); ?></option>
|
|
||||||
<option value="infinite"<?php echo $infiniteselected; ?>><?php echo _("Infinite"); ?></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
|
|
||||||
<?php
|
|
||||||
|
|
||||||
if ($dnsmasq_state) {
|
|
||||||
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />';
|
|
||||||
} else {
|
|
||||||
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div><!-- /.tab-pane -->
|
|
||||||
|
|
||||||
<div class="tab-pane fade in" id="client-list">
|
|
||||||
<h4>Client list</h4>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading"><?php echo _("Active DHCP leases"); ?></div>
|
|
||||||
<!-- /.panel-heading -->
|
|
||||||
<div class="panel-body">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><?php echo _("Expire time"); ?></th>
|
|
||||||
<th><?php echo _("MAC Address"); ?></th>
|
|
||||||
<th><?php echo _("IP Address"); ?></th>
|
|
||||||
<th><?php echo _("Host name"); ?></th>
|
|
||||||
<th><?php echo _("Client ID"); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
|
|
||||||
foreach ($leases as $lease) {
|
|
||||||
echo ' <tr>'.PHP_EOL;
|
|
||||||
$lease_items = explode(' ', $lease);
|
|
||||||
foreach ($lease_items as $lease_item) {
|
|
||||||
echo ' <td>'.htmlspecialchars($lease_item, ENT_QUOTES).'</td>'.PHP_EOL;
|
|
||||||
}
|
|
||||||
echo ' </tr>'.PHP_EOL;
|
|
||||||
};
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div><!-- /.table-responsive -->
|
|
||||||
</div><!-- /.panel-body -->
|
|
||||||
</div><!-- /.panel -->
|
|
||||||
</div><!-- /.col-lg-12 -->
|
|
||||||
</div><!-- /.row -->
|
|
||||||
</div><!-- /.tab-pane -->
|
|
||||||
|
|
||||||
<div class="tab-pane fade in" id="static-leases">
|
|
||||||
<div class="dhcp-static-leases js-dhcp-static-lease-container">
|
|
||||||
<?php foreach ($dhcpHost as $host): ?>
|
|
||||||
<?php list($mac, $ip) = array_map("trim", explode(",", $host)); ?>
|
|
||||||
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
|
|
||||||
<div class="col-md-5 col-xs-5">
|
|
||||||
<input type="text" name="static_leases[mac][]" value="<?php echo htmlspecialchars($mac, ENT_QUOTES) ?>" placeholder="<?php echo _("MAC address") ?>" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-5 col-xs-4">
|
|
||||||
<input type="text" name="static_leases[ip][]" value="<?php echo htmlspecialchars($ip, ENT_QUOTES) ?>" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2 col-xs-3">
|
|
||||||
<button type="button" class="btn btn-danger js-remove-dhcp-static-lease"><?php echo _("Remove") ?></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5><?php echo _("Add static DHCP lease") ?></h5>
|
|
||||||
<div class="row dhcp-static-lease-row js-new-dhcp-static-lease">
|
|
||||||
<div class="col-md-5 col-xs-5">
|
|
||||||
<input type="text" name="mac" value="" placeholder="<?php echo _("MAC address") ?>" class="form-control" autofocus="autofocus">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-5 col-xs-4">
|
|
||||||
<input type="text" name="ip" value="" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2 col-xs-3">
|
|
||||||
<button type="button" class="btn btn-success js-add-dhcp-static-lease"><?php echo _("Add") ?></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template id="js-dhcp-static-lease-row">
|
|
||||||
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
|
|
||||||
<div class="col-md-5 col-xs-5">
|
|
||||||
<input type="text" name="static_leases[mac][]" value="{{ mac }}" placeholder="<?php echo _("MAC address") ?>" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-5 col-xs-4">
|
|
||||||
<input type="text" name="static_leases[ip][]" value="{{ ip }}" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2 col-xs-3">
|
|
||||||
<button type="button" class="btn btn-warning js-remove-dhcp-static-lease"><?php echo _("Remove") ?></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
|
|
||||||
<?php
|
|
||||||
|
|
||||||
if ($dnsmasq_state) {
|
|
||||||
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />';
|
|
||||||
} else {
|
|
||||||
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div><!-- /.tab-content -->
|
|
||||||
</form>
|
|
||||||
</div><!-- ./ Panel body -->
|
|
||||||
<div class="panel-footer"> <?php echo _("Information provided by Dnsmasq"); ?></div>
|
|
||||||
</div><!-- /.panel-primary -->
|
|
||||||
</div><!-- /.col-lg-12 -->
|
|
||||||
</div><!-- /.row -->
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
|
188
templates/dhcp.php
Normal file
188
templates/dhcp.php
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-exchange fa-fw"></i> <?php echo _("Configure DHCP"); ?>
|
||||||
|
<span class="label pull-right service-status-<?php echo $serviceStatus ?>">dnsmasq <?php echo _($serviceStatus) ?></span>
|
||||||
|
</div>
|
||||||
|
<!-- /.panel-heading -->
|
||||||
|
<div class="panel-body">
|
||||||
|
<p><?php $status->showMessages(); ?></p>
|
||||||
|
<form method="POST" action="?page=dhcpd_conf" class="js-dhcp-settings-form">
|
||||||
|
<?php echo CSRFTokenFieldTag() ?>
|
||||||
|
<!-- Nav tabs -->
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li class="active"><a href="#server-settings" data-toggle="tab"><?php echo _("Server settings"); ?></a>
|
||||||
|
</li>
|
||||||
|
<li><a href="#static-leases" data-toggle="tab"><?php echo _("Static Leases") ?></a></li>
|
||||||
|
<li><a href="#client-list" data-toggle="tab"><?php echo _("Client list"); ?></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- Tab panes -->
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane fade in active" id="server-settings">
|
||||||
|
<h4>DHCP server settings</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="code">Interface</label>
|
||||||
|
<select class="form-control" name="interface">
|
||||||
|
<?php
|
||||||
|
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||||
|
|
||||||
|
foreach ($interfaces as $inet) {
|
||||||
|
$select = '';
|
||||||
|
if ($inet === $conf['interface']) {
|
||||||
|
$select = ' selected="selected"';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ' <option value="'.htmlspecialchars($inet, ENT_QUOTES).'"'.
|
||||||
|
$select.'>'.htmlspecialchars($inet, ENT_QUOTES).'</option>' , PHP_EOL;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="code"><?php echo _("Starting IP Address"); ?></label>
|
||||||
|
<input type="text" class="form-control"name="RangeStart" value="<?php echo htmlspecialchars($RangeStart, ENT_QUOTES); ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="code"><?php echo _("Ending IP Address"); ?></label>
|
||||||
|
<input type="text" class="form-control" name="RangeEnd" value="<?php echo htmlspecialchars($RangeEnd, ENT_QUOTES); ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-xs-2 col-sm-2">
|
||||||
|
<label for="code"><?php echo _("Lease Time"); ?></label>
|
||||||
|
<input type="text" class="form-control" name="RangeLeaseTime" value="<?php echo htmlspecialchars($arrRangeLeaseTime[1], ENT_QUOTES); ?>" />
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-2 col-sm-2">
|
||||||
|
<label for="code"><?php echo _("Interval"); ?></label>
|
||||||
|
<select name="RangeLeaseTimeUnits" class="form-control" >
|
||||||
|
<option value="m"<?php echo $mselected; ?>><?php echo _("Minute(s)"); ?></option>
|
||||||
|
<option value="h"<?php echo $hselected; ?>><?php echo _("Hour(s)"); ?></option>
|
||||||
|
<option value="d"<?php echo $dselected; ?>><?php echo _("Day(s)"); ?></option>
|
||||||
|
<option value="infinite"<?php echo $infiniteselected; ?>><?php echo _("Infinite"); ?></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($dnsmasq_state) {
|
||||||
|
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />';
|
||||||
|
} else {
|
||||||
|
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div><!-- /.tab-pane -->
|
||||||
|
|
||||||
|
<div class="tab-pane fade in" id="client-list">
|
||||||
|
<h4>Client list</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading"><?php echo _("Active DHCP leases"); ?></div>
|
||||||
|
<!-- /.panel-heading -->
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php echo _("Expire time"); ?></th>
|
||||||
|
<th><?php echo _("MAC Address"); ?></th>
|
||||||
|
<th><?php echo _("IP Address"); ?></th>
|
||||||
|
<th><?php echo _("Host name"); ?></th>
|
||||||
|
<th><?php echo _("Client ID"); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
|
||||||
|
foreach ($leases as $lease) {
|
||||||
|
echo ' <tr>'.PHP_EOL;
|
||||||
|
$lease_items = explode(' ', $lease);
|
||||||
|
foreach ($lease_items as $lease_item) {
|
||||||
|
echo ' <td>'.htmlspecialchars($lease_item, ENT_QUOTES).'</td>'.PHP_EOL;
|
||||||
|
}
|
||||||
|
echo ' </tr>'.PHP_EOL;
|
||||||
|
};
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div><!-- /.table-responsive -->
|
||||||
|
</div><!-- /.panel-body -->
|
||||||
|
</div><!-- /.panel -->
|
||||||
|
</div><!-- /.col-lg-12 -->
|
||||||
|
</div><!-- /.row -->
|
||||||
|
</div><!-- /.tab-pane -->
|
||||||
|
|
||||||
|
<div class="tab-pane fade in" id="static-leases">
|
||||||
|
<div class="dhcp-static-leases js-dhcp-static-lease-container">
|
||||||
|
<?php foreach ($dhcpHost as $host): ?>
|
||||||
|
<?php list($mac, $ip) = array_map("trim", explode(",", $host)); ?>
|
||||||
|
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
|
||||||
|
<div class="col-md-5 col-xs-5">
|
||||||
|
<input type="text" name="static_leases[mac][]" value="<?php echo htmlspecialchars($mac, ENT_QUOTES) ?>" placeholder="<?php echo _("MAC address") ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5 col-xs-4">
|
||||||
|
<input type="text" name="static_leases[ip][]" value="<?php echo htmlspecialchars($ip, ENT_QUOTES) ?>" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2 col-xs-3">
|
||||||
|
<button type="button" class="btn btn-danger js-remove-dhcp-static-lease"><?php echo _("Remove") ?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h5><?php echo _("Add static DHCP lease") ?></h5>
|
||||||
|
<div class="row dhcp-static-lease-row js-new-dhcp-static-lease">
|
||||||
|
<div class="col-md-5 col-xs-5">
|
||||||
|
<input type="text" name="mac" value="" placeholder="<?php echo _("MAC address") ?>" class="form-control" autofocus="autofocus">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5 col-xs-4">
|
||||||
|
<input type="text" name="ip" value="" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2 col-xs-3">
|
||||||
|
<button type="button" class="btn btn-success js-add-dhcp-static-lease"><?php echo _("Add") ?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template id="js-dhcp-static-lease-row">
|
||||||
|
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
|
||||||
|
<div class="col-md-5 col-xs-5">
|
||||||
|
<input type="text" name="static_leases[mac][]" value="{{ mac }}" placeholder="<?php echo _("MAC address") ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5 col-xs-4">
|
||||||
|
<input type="text" name="static_leases[ip][]" value="{{ ip }}" placeholder="<?php echo _("IP address") ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2 col-xs-3">
|
||||||
|
<button type="button" class="btn btn-warning js-remove-dhcp-static-lease"><?php echo _("Remove") ?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($dnsmasq_state) {
|
||||||
|
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />';
|
||||||
|
} else {
|
||||||
|
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div><!-- /.tab-content -->
|
||||||
|
</form>
|
||||||
|
</div><!-- ./ Panel body -->
|
||||||
|
<div class="panel-footer"> <?php echo _("Information provided by Dnsmasq"); ?></div>
|
||||||
|
</div><!-- /.panel-primary -->
|
||||||
|
</div><!-- /.col-lg-12 -->
|
||||||
|
</div><!-- /.row -->
|
Loading…
Reference in New Issue
Block a user