Interface count for asset

master
Thomas Hooge 2 years ago
parent 6c9a169600
commit 42e327776c
  1. 3
      assetedit.php
  2. 2
      assetview.php
  3. 1
      lang/de.php
  4. 1
      lang/en.php
  5. 2
      lib.php
  6. 28
      nat.php
  7. 14
      submit.php
  8. 8
      tpl/assetadd.tpl
  9. 8
      tpl/assetedit.tpl
  10. 8
      tpl/assetview.tpl
  11. 50
      tpl/nat.tpl
  12. 8
      tpl/useradd.tpl
  13. 10
      tpl/userview.tpl
  14. 8
      useradd.php

@ -13,7 +13,8 @@ $asset_id = sanitize($_GET['asset_id']);
include("header.php"); include("header.php");
$sql = "SELECT asset_id, asset_name, asset_hostname, asset_info, assetclass_id $sql = "SELECT asset_id, asset_name, asset_hostname, asset_info, asset_intf,
assetclass_id
FROM asset FROM asset
WHERE asset_id=?"; WHERE asset_id=?";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);

@ -14,7 +14,7 @@ $asset_id = sanitize($_GET['asset_id']);
include("header.php"); include("header.php");
$sql = "SELECT a.asset_id, a.asset_name, a.asset_hostname, a.asset_info, $sql = "SELECT a.asset_id, a.asset_name, a.asset_hostname, a.asset_info,
c.assetclass_id, c.assetclass_name a.asset_intf, c.assetclass_id, c.assetclass_name
FROM asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id) FROM asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id)
WHERE a.asset_id=?"; WHERE a.asset_id=?";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);

@ -56,6 +56,7 @@ $lang = array(
'lang_asset_name' => 'Objektname', 'lang_asset_name' => 'Objektname',
'lang_asset_hostname' => 'Hostname', 'lang_asset_hostname' => 'Hostname',
'lang_asset_none' => 'Es sind keine Objekte vorhanden', 'lang_asset_none' => 'Es sind keine Objekte vorhanden',
'lang_asset_intf' => 'Anzahl Schnittstellen',
'lang_assetclass_add' => 'Objektklasse hinzufügen', 'lang_assetclass_add' => 'Objektklasse hinzufügen',
'lang_assetclass_del' => 'Objektklasse löschen', 'lang_assetclass_del' => 'Objektklasse löschen',

@ -56,6 +56,7 @@ $lang = array(
'lang_asset_name' => 'Asset name', 'lang_asset_name' => 'Asset name',
'lang_asset_hostname' => 'Hostname', 'lang_asset_hostname' => 'Hostname',
'lang_asset_none' => 'There are no assets defined', 'lang_asset_none' => 'There are no assets defined',
'lang_asset_intf' => 'Number of interfaces',
'lang_assetclass_add' => 'Add assetclass', 'lang_assetclass_add' => 'Add assetclass',
'lang_assetclass_del' => 'Delete assetclass', 'lang_assetclass_del' => 'Delete assetclass',

@ -39,7 +39,7 @@ function db_load_enum($table, $column) {
WHERE table_name=? AND column_name=?"; WHERE table_name=? AND column_name=?";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);
$sth->execute([$table, $column]); $sth->execute([$table, $column]);
return array_map(fn($x) => trim($x, "'"), explode(',', $sth->fetch(PDO::FETCH_NUM))); return array_map(fn($x) => trim($x, "'"), explode(',', $sth->fetchColumn()));
} }
function db_get_options_asset() { function db_get_options_asset() {

@ -0,0 +1,28 @@
<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
include("includes.php");
include("header.php");
$sql = "SELECT n.nat_id AS id, n.nat_type, n.nat_ext, n.nat_int,
n.nat_ext_port AS port_ext, n.nat_int_port AS port_int,
n.nat_description AS description,
n1.node_ip AS node_ip_int, n2.node_ip AS node_ip_ext
FROM nat AS n
LEFT JOIN node AS n1 ON (n.nat_int=n1.node_id)
LEFT JOIN node AS n2 ON (n.nat_ext=n2.node_id)
ORDER BY INET_ATON(nat_ext)";
$sth = $dbh->query($sql);
$smarty->assign("nats", $sth->fetchAll());
$smarty->display("nat.tpl");
include("footer.php");
?>

@ -106,13 +106,14 @@ if (isset($_POST['add'])) {
$hostname = sanitize($_POST['asset_hostname']); $hostname = sanitize($_POST['asset_hostname']);
$assetclass_id = sanitize($_POST['assetclass_id']); $assetclass_id = sanitize($_POST['assetclass_id']);
$info = sanitize($_POST['asset_info']); $info = sanitize($_POST['asset_info']);
$intf = sanitize($_POST['asset_intf']);
$sql = "INSERT INTO asset $sql = "INSERT INTO asset
(asset_name, asset_hostname, assetclass_id, asset_info) (asset_name, asset_hostname, assetclass_id, asset_info, asset_intf)
VALUE VALUE
(?, ?, ?, ?)"; (?, ?, ?, ?, ?)";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);
$sth->execute([$name, $hostname, $assetclass_id, $info]); $sth->execute([$name, $hostname, $assetclass_id, $info, $intf]);
header_location("assetview.php?asset_id=" . $dbh->lastInsertId()); header_location("assetview.php?asset_id=" . $dbh->lastInsertId());
break; break;
@ -528,15 +529,18 @@ if (isset($_POST['edit'])) {
$asset_id = sanitize($_POST['asset_id']); $asset_id = sanitize($_POST['asset_id']);
$asset_name = sanitize($_POST['asset_name']); $asset_name = sanitize($_POST['asset_name']);
$asset_info = sanitize($_POST['asset_info']); $asset_info = sanitize($_POST['asset_info']);
$asset_intf = sanitize($_POST['asset_intf']);
$asset_hostname = sanitize($_POST['asset_hostname']); $asset_hostname = sanitize($_POST['asset_hostname']);
$assetclass_id = sanitize($_POST['assetclass_id']); $assetclass_id = sanitize($_POST['assetclass_id']);
$sql = "UPDATE asset SET $sql = "UPDATE asset SET
asset_name=?, asset_info=?, asset_hostname=?, asset_name=?, asset_info=?, asset_hostname=?,
assetclass_id=? assetclass_id=?, asset_intf=?
WHERE asset_id=?"; WHERE asset_id=?";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);
$sth->execute([$asset_name, $asset_info, $asset_hostname, $assetclass_id, $asset_id]); $sth->execute([$asset_name, $asset_info, $asset_hostname,
$assetclass_id, $asset_intf,
$asset_id]);
header_location("assetview.php?asset_id=" . $asset_id); header_location("assetview.php?asset_id=" . $asset_id);

@ -46,6 +46,14 @@
<textarea name="asset_info" cols="30" rows="10"></textarea> <textarea name="asset_info" cols="30" rows="10"></textarea>
</td> </td>
</tr> </tr>
<tr>
<td class="label">
{$lang_asset_intf}
</td>
<td class="value">
<input type="text" size="6" maxlength="6" name="asset_intf" value="1">
</td>
</tr>
</table> </table>
<table class="info"> <table class="info">

@ -48,6 +48,14 @@
<textarea name="asset_info" cols="30" rows="10">{$asset->asset_info}</textarea> <textarea name="asset_info" cols="30" rows="10">{$asset->asset_info}</textarea>
</td> </td>
</tr> </tr>
<tr>
<td class="label">
{$lang_asset_intf}
</td>
<td class="value">
<input type="text" size="6" maxlength="6" name="asset_intf" value="{$asset->asset_intf}">
</td>
</tr>
</table> </table>
<table class="info"> <table class="info">

@ -44,6 +44,14 @@
{$asset->asset_info} {$asset->asset_info}
</td> </td>
</tr> </tr>
<tr>
<td class="label">
{$lang_asset_intf}
</td>
<td class="value">
{$asset->asset_intf}
</td>
</tr>
</table> </table>

@ -0,0 +1,50 @@
<table class="title">
<tr>
<td class="header">
{$lang_nat_rules} ({$nats|@count})
</td>
<td align="right">
&nbsp;
</td>
</tr>
</table>
<table class="info">
<tr>
<td class="header">
{$lang_nat}
</td>
<td class="header">
{$lang_source} (ext)
</td>
<td class="header">
{$lang_target} (int)
</td>
<td class="header">
{$lang_nat_type}
</td>
</tr>
{foreach item=nat from=$nats}
<tr>
<td class="label">
Rule #{$nat.id} {$nat.description}
</td>
<td class="label">
<a href="nodeview.php?node_id={$nat.nat_ext}">{$nat.node_ip_ext}</a>
{if $nat.port_ext}:{$nat.port_ext}{/if}
<td class="label">
<a href="nodeview.php?node_id={$nat.nat_int}">{$nat.node_ip_int}</a>
{if $nat.port_int}:{$nat.port_int}{/if}
</td>
<td class="value">
{$nat.nat_type}
</td>
</tr>
{foreachelse}
<tr>
<td colspan="3">
{$lang_nat_none}
</td>
</tr>
{/foreach}
</table>

@ -47,5 +47,13 @@
<input type="text" name="user_password"> <input type="text" name="user_password">
</td> </td>
</tr> </tr>
<tr>
<td class="label">
{$lang_user_realm}
</td>
<td class="value">
{html_radios name=user_realm values=$realm_ids output=$realm_names selected=$realm_selected}
</td>
</tr>
</table> </table>
</form> </form>

@ -19,14 +19,6 @@
<td class="header_right"> <td class="header_right">
&nbsp; &nbsp;
</td> </td>
<tr>
<td class="label">
{$lang_user_realm}
</td>
<td class="value">
{$user_realm}
</td>
</tr>
</tr> </tr>
<tr> <tr>
<td class="label"> <td class="label">
@ -49,7 +41,7 @@
{$lang_user_realm} {$lang_user_realm}
</td> </td>
<td class="value"> <td class="value">
{$user_realm} {$user->realm}
</td> </td>
</tr> </tr>
</table> </table>

@ -9,7 +9,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
include("includes.php"); include("includes.php");
include("header.php"); include("header.php");
$realms = db_load_enum('user','user_realm');
$smarty->assign("realm_ids", $realms);
$smarty->assign("realm_names", $realms);
$smarty->assign("realm_selected", $realms[0]);
$smarty->display("useradd.tpl"); $smarty->display("useradd.tpl");
include("footer.php"); include("footer.php");