Compare commits

..

No commits in common. 'c13c7494bf8c5f8f1f50418ee1651f7fe1d41c37' and 'c500face92c27178ad9a0c007ef7d66a2170f520' have entirely different histories.

  1. 1
      assignnodetoasset.php
  2. 3
      lib.php
  3. 262
      lib/functions.php
  4. 3
      node.php
  5. 1
      nodeadd.php
  6. 2
      tpl/assignnodetoasset.tpl
  7. 4
      tpl/header.tpl
  8. 2
      tpl/node.tpl
  9. 2
      tpl/nodeadd.tpl

@ -17,7 +17,6 @@ include("header.php");
$smarty->assign("node_ip", $node_ip); $smarty->assign("node_ip", $node_ip);
$smarty->assign("asset_id", $asset_id); $smarty->assign("asset_id", $asset_id);
$smarty->assign("subnet_id", $subnet_id);
$query = "SELECT $query = "SELECT
asset_id, asset_id,

@ -26,7 +26,6 @@ $smarty = new Smarty();
$smarty->template_dir = 'tpl'; $smarty->template_dir = 'tpl';
$smarty->compile_dir = 'tpl_c'; $smarty->compile_dir = 'tpl_c';
$smarty->registerPlugin('function', 'treelist', 'print_tree'); $smarty->registerPlugin('function', 'treelist', 'print_tree');
$smarty->assign("suser_tooltips", $_SESSION['suser_tooltips']);
$smarty->assign("suser_tooltips", $_SESSION['suser_tooltips'] ?? 'off');
?> ?>

@ -1,158 +1,170 @@
<?php <?php
/***************************************************************************** /*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5) Copyright (C) 2007-2009 Wietse Warendorff
Copyright (C) 2011-2023 Thomas Hooge
SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
// strip mac address to 12 char string
function strip_mac($mac) {
// strip chars we don't need
$mac = preg_replace("|[^a-fA-F0-9]|", "", $mac);
// capitalize (just because it looks better eh)
$mac = strtoupper($mac);
// and return
return ($mac);
}
// rebuild mac address
function write_mac($mac) {
// check string length
if (strlen($mac)!=12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
} else {
// count to 12...
for ($i=0; $i<12; $i++) {
// ... and strip mac to pieces
${"mac".$i} = $mac{$i};
}
// get user preference This program is free software: you can redistribute it and/or modify
$user_mac = $_SESSION['suser_mac']; it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
// count to 12 again... This program is distributed in the hope that it will be useful,
for($i=0; $i<12; $i++) { but WITHOUT ANY WARRANTY; without even the implied warranty of
// ... and replace user preference with pieces MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$user_mac = preg_replace("/x/", ${"mac".$i}, $user_mac, 1); GNU General Public License for more details.
}
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For more information, visit http://sourceforge.net/projects/ipreg,
or contact me at wietsew@users.sourceforge.net
*****************************************************************************/
// strip mac address to 12 char string
function strip_mac($mac) {
// strip chars we don't need
$mac = preg_replace("|[^a-fA-F0-9]|", "", $mac);
// capitalize (just because it looks better eh)
$mac = strtoupper($mac);
// and return // and return
return $user_mac; return ($mac);
} }
}
// redirect page // rebuild mac address
function header_location($location) { function write_mac($mac) {
// send header // check string length
header("location: " . $location); if (strlen($mac)!=12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
} else {
// count to 12...
for($i=0;$i<12;$i++) {
// ... and strip mac to pieces
${"mac".$i} = $mac{$i};
}
// exit to be sure // get user preference
exit; $user_mac = $_SESSION['suser_mac'];
}
// sanitize input // count to 12 again...
function sanitize($input) { for($i=0;$i<12;$i++) {
global $dblink; // ... and replace user preference with pieces
$user_mac = preg_replace("/x/", ${"mac".$i}, $user_mac, 1);
}
// trim whitespaces // and return
$input = @trim($input); return $user_mac;
}
}
// magic quotes enabled? // redirect page
if(get_magic_quotes_gpc()) { function header_location($location) {
// strip slashes // send header
$input = stripslashes($input); header("location: " . $location);
// exit to be sure
exit;
} }
// convert to utf-8 // sanitize input
iconv("UTF-8", "UTF-8", $input); function sanitize($input) {
global $dblink;
// trim whitespaces
$input = @trim($input);
// convert special chars // magic quotes enabled?
$input = htmlentities($input,ENT_QUOTES,'UTF-8'); if(get_magic_quotes_gpc()) {
// strip slashes
$input = stripslashes($input);
}
// convert to utf-8
iconv("UTF-8", "UTF-8", $input);
// make sql ready // convert special chars
$input = mysqli_real_escape_string($dblink, $input); $input = htmlentities($input,ENT_QUOTES,'UTF-8');
// and return // make sql ready
return $input; $input = mysqli_real_escape_string($dblink, $input);
}
function mysql_nullstring($input) { // and return
if (isset($input)) {
return $input; return $input;
} else {
return '';
} }
}
function lang_getfrombrowser ($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true) { function mysql_nullstring($input) {
if ($lang_variable === null) { if (isset($input)) {
$lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE']; return $input;
} } else {
if (empty($lang_variable)) { return '';
return $default_language; }
} }
$accepted_languages = preg_split('/,\s*/', $lang_variable);
$current_lang = $default_language; function lang_getfrombrowser ($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true) {
$current_q = 0; if ($lang_variable === null) {
foreach ($accepted_languages as $accepted_language) { $lang_variable = $_SERVER['HTTP_ACCEPT_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 (empty($lang_variable)) {
if (isset($matches[2])) { return $default_language;
$lang_quality = (float)$matches[2];
} else {
$lang_quality = 1.0;
} }
while (count ($lang_code)) { $accepted_languages = preg_split('/,\s*/', $lang_variable);
if (in_array (strtolower (join ('-', $lang_code)), $allowed_languages)) { $current_lang = $default_language;
if ($lang_quality > $current_q) { $current_q = 0;
$current_lang = strtolower (join ('-', $lang_code)); foreach ($accepted_languages as $accepted_language) {
$current_q = $lang_quality; $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; break;
} }
array_pop ($lang_code);
} }
if ($strict_mode) {
break;
}
array_pop ($lang_code);
} }
return $current_lang;
} }
return $current_lang;
} function print_tree_rec($tree, $level) {
$output = '<ul class="treelvl' . $level. '">' . "\n";
function print_tree_rec($tree, $level) { foreach ($tree as $node) {
$output = '<ul class="treelvl' . $level. '">' . "\n"; $output .= '<li><a href="' . $node['href'] . '">' . $node['value'] . '</a>';
foreach ($tree as $node) { if ($node['children']) {
$output .= '<li><a href="' . $node['href'] . '">' . $node['value'] . '</a>'; $output .= "\n" . print_tree_rec($node['children'], $level+1);
if ($node['children']) { }
$output .= "\n" . print_tree_rec($node['children'], $level+1); $output .= "</li>\n";
} }
$output .= "</li>\n"; $output .= "</ul>\n";
return $output;
} }
$output .= "</ul>\n";
return $output; function print_tree ($params, &$smarty) {
} if (empty($params['level'])) {
$level = 0;
//function print_tree($params, &$smarty) { } else {
function print_tree($params, Smarty_Internal_Template $template) { $level = $params['level'];
if (empty($params['level'])) { }
$level = 0; if (empty($params['tree'])) {
} else { return '';
$level = $params['level']; } else {
} return print_tree_rec($params['tree'], $level);
if (empty($params['tree'])) { }
return '';
} else {
return print_tree_rec($params['tree'], $level);
} }
}
?> ?>

@ -15,8 +15,7 @@ if(isset($_GET['subnet_id'])) {
$subnet_view = "WHERE node.subnet_id=" . $subnet_id; $subnet_view = "WHERE node.subnet_id=" . $subnet_id;
$smarty->assign("subnet_id", $subnet_id); $smarty->assign("subnet_id", $subnet_id);
} else { } else {
$smarty->assign("subnet_id", ''); $smarty->assign("subnet_id", "");
$subnet_view = '';
} }
$query = "SELECT $query = "SELECT

@ -17,7 +17,6 @@ include("header.php");
$smarty->assign("user_dns1suffix", $_SESSION['suser_dns1suffix']); $smarty->assign("user_dns1suffix", $_SESSION['suser_dns1suffix']);
$smarty->assign("user_dns2suffix", $_SESSION['suser_dns2suffix']); $smarty->assign("user_dns2suffix", $_SESSION['suser_dns2suffix']);
$smarty->assign("node_ip", $node_ip); $smarty->assign("node_ip", $node_ip);
$smarty->assign("subnet_id", $subnet_id);
$smarty->assign("subnet_options", $db->options_subnet()); $smarty->assign("subnet_options", $db->options_subnet());
$smarty->assign("assetclass_options", $db->options_assetclass()); $smarty->assign("assetclass_options", $db->options_assetclass());

@ -97,7 +97,7 @@
{$lang_subnet_subnetaddress}/{$lang_subnet_mask} {$lang_subnet_subnetaddress}/{$lang_subnet_mask}
</td> </td>
<td class="value"> <td class="value">
{html_options name=subnet_id options=$subnet_options selected=$subnet_id} {html_options name=subnet_id options=$subnet_options}
</td> </td>
</tr> </tr>
</table> </table>

@ -6,16 +6,12 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="images/shield.ico"> <link rel="shortcut icon" href="images/shield.ico">
<link rel="stylesheet" href="tpl/style.css" type="text/css"> <link rel="stylesheet" href="tpl/style.css" type="text/css">
{if isset($styles)}
{foreach item=style from=$styles} {foreach item=style from=$styles}
<link rel="stylesheet" href="css/{$style[0]}" type="text/css" media="{$style[1]}" /> <link rel="stylesheet" href="css/{$style[0]}" type="text/css" media="{$style[1]}" />
{/foreach} {/foreach}
{/if}
{if isset($scripts)}
{foreach item=script from=$scripts} {foreach item=script from=$scripts}
<script type="text/javascript" src="lib/{$script}"></script> <script type="text/javascript" src="lib/{$script}"></script>
{/foreach} {/foreach}
{/if}
</head> </head>
<body> <body>

@ -2,7 +2,7 @@
<tr> <tr>
<td class="header"> <td class="header">
<img class="icon" src="images/network-ethernet.png" alt="" /> <img class="icon" src="images/network-ethernet.png" alt="" />
{$lang_nodes} ({$nodes|@count}) {$lang_nodes} ({$node|@count})
</td> </td>
<td align="right"> <td align="right">
<a href="nodeadd.php?subnet_id={$subnet_id}"><img src="image.php?icon=add" alt="{$lang_node_add}"></a> <a href="nodeadd.php?subnet_id={$subnet_id}"><img src="image.php?icon=add" alt="{$lang_node_add}"></a>

@ -125,7 +125,7 @@
{$lang_subnet_subnetaddress}/{$lang_subnet_mask} {$lang_subnet_subnetaddress}/{$lang_subnet_mask}
</td> </td>
<td class="value"> <td class="value">
{html_options name=subnet_id options=$subnet_options selected=$subnet_id} {html_options name=subnet_id options=$subnet_options}
</td> </td>
</tr> </tr>
</table> </table>