Compare commits

..

No commits in common. 'c76e8fe9d39cb15be2ce22ac057ab67b636ff872' and 'aabd37bd1aba6590cee55bb50acb140b645d68cb' have entirely different histories.

  1. 27
      asset.php
  2. 3
      header.php
  3. BIN
      images/key_add.png
  4. 2
      includes.php
  5. 14
      install/mysql_sample.sql
  6. 4
      lang/de.php
  7. 4
      lang/en.php
  8. 95
      lib.php
  9. 94
      lib/functions.php
  10. 3
      location.php
  11. 3
      login.php
  12. 20
      options.php
  13. 2
      tpl/asset.tpl
  14. 8
      tpl/options.tpl
  15. 6
      tpl/optionseditdisplay.tpl
  16. 6
      tpl/useredit.tpl
  17. 24
      tpl/userview.tpl
  18. 34
      user.php

@ -106,39 +106,32 @@ if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior ======================================= // ========== VARIANT: default behavior =======================================
// create letter links // create letter links
$sql = "SELECT DISTINCT SUBSTRING(UPPER(asset_name),1,1) AS bst $sql = "SELECT DISTINCT SUBSTRING(UPPER(asset_name),1,1) AS asset_letter
FROM asset FROM asset
ORDER BY bst"; ORDER BY asset_letter";
$sth = $dbh->query($sql); $sth = $dbh->query($sql);
$alphabet = $sth->fetchAll(); $alphabet = $sth->fetchAll();
$alphabet[] = ['bst' => '*'];
$smarty->assign("alphabet", $alphabet); $smarty->assign("alphabet", $alphabet);
// total asset count // total asset count
$sth = $dbh->query("SELECT COUNT(*) FROM asset"); $sth = $dbh->query("SELECT COUNT(*) FROM asset");
$assetcount = $sth->fetchColumn(); $smarty->assign("assetcount", $sth->fetchColumn());
$smarty->assign("assetcount", $sassetcount);
// assets for current letter // assets for current letter
if (isset($_GET['bst'])) { if (isset($_GET['asset_letter'])) {
$bst = sanitize($_GET['bst']); $asset_letter = sanitize($_GET['asset_letter']);
} else { } else {
$bst = $alphabet[0]['bst']; $asset_letter = $alphabet[0]['asset_letter'];
} }
$sql = "SELECT a.asset_id, IF(LENGTH(a.asset_name)>0, a.asset_name, '...') AS asset_name, $sql = "SELECT a.asset_id, IF(LENGTH(a.asset_name)>0, a.asset_name, '...') AS asset_name,
a.asset_info, c.assetclass_id, c.assetclass_name a.asset_info, 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)
if ($bst != '*') { WHERE SUBSTRING(a.asset_name,1,1)=?
$sql .= " WHERE SUBSTRING(a.asset_name,1,1)=?"; ORDER BY a.asset_name";
$p = array($bst);
} else {
$p = array();
}
$sql .= " ORDER BY a.asset_name";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);
$sth->execute($p); $sth->execute([$asset_letter]);
$smarty->assign("assets", $sth->fetchAll()); $smarty->assign("assets", $sth->fetchAll());
$smarty->display("asset.tpl"); $smarty->display("asset.tpl");

@ -43,9 +43,6 @@ if ($_SESSION['suser_menu_locations']) {
if ($_SESSION['suser_menu_nodes']) { if ($_SESSION['suser_menu_nodes']) {
$menu[] = '<a href="node.php">' . $lang['lang_nodes'] . "</a>\n"; $menu[] = '<a href="node.php">' . $lang['lang_nodes'] . "</a>\n";
} }
if ($_SESSION['suser_menu_nats']) {
$menu[] = '<a href="nat.php">' . $lang['lang_nats'] . "</a>\n";
}
if ($_SESSION['suser_menu_subnets']) { if ($_SESSION['suser_menu_subnets']) {
$menu[] = '<a href="subnet.php">' . $lang['lang_subnets'] . "</a>\n"; $menu[] = '<a href="subnet.php">' . $lang['lang_subnets'] . "</a>\n";
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

@ -32,4 +32,4 @@ $dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
include("lib.php"); include("lib.php");
// $language = lang_getfrombrowser($config_lang, $config_lang_default); $language = lang_getfrombrowser($config_lang, $config_lang_default, null, false);

@ -1,11 +1,8 @@
INSERT INTO asset (asset_name, assetclass_id) VALUES INSERT INTO asset (asset_name, assetclass_id) VALUES
('Computer Alice', 1), ('Computer', 1),
('Computer Bob', 1),
('Computer Admin', 1),
('Server', 3), ('Server', 3),
('Printer', 4), ('Printer', 4),
('Firewall', 6), ('Firewall', 6);
('Air Condition System', 8);
INSERT INTO assetclass (assetclassgroup_id, assetclass_name) VALUES INSERT INTO assetclass (assetclassgroup_id, assetclass_name) VALUES
(1, 'Desktop'), (1, 'Desktop'),
@ -14,8 +11,7 @@ INSERT INTO assetclass (assetclassgroup_id, assetclass_name) VALUES
(3, 'Printer'), (3, 'Printer'),
(4, 'Switch'), (4, 'Switch'),
(4, 'Firewall'), (4, 'Firewall'),
(5, 'Scanner'), (5, 'Scanner');
(5, 'Other');
INSERT INTO assetclassgroup (assetclassgroup_name, assetclassgroup_color) VALUES INSERT INTO assetclassgroup (assetclassgroup_name, assetclassgroup_color) VALUES
('Personal Computer', '000000'), ('Personal Computer', '000000'),
@ -58,9 +54,7 @@ INSERT INTO user (user_name, user_pass, user_displayname) VALUES
('bob', '$2y$10$hl4NN4lOyuz7KN0ZjLHbOuCqGi08GVaTvl/RiMcL1mbFqGmtzDN76', 'Bob'); ('bob', '$2y$10$hl4NN4lOyuz7KN0ZjLHbOuCqGi08GVaTvl/RiMcL1mbFqGmtzDN76', 'Bob');
INSERT INTO vlan (vlan_number, vlan_name) VALUES INSERT INTO vlan (vlan_number, vlan_name) VALUES
(1, 'DEFAULT_VLAN'), (1, 'DEFAULT_VLAN');
(2, 'WLAN'),
(3, 'DMZ');
INSERT INTO zone (zone_soa, zone_origin, zone_hostmaster, zone_serial, zone_ns1) VALUES INSERT INTO zone (zone_soa, zone_origin, zone_hostmaster, zone_serial, zone_ns1) VALUES
('ns1.example.com.', 'example.com.', 'hostmaster.example.com.', '2023021301', 'ns1.example.com'); ('ns1.example.com.', 'example.com.', 'hostmaster.example.com.', '2023021301', 'ns1.example.com');

@ -14,8 +14,6 @@ $lang = array(
'lang_location' => 'Standort', 'lang_location' => 'Standort',
'lang_locations' => 'Standorte', 'lang_locations' => 'Standorte',
'lang_menu' => 'Menü', 'lang_menu' => 'Menü',
'lang_nat' => 'NAT',
'lang_nats' => 'NATs',
'lang_node' => 'Knoten', 'lang_node' => 'Knoten',
'lang_nodes' => 'Knoten', 'lang_nodes' => 'Knoten',
'lang_user' => 'Benutzer', 'lang_user' => 'Benutzer',
@ -42,7 +40,6 @@ $lang = array(
'lang_logout' => 'Abmelden', 'lang_logout' => 'Abmelden',
'lang_options' => 'Optionen', 'lang_options' => 'Optionen',
'lang_option_none' => '(kein)', 'lang_option_none' => '(kein)',
'lang_pass_set' => 'Neues Kennwort einstellen',
'lang_reset' => 'Zur&uuml;cksetzen', 'lang_reset' => 'Zur&uuml;cksetzen',
'lang_search' => 'Suche', 'lang_search' => 'Suche',
'lang_statistics' => 'Statistik', 'lang_statistics' => 'Statistik',
@ -131,6 +128,7 @@ $lang = array(
'lang_mac' => 'MAC-Adresse', 'lang_mac' => 'MAC-Adresse',
'lang_proto_vers' => 'Protokollversion', 'lang_proto_vers' => 'Protokollversion',
'lang_nat' => 'NAT',
'lang_nat_add' => 'NAT hinzufügen', 'lang_nat_add' => 'NAT hinzufügen',
'lang_nat_del' => 'NAT löschen', 'lang_nat_del' => 'NAT löschen',
'lang_nat_edit' => 'NAT ändern', 'lang_nat_edit' => 'NAT ändern',

@ -14,8 +14,6 @@ $lang = array(
'lang_location' => 'Location', 'lang_location' => 'Location',
'lang_locations' => 'Locations', 'lang_locations' => 'Locations',
'lang_menu' => 'Menu', 'lang_menu' => 'Menu',
'lang_nat' => 'NAT',
'lang_nats' => 'NATs',
'lang_node' => 'Node', 'lang_node' => 'Node',
'lang_nodes' => 'Nodes', 'lang_nodes' => 'Nodes',
'lang_user' => 'User', 'lang_user' => 'User',
@ -42,7 +40,6 @@ $lang = array(
'lang_logout' => 'Logout', 'lang_logout' => 'Logout',
'lang_options' => 'Options', 'lang_options' => 'Options',
'lang_option_none' => '(none)', 'lang_option_none' => '(none)',
'lang_pass_set' => 'Set new password',
'lang_reset' => 'Reset', 'lang_reset' => 'Reset',
'lang_search' => 'Search', 'lang_search' => 'Search',
'lang_statistics' => 'Statistics', 'lang_statistics' => 'Statistics',
@ -131,6 +128,7 @@ $lang = array(
'lang_mac' => 'MAC Address', 'lang_mac' => 'MAC Address',
'lang_proto_vers' => 'Protocol version', 'lang_proto_vers' => 'Protocol version',
'lang_nat' => 'NAT',
'lang_nat_add' => 'Add NAT', 'lang_nat_add' => 'Add NAT',
'lang_nat_del' => 'Delete NAT', 'lang_nat_del' => 'Delete NAT',
'lang_nat_edit' => 'Modify NAT', 'lang_nat_edit' => 'Modify NAT',

@ -30,7 +30,7 @@ define ('ACT_PASSWORD', 14);
// ========== GLOBAL PAGE START CODE ========================================== // ========== GLOBAL PAGE START CODE ==========================================
// global version string // global version string
$config_version = 'v0.9.1'; $config_version = 'v0.9';
// available languages // available languages
$config_lang = array('de', 'en'); $config_lang = array('de', 'en');
@ -60,42 +60,6 @@ $g_error = new MessageError;
$action = ACT_DEFAULT; $action = ACT_DEFAULT;
// ========== LANGUAGE FUNCTIONS ==============================================
function lang_getfrombrowser($allowed, $default) {
// get browser most preferred language if possible
if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
return $default;
}
$accepted = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$current_lang = $default;
$current_q = 0;
foreach ($accepted as $lang) {
$res = preg_match ('/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
$lang, $matches);
if (!$res) {
continue;
}
$lang_code = explode ('-', $matches[1]);
if (isset($matches[2])) {
$lang_quality = (float)$matches[2];
} else {
$lang_quality = 1.0;
}
while (count($lang_code)) {
if (in_array(strtolower(join ('-', $lang_code)), $allowed)) {
if ($lang_quality > $current_q) {
$current_lang = strtolower (join ('-', $lang_code));
$current_q = $lang_quality;
break;
}
}
array_pop($lang_code);
}
}
return $current_lang;
}
// ========== FEEDBACK FUNCTIONS ============================================== // ========== FEEDBACK FUNCTIONS ==============================================
class Message { class Message {
@ -172,13 +136,6 @@ class MessageError extends Message {
} }
} }
function msgout(array $parameters, Smarty_Internal_Template $smarty) {
// This is just a quick hack around missing {php} in Smarty3
$GLOBALS['g_error']->PrintOut();
$GLOBALS['g_warning']->PrintOut();
$GLOBALS['g_message']->PrintOut();
}
// ========== FORM FUNCTIONS ================================================== // ========== FORM FUNCTIONS ==================================================
function form_get_action() { function form_get_action() {
@ -202,7 +159,7 @@ function submit_error($action) {
function by default. An exit() is conscious here *not* installed, function by default. An exit() is conscious here *not* installed,
since it could be that despite such an error the program since it could be that despite such an error the program
execution should be continued. */ execution should be continued. */
return sprintf('The action "%s" is unknown. It is probably a program error.<br> Please inform your administrator of the exact circumstances of how this situation came about.', strtoupper($action)); return sprintf('The action "%s" is unknown. It is probably a program error.<br /> Please inform your administrator of the exact circumstances of how this situation came about.', strtoupper($action));
} }
// ========== DATABASE FUCTIONS =============================================== // ========== DATABASE FUCTIONS ===============================================
@ -304,51 +261,3 @@ function db_get_options_zone($default = NULL) {
} }
return $options; return $options;
} }
// ========== MISC FUCTIONS ===================================================
function strip_mac($mac, $caps=true) {
// strip mac address to 12 char string
// strip chars we don't need
$mac = preg_replace('/[^a-fA-F0-9]/', '', $mac);
if ($caps) {
$mac = strtoupper($mac);
} else {
$mac = strtolower($mac);
}
return $mac;
}
function write_mac($mac, $user_mac='xx:xx:xx:xx:xx:xx') {
// rebuild mac address using user supplied format
if (strlen($mac) != 12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
}
// check format of user mac: count upper or lower char
$chars = count_chars($user_mac, 1);
if (array_key_exists(88, $chars) and $chars[88] == 12) {
$pattern = '/X/';
$mac = strtoupper($mac);
} elseif (array_key_exists(120, $chars) and $chars[120] == 12) {
$pattern = '/x/';
$mac = strtolower($mac);
} else {
// invalid format
return $mac;
}
for($i=0; $i<12; $i++) {
$user_mac = preg_replace($pattern, $mac[$i], $user_mac, 1);
}
return $user_mac;
}
function header_location($location) {
// redirect page
header('location:' . $location);
exit;
}

@ -7,6 +7,52 @@ Copyright (C) 2011-2023 Thomas Hooge
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/ *****************************************************************************/
function strip_mac($mac, $caps=true) {
// strip mac address to 12 char string
// strip chars we don't need
$mac = preg_replace('/[^a-fA-F0-9]/', '', $mac);
if ($caps) {
$mac = strtoupper($mac);
} else {
$mac = strtolower($mac);
}
return $mac;
}
function write_mac($mac, $user_mac='xx:xx:xx:xx:xx:xx') {
// rebuild mac address using user supplied format
if (strlen($mac) != 12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
}
// check format of user mac: count upper or lower char
$chars = count_chars($user_mac, 1);
if (array_key_exists(88, $chars) and $chars[88] == 12) {
$pattern = '/X/';
$mac = strtoupper($mac);
} elseif (array_key_exists(120, $chars) and $chars[120] == 12) {
$pattern = '/x/';
$mac = strtolower($mac);
} else {
// invalid format
return $mac;
}
for($i=0; $i<12; $i++) {
$user_mac = preg_replace($pattern, $mac[$i], $user_mac, 1);
}
return $user_mac;
}
function header_location($location) {
// redirect page
header('location:' . $location);
exit;
}
// sanitize input // sanitize input
function sanitize($input) { function sanitize($input) {
global $dblink; global $dblink;
@ -30,13 +76,49 @@ function sanitize($input) {
return $input; return $input;
} }
function lang_getfrombrowser ($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true) {
if ($lang_variable === null) {
$lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
if (empty($lang_variable)) {
return $default_language;
}
$accepted_languages = preg_split('/,\s*/', $lang_variable);
$current_lang = $default_language;
$current_q = 0;
foreach ($accepted_languages as $accepted_language) {
$res = preg_match ('/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
$accepted_language, $matches);
if (!$res) {
continue;
}
$lang_code = explode ('-', $matches[1]);
if (isset($matches[2])) {
$lang_quality = (float)$matches[2];
} else {
$lang_quality = 1.0;
}
while (count ($lang_code)) {
if (in_array (strtolower (join ('-', $lang_code)), $allowed_languages)) {
if ($lang_quality > $current_q) {
$current_lang = strtolower (join ('-', $lang_code));
$current_q = $lang_quality;
break;
}
}
if ($strict_mode) {
break;
}
array_pop ($lang_code);
}
}
return $current_lang;
}
function print_tree_rec($tree, $level) { function print_tree_rec($tree, $level) {
$output = '<ul class="treelvl' . $level. '">' . "\n"; $output = '<ul class="treelvl' . $level. '">' . "\n";
foreach ($tree as $node) { foreach ($tree as $node) {
$output .= '<li><a href="' . $node['href'] . '">' . $node['value'] . '</a>'; $output .= '<li><a href="' . $node['href'] . '">' . $node['value'] . '</a>';
if ($node['info']) {
$output .= ' - ' . $node['info'];
}
if ($node['children']) { if ($node['children']) {
$output .= "\n" . print_tree_rec($node['children'], $level+1); $output .= "\n" . print_tree_rec($node['children'], $level+1);
} }
@ -59,3 +141,9 @@ function print_tree($params, Smarty_Internal_Template $template) {
} }
} }
function msgout(array $parameters, Smarty_Internal_Template $smarty) {
// This is just a quick hack around missing {php} in Smarty3
$GLOBALS['g_error']->PrintOut();
$GLOBALS['g_warning']->PrintOut();
$GLOBALS['g_message']->PrintOut();
}

@ -142,8 +142,7 @@ include("header.php");
if ($action == ACT_DEFAULT): if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior ======================================= // ========== VARIANT: default behavior =======================================
$sql = "SELECT location_id AS id, location_name AS value, location_parent AS parent_id, $sql = "SELECT location_id AS id, location_name AS value, location_parent AS parent_id
CONCAT(LEFT(location_info,40), IF(CHAR_LENGTH(location_info)>40,'...','')) AS info
FROM location FROM location
ORDER BY location_parent, location_sort, location_name"; ORDER BY location_parent, location_sort, location_name";
$sth = $dbh->query($sql); $sth = $dbh->query($sql);

@ -136,7 +136,6 @@ function user_login ($user_name, $user_pass) {
$_SESSION['suser_menu_cables'] = in_array('cable', $menu); $_SESSION['suser_menu_cables'] = in_array('cable', $menu);
$_SESSION['suser_menu_locations'] = in_array('location', $menu); $_SESSION['suser_menu_locations'] = in_array('location', $menu);
$_SESSION['suser_menu_nodes'] = in_array('node', $menu); $_SESSION['suser_menu_nodes'] = in_array('node', $menu);
$_SESSION['suser_menu_nats'] = in_array('nat', $menu);
$_SESSION['suser_menu_subnets'] = in_array('subnet', $menu); $_SESSION['suser_menu_subnets'] = in_array('subnet', $menu);
$_SESSION['suser_menu_vlans'] = in_array('vlan', $menu); $_SESSION['suser_menu_vlans'] = in_array('vlan', $menu);
$_SESSION['suser_menu_zones'] = in_array('zone', $menu); $_SESSION['suser_menu_zones'] = in_array('zone', $menu);
@ -148,7 +147,7 @@ function user_login ($user_name, $user_pass) {
// ========== LOGIN: HERE BE DRAGONS ========================================== // ========== LOGIN: HERE BE DRAGONS ==========================================
$language = lang_getfrombrowser($config_lang, $config_lang_default); $language = lang_getfrombrowser($config_lang, $config_lang_default, null, false);
include('lang/' . $language . '.php'); include('lang/' . $language . '.php');
if ($_SERVER['REQUEST_METHOD'] == "POST" ) { if ($_SERVER['REQUEST_METHOD'] == "POST" ) {

@ -34,7 +34,6 @@ switch ($submit = form_get_action()) {
$menu_cables = sanitize($_POST['user_menu_cables']); $menu_cables = sanitize($_POST['user_menu_cables']);
$menu_locations = sanitize($_POST['user_menu_locations']); $menu_locations = sanitize($_POST['user_menu_locations']);
$menu_nodes = sanitize($_POST['user_menu_nodes']); $menu_nodes = sanitize($_POST['user_menu_nodes']);
$menu_nats = sanitize($_POST['user_menu_nats']);
$menu_subnets = sanitize($_POST['user_menu_subnets']); $menu_subnets = sanitize($_POST['user_menu_subnets']);
$menu_vlans = sanitize($_POST['user_menu_vlans']); $menu_vlans = sanitize($_POST['user_menu_vlans']);
$menu_zones = sanitize($_POST['user_menu_zones']); $menu_zones = sanitize($_POST['user_menu_zones']);
@ -47,7 +46,6 @@ switch ($submit = form_get_action()) {
if ($menu_cables) $menu[] = 'cable'; if ($menu_cables) $menu[] = 'cable';
if ($menu_locations) $menu[] = 'location'; if ($menu_locations) $menu[] = 'location';
if ($menu_nodes) $menu[] = 'node'; if ($menu_nodes) $menu[] = 'node';
if ($menu_nats) $menu[] = 'nat';
if ($menu_subnets) $menu[] = 'subnet'; if ($menu_subnets) $menu[] = 'subnet';
if ($menu_vlans) $menu[] = 'vlan'; if ($menu_vlans) $menu[] = 'vlan';
if ($menu_zones) $menu[] = 'zone'; if ($menu_zones) $menu[] = 'zone';
@ -78,7 +76,6 @@ switch ($submit = form_get_action()) {
$_SESSION['suser_menu_cables'] = $menu_cables; $_SESSION['suser_menu_cables'] = $menu_cables;
$_SESSION['suser_menu_locations'] = $menu_locations; $_SESSION['suser_menu_locations'] = $menu_locations;
$_SESSION['suser_menu_nodes'] = $menu_nodes; $_SESSION['suser_menu_nodes'] = $menu_nodes;
$_SESSION['suser_menu_nats'] = $menu_nats;
$_SESSION['suser_menu_subnets'] = $menu_subnets; $_SESSION['suser_menu_subnets'] = $menu_subnets;
$_SESSION['suser_menu_vlans'] = $menu_vlans; $_SESSION['suser_menu_vlans'] = $menu_vlans;
$_SESSION['suser_menu_zones'] = $menu_zones; $_SESSION['suser_menu_zones'] = $menu_zones;
@ -136,15 +133,7 @@ $smarty->display("options.tpl");
elseif ($action == ACT_EDIT): elseif ($action == ACT_EDIT):
// ========== VARIANT: edit display options =================================== // ========== VARIANT: edit display options ===================================
$smarty->assign("language", lang_getfrombrowser($config_lang, $config_lang_default)); $smarty->assign("language", $language);
// available languages
$lang_options = array();
foreach ($config_lang as $lang) {
$lang_options[$lang] = $lang;
}
$smarty->assign("lang_options", $lang_options);
if($_SESSION['suser_menu_assets']=='on') { if($_SESSION['suser_menu_assets']=='on') {
$user_menu_assets_checked = 'checked'; $user_menu_assets_checked = 'checked';
@ -181,12 +170,6 @@ if($_SESSION['suser_menu_nodes']=='on') {
} else { } else {
$user_menu_nodes_checked = ''; $user_menu_nodes_checked = '';
} }
// nats
if($_SESSION['suser_menu_nats']=='on') {
$user_menu_nats_checked = 'checked';
} else {
$user_menu_nats_checked = '';
}
// subnets // subnets
if($_SESSION['suser_menu_subnets']=='on') { if($_SESSION['suser_menu_subnets']=='on') {
$user_menu_subnets_checked = 'checked'; $user_menu_subnets_checked = 'checked';
@ -226,7 +209,6 @@ $smarty->assign("user_menu_assetclassgroups_checked", $user_menu_assetclassgroup
$smarty->assign("user_menu_cables_checked", $user_menu_cables_checked); $smarty->assign("user_menu_cables_checked", $user_menu_cables_checked);
$smarty->assign("user_menu_locations_checked", $user_menu_locations_checked); $smarty->assign("user_menu_locations_checked", $user_menu_locations_checked);
$smarty->assign("user_menu_nodes_checked", $user_menu_nodes_checked); $smarty->assign("user_menu_nodes_checked", $user_menu_nodes_checked);
$smarty->assign("user_menu_nats_checked", $user_menu_nats_checked);
$smarty->assign("user_menu_subnets_checked", $user_menu_subnets_checked); $smarty->assign("user_menu_subnets_checked", $user_menu_subnets_checked);
$smarty->assign("user_menu_vlans_checked", $user_menu_vlans_checked); $smarty->assign("user_menu_vlans_checked", $user_menu_vlans_checked);
$smarty->assign("user_menu_zones_checked", $user_menu_zones_checked); $smarty->assign("user_menu_zones_checked", $user_menu_zones_checked);

@ -16,7 +16,7 @@
<tr> <tr>
{foreach item=letter from=$alphabet} {foreach item=letter from=$alphabet}
<td> <td>
<a href="asset.php?bst={$letter.bst}">{$letter.bst}</a>&nbsp; <a href="asset.php?asset_letter={$letter.asset_letter}">{$letter.asset_letter}</a>&nbsp;
</td> </td>
{/foreach} {/foreach}
</tr> </tr>

@ -47,16 +47,16 @@
</td> </td>
<td class="label"> <td class="label">
{if $role_add} {if $role_add}
<img src="images/add.png" alt="[Add]"> {$lang_user_role_add}<br> <img src="images/page_add.png" alt="[Add]"> {$lang_user_role_add} <br>
{/if} {/if}
{if $role_edit} {if $role_edit}
<img src="images/edit.png" alt="[Edit]"> {$lang_user_role_edit}<br> <img src="images/page_edit.png" alt="[Edit]"> {$lang_user_role_edit} <br>
{/if} {/if}
{if $role_edit} {if $role_edit}
<img src="images/delete.png" alt="[Del]"> {$lang_user_role_delete}<br> <img src="images/page_delete.png" alt="[Del]"> {$lang_user_role_delete} <br>
{/if} {/if}
{if $role_manage} {if $role_manage}
<img src="images/manage.png" alt="[Manage]"> {$lang_user_role_manage}<br> <img src="images/manage.png" alt="[Manage]"> {$lang_user_role_manage} <br>
{/if} {/if}
{if $role_manage} {if $role_manage}
<img src="images/admin.png" alt="[Admin]"> {$lang_user_role_admin} <img src="images/admin.png" alt="[Admin]"> {$lang_user_role_admin}

@ -27,7 +27,7 @@
<span class="help" title="{$lang_options_language_help}">{$lang_user_language}</span> <span class="help" title="{$lang_options_language_help}">{$lang_user_language}</span>
</td> </td>
<td class="value"> <td class="value">
{html_options name=user_language options=$lang_options selected={$user_language}} <input type="text" name="user_language" value="{$user_language}" size="2">
({$language}) ({$language})
</td> </td>
</tr> </tr>
@ -53,7 +53,6 @@
</td> </td>
<td class="value"> <td class="value">
<input type="text" name="user_mac" value="{$user_mac}"> <input type="text" name="user_mac" value="{$user_mac}">
(xx:xx:xx:xx:xx:xx)
</td> </td>
</tr> </tr>
<tr> <tr>
@ -93,9 +92,6 @@
{/if} {/if}
<input type="checkbox" name="user_menu_locations" {$user_menu_locations_checked}>{$lang_locations}<br /> <input type="checkbox" name="user_menu_locations" {$user_menu_locations_checked}>{$lang_locations}<br />
<input type="checkbox" name="user_menu_nodes" {$user_menu_nodes_checked}>{$lang_nodes}<br /> <input type="checkbox" name="user_menu_nodes" {$user_menu_nodes_checked}>{$lang_nodes}<br />
{if $suser_admin}
<input type="checkbox" name="user_menu_nats" {$user_menu_nats_checked}>{$lang_nats}<br />
{/if}
<input type="checkbox" name="user_menu_subnets" {$user_menu_subnets_checked}>{$lang_subnets}<br /> <input type="checkbox" name="user_menu_subnets" {$user_menu_subnets_checked}>{$lang_subnets}<br />
<input type="checkbox" name="user_menu_vlans" {$user_menu_vlans_checked}>{$lang_vlans}<br /> <input type="checkbox" name="user_menu_vlans" {$user_menu_vlans_checked}>{$lang_vlans}<br />
<input type="checkbox" name="user_menu_zones" {$user_menu_zones_checked}>{$lang_zones} <input type="checkbox" name="user_menu_zones" {$user_menu_zones_checked}>{$lang_zones}

@ -60,7 +60,7 @@
{$lang_user_role_add} {$lang_user_role_add}
</td> </td>
<td class="value"> <td class="value">
<img src="images/add.png" alt="[Add]"> <img src="images/page_add.png" alt="[Add]">
<input type="checkbox" name="role_add" {if in_array('add', $user->role)} checked="checked"{/if} <input type="checkbox" name="role_add" {if in_array('add', $user->role)} checked="checked"{/if}
</td> </td>
</tr> </tr>
@ -69,7 +69,7 @@
{$lang_user_role_edit} {$lang_user_role_edit}
</td> </td>
<td class="value"> <td class="value">
<img src="images/edit.png" alt="[Edit]"> <img src="images/page_edit.png" alt="[Edit]">
<input type="checkbox" name="role_edit" {if in_array('edit', $user->role)} checked="checked"{/if} <input type="checkbox" name="role_edit" {if in_array('edit', $user->role)} checked="checked"{/if}
</td> </td>
</tr> </tr>
@ -79,7 +79,7 @@
{$lang_user_role_delete} {$lang_user_role_delete}
</td> </td>
<td class="value"> <td class="value">
<img src="images/delete.png" alt="[Delete]"> <img src="images/page_delete.png" alt="[Delete]">
<input type="checkbox" name="role_delete" {if in_array('delete', $user->role)} checked="checked"{/if} <input type="checkbox" name="role_delete" {if in_array('delete', $user->role)} checked="checked"{/if}
</td> </td>
</tr> </tr>

@ -50,13 +50,13 @@
</td> </td>
<td class="value"> <td class="value">
{if in_array('add', $user->role)} {if in_array('add', $user->role)}
<img src="images/add.png" alt="{$lang_user_role_add}"{if $suser_tooltips} title="{$lang_user_role_add}"{/if} /> <img src="images/page_add.png" alt="{$lang_user_role_add}"{if $suser_tooltips} title="{$lang_user_role_add}"{/if} />
{/if} {/if}
{if in_array('edit', $user->role)} {if in_array('edit', $user->role)}
<img src="images/edit.png" alt="{$lang_user_role_edit}"{if $suser_tooltips} title="{$lang_user_role_edit}"{/if} /> <img src="images/page_edit.png" alt="{$lang_user_role_edit}"{if $suser_tooltips} title="{$lang_user_role_edit}"{/if} />
{/if} {/if}
{if in_array('delete', $user->role)} {if in_array('delete', $user->role)}
<img src="images/delete.png" alt="{$lang_user_role_delete}"{if $suser_tooltips} title="{$lang_user_role_delete}"{/if} /> <img src="images/page_delete.png" alt="{$lang_user_role_delete}"{if $suser_tooltips} title="{$lang_user_role_delete}"{/if} />
{/if} {/if}
{if in_array('manage', $user->role)} {if in_array('manage', $user->role)}
<img src="images/manage.png" alt="{$lang_user_role_manage}"{if $suser_tooltips} title="{$lang_user_role_manage}"{/if} /> <img src="images/manage.png" alt="{$lang_user_role_manage}"{if $suser_tooltips} title="{$lang_user_role_manage}"{/if} />
@ -66,22 +66,4 @@
{/if} {/if}
</td> </td>
</tr> </tr>
{if $suser_manage}
<tr>
<td class="label">
{if $newpass}
{$lang_options_newpassword1}
{else}
{$lang_pass_set}
{/if}
</td>
<td class="value">
{if $newpass}
{$newpass}
{else}
<a href="{$g_scriptname}?f=pass&amp;id={$user->id}"><img src="images/key_add.png" alt="{$lang_reset}"{if $suser_tooltips} title="{$lang_pass_set}"{/if} /></a>
{/if}
</td>
</tr>
{/if}
</table> </table>

@ -18,23 +18,6 @@ if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'] or $id = 0; $id = (int) $_REQUEST['id'] or $id = 0;
} }
function makepwd($length) {
mt_srand((double) microtime() * 1000000);
$digits = "0123456789";
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$umlauts = "ÄÖÜäöüß";
$specials = "!§$%&/()=?[]{}+~*#.,;:<>|";
$vocals = "AEIOUaeiou";
$consonants = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz";
$passwd = '';
$possible = $chars . $digits;
$l = strlen($possible)-1;
for ($k = 0; $k < $length; $k += 1) {
$passwd .= $possible[mt_rand(0, $l)];
}
return $passwd;
}
// ========== ACTIONS START =================================================== // ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) { switch ($submit = form_get_action()) {
@ -45,22 +28,6 @@ switch ($submit = form_get_action()) {
case 'edit': $action = ACT_EDIT; break; case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break; case 'del': $action = ACT_DELETE; break;
case 'pass':
// Create new random password to display once
$newpass = makepwd(8);
$sql = "UPDATE user SET user_pass=:pass WHERE user_id=:id";
$sth = $dbh->prepare($sql);
$sth->bindValue(':id', $id, PDO::PARAM_INT);
$sth->bindValue(':pass', password_hash($newpass, PASSWORD_BCRYPT), PDO::PARAM_STR);
try {
$sth->execute();
} catch (PDOException $e) {
$g_warning->Add($e->getMessage());
}
$smarty->assign('newpass', $newpass);
$action = ACT_VIEW;
break;
case 'insert': case 'insert':
$user_name = strtolower(sanitize($_POST['user_name'])); $user_name = strtolower(sanitize($_POST['user_name']));
$user_displayname = sanitize($_POST['user_displayname']); $user_displayname = sanitize($_POST['user_displayname']);
@ -189,7 +156,6 @@ $user = $sth->fetch(PDO::FETCH_OBJ);
$user->role = explode(',', $user->role); $user->role = explode(',', $user->role);
$smarty->assign("user", $user); $smarty->assign("user", $user);
// auth realms // auth realms
$smarty->assign("realm_ids", ['local', 'ldap']); $smarty->assign("realm_ids", ['local', 'ldap']);
$smarty->assign("realm_names", ['Local', 'LDAP']); $smarty->assign("realm_names", ['Local', 'LDAP']);