Make use of Yapter Template Engine

master v0.3
Thomas Hooge 1 year ago
parent 7322231d3e
commit 8d00ee5e1b
  1. 37
      asset.php
  2. 86
      assetadd.php
  3. 37
      assetclass.php
  4. 69
      assetclassadd.php
  5. 24
      assetclassdel.php
  6. 92
      assetclassedit.php
  7. 79
      assetclassgroupview.php
  8. 94
      assetclassview.php
  9. 30
      assetdel.php
  10. 113
      assetedit.php
  11. 190
      assetview.php
  12. 140
      assigniptoasset.php
  13. 74
      assigniptonode.php
  14. 71
      assignlocationtosubnet.php
  15. 2
      assignsubnettolocation.php
  16. 74
      assignvlantosubnet.php
  17. 49
      config.php
  18. 21
      error.php
  19. 27
      footer.php
  20. 49
      functions.php
  21. 73
      header.php
  22. BIN
      images/warning.gif
  23. 83
      index.php
  24. 247
      install/install.sql
  25. 2
      install/install.txt
  26. 116
      lang/en.php
  27. 91
      location.php
  28. 68
      locationadd.php
  29. 24
      locationdel.php
  30. 92
      locationedit.php
  31. 156
      locationview.php
  32. 8
      login.php
  33. 3
      logout.php
  34. 212
      nodeadd.php
  35. 28
      nodedel.php
  36. 148
      nodeedit.php
  37. 102
      nodelist.php
  38. 129
      nodeview.php
  39. 91
      options.php
  40. 190
      search.php
  41. 419
      submit.php
  42. 40
      subnet.php
  43. 53
      subnetadd.php
  44. 34
      subnetdel.php
  45. 117
      subnetedit.php
  46. 397
      subnetview.php
  47. 16
      tpl/asset.tpl
  48. 53
      tpl/assetadd.tpl
  49. 16
      tpl/assetclass.tpl
  50. 37
      tpl/assetclassadd.tpl
  51. 34
      tpl/assetclassdel.tpl
  52. 38
      tpl/assetclassedit.tpl
  53. 49
      tpl/assetclassgroupview.tpl
  54. 49
      tpl/assetclassview.tpl
  55. 51
      tpl/assetdel.tpl
  56. 54
      tpl/assetedit.tpl
  57. 118
      tpl/assetview.tpl
  58. 89
      tpl/assigniptoasset.tpl
  59. 38
      tpl/assigniptonode.tpl
  60. 44
      tpl/assignlocationtosubnet.tpl
  61. 43
      tpl/assignvlantosubnet.tpl
  62. 12
      tpl/error.tpl
  63. 13
      tpl/footer.tpl
  64. 31
      tpl/header.tpl
  65. 57
      tpl/index.tpl
  66. 16
      tpl/location.tpl
  67. 38
      tpl/locationadd.tpl
  68. 29
      tpl/locationdel.tpl
  69. 47
      tpl/locationedit.tpl
  70. 73
      tpl/locationview.tpl
  71. 91
      tpl/nodeadd.tpl
  72. 30
      tpl/nodedel.tpl
  73. 78
      tpl/nodeedit.tpl
  74. 46
      tpl/nodelist.tpl
  75. 87
      tpl/nodeview.tpl
  76. 102
      tpl/options.tpl
  77. 41
      tpl/search.tpl
  78. 39
      tpl/style.css
  79. 16
      tpl/subnet.tpl
  80. 31
      tpl/subnetadd.tpl
  81. 51
      tpl/subnetdel.tpl
  82. 55
      tpl/subnetedit.tpl
  83. 153
      tpl/subnetview.tpl
  84. 41
      tpl/useradd.tpl
  85. 46
      tpl/useredit.tpl
  86. 39
      tpl/userpassedit.tpl
  87. 16
      tpl/vlan.tpl
  88. 31
      tpl/vlanadd.tpl
  89. 29
      tpl/vlandel.tpl
  90. 40
      tpl/vlanedit.tpl
  91. 64
      tpl/vlanview.tpl
  92. 71
      useradd.php
  93. 50
      useredit.php
  94. 76
      userpassedit.php
  95. 40
      vlan.php
  96. 52
      vlanadd.php
  97. 25
      vlandel.php
  98. 80
      vlanedit.php
  99. 113
      vlanview.php
  100. 483
      yapter.php

@ -1,23 +1,24 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>Asset:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="assetview.php?asset_id=' . $row->asset_id . '">' . $row->asset_name . '</a></td></tr>';
}
?>
</table>
<?
// set template
$tp = new Template("tpl/asset.tpl");
// set language variables
$tp->setvars($lang);
// get asset info
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("asset_id", $row->asset_id);
$tp->set("asset_name", $row->asset_name);
$tp->parse("assetrow");
}
if (($i>0) ? $tp->parse("asset") : $tp->hide("asset"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,80 +1,24 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/assetadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$asset_info = $_POST['asset_info'];
mysql_query("INSERT INTO asset (asset_name, hostname, assetclass_id, asset_info) VALUE ('$asset_name', '$hostname', '$assetclass_id', '$asset_info')") or die(mysql_error());
$asset_id = mysql_insert_id();
header_location("assetview.php?asset_id=" . $asset_id);
}
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="assetadd.php">
<input type="hidden" name="asset_id" value="<?php echo $asset_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Add asset:</b><br>
</td>
</tr>
<tr>
<td>
Asset name:
</td>
<td>
<input type="text" name="asset_name">
</td>
</tr>
<tr>
<td>
Hostname:
</td>
<td>
<input type="text" name="hostname">
</td>
</tr>
<tr>
<td>
Asset class:
</td>
<td>
<select name="assetclass_id">
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->assetclass_id . '">' . $row->assetclass_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Asset info:
</td>
<td>
<textarea name="asset_info"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get assetclassgroup information
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("assetclass_id", $row->assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
$tp->parse("assetclassrow");
}
if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,23 +1,24 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>Assetclass:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="assetclassview.php?assetclass_id=' . $row->assetclass_id . '">' . $row->assetclass_name . '</a></td></tr>';
}
?>
</table>
<?php
// set template
$tp = new Template("tpl/assetclass.tpl");
// set language variables
$tp->setvars($lang);
// get assetclass info
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("assetclass_id", $row->assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
$tp->parse("assetclassrow");
}
if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,63 +1,24 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/assetclassadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$assetclass_name = $_POST['assetclass_name'];
$assetclassgroup_id = $_POST['assetclassgroup_id'];
mysql_query("INSERT INTO assetclass (assetclass_name, assetclassgroup_id) VALUE ('$assetclass_name', '$assetclassgroup_id')") or die(mysql_error());
$assetclass_id = mysql_insert_id();
header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
}
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="assetclassadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new assetclass:</b><br>
</td>
</tr>
<tr>
<td>
Assetclass name:
</td>
<td>
<input type="text" name="assetclass_name">
</td>
</tr>
<tr>
<td>
Assetclass Group:<br>
</td>
<td>
<select name="assetclassgroup_id">
<?php
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->assetclassgroup_id . '">' . $row->assetclassgroup_name. '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get assetclassgroup information
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("assetclassgroup_id", $row->assetclassgroup_id);
$tp->set("assetclassgroup_name", $row->assetclassgroup_name);
$tp->parse("assetclassgrouprow");
}
if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,24 @@
<?php
include("header.php");
// get id
$assetclass_id = $_GET['assetclass_id'];
// set template
$tp = new Template("tpl/assetclassdel.tpl");
// set language variables
$tp->setvars($lang);
// get assetclass info
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass WHERE assetclass_id='$assetclass_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("assetclass_id", $row->assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,78 +1,36 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
$assetclass_id = $_GET['assetclass_id'];
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$assetclass_id = $_POST['assetclass_id'];
$assetclass_name = $_POST['assetclass_name'];
$assetclassgroup_id = $_POST['assetclassgroup_id'];
mysql_query("UPDATE assetclass SET assetclass_name='$assetclass_name', assetclassgroup_id='$assetclassgroup_id' WHERE assetclass_id='$assetclass_id'") or die(mysql_error());
header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
}
// set template
$tp = new Template("tpl/assetclassedit.tpl");
$assetclass_id = $_GET['assetclass_id'];
// set language variables
$tp->setvars($lang);
// get assetclass information
$result = mysql_query("SELECT assetclass_name, assetclassgroup_id FROM assetclass WHERE assetclass_id='$assetclass_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$assetclassgroup_id = $row->assetclassgroup_id;
$tp->set("assetclass_id", $assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
$tp->set("assetclassgroup_id", $assetclassgroup_id);
// get current information
$result = mysql_query("SELECT assetclass_name, assetclassgroup_id FROM assetclass WHERE assetclass_id='$assetclass_id'");
while ($row = mysql_fetch_object($result)) {
$assetclass_name = $row->assetclass_name;
$assetclassgroup_id = $row->assetclassgroup_id;
// get assetclassgroup information
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->assetclassgroup_id==$assetclassgroup_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("assetclassgroup_id", $row->assetclassgroup_id);
$tp->set("assetclassgroup_name", $row->assetclassgroup_name);
$tp->parse("assetclassgrouprow");
}
?>
if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup"));
<form method="POST" action="assetclassedit.php">
<input type="hidden" name="assetclass_id" value="<?php echo $assetclass_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit assetclass:</b><br>
</td>
</tr>
<tr>
<td>
Assetclass name:
</td>
<td>
<input type="text" name="assetclass_name" value="<?php echo $assetclass_name; ?>">
</td>
</tr>
<tr>
<td>
Assetclass Group:<br>
</td>
<td>
<select name="assetclassgroup_id">
<?php
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name FROM assetclassgroup ORDER BY assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
if ($row->assetclassgroup_id==$assetclassgroup_id) {
$selected = "selected";
} else {
$selected = "";
}
echo '<option value="' . $row->assetclassgroup_id . '" ' . $selected . '>' . $row->assetclassgroup_name. '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -3,49 +3,44 @@
// get id
$assetclassgroup_id = $_GET['assetclassgroup_id'];
// set template
$tp = new Template("tpl/assetclassgroupview.tpl");
// set language variables
$tp->setvars($lang);
// get assetclassgroup info
$result = mysql_query("SELECT assetclassgroup_name, color FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'");
while ($row = mysql_fetch_object($result)) {
$assetclassgroup_name = $row->assetclassgroup_name;
$color = $row->color;
$result = mysql_query("SELECT assetclassgroup_name, color FROM assetclassgroup WHERE assetclassgroup_id='$assetclassgroup_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("assetclassgroup_name", $row->assetclassgroup_name);
$tp->set("color", $row->color);
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass WHERE assetclassgroup_id='$assetclassgroup_id' ORDER BY assetclass_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("assetclass_name", $row->assetclass_name);
$tp->set("assetclass_id", $row->assetclass_id);
$tp->parse("assetclassrow");
}
?>
<table border="0">
<tr>
<td>
<b>Assetclass Groupname:</b>
</td>
<td>
<?php echo $assetclassgroup_name; ?>
</td>
</tr>
<tr>
<td>
<b>Color:</b>
</td>
<td>
<img src="images/<?php echo $color; ?>.jpg">
</td>
</tr>
<tr>
<td>
<b>Assetclass(es):</b>
</td>
<td>
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass WHERE assetclassgroup_id='$assetclassgroup_id' ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<a href="assetclassview.php?assetclass_id=' . $row->assetclass_id . '">' . $row->assetclass_name . '</a><br>';
}
?>
</td>
</tr>
</table>
<?php
if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass"));
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assetclassgroupedit) {
$tp->set("assetclassgroup_id", $assetclassgroup_id);
$tp->parse("assetclassgroupedit");
} else {
$tp->hide("assetclassgroupedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_assetclassgroupdel) {
$tp->set("assetclassgroup_id", $assetclassgroup_id);
$tp->parse("assetclassgroupdel");
} else {
$tp->hide("assetclassgroupdel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -3,68 +3,46 @@
// get id
$assetclass_id = $_GET['assetclass_id'];
// set template
$tp = new Template("tpl/assetclassview.tpl");
// set language variables
$tp->setvars($lang);
// get assetclassgroup info
$result = mysql_query("SELECT ac.assetclassgroup_id, ac.assetclass_name, acg.assetclassgroup_name FROM assetclass ac, assetclassgroup acg WHERE ac.assetclass_id='$assetclass_id' AND acg.assetclassgroup_id=ac.assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
$assetclass_name = $row->assetclass_name;
$assetclassgroup_id = $row->assetclassgroup_id;
$assetclassgroup_name = $row->assetclassgroup_name;
$result = mysql_query("SELECT ac.assetclassgroup_id, ac.assetclass_name, acg.assetclassgroup_name FROM assetclass ac, assetclassgroup acg WHERE ac.assetclass_id='$assetclass_id' AND acg.assetclassgroup_id=ac.assetclassgroup_id") or die(mysql_error());
$row = mysql_fetch_object($result);
$tp->set("assetclass_name", $row->assetclass_name);
$tp->set("assetclassgroup_id", $row->assetclassgroup_id);
$tp->set("assetclassgroup_name", $row->assetclassgroup_name);
// get assets for this assetclassgroup
$result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE assetclass_id='$assetclass_id' ORDER BY asset_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("asset_id", $row->asset_id);
$tp->set("asset_name", $row->asset_name);
$tp->parse("assetrow");
}
?>
<table border="0">
<tr>
<td>
<b>Assetclass Name:</b>
</td>
<td>
<?php echo $assetclass_name; ?>
</td>
</tr>
<tr>
<td>
<b>Assetclass Groupname:</b>
</td>
<td>
<a href="assetclassgroupview.php?assetclassgroup_id=<?php echo $assetclassgroup_id; ?>"><?php echo $assetclassgroup_name; ?></a>
</td>
</tr>
<tr>
<td>
<b>Asset(s):</b><br>
</td>
<td>
<?php
$result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE assetclass_id='$assetclass_id' ORDER BY asset_name");
while ($row = mysql_fetch_object($result)) {
echo '<a href="assetview.php?asset_id=' . $row->asset_id . '">' . $row->asset_name . '</a><br>';
}
?>
</td>
</tr>
</table>
if (($i>0) ? $tp->parse("asset") : $tp->hide("asset"));
<p>
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetclassedit.php?assetclass_id=<?php echo $assetclass_id; ?>">Modify assetclass</a>
</td>
</tr>
</table>
<?php
// end display only if admin
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assetclassedit) {
$tp->set("assetclass_id", $assetclass_id);
$tp->parse("assetclassedit");
} else {
$tp->hide("assetclassedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_assetclassdel) {
$tp->set("assetclass_id", $assetclass_id);
$tp->parse("assetclassdel");
} else {
$tp->hide("assetclassdel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,17 +1,33 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
$asset_id = $_GET['asset_id'];
mysql_query("DELETE FROM asset WHERE asset_id='$asset_id'") or die(mysql_error());
mysql_query("DELETE FROM node WHERE asset_id='$asset_id'") or die(mysql_error());
header("Location: asset.php");
// set template
$tp = new Template("tpl/assetdel.tpl");
// set language variables
$tp->setvars($lang);
// get asset info
$result = mysql_query("SELECT asset_name FROM asset WHERE asset_id='$asset_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("asset_id", $asset_id);
$tp->set("asset_name", $row->asset_name);
// end display only if admin
// get node info
$result = mysql_query("SELECT n.node_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM node n, subnet s WHERE asset_id='$asset_id' AND s.subnet_id=n.subnet_id ORDER BY INET_ATON(n.ip)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("node_id", $row->node_id);
$tp->set("ip", $row->ip);
$tp->parse("noderow");
}
if (($i>0) ? $tp->parse("node") : $tp->hide("node"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,96 +1,37 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$asset_id = $_POST['asset_id'];
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$asset_info = $_POST['asset_info'];
mysql_query("UPDATE asset SET asset_name='$asset_name', hostname='$hostname', assetclass_id='$assetclass_id', asset_info='$asset_info' WHERE asset_id='$asset_id'") or die(mysql_error());
header_location("assetview.php?asset_id=" . $asset_id);
}
// get id
$asset_id = $_GET['asset_id'];
// get current information
$result = mysql_query("SELECT asset_name, hostname, assetclass_id, asset_info FROM asset WHERE asset_id='$asset_id'");
while ($row = mysql_fetch_object($result)) {
$asset_name = $row->asset_name;
$hostname = $row->hostname;
$assetclass_id = $row->assetclass_id;
$asset_info = $row->asset_info;
}
?>
// set template
$tp = new Template("tpl/assetedit.tpl");
<form method="POST" action="assetedit.php">
<input type="hidden" name="asset_id" value="<?php echo $asset_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit asset:</b><br>
</td>
</tr>
<tr>
<td>
Asset name:
</td>
<td>
<input type="text" name="asset_name" value="<?php echo $asset_name; ?>">
</td>
</tr>
<tr>
<td>
Hostname:
</td>
<td>
<input type="text" name="hostname" value="<?php echo $hostname; ?>">
</td>
</tr>
<tr>
<td>
Asset class:
</td>
<td>
<select name="assetclass_id">
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
if ($row->assetclass_id==$assetclass_id) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $row->assetclass_id . '" ' . $selected . '>' . $row->assetclass_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Asset info:
</td>
<td>
<textarea name="asset_info"><?php echo $asset_info; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// set language variables
$tp->setvars($lang);
// get asset information
$result = mysql_query("SELECT asset_name, hostname, assetclass_id, asset_info FROM asset WHERE asset_id='$asset_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$assetclass_id = $row->assetclass_id;
$tp->set("asset_id", $asset_id);
$tp->set("asset_name", $row->asset_name);
$tp->set("hostname", $row->hostname);
$tp->set("asset_info", $row->asset_info);
// get assetclass information
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->assetclass_id==$assetclass_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("assetclass_id", $row->assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
$tp->parse("assetclassrow");
}
if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -3,156 +3,56 @@
// get id
$asset_id = $_GET['asset_id'];
// set template
$tp = new Template("tpl/assetview.tpl");
// set language variables
$tp->setvars($lang);
// get asset info
$result = mysql_query("SELECT a.asset_name, a.hostname, a.asset_info, ac.assetclass_id, ac.assetclass_name FROM asset a, assetclass ac WHERE a.asset_id='$asset_id' AND ac.assetclass_id=a.assetclass_id");
while ($row = mysql_fetch_object($result)) {
$asset_name = $row->asset_name;
$hostname = $row->hostname;
$asset_info = $row->asset_info;
$assetclass_id = $row->assetclass_id;
$assetclass_name = $row->assetclass_name;
}
?>
<table border="0">
<tr>
<td>
<b>Asset name:</b>
</td>
<td>
<?php echo $asset_name; ?>
</td>
</tr>
<tr>
<td>
<b>Hostname:</b>
</td>
<td>
<?php echo $hostname; ?>
</td>
</tr>
<tr>
<td>
<b>Asset class:</b>
</td>
<td>
<a href="assetclassview.php?assetclass_id=<?php echo $assetclass_id; ?>"><?php echo $assetclass_name; ?></a>
</td>
</tr>
<tr>
<td>
<b>Asset info:</b>
</td>
<td>
<?php echo nl2br($asset_info); ?>
</td>
</tr>
</table>
<?php
// get node info
$nodecount=0;
$result = mysql_query("SELECT n.node_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM node n, subnet s WHERE asset_id='$asset_id' AND s.subnet_id=n.subnet_id ORDER BY INET_ATON(n.ip)");
while ($row = mysql_fetch_object($result)) {
$node_id = $row->node_id;
$ip = $row->ip;
$mac = write_mac($row->mac);
$dns1 = $row->dns1;
$dns2 = $row->dns2;
$subnet_id = $row->subnet_id;
$node_info = $row->node_info;
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$nodecount++;
?>
<p>
<table border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<b>Node #<?php echo $nodecount; ?></b>
</td>
</tr>
<tr>
<td>
<b>IP Address:</b>
</td>
<td>
<a href="nodeview.php?node_id=<?php echo $node_id; ?>"><?php echo $ip; ?></a>
</td>
</tr>
<tr>
<td>
<b>Subnet:</b>
</td>
<td>
<a href="subnetview.php?subnet_id=<?php echo $subnet_id; ?>&page=<?php echo page($ip); ?>"><?php echo $subnet_address; ?>/<?php echo $subnet_mask; ?></a>
</td>
</tr>
<tr>
<td>
<b>MAC Address:</b>
</td>
<td>
<?php echo $mac; ?>
</td>
</tr>
<tr>
<td>
<b>DNS name:</b>
</td>
<td>
<?php echo $dns1; ?>
</td>
</tr>
<tr>
<td>
<b>DNS alias:</b>
</td>
<td>
<?php echo $dns2; ?>
</td>
</tr>
<tr>
<td>
<b>Node info:</b>
</td>
<td>
<?php echo nl2br($node_info); ?>
</td>
</tr>
</table>
$result = mysql_query("SELECT a.asset_name, a.hostname, a.asset_info, ac.assetclass_id, ac.assetclass_name FROM asset a, assetclass ac WHERE a.asset_id='$asset_id' AND ac.assetclass_id=a.assetclass_id") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("asset_name", $row->asset_name);
$tp->set("hostname", $row->hostname);
$tp->set("asset_info", nl2br($row->asset_info));
$tp->set("assetclass_id", $row->assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
<?php
// get node info
$result = mysql_query("SELECT n.node_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM node n, subnet s WHERE asset_id='$asset_id' AND s.subnet_id=n.subnet_id ORDER BY INET_ATON(n.ip)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("node_id", $row->node_id);
$tp->set("ip", $row->ip);
$tp->set("mac", write_mac($row->mac));
$tp->set("dns1", $row->dns1);
$tp->set("dns2", $row->dns2);
$tp->set("node_info", nl2br($row->node_info));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->set("nodecount", $i+1);
$tp->parse("noderow");
}
if (($i>0) ? $tp->parse("node") : $tp->hide("node"));
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetedit.php?asset_id=<?php echo $asset_id; ?>">Modify asset</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetdel.php?asset_id=<?php echo $asset_id; ?>">Delete asset</a>
</td>
</tr>
</table>
<?php
// end display only if admin
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assetedit) {
$tp->set("asset_id", $asset_id);
$tp->parse("assetedit");
} else {
$tp->hide("assetedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_assetdel) {
$tp->set("asset_id", $asset_id);
$tp->parse("assetdel");
} else {
$tp->hide("assetdel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,115 +1,45 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get ip and id
if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = "");
if((isset($_GET['ip'])) ? $ip = $_GET['ip'] : $ip = "");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$ip = $_POST['ip'];
$mac = strip_mac($_POST['mac']);
$subnet_id = $_POST['subnet_id'];
$asset_id = $_POST['asset_id'];
$node_info = $_POST['node_info'];
// DNS1
if (!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) {
$dns1 = $_POST['dns1'] . $config_dns1suffix;
} else {
$dns1 = $_POST['dns1'];
}
// DNS2
if (!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) {
$dns2 = $_POST['dns2'] . $config_dns2suffix;
} else {
$dns2 = $_POST['dns2'];
}
mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id, node_info) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id', '$node_info')") or die(mysql_error());
header_location("assetview.php?asset_id=" . $asset_id);
}
// set template
$tp = new Template("tpl/assigniptoasset.tpl");
$ip = $_GET['ip'];
$subnet_id = $_GET['subnet_id'];
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="assigniptoasset.php">
<input type="hidden" name="ip" value="<?php echo $ip; ?>">
<input type="hidden" name="subnet_id" value="<?php echo $subnet_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign <?php echo $ip; ?>:</b><br>
</td>
</tr>
<tr>
<td>
Asset:
</td>
<td>
<select name="asset_id">
<?php
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->asset_id . '">' . $row->asset_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
MAC address:
</td>
<td>
<input type="text" name="mac">
</td>
</tr>
<tr>
<td>
DNS name:
</td>
<td>
<input type="text" name="dns1">
</td>
<td>
<input type="checkbox" name="dns1suffix" checked><?php echo $config_dns1suffix; ?>
</td>
</tr>
<tr>
<td>
DNS alias:
</td>
<td>
<input type="text" name="dns2">
</td>
<td>
<input type="checkbox" name="dns2suffix" checked><?php echo $config_dns2suffix; ?>
</td>
</tr>
<tr>
<td>
Node info:
</td>
<td>
<textarea name="node_info"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// set variables
$tp->set("ip", $ip);
$tp->set("subnet_id", $subnet_id);
$tp->set("config_dns1suffix", $config_dns1suffix);
$tp->set("config_dns2suffix", $config_dns2suffix);
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
// get asset info
$result = mysql_query("SELECT asset_id, asset_name FROM asset ORDER BY asset_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("asset_id", $row->asset_id);
$tp->set("asset_name", $row->asset_name);
$tp->parse("assetrow");
}
if (($i>0) ? $tp->parse("asset") : $tp->hide("asset"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,59 +1,41 @@
<?php
include("header.php");
// get ip and id
$ip = $_GET['ip'];
$subnet_id = $_GET['subnet_id'];
// get node info
$result = mysql_query("SELECT subnet_address, subnet_mask FROM subnet WHERE subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
}
?>
// set template
$tp = new Template("tpl/assigniptonode.tpl");
<table border="0">
<tr>
<td>
<b>IP:</b>
</td>
<td>
<?php echo $ip; ?>
</td>
</tr>
<tr>
<td>
<b>Subnet:</b>
</td>
<td>
<a href="subnetview.php?subnet_id=<?php echo $subnet_id; ?>&page=<?php echo page($ip); ?>"><?php echo $subnet_address; ?>/<?php echo $subnet_mask; ?></a>
</td>
</tr>
</table>
// set language variables
$tp->setvars($lang);
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
// set variables
$tp->set("ip", $ip);
$tp->set("subnet_id", $subnet_id);
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assigniptoasset.php?ip=<?php echo $ip; ?>&subnet_id=<?php echo $subnet_id; ?>">Assign IP to asset</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodeadd.php?ip=<?php echo $ip; ?>&subnet_id=<?php echo $subnet_id; ?>">Create new asset</a>
</td>
</tr>
</table>
<?php
// end display only if admin
// get subnet info
$result = mysql_query("SELECT subnet_address, subnet_mask FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assigniptonode) {
$tp->parse("assigniptonode");
} else {
$tp->hide("assigniptonode");
}
if($_SESSION['suser_level'] >= $config_userlevel_nodeadd) {
$tp->parse("nodeadd");
} else {
$tp->hide("nodeadd");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,53 +1,40 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
if((isset($_GET['location_id'])) ? $location_id = $_GET['location_id'] : $location_id = "");
if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = "");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$location_id = $_POST['location_id'];
$subnet_id = $_POST['subnet_id'];
mysql_query("INSERT INTO subnetlocation (location_id, subnet_id) VALUE ('$location_id', '$subnet_id')") or die(mysql_error());
// set template
$tp = new Template("tpl/assignlocationtosubnet.tpl");
// set language variables
$tp->setvars($lang);
header("Location: location.php");
// get location info
$result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name");
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->location_id==$location_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("location_id", $row->location_id);
$tp->set("location_name", $row->location_name);
$tp->parse("locationrow");
}
if (($i>0) ? $tp->parse("location") : $tp->hide("location"));
$location_id = $_GET['location_id'];
?>
<form method="POST" action="assignlocationtosubnet.php">
<input type="hidden" name="location_id" value="<?php echo $location_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign to:</b><br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->subnet_id . '">' . $row->subnet_address . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -29,7 +29,7 @@
<?php
function display_children($parent, $level) {
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$parent' ORDER BY location_name");
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$parent' ORDER BY location_name") or die(mysql_error());
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->location_id . '">' . str_repeat('&nbsp;&nbsp;&nbsp;',$level) . $row->location_name . '</option>';
display_children($row->location_id, $level+1);

@ -1,53 +1,41 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/assignvlantosubnet.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$vlan_id = $_POST['vlan_id'];
$subnet_id = $_POST['subnet_id'];
mysql_query("UPDATE subnet SET vlan_id='$vlan_id' WHERE subnet_id='$subnet_id'") or die(mysql_error());
header("location: vlanview.php?vlan_id=" . $vlan_id);
}
// set language variables
$tp->setvars($lang);
$vlan_id = $_GET['vlan_id'];
?>
// get id
if((isset($_GET['vlan_id'])) ? $vlan_id = $_GET['vlan_id'] : $vlan_id = "");
if((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = "");
<form method="POST" action="assignvlantosubnet.php">
<input type="hidden" name="vlan_id" value="<?php echo $vlan_id; ?>">
<table border="0">
<tr>
<td>
<b>Assign to:</b><br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->subnet_id . '">' . $row->subnet_address . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get vlan info
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->vlan_id==$vlan_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("vlan_id", $row->vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->set("vlan_number", $row->vlan_number);
$tp->parse("vlanrow");
}
if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan"));
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,17 +1,52 @@
<?php
// version
$config_version = 'v0.1';
$config_version = 'v0.3';
// db connection
$mysql_host = "localhost";
$mysql_username = "dbuser";
$mysql_password = "dbpass";
$mysql_dbname = "dbname";
$mysql_username = "db_user";
$mysql_password = "db_pass";
$mysql_dbname = "db_name";
// standard password for new users
$config_user_lang = "en";
$config_user_pass = "welcome";
// set userlevels
$config_userlevel_assetadd = 2;
$config_userlevel_assetdel = 2;
$config_userlevel_assetedit = 2;
$config_userlevel_assetview = 1;
$config_userlevel_assetclassadd = 2;
$config_userlevel_assetclassdel = 2;
$config_userlevel_assetclassedit = 2;
$config_userlevel_assetclassview = 1;
$config_userlevel_assetclassgroupadd = 2;
$config_userlevel_assetclassgroupdel = 2;
$config_userlevel_assetclassgroupedit = 2;
$config_userlevel_assetclassgroupview = 1;
$config_userlevel_locationadd = 2;
$config_userlevel_locationdel = 2;
$config_userlevel_locationedit = 2;
$config_userlevel_locationview = 1;
$config_userlevel_nodeadd = 2;
$config_userlevel_nodedel = 2;
$config_userlevel_nodeedit = 2;
$config_userlevel_nodeview = 1;
$config_userlevel_subnetadd = 2;
$config_userlevel_subnetdel = 2;
$config_userlevel_subnetedit = 2;
$config_userlevel_subnetview = 1;
$config_userlevel_useradd = 2;
$config_userlevel_userdel = 2;
$config_userlevel_useredit = 2;
$config_userlevel_userview = 1;
$config_userlevel_vlanadd = 2;
$config_userlevel_vlandel = 2;
$config_userlevel_vlanedit = 2;
$config_userlevel_vlanview = 1;
// domain suffix for dns input fields
$config_dns1suffix = '.your.domain';
$config_dns2suffix = '.your.domain';
$config_dns1suffix = '.yourdomain.com';
$config_dns2suffix = '.yourdomain.com';
?>

@ -0,0 +1,21 @@
<?php
include("header.php");
// set template
$tp = new Template("tpl/error.tpl");
// set language variables
$tp->setvars($lang);
// get error
$error = $_GET['error'];
// set veriables
$tp->set("error", $lang['lang_error_' . $error]);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,20 +1,11 @@
<?php
// start footer output
?>
<hr>
<table border="0" width="100%">
<tr>
<td align="center">
<a href="index.php" class="label">IP Reg <?php echo $config_version; ?></a>
</td>
</tr>
</table>
</body>
</html>
<?php
ob_end_flush();
// set template
$tp = new Template("tpl/footer.tpl");
// get version for the footer-stamp
$tp->set("config_version", $config_version);
// output
$tp->parse();
$tp->spit();
?>

@ -13,17 +13,26 @@
// rebuild mac address
function write_mac($mac) {
// check for invalid mac
if (strlen($mac)!=12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
} else {
} else {
// length is good, continue
$mac1 = substr($mac, 0, 2);
$mac2 = substr($mac, 2, 2);
$mac3 = substr($mac, 4, 2);
$mac4 = substr($mac, 6, 2);
$mac5 = substr($mac, 8, 2);
$mac6 = substr($mac, 10, 2);
$mac = $mac1 . '-' . $mac2 . '-' . $mac3 . '-' . $mac4 . '-' . $mac5 . '-' . $mac6;
// check session for preference (if 0, do nothing), if changed: update useredit.php too!
if ($_SESSION['suser_mac']==1) {
$mac = $mac1 . '-' . $mac2 . '-' . $mac3 . '-' . $mac4 . '-' . $mac5 . '-' . $mac6;
} else if ($_SESSION['suser_mac']==2) {
$mac = $mac1 . ':' . $mac2 . ':' . $mac3 . ':' . $mac4 . ':' . $mac5 . ':' . $mac6;
} else if ($_SESSION['suser_mac']==3) {
$mac = $mac1 . $mac2 . $mac3 . '-' . $mac4 . $mac5 . $mac6;
}
return $mac;
}
@ -31,39 +40,7 @@
// redirect page
function header_location($location) {
return header("location: " . $location);
header("location: " . $location);
exit;
}
// get location name and that of its parents and return with links to the locations
function location_name($location_id, $seperator) {
// create an array
$location_name = array();
// get location name(s)
$result = mysql_query("SELECT location_name, parent FROM location WHERE location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
// put this parent before any children
array_unshift($location_name, $row->location_name);
// repeat
location_name($row->parent, '.');
}
// count total no. of found locations
$location_count = count($location_name);
// display location for every array value
for ($i = 0; $i < $location_count; $i++ ) {
echo '<a href="locationview.php?location_id=' . $location_id . '">' . $location_name[$i] . '</a>' . $seperator;
}
}
// calculate page for pagination (pagination is used in subnetview.php)
function page($ip) {
$iprange = explode('.', $ip);
$iprange3 = $iprange[2];
return $iprange3;
}
?>

@ -1,17 +1,26 @@
<?php
session_start();
ob_start();
// check for user_id, if unnkown -> login
if(empty($_SESSION['suser_id'])) {
header("Location: login.php");
exit;
}
// includes
include("config.php");
include("dbconnect.php");
include("functions.php");
include("yapter.php");
// check for session
if(empty($_SESSION['suser_id'])) {
header("Location: login.php");
exit;
}
// include language file
include('lang/' . $_SESSION['suser_lang'] . '.php');
// set template
$tp = new Template("tpl/header.tpl");
// set language variables
$tp->setvars($lang);
// fill search box
if (isset($_POST['search'])) {
@ -25,47 +34,11 @@
}
}
// start header output
?>
<html>
<header>
<title>IP Reg</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</header>
<body>
<form method="POST" action="search.php">
<table border="0" width="100%">
<tr>
<td>
View by: <a href="asset.php">Asset</a> -
<a href="assetclass.php">Assetclass</a> -
<a href="location.php">Location</a> -
<a href="subnet.php">Subnet</a> -
<a href="vlan.php">VLAN</a>&nbsp;
.:<input type="text" name="search" value="<?php echo $search; ?>"><input type="submit" value="Search!">
</td>
<td align="right">
<?php
$suser_id = $_SESSION['suser_id'];
$result = mysql_query("SELECT displayname FROM user WHERE user_id='$suser_id'");
while ($row = mysql_fetch_object($result)) {
echo $displayname = $row->displayname . ' - ';
}
// TEMP display only if admin
if($_SESSION['suser_level'] >= 2) {
echo '<a href="nodeadd.php">Add new node</a> - ';
}
?>
<a href="options.php">Options</a> -
<a href="logout.php">Log out</a>
</td>
</tr>
</table>
</form>
<hr>
// give these to the templates too
$tp->set("suser_displayname", $_SESSION['suser_displayname']);
$tp->set("search", $search);
// output
$tp->parse();
$tp->spit();
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -1,81 +1,40 @@
<?php
include("header.php");
// calculate stats
// set template
$tp = new Template("tpl/index.tpl");
// set language variables
$tp->setvars($lang);
// calculate assets
$query = mysql_query("SELECT asset_id FROM asset") or die(mysql_error());
$assetcount = mysql_num_rows($query);
$tp->set('assetcount', $assetcount);
// calculate locations
$query = mysql_query("SELECT location_id FROM location") or die(mysql_error());
$locationcount = mysql_num_rows($query);
$tp->set('locationcount', $locationcount);
// calculate nodes
$query = mysql_query("SELECT node_id FROM node") or die(mysql_error());
$nodecount = mysql_num_rows($query);
$tp->set('nodecount', $nodecount);
// calculate subnets
$query = mysql_query("SELECT subnet_id FROM subnet") or die(mysql_error());
$subnetcount = mysql_num_rows($query);
$tp->set('subnetcount', $subnetcount);
// calculate vlans
$query = mysql_query("SELECT vlan_id FROM vlan") or die(mysql_error());
$vlancount = mysql_num_rows($query);
?>
<table border="0">
<tr>
<td>
<b>IP Reg <?php echo $config_version; ?></b><br>
</td>
</tr>
</table>
$tp->set('vlancount', $vlancount);
<p>
<table border="0">
<tr>
<td colspan="2">
<b>Statistics:</b>
</td>
</tr>
<tr>
<td width="100">
Assets:
</td>
<td align="right">
<?php echo $assetcount; ?>
</td>
</tr>
<tr>
<td>
Locations:
</td>
<td align="right">
<?php echo $locationcount; ?>
</td>
</tr>
<tr>
<td>
Nodes:
</td>
<td align="right">
<?php echo $nodecount; ?>
</td>
</tr>
<tr>
<td>
Subnets:
</td>
<td align="right">
<?php echo $subnetcount; ?>
</td>
</tr>
<tr>
<td>
VLANs:
</td>
<td align="right">
<?php echo $vlancount; ?>
</td>
</tr>
</table>
<?php
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,136 +1,213 @@
--
-- Database: `ipreg`
--
-- --------------------------------------------------------
--
-- Table structure for table `asset`
--
CREATE TABLE `asset` (
`asset_id` int(10) NOT NULL auto_increment,
`asset_name` varchar(100) NOT NULL default '',
`hostname` varchar(100) NOT NULL default '',
`assetclass_id` int(10) NOT NULL default '0',
`asset_info` text NOT NULL,
PRIMARY KEY (`asset_id`)
) ;
CREATE TABLE `asset` (
`asset_id` int(10) NOT NULL auto_increment,
`asset_name` varchar(100) NOT NULL default '',
`hostname` varchar(100) NOT NULL default '',
`assetclass_id` int(10) NOT NULL default '0',
`asset_info` text NOT NULL,
PRIMARY KEY (`asset_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `asset`
--
INSERT INTO `asset` VALUES (1, 'My Router', 'Router', 4, 'This is my router');
INSERT INTO `asset` VALUES (2, 'My PC', 'PC', 10, 'This is my workstation');
-- --------------------------------------------------------
--
-- Table structure for table `assetclass`
--
CREATE TABLE `assetclass` (
`assetclass_id` int(10) NOT NULL auto_increment,
`assetclassgroup_id` int(10) NOT NULL default '0',
`assetclass_name` varchar(100) NOT NULL default '',
PRIMARY KEY (`assetclass_id`)
) ;
CREATE TABLE `assetclass` (
`assetclass_id` int(10) NOT NULL auto_increment,
`assetclassgroup_id` int(10) NOT NULL default '0',
`assetclass_name` varchar(100) NOT NULL default '',
PRIMARY KEY (`assetclass_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
INSERT INTO `assetclass` VALUES ('', 1, 'Access device');
INSERT INTO `assetclass` VALUES ('', 1, 'Firewall');
INSERT INTO `assetclass` VALUES ('', 1, 'HUB');
INSERT INTO `assetclass` VALUES ('', 1, 'Router');
INSERT INTO `assetclass` VALUES ('', 1, 'Switch');
INSERT INTO `assetclass` VALUES ('', 2, 'Server');
INSERT INTO `assetclass` VALUES ('', 2, 'NAS');
INSERT INTO `assetclass` VALUES ('', 3, 'IP Phone');
INSERT INTO `assetclass` VALUES ('', 4, 'Laptop');
INSERT INTO `assetclass` VALUES ('', 4, 'PC');
INSERT INTO `assetclass` VALUES ('', 4, 'Printer');
INSERT INTO `assetclass` VALUES ('', 4, 'Thin Client');
--
-- Dumping data for table `assetclass`
--
INSERT INTO `assetclass` VALUES (1, 1, 'Access device');
INSERT INTO `assetclass` VALUES (2, 1, 'Firewall');
INSERT INTO `assetclass` VALUES (3, 1, 'HUB');
INSERT INTO `assetclass` VALUES (4, 1, 'Router');
INSERT INTO `assetclass` VALUES (5, 1, 'Switch');
INSERT INTO `assetclass` VALUES (6, 2, 'Server');
INSERT INTO `assetclass` VALUES (7, 2, 'NAS');
INSERT INTO `assetclass` VALUES (8, 3, 'IP Phone');
INSERT INTO `assetclass` VALUES (9, 4, 'Laptop');
INSERT INTO `assetclass` VALUES (10, 4, 'PC');
INSERT INTO `assetclass` VALUES (11, 4, 'Printer');
INSERT INTO `assetclass` VALUES (12, 4, 'Thin Client');
-- --------------------------------------------------------
--
-- Table structure for table `assetclassgroup`
--
CREATE TABLE `assetclassgroup` (
`assetclassgroup_id` int(10) NOT NULL auto_increment,
`assetclassgroup_name` varchar(100) NOT NULL default '',
`color` varchar(10) NOT NULL default '',
PRIMARY KEY (`assetclassgroup_id`)
) ;
CREATE TABLE `assetclassgroup` (
`assetclassgroup_id` int(10) NOT NULL auto_increment,
`assetclassgroup_name` varchar(100) NOT NULL default '',
`color` varchar(10) NOT NULL default '',
PRIMARY KEY (`assetclassgroup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--
-- Dumping data for table `assetclassgroup`
--
INSERT INTO `assetclassgroup` VALUES (1, 'Network', 'red');
INSERT INTO `assetclassgroup` VALUES (2, 'Servers', 'green');
INSERT INTO `assetclassgroup` VALUES (3, 'VOIP', 'orange');
INSERT INTO `assetclassgroup` VALUES (4, 'Workstations', 'blue');
INSERT INTO `assetclassgroup` VALUES (5, 'Other', 'black');
INSERT INTO `assetclassgroup` VALUES ('', 'Network', 'green');
INSERT INTO `assetclassgroup` VALUES ('', 'Servers', 'red');
INSERT INTO `assetclassgroup` VALUES ('', 'VOIP', 'orange');
INSERT INTO `assetclassgroup` VALUES ('', 'Workstations', 'blue');
INSERT INTO `assetclassgroup` VALUES ('', 'Other', 'black');
-- --------------------------------------------------------
--
-- Table structure for table `location`
--
CREATE TABLE `location` (
`location_id` int(10) NOT NULL auto_increment,
`location_name` varchar(100) NOT NULL default '',
`parent` int(1) NOT NULL default '0',
`location_info` text NOT NULL,
PRIMARY KEY (`location_id`)
) ;
CREATE TABLE `location` (
`location_id` int(10) NOT NULL auto_increment,
`location_name` varchar(100) NOT NULL default '',
`parent` int(1) NOT NULL default '0',
`location_info` text NOT NULL,
PRIMARY KEY (`location_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
--
-- Dumping data for table `location`
--
INSERT INTO `location` VALUES (1, 'Head Office', 0, '');
INSERT INTO `location` VALUES (2, '1st floor', 1, '');
INSERT INTO `location` VALUES (3, '2nd floor', 1, '');
INSERT INTO `location` VALUES (4, 'Administration', 2, '');
INSERT INTO `location` VALUES (5, 'Finance', 2, '');
INSERT INTO `location` VALUES (6, 'Branch office', 0, '');
INSERT INTO `location` VALUES (7, 'Planning', 3, '');
INSERT INTO `location` VALUES (8, 'Logistics', 6, '');
-- --------------------------------------------------------
--
-- Table structure for table `node`
--
CREATE TABLE `node` (
`node_id` int(10) NOT NULL auto_increment,
`ip` varchar(15) NOT NULL default '',
`mac` varchar(12) NOT NULL default '',
`dns1` varchar(100) NOT NULL default '',
`dns2` varchar(100) NOT NULL default '',
`subnet_id` int(10) NOT NULL default '0',
`asset_id` int(10) NOT NULL default '0',
`node_info` text NOT NULL,
PRIMARY KEY (`node_id`)
) ;
CREATE TABLE `node` (
`node_id` int(10) NOT NULL auto_increment,
`ip` varchar(15) NOT NULL default '',
`mac` varchar(12) NOT NULL default '',
`dns1` varchar(100) NOT NULL default '',
`dns2` varchar(100) NOT NULL default '',
`subnet_id` int(10) NOT NULL default '0',
`asset_id` int(10) NOT NULL default '0',
`node_info` text NOT NULL,
PRIMARY KEY (`node_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `node`
--
INSERT INTO `node` VALUES (1, '192.168.0.1', 'aabbcc112233', 'router1', '', 1, 1, '');
INSERT INTO `node` VALUES (2, '192.168.0.11', 'aa11bb22cc33', 'pc1', '', 1, 2, '');
-- --------------------------------------------------------
--
-- Table structure for table `subnet`
--
CREATE TABLE `subnet` (
`subnet_id` int(10) NOT NULL auto_increment,
`subnet_address` varchar(15) NOT NULL default '',
`subnet_mask` int(2) NOT NULL default '0',
`vlan_id` int(10) NOT NULL default '0',
`subnet_info` text NOT NULL,
PRIMARY KEY (`subnet_id`)
) ;
CREATE TABLE `subnet` (
`subnet_id` int(10) NOT NULL auto_increment,
`subnet_address` varchar(15) NOT NULL default '',
`subnet_mask` int(2) NOT NULL default '0',
`vlan_id` int(10) NOT NULL default '0',
`subnet_info` text NOT NULL,
PRIMARY KEY (`subnet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `subnet`
--
INSERT INTO `subnet` VALUES (1, '192.168.0.0', 24, 1, '');
-- --------------------------------------------------------
--
-- Table structure for table `subnetlocation`
--
CREATE TABLE `subnetlocation` (
`subnetlocation_id` int(10) NOT NULL auto_increment,
`subnet_id` int(10) NOT NULL default '0',
`location_id` int(10) NOT NULL default '0',
PRIMARY KEY (`subnetlocation_id`)
) ;
CREATE TABLE `subnetlocation` (
`subnetlocation_id` int(10) NOT NULL auto_increment,
`subnet_id` int(10) NOT NULL default '0',
`location_id` int(10) NOT NULL default '0',
PRIMARY KEY (`subnetlocation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `subnetlocation`
--
INSERT INTO `subnetlocation` VALUES (1, 1, 1);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`user_id` int(10) NOT NULL auto_increment,
`user_name` varchar(100) NOT NULL default '',
`user_pass` varchar(32) NOT NULL default '',
`user_level` int(1) NOT NULL default '0',
`displayname` varchar(100) NOT NULL default '',
PRIMARY KEY (`user_id`)
) ;
CREATE TABLE `user` (
`user_id` int(10) NOT NULL auto_increment,
`user_name` varchar(100) NOT NULL default '',
`user_pass` varchar(32) NOT NULL default '',
`user_level` int(1) NOT NULL default '0',
`user_displayname` varchar(100) NOT NULL default '',
`user_mac` int(1) NOT NULL default '0',
`user_lang` varchar(3) NOT NULL default '',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 2, 'admin');
INSERT INTO `user` VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 2, 'Administrator', 0, 'en');
-- --------------------------------------------------------
--
-- Table structure for table `vlan`
--
CREATE TABLE `vlan` (
`vlan_id` int(10) NOT NULL auto_increment,
`vlan_number` int(3) NOT NULL default '0',
`vlan_name` varchar(100) NOT NULL default '',
`vlan_info` text NOT NULL,
PRIMARY KEY (`vlan_id`)
) ;
CREATE TABLE `vlan` (
`vlan_id` int(10) NOT NULL auto_increment,
`vlan_number` int(3) NOT NULL default '0',
`vlan_name` varchar(100) NOT NULL default '',
`vlan_info` text NOT NULL,
PRIMARY KEY (`vlan_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `vlan`
--
INSERT INTO `vlan` VALUES (1, 1, 'DEFAULT_VLAN', '');

@ -1,5 +1,5 @@
---
--- IP Reg 0.1
--- IP Reg
--- http://ipreg.sourceforge.net
---

@ -0,0 +1,116 @@
<?php
$lang = array(
'lang_asset' => 'Asset',
'lang_assets' => 'Assets',
'lang_assetclass' => 'Assetclass',
'lang_assetclasses' => 'Assetclasses',
'lang_assetclassgroup' => 'Assetclassgroup',
'lang_assetclassgroups' => 'Assetclassgroups',
'lang_location' => 'Location',
'lang_locations' => 'Locations',
'lang_node' => 'Node',
'lang_nodes' => 'Nodes',
'lang_sublocation' => 'Sub-location',
'lang_sublocations' => 'Sub-locations',
'lang_subnet' => 'Subnet',
'lang_subnets' => 'Subnets',
'lang_vlan' => 'VLAN',
'lang_vlans' => 'VLANs',
'lang_color' => 'Color',
'lang_error' => 'Error',
'lang_header_viewby' => 'View by',
'lang_language' => 'Language',
'lang_login' => 'Login',
'lang_logout' => 'Logout',
'lang_options' => 'Options',
'lang_reset' => 'Reset',
'lang_search' => 'Search!',
'lang_statistics' => 'Statistics',
'lang_submit' => 'Submit',
'lang_unassigned' => 'Unassigned',
'lang_asset_add' => 'Add asset',
'lang_asset_del' => 'Delete asset',
'lang_asset_edit' => 'Modify asset',
'lang_asset_info' => 'Asset info',
'lang_asset_name' => 'Asset name',
'lang_hostname' => 'Hostname',
'lang_assetclass_add' => 'Add assetclass',
'lang_assetclass_del' => 'Delete assetclass',
'lang_assetclass_edit' => 'Mofidy assetclass',
'lang_assetclass_name' => 'Assetclass name',
'lang_assetclassgroup_add' => 'Add assetclassgroup',
'lang_assetclassgroup_del' => 'Delete assetclassgroup',
'lang_assetclassgroup_edit' => 'Modify assetclassgroup',
'lang_assetclassgroup_name' => 'Assetclass Groupname',
'lang_assigniptoasset' => 'Assign IP to asset',
'lang_assignlocationtosubnet' => 'Assign location to subnet',
'lang_assignvlantosubnet' => 'Assign VLAN to subnet',
'lang_error_ipinuse' => 'IP in use',
'lang_error_locationisparent' => 'This location has sub-locations',
'lang_error_notallowed' => 'Not allowed',
'lang_error_usernameinuse' => 'Username in use',
'lang_goback' => 'Go back',
'lang_location_add' => 'Add location',
'lang_location_del' => 'Delete location',
'lang_location_edit' => 'Mofidy location',
'lang_location_info' => 'Location info',
'lang_location_name' => 'Location name',
'lang_location_parent' => 'Parent',
'lang_node_add' => 'Add node',
'lang_node_del' => 'Delete node',
'lang_node_edit' => 'Modify node',
'lang_node_info' => 'Node info',
'lang_node_new' => 'Create new node',
'lang_dns1' => 'DNS name',
'lang_dns2' => 'DNS Alias',
'lang_ip' => 'IP Address',
'lang_mac' => 'MAC Address',
'lang_search_found' => 'found',
'lang_search_results_found' => 'Total results found',
'lang_subnet_add' => 'Add subnet',
'lang_subnet_subnetaddress' => 'Subnet address',
'lang_subnet_broadcastaddress' => 'Broadcast address',
'lang_subnet_del' => 'Delete subnet',
'lang_subnet_edit' => 'Modify subnet',
'lang_subnet_info' => 'Subnet info',
'lang_subnet_mask' => 'Subnet mask',
'lang_user_add' => 'Add user',
'lang_user_del' => 'Delete user',
'lang_user_displayname' => 'Displayname',
'lang_user_edit' => 'Mofidy user',
'lang_user_level' => 'Userlevel',
'lang_user_name' => 'Username',
'lang_user_pass' => 'Password',
'lang_user_passnew1' => 'New password',
'lang_user_passnew2' => 'Retype new password',
'lang_user_passold' => 'Current password',
'lang_vlan_add' => 'Add VLAN',
'lang_vlan_del' => 'Delete VLAN',
'lang_vlan_edit' => 'Modify VLAN',
'lang_vlan_number' => 'VLAN ID',
'lang_vlan_info' => 'VLAN info',
'lang_vlan_name' => 'VLAN name',
'lang_warning_asset_del_nodes' => 'These nodes will also be deleted!',
'lang_warning_search_nosearch' => 'Nothing to search for!',
'lang_options_ipreg' => 'IP Reg options',
'lang_options_password_edit' => 'Modify password',
'lang_options_personal' => 'Personal options',
'lang_options_settings_edit' => 'Modify settings',
);
?>

@ -1,48 +1,69 @@
<?php
include("header.php");
function display_subnet ($location_id) {
$subnet = '';
$result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id' ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
$subnet .= '<a href="subnetview.php?subnet_id='. $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a><br>';
}
return $subnet;
// set template
$tp = new Template("tpl/location.tpl");
// set language variables
$tp->setvars($lang);
// create array with parent index and location names
$parents = array();
$location_names = array();
// get location information and insert to the arrays
$result = mysql_query("SELECT location_id, location_name, parent FROM location") or die(mysql_error());
while ($row = mysql_fetch_object($result)) {
$location_names[$row->location_id] = $row->location_name;
$parents[$row->parent][] = $row->location_id;
}
// displaysubnet link (or not)
if (isset($_GET['displaysubnet'])) {
$displaysubnetlink = '<a href="location.php">(hide subnets)</a>';
} else {
$displaysubnetlink = '<a href="location.php?displaysubnet">(display subnets)</a>';
// look for parents and create a new array for every child
function location($parents, $parent = 0) {
$children = array();
foreach ($parents[$parent] as $child) {
if (isset($parents[$child])) {
// element has children
$children[$child] = location($parents, $child);
} else {
// no children, set NULL
$children[$child] = NULL;
}
}
return $children;
}
// "menu"
function display_children($parent, $level) {
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$parent' ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
if (isset($_GET['displaysubnet'])) {
$displaysubnet = display_subnet($row->location_id);
// recursive children check to template
function checkchildren ($array, $level) {
global $tp;
global $location_names;
foreach ($array as $location_id=>$val) {
if($val != "") {
$tp->set("location_id", $location_id);
$tp->set("location_name", $location_names[$location_id]);
$tp->set("nbsp", str_repeat("&nbsp;&nbsp;&nbsp;",$level));
$tp->parse("locationrow");
checkchildren($val, $level+1);
} else {
$displaysubnet = '';
$tp->set("location_id", $location_id);
$tp->set("location_name", $location_names[$location_id]);
$tp->set("nbsp", str_repeat("&nbsp;&nbsp;&nbsp;",$level));
$tp->parse("locationrow");
}
echo '<tr><td>' . str_repeat('&nbsp;&nbsp;&nbsp;',$level) . '<a href="locationview.php?location_id=' . $row->location_id . '">' . $row->location_name . '</a></td><td>&nbsp;</td><td>' . $displaysubnet . '</td></tr>';
display_children($row->location_id, $level+1);
}
$tp->parse("location");
$tp->clear("location");
}
?>
<table border="0">
<tr>
<td>
<b>Location:</b> <?php echo $displaysubnetlink; ?>
</td>
</tr>
<?php display_children('',0); ?>
</table>
<?php
// assemble the tree
$tree = location($parents);
// check for values and build template
checkchildren($tree, 0);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,62 +1,24 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/locationadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$location_name = $_POST['location_name'];
$parent = $_POST['parent'];
mysql_query("INSERT INTO location (location_name, parent) VALUE ('$location_name', '$parent')") or die(mysql_error());
$location_id = mysql_insert_id();
header_location("locationview.php?location_id=" . $location_id);
}
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="locationadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new location:</b><br>
</td>
</tr>
<tr>
<td>
Location name:
</td>
<td>
<input type="text" name="location_name">
</td>
</tr>
<tr>
<td>
Parent:
</td>
<td>
<select name="parent">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT location_name, location_id FROM location ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->location_id . '">' . $row->location_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get location info
$result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name");
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("location_id", $row->location_id);
$tp->set("location_name", $row->location_name);
$tp->parse("locationrow");
}
if (($i>0) ? $tp->parse("location") : $tp->hide("location"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,24 @@
<?php
include("header.php");
// get id
$location_id = $_GET['location_id'];
// set template
$tp = new Template("tpl/locationdel.tpl");
// set language variables
$tp->setvars($lang);
// get location info
$result = mysql_query("SELECT location_name FROM location WHERE location_id='$location_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("location_id", $location_id);
$tp->set("location_name", $row->location_name);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,8 +1,14 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
$location_id = $_GET['location_id'];
// set template
$tp = new Template("tpl/locationedit.tpl");
// set language variables
$tp->setvars($lang);
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
@ -15,73 +21,27 @@
header_location("locationview.php?location_id=" . $location_id);
}
$location_id = $_GET['location_id'];
// get current information
$result = mysql_query("SELECT location_name, parent, location_info FROM location WHERE location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
$location_name = $row->location_name;
$location_info = $row->location_info;
$parent = $row->parent;
}
?>
$result = mysql_query("SELECT location_name, parent, location_info FROM location WHERE location_id='$location_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$parent = $row->parent;
$tp->set("location_id", $location_id);
$tp->set("location_name", $row->location_name);
$tp->set("location_info", $row->location_info);
<form method="POST" action="locationedit.php">
<input type="hidden" name="location_id" value="<?php echo $location_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit location:</b><br>
</td>
</tr>
<tr>
<td>
Location name:
</td>
<td>
<input type="text" name="location_name" value="<?php echo $location_name; ?>">
</td>
</tr>
<tr>
<td>
Parent:
</td>
<td>
<select name="parent">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT location_name, location_id FROM location ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
if ($row->location_id==$parent) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $row->location_id . '" ' . $selected . '>' . $row->location_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Location info:
</td>
<td>
<textarea name="location_info"><?php echo $location_info; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get parent info
$result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name");
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->location_id==$parent) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("parent_id", $row->location_id);
$tp->set("parent_name", $row->location_name);
$tp->parse("parentrow");
}
if (($i>0) ? $tp->parse("parent") : $tp->hide("parent"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -4,87 +4,101 @@
// get id
$location_id = $_GET['location_id'];
// get all info
$result = mysql_query("SELECT location_name, location_info FROM location WHERE location_id='$location_id'");
// set template
$tp = new Template("tpl/locationview.tpl");
// set language variables
$tp->setvars($lang);
// create breadcrumb arrays
$parents = array();
$location_names = array();
$crumbs = array();
// get location information and insert to the arrays
$result = mysql_query("SELECT location_id, location_name, parent FROM location") or die(mysql_error());
while ($row = mysql_fetch_object($result)) {
$location_info = $row->location_info;
$location_names[$row->location_id] = $row->location_name;
$parents[$row->location_id] = $row->parent;
}
?>
<table border="0">
<tr>
<td>
<b>Location name:</b>
</td>
<td>
<?php echo location_name($location_id, ''); ?>
</td>
</tr>
<tr>
<td>
<b>Location info:</b>
</td>
<td>
<?php echo nl2br($location_info); ?>
</td>
</tr>
<tr>
<td>
<b>Subnet(s):</b>
</td>
<td>
<?php
// search subnets for this location
$result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
echo '<a href="subnetview.php?subnet_id='. $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a><br>';
// function to build array with parents
function parent($location_id) {
// use names index
global $parents;
global $crumbs;
global $location_names;
// fill array with this value
$crumbs[$location_id] = $location_id;
if (($parents[$location_id])>0) {
// still not on top, so do it again
parent($parents[$location_id]);
}
// return the array
return $location_id;
}
?>
</td>
</tr>
<tr>
<td>
<b>Sub-location(s):</b>
</td>
<td>
<?php
// search sub-locations for this location
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$location_id' ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
echo '<a href="locationview.php?location_id='. $row->location_id . '">' . $row->location_name . '</a><br>';
// build parents
parent($location_id);
// loop array in reverse order and send to template
foreach (array_reverse($crumbs) as $key=>$val) {
$tp->set("location_id", $val);
$tp->set("location_name", $location_names[$val]);
if (($key>0) ? $tp->set("seperator", ".&nbsp;") : $tp->set("seperator", ""));
$tp->parse("locationcrumbrow");
}
?>
</td>
</tr>
</table>
$tp->parse("locationcrumb");
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
// get location info
$result = mysql_query("SELECT location_name, location_info FROM location WHERE location_id='$location_id'");
$row=mysql_fetch_object($result);
$tp->set("location_info", nl2br($row->location_info));
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="locationedit.php?location_id=<?php echo $location_id; ?>">Modify location</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assignlocationtosubnet.php?location_id=<?php echo $location_id; ?>">Assign subnet</a>
</td>
</tr>
</table>
// search subnets for this location
$result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id'") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
<?php
// end display only if admin
// search sub-locations for this location
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$location_id' ORDER BY location_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("sublocation_id", $row->location_id);
$tp->set("sublocation_name", $row->location_name);
$tp->parse("sublocationrow");
}
if (($i>0) ? $tp->parse("sublocation") : $tp->hide("sublocation"));
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assignlocationtosubnet) {
$tp->set("location_id", $location_id);
$tp->parse("assignlocationtosubnet");
} else {
$tp->hide("assignlocationtosubnet");
}
if($_SESSION['suser_level'] >= $config_userlevel_locationedit) {
$tp->set("location_id", $location_id);
$tp->parse("locationedit");
} else {
$tp->hide("locationedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_locationdel) {
$tp->set("location_id", $location_id);
$tp->parse("locationdel");
} else {
$tp->hide("locationdel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,6 +1,5 @@
<?php
session_start();
ob_start();
// includes
include("config.php");
@ -11,13 +10,16 @@
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
if(isset($_POST['user_name']) && isset($_POST['user_pass']) && trim($_POST['user_name']) <> "" && trim($_POST['user_pass']) <> "") {
$user_name = $_POST['user_name'];
$result = mysql_query("SELECT user_id, user_pass, user_level FROM user WHERE user_name='$user_name'") or die(mysql_error());
$result = mysql_query("SELECT user_id, user_pass, user_level, user_displayname, user_mac, user_lang FROM user WHERE user_name='$user_name'") or die(mysql_error());
if(mysql_num_rows($result) > 0) {
if(!strcmp(md5($_POST['user_pass']), mysql_result($result, 0, "user_pass"))) {
// all ok, user logged in
$_SESSION['suser_id'] = mysql_result($result, 0, "user_id");
$_SESSION['suser_level'] = mysql_result($result, 0, "user_level");
$_SESSION['suser_displayname'] = mysql_result($result, 0, "user_displayname");
$_SESSION['suser_mac'] = mysql_result($result, 0, "user_mac");
$_SESSION['suser_lang'] = mysql_result($result, 0, "user_lang");
header("Location: index.php");
} else {
@ -37,7 +39,7 @@
<header>
<title>IP Reg</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="tpl/style.css" type="text/css">
</header>
<body>
<br>

@ -1,5 +1,5 @@
<?php
include("header.php");
session_start();
// clear and destroy session
$_SESSION = array();
@ -7,5 +7,4 @@
header("Location: index.php");
include("footer.php");
?>

@ -1,191 +1,43 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/nodeadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$ip = str_replace(' ', '', $_POST['ip']);
// IP in use?
$result = mysql_query("SELECT * FROM node WHERE ip='$ip'");
if (mysql_num_rows($result)!=0) {
echo 'IP in use!';
exit;
} else {
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
mysql_query("INSERT INTO asset (asset_name, hostname, assetclass_id) VALUE ('$asset_name', '$hostname', '$assetclass_id')") or die(mysql_error());
// get asset_id for new node
$asset_id = mysql_insert_id();
$mac = strip_mac($_POST['mac']);
// DNS1
if (!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) {
$dns1 = $_POST['dns1'] . $config_dns1suffix;
} else {
$dns1 = $_POST['dns1'];
}
// DNS2
if (!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) {
$dns2 = $_POST['dns2'] . $config_dns2suffix;
} else {
$dns2 = $_POST['dns2'];
}
$subnet_id = $_POST['subnet_id'];
mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id')") or die(mysql_error());
$node_id = mysql_insert_id();
header_location("assetview.php?asset_id=" . $asset_id);
}
}
// set language variables
$tp->setvars($lang);
// check for ip
if (isset($_GET['ip'])) {
$ip = $_GET['ip'];
} else {
$ip = "";
}
// check for subnet_id
if (isset($_GET['subnet_id'])) {
$subnet_id = $_GET['subnet_id'];
} else {
$subnet_id = '';
// check for set ip and/or subnet_id
if ((isset($_GET['ip'])) ? $ip = $tp->set("ip", $_GET['ip']) : $tp->set("ip", ""));
if ((isset($_GET['subnet_id'])) ? $subnet_id = $_GET['subnet_id'] : $subnet_id = '');
// set variables
$tp->set("config_dns1suffix", $config_dns1suffix);
$tp->set("config_dns2suffix", $config_dns2suffix);
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
?>
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
<form method="POST" action="nodeadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new node:</b><br>
</td>
</tr>
<tr>
<td>
Asset name:
</td>
<td>
<input type="text" name="asset_name">
</td>
<td>
*
</td>
</tr>
<tr>
<td>
Hostname:
</td>
<td>
<input type="text" name="hostname">
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
IP Address:
</td>
<td>
<input type="text" name="ip" value="<?php echo $ip; ?>">
</td>
<td>
*
</td>
</tr>
<tr>
<td>
Subnet:<br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
if ($row->subnet_id==$subnet_id) {
$selected = ' selected';
} else {
$selected = '';
}
echo '<option value="' . $row->subnet_id . '" ' . $selected . '>' . $row->subnet_address . '/' . $row->subnet_mask . '</option>';
}
?>
</select>
</td>
<td>
*
</td>
</tr>
<tr>
<td>
Asset class:
</td>
<td>
<select name="assetclass_id">
<?php
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->assetclass_id . '" ' . $selected . '>' . $row->assetclass_name . '</option>';
}
?>
</select>
</td>
<td>
*
</td>
</tr>
<tr>
<td>
MAC Address:
</td>
<td>
<input type="text" name="mac">
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
DNS name:
</td>
<td>
<input type="text" name="dns1">
</td>
<td>
<input type="checkbox" name="dns1suffix" checked><?php echo $config_dns1suffix; ?>
</td>
</tr>
<tr>
<td>
DNS alias:
</td>
<td>
<input type="text" name="dns2">
</td>
<td>
<input type="checkbox" name="dns2suffix" checked><?php echo $config_dns2suffix; ?>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get assetclassgroup information
$result = mysql_query("SELECT assetclass_id, assetclass_name FROM assetclass ORDER BY assetclass_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("assetclass_id", $row->assetclass_id);
$tp->set("assetclass_name", $row->assetclass_name);
$tp->parse("assetclassrow");
}
if (($i>0) ? $tp->parse("assetclass") : $tp->hide("assetclass"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,23 +1,25 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
$node_id = $_GET['node_id'];
// get asset id
$result = mysql_query("SELECT asset_id FROM node WHERE node_id='$node_id'") or die(mysql_error());
$asset_id = mysql_result($result, 0, "asset_id");
// delete node
mysql_query("DELETE FROM node WHERE node_id='$node_id'") or die(mysql_error());
// set template
$tp = new Template("tpl/nodedel.tpl");
// redirect
header("Location: assetview.php?asset_id=" . $asset_id);
// set language variables
$tp->setvars($lang);
// end display only if admin
}
// get asset info
$result = mysql_query("SELECT ip, asset_id FROM node WHERE node_id='$node_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("node_id", $node_id);
$tp->set("asset_id", $row->asset_id);
$tp->set("ip", $row->ip);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,129 +1,41 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$node_id = $_POST['node_id'];
$subnet_id = $_POST['subnet_id'];
$mac = strip_mac($_POST['mac']);
$dns1 = $_POST['dns1'];
$dns2 = $_POST['dns2'];
$node_info = $_POST['node_info'];
mysql_query("UPDATE node SET subnet_id='$subnet_id', mac='$mac', dns1='$dns1', dns2='$dns2', node_info='$node_info' WHERE node_id='$node_id'") or die(mysql_error());
header_location("nodeview.php?node_id=" . $node_id);
}
// get id
$node_id = $_GET['node_id'];
// set template
$tp = new Template("tpl/nodeedit.tpl");
// set language variables
$tp->setvars($lang);
// get node info
$result = mysql_query("SELECT a.asset_name, n.ip, n.mac, n.dns1, n.dns2, n.subnet_id, n.node_info FROM asset a, node n WHERE node_id='$node_id' AND a.asset_id=n.asset_id");
while ($row = mysql_fetch_object($result)) {
$ip = $row->ip;
$subnet_id = $row->subnet_id;
$mac = $row->mac;
$dns1 = $row->dns1;
$dns2 = $row->dns2;
$node_info = $row->node_info;
$asset_name = $row->asset_name;
}
?>
$result = mysql_query("SELECT a.asset_name, n.ip, n.mac, n.dns1, n.dns2, n.subnet_id, n.node_info FROM asset a, node n WHERE node_id='$node_id' AND a.asset_id=n.asset_id") or die(mysql_error());
$row = mysql_fetch_object($result);
$subnet_id = $row->subnet_id;
$tp->set("node_id", $node_id);
$tp->set("asset_name", $row->asset_name);
$tp->set("ip", $row->ip);
$tp->set("mac", write_mac($row->mac));
$tp->set("dns1", $row->dns1);
$tp->set("dns2", $row->dns2);
$tp->set("node_info", nl2br($row->node_info));
<form method="POST" action="nodeedit.php">
<input type="hidden" name="node_id" value="<?php echo $node_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit node:</b><br>
</td>
</tr>
<tr>
<td>
Asset:
</td>
<td>
<?php echo $asset_name; ?>
</td>
</tr>
<tr>
<td>
IP Address:
</td>
<td>
<?php echo $ip; ?>
</td>
</tr>
<tr>
<td>
Subnet:<br>
</td>
<td>
<select name="subnet_id">
<?php
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
if ($row->subnet_id==$subnet_id) {
$selected = ' selected';
} else {
$selected = '';
}
echo '<option value="' . $row->subnet_id . '" ' . $selected . '>' . $row->subnet_address . '/' . $row->subnet_mask . '</option>';
}
?>
</select>
</td>
<td>
*
</td>
</tr>
<tr>
<td>
MAC Address:
</td>
<td>
<input type="text" name="mac" value="<?php echo $mac; ?>">
</td>
</tr>
<tr>
<td>
DNS name:
</td>
<td>
<input type="text" name="dns1" value="<?php echo $dns1; ?>">
</td>
</tr>
<tr>
<td>
DNS alias:
</td>
<td>
<input type="text" name="dns2" value="<?php echo $dns2; ?>">
</td>
</tr>
<tr>
<td>
Node info:
</td>
<td>
<textarea name="node_info"><?php echo $node_info; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->subnet_id==$subnet_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -4,77 +4,47 @@
// get id
$subnet_id = $_GET['subnet_id'];
// get ordering
// set template
$tp = new Template("tpl/nodelist.tpl");
// set language variables
$tp->setvars($lang);
// set variables
$tp->set("subnet_id", $subnet_id);
// set ordering
if (isset($_GET['order'])) {
$order = $_GET['order'];
switch($_GET['order']) {
case ("asset_name") : $order = "a.asset_name"; break;
case ("hostname") : $order = "a.hostname"; break;
case ("mac") : $order = "n.mac"; break;
case ("dns1") : $order = "n.dns1"; break;
case ("dns2") : $order = "n.dns2"; break;
default : $order = "INET_ATON(n.ip)";
}
} else {
$order = "INET_ATON(n.ip)";
}
?>
<table border="0">
<tr>
<td width="100">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=INET_ATON(n.ip)"><b>IP Address:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=a.asset_name"><b>Asset name:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=a.hostname"><b>Hostname:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=n.mac"><b>MAC Address:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=n.dns1"><b>DNS name:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>&order=n.dns2"><b>DNS alias:</b></a>
</td>
</tr>
<?php
// get node info
$result = mysql_query("SELECT a.asset_id, a.asset_name, a.hostname, n.node_id, n.ip, n.mac, n.dns1, n.dns2 FROM asset a, node n WHERE n.subnet_id='$subnet_id' AND a.asset_id=n.asset_id ORDER BY $order");
while ($row = mysql_fetch_object($result)) {
$asset_id = $row->asset_id;
$asset_name = $row->asset_name;
$hostname = $row->hostname;
$node_id = $row->node_id;
$ip = $row->ip;
$mac = write_mac($row->mac);
$dns1 = $row->dns1;
$dns2 = $row->dns2;
?>
<tr>
<td>
<a href="nodeview.php?node_id=<?php echo $node_id; ?>"><?php echo $ip; ?></a>
</td>
<td>
<a href="assetview.php?asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
</td>
<td>
<?php echo $hostname; ?>
</td>
<td>
<?php echo $mac; ?>
</td>
<td>
<?php echo $dns1; ?>
</td>
<td>
<?php echo $dns2; ?>
</td>
</tr>
<?php
// get node info
$result = mysql_query("SELECT a.asset_id, a.asset_name, a.hostname, n.node_id, n.ip, n.mac, n.dns1, n.dns2 FROM asset a, node n WHERE n.subnet_id='$subnet_id' AND a.asset_id=n.asset_id ORDER BY $order") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("asset_id", $row->asset_id);
$tp->set("asset_name", $row->asset_name);
$tp->set("hostname", $row->hostname);
$tp->set("node_id", $row->node_id);
$tp->set("ip", $row->ip);
$tp->set("mac", write_mac($row->mac));
$tp->set("dns1", $row->dns1);
$tp->set("dns2", $row->dns2);
$tp->parse("noderow");
}
?>
</table>
<?php
if (($i>0) ? $tp->parse("node") : $tp->hide("node"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -4,106 +4,43 @@
// get id
$node_id = $_GET['node_id'];
// get node info
$result = mysql_query("SELECT a.asset_name, a.asset_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM asset a, node n, subnet s WHERE n.node_id='$node_id' AND a.asset_id=n.asset_id AND s.subnet_id=n.subnet_id");
while ($row = mysql_fetch_object($result)) {
$asset_id = $row->asset_id;
$asset_name = $row->asset_name;
$ip = $row->ip;
$mac = write_mac($row->mac);
$dns1 = $row->dns1;
$dns2 = $row->dns2;
$node_info = $row->node_info;
$subnet_id = $row->subnet_id;
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
}
?>
// set template
$tp = new Template("tpl/nodeview.tpl");
<table border="0">
<tr>
<td>
<b>IP Address:</b>
</td>
<td>
<?php echo $ip; ?>
</td>
</tr>
<tr>
<td>
<b>Subnet</b>
</td>
<td>
<a href="subnetview.php?subnet_id=<?php echo $subnet_id; ?>&page=<?php echo page($ip); ?>"><?php echo $subnet_address; ?>/<?php echo $subnet_mask; ?></a>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td>
<b>Asset name:</b>
</td>
<td>
<a href="assetview.php?asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
</td>
</tr>
<tr>
<td>
<b>MAC Address:</b>
</td>
<td>
<?php echo $mac; ?>
</td>
</tr>
<tr>
<td>
<b>DNS name:</b>
</td>
<td>
<?php echo $dns1; ?>
</td>
</tr>
<tr>
<td>
<b>DNS alias:</b>
</td>
<td>
<?php echo $dns2; ?>
</td>
</tr>
<tr>
<td>
<b>Node info:</b>
</td>
<td>
<?php echo nl2br($node_info); ?>
</td>
</tr>
</table>
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
// set language variables
$tp->setvars($lang);
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodeedit.php?node_id=<?php echo $node_id; ?>">Modify node</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodedel.php?node_id=<?php echo $node_id; ?>">Delete node</a>
</td>
</tr>
</table>
// get node info
$result = mysql_query("SELECT a.asset_name, a.asset_id, n.ip, n.mac, n.dns1, n.dns2, n.node_info, s.subnet_id, s.subnet_address, s.subnet_mask FROM asset a, node n, subnet s WHERE n.node_id='$node_id' AND a.asset_id=n.asset_id AND s.subnet_id=n.subnet_id") or die(mysql_error());
$row = mysql_fetch_object($result);
$tp->set("asset_id", $row->asset_id);
$tp->set("asset_name", $row->asset_name);
$tp->set("ip", $row->ip);
$tp->set("mac", write_mac($row->mac));
$tp->set("dns1", $row->dns1);
$tp->set("dns2", $row->dns2);
$tp->set("node_info", nl2br($row->node_info));
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
<?php
// end display only if admin
// display options
if($_SESSION['suser_level'] >= $config_userlevel_nodeedit) {
$tp->set("node_id", $node_id);
$tp->parse("nodeedit");
} else {
$tp->hide("nodeedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_nodedel) {
$tp->set("node_id", $node_id);
$tp->parse("nodedel");
} else {
$tp->hide("nodedel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,77 +1,28 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<table border="0">
<tr>
<td>
<b>IP Reg options</b>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetadd.php">Add new asset</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assetclassadd.php">Add new assetclass</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="locationadd.php">Add new location</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodeadd.php">Add new node</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="useradd.php">Add new user</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="subnetadd.php">Add new subnet</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="vlanadd.php">Add new vlan</a>
</td>
</tr>
</table>
<?php
// end display only if admin
}
?>
// set template
$tp = new Template("tpl/options.tpl");
// set language variables
$tp->setvars($lang);
// display options
if(($_SESSION['suser_level'] >= $config_userlevel_assetadd) ? $tp->parse("assetadd") : $tp->hide("assetadd"));
if(($_SESSION['suser_level'] >= $config_userlevel_assetclassadd) ? $tp->parse("assetclassadd") : $tp->hide("assetclassadd"));
if(($_SESSION['suser_level'] >= $config_userlevel_locationadd) ? $tp->parse("locationadd") : $tp->hide("locationadd"));
if(($_SESSION['suser_level'] >= $config_userlevel_nodeadd) ? $tp->parse("nodeadd") : $tp->hide("nodeadd"));
if(($_SESSION['suser_level'] >= $config_userlevel_useradd) ? $tp->parse("useradd") : $tp->hide("useradd"));
if(($_SESSION['suser_level'] >= $config_userlevel_subnetadd) ? $tp->parse("subnetadd") : $tp->hide("subnetadd"));
if(($_SESSION['suser_level'] >= $config_userlevel_vlanadd) ? $tp->parse("vlanadd") : $tp->hide("vlanadd"));
if(($_SESSION['suser_level'] >= $config_userlevel_assigniptoasset) ? $tp->parse("assigniptoasset") : $tp->hide("assigniptoasset"));
if(($_SESSION['suser_level'] >= $config_userlevel_assignlocationtosubnet) ? $tp->parse("assignlocationtosubnet") : $tp->hide("assignlocationtosubnet"));
if(($_SESSION['suser_level'] >= $config_userlevel_assignvlantosubnet) ? $tp->parse("assignvlantosubnet") : $tp->hide("assignvlantosubnet"));
<p>
<table border="0">
<tr>
<td>
<b>Personal options</b>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="useredit.php">Modify settings</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="userpassedit.php">Modify password</a>
</td>
</tr>
</table>
// output
$tp->parse();
$tp->spit();
<?
include("footer.php");
?>

@ -1,103 +1,105 @@
<?php
include("header.php");
// get string that was searched for
if (empty($search)) {
echo 'Nothing to search for...';
exit;
}
$needle = '%' . $search . '%';
// set resultcounter to zero
$resultcounter = 0;
echo '<table border="0">';
// look for asset
$result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE asset_name LIKE '$needle' OR asset_info LIKE '%$needle%' ORDER BY asset_name");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Asset(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="assetview.php?asset_id=' . $row->asset_id . '">' . $row->asset_name . '</a></td></tr>';
$resultcounter++;
}
// look for location
$result = mysql_query("SELECT location_id, location_name FROM location WHERE location_name LIKE '$needle' OR location_info LIKE '%$needle%' ORDER BY location_name");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Location(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="locationview.php?location_id=' . $row->location_id . '">' . $row->location_name . '</a></td></tr>';
$resultcounter++;
}
// look for ip
$result = mysql_query("SELECT node_id, ip FROM node WHERE ip LIKE '$needle' ORDER BY ip");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Registered IP(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . $row->ip . '</a></td></tr>';
$resultcounter++;
}
// look for mac
$mac = strip_mac($needle);
$result = mysql_query("SELECT node_id, mac FROM node WHERE mac LIKE '$mac' ORDER BY mac");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>MAC(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . write_mac($row->mac) . '</a></td></tr>';
$resultcounter++;
}
// look for dns1
$result = mysql_query("SELECT node_id, dns1 FROM node WHERE dns1 LIKE '$needle' ORDER BY dns1");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>DNS name(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . $row->dns1 . '</a></td></tr>';
$resultcounter++;
}
// set template
$tp = new Template("tpl/search.tpl");
// look for dns2
$result = mysql_query("SELECT node_id, dns2 FROM node WHERE dns2 LIKE '$needle' ORDER BY dns2");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>DNS alias(es):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="nodeview.php?node_id=' . $row->node_id . '">' . $row->dns2 . '</a></td></tr>';
$resultcounter++;
}
// set language variables
$tp->setvars($lang);
// look for subnet
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet WHERE subnet_address LIKE '$needle' OR subnet_info LIKE '%$needle%' ORDER BY INET_ATON(subnet_address)");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>Subnet(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="subnetview.php?subnet_id=' . $row->subnet_id . '">' . $row->subnet_address . '</a></td></tr>';
$resultcounter++;
}
// look for vlan
$result = mysql_query("SELECT vlan_id, vlan_name FROM vlan WHERE vlan_name LIKE '$needle' OR vlan_info LIKE '%$needle%' ORDER BY vlan_name");
if (mysql_num_rows($result)>0) {
echo '<tr><td><b>VLAN(s):</b></td></tr>';
}
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . '</a></td></tr>';
$resultcounter++;
// get string that was searched for
if (empty($search)) {
$tp->parse("nosearch");
$tp->hide("asset");
$tp->hide("location");
$tp->hide("node");
$tp->hide("subnet");
$tp->hide("vlan");
$tp->hide("resultcount");
} else {
$tp->hide("nosearch");
// set needle and counter
$needle = '%' . $search . '%';
$resultcounter = 0;
// search assets
$result = mysql_query("SELECT asset_id, asset_name FROM asset WHERE asset_name LIKE '$needle' OR asset_info LIKE '%$needle%' ORDER BY asset_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("counter", $i+1);
$tp->set("item_name", $lang['lang_assets']);
$tp->set("item", "asset");
$tp->set("id", $row->asset_id);
$tp->set("name", $row->asset_name);
$resultcounter++;
$tp->parse("row");
}
if (($i>0) ? $tp->parse("asset") : $tp->hide("asset"));
$tp->clear("row");
// search locations
$result = mysql_query("SELECT location_id, location_name FROM location WHERE location_name LIKE '$needle' OR location_info LIKE '%$needle%' ORDER BY location_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("counter", $i+1);
$tp->set("item_name", $lang['lang_locations']);
$tp->set("item", "location");
$tp->set("id", $row->location_id);
$tp->set("name", $row->location_name);
$resultcounter++;
$tp->parse("row");
}
if (($i>0) ? $tp->parse("location") : $tp->hide("location"));
$tp->clear("row");
// search node
$result = mysql_query("SELECT node_id, ip FROM node WHERE ip LIKE '$needle' OR mac LIKE '$needle' OR dns1 LIKE '$needle' OR dns2 LIKE '$needle' OR node_info LIKE '$needle' ORDER BY ip") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("counter", $i+1);
$tp->set("item_name", $lang['lang_nodes']);
$tp->set("item", "node");
$tp->set("id", $row->node_id);
$tp->set("name", $row->ip);
$resultcounter++;
$tp->parse("row");
}
if (($i>0) ? $tp->parse("node") : $tp->hide("node"));
$tp->clear("row");
// search subnet
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet WHERE subnet_address LIKE '$needle' OR subnet_info LIKE '%$needle%' ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("counter", $i+1);
$tp->set("item_name", $lang['lang_subnets']);
$tp->set("item", "subnet");
$tp->set("id", $row->subnet_id);
$tp->set("name", $row->subnet_address);
$resultcounter++;
$tp->parse("row");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
$tp->clear("row");
// search vlan
$result = mysql_query("SELECT vlan_id, vlan_name FROM vlan WHERE vlan_name LIKE '$needle' OR vlan_info LIKE '%$needle%' ORDER BY vlan_name") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("counter", $i+1);
$tp->set("item_name", $lang['lang_vlans']);
$tp->set("item", "vlan");
$tp->set("id", $row->vlan_id);
$tp->set("name", $row->vlan_name);
$resultcounter++;
$tp->parse("row");
}
if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan"));
$tp->clear("row");
$tp->set("resultcounter", $resultcounter);
$tp->parse("resultcount");
}
echo '<tr><td>&nbsp;</td></tr>';
echo '<tr><td>Results found: ' . $resultcounter . '</td></tr>';
echo '</table>';
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,419 @@
<?php
session_start();
// check for user_id, if unnkown -> login
if(empty($_SESSION['suser_id'])) {
header("Location: login.php");
exit;
}
// includes
include("config.php");
include("dbconnect.php");
include("functions.php");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
// check for action
if (isset($_POST['add'])) {
switch ($_POST['add']) {
case ("asset") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assetadd) {
// get variables
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$asset_info = $_POST['asset_info'];
// update db
mysql_query("INSERT INTO asset(asset_name, hostname, assetclass_id, asset_info) VALUE ('$asset_name', '$hostname', '$assetclass_id', '$asset_info')") or die(mysql_error());
$asset_id = mysql_insert_id();
// redirect
header_location("assetview.php?asset_id=" . $asset_id);
}
break;
case ("assetclass") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assetclassadd) {
// get variables
$assetclass_name = $_POST['assetclass_name'];
$assetclassgroup_id = $_POST['assetclassgroup_id'];
// update db
mysql_query("INSERT INTO assetclass (assetclass_name, assetclassgroup_id) VALUE ('$assetclass_name', '$assetclassgroup_id')") or die(mysql_error());
$assetclass_id = mysql_insert_id();
// redirect
header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
}
break;
case ("assigniptoasset") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assigniptoasset) {
// get variables
$ip = $_POST['ip'];
$subnet_id = $_POST['subnet_id'];
$asset_id = $_POST['asset_id'];
$mac = strip_mac($_POST['mac']);
if ((!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) ? $dns1 = $_POST['dns1'] . $config_dns1suffix : $dns1 = $_POST['dns1']);
if ((!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) ? $dns2 = $_POST['dns2'] . $config_dns2suffix : $dns2 = $_POST['dns2']);
$node_info = $_POST['node_info'];
// update db
mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id, node_info) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id', '$node_info')") or die(mysql_error());
// redirect
header_location("assetview.php?asset_id=" . $asset_id);
}
break;
case ("assignlocationtosubnet") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assignlocationtosubnet) {
// get variables
$location_id = $_POST['location_id'];
$subnet_id = $_POST['subnet_id'];
// update db
mysql_query("INSERT INTO subnetlocation (location_id, subnet_id) VALUE ('$location_id', '$subnet_id')") or die(mysql_error());
// redirect
header_location("Location: location.php");
}
break;
case ("assignvlantosubnet") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assignvlantosubnet) {
// get variables
$vlan_id = $_POST['vlan_id'];
$subnet_id = $_POST['subnet_id'];
// update db
mysql_query("UPDATE subnet SET vlan_id='$vlan_id' WHERE subnet_id='$subnet_id'") or die(mysql_error());
// redirect
header_location("vlanview.php?vlan_id=" . $vlan_id);
}
break;
case ("location") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_locationadd) {
// get variables
$location_name = $_POST['location_name'];
$parent = $_POST['parent'];
// update db
mysql_query("INSERT INTO location (location_name, parent) VALUE ('$location_name', '$parent')") or die(mysql_error());
$location_id = mysql_insert_id();
// redirect
header_location("locationview.php?location_id=" . $location_id);
}
break;
case ("node") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_nodeadd) {
$result = mysql_query("SELECT * FROM node WHERE ip='$ip'") or die(mysql_error());
if (mysql_num_rows($result) == 0) {
// get variables
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$ip = $_POST['ip'];
$mac = strip_mac($_POST['mac']);
if ((!empty($_POST['dns1']) && isset($_POST['dns1suffix'])) ? $dns1 = $_POST['dns1'] . $config_dns1suffix : $dns1 = $_POST['dns1']);
if ((!empty($_POST['dns2']) && isset($_POST['dns2suffix'])) ? $dns2 = $_POST['dns2'] . $config_dns2suffix : $dns2 = $_POST['dns2']);
$subnet_id = $_POST['subnet_id'];
// update db
mysql_query("INSERT INTO asset (asset_name, hostname, assetclass_id) VALUE ('$asset_name', '$hostname', '$assetclass_id')") or die(mysql_error());
$asset_id = mysql_insert_id();
mysql_query("INSERT INTO node (ip, mac, dns1, dns2, subnet_id, asset_id) VALUE ('$ip', '$mac', '$dns1', '$dns2', '$subnet_id', '$asset_id')") or die(mysql_error());
$node_id = mysql_insert_id();
// redirect
header_location("assetview.php?asset_id=" . $asset_id);
}
// display error
$error = "ipinuse";
}
break;
case ("subnet") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_subnetadd) {
// get variables
$subnet_address= $_POST['subnet_address'];
$subnet_mask = $_POST['subnet_mask'];
// update db
mysql_query("INSERT INTO subnet (subnet_address, subnet_mask) VALUE ('$subnet_address', '$subnet_mask')") or die(mysql_error());
$subnet_id = mysql_insert_id();
// redirect
header_location("subnetview.php?subnet_id=" . $subnet_id);
}
break;
case ("user") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_useradd) {
// check for unique username
$result = mysql_query("SELECT user_name FROM user WHERE user_name='$user_name'") or die(mysql_error());
if(mysql_num_rows($result) == 0) {
// get variables
$user_name = $_POST['user_name'];
$user_pass = md5($config_user_pass);
$user_level = $_POST['user_level'];
$displayname = $_POST['user_name'];
$user_lang = $config_user_lang;
// update db
mysql_query("INSERT INTO user (user_name, user_pass, user_level, user_displayname, user_lang) VALUE ('$user_name', '$user_pass', '$user_level', '$displayname', '$user_lang')") or die(mysql_error());
// redirect
header_location("options.php");
}
// display error
$error = "usernameinuse";
}
break;
case ("vlan") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_vlanadd) {
// get variables
$vlan_name = $_POST['vlan_name'];
$vlan_number= $_POST['vlan_number'];
// update db
mysql_query("INSERT INTO vlan (vlan_name, vlan_number) VALUE ('$vlan_name', '$vlan_number')") or die(mysql_error());
$vlan_id = mysql_insert_id();
// redirect
header_location("vlan.php?vlan_id=" . $vlan_id);
}
break;
}
}
if (isset($_POST['edit'])) {
switch ($_POST['edit']) {
case ("asset") :
if($_SESSION['suser_level'] >= $config_userlevel_assetedit) {
// get variables
$asset_id = $_POST['asset_id'];
$asset_name = $_POST['asset_name'];
$hostname = $_POST['hostname'];
$assetclass_id = $_POST['assetclass_id'];
$asset_info = $_POST['asset_info'];
// update db
mysql_query("UPDATE asset SET asset_name='$asset_name', hostname='$hostname', assetclass_id='$assetclass_id', asset_info='$asset_info' WHERE asset_id='$asset_id'") or die(mysql_error()) or die(mysql_error());
// redirect
header_location("assetview.php?asset_id=" . $asset_id);
}
break;
case ("assetclass") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assetclassedit) {
// get variables
$assetclass_id = $_POST['assetclass_id'];
$assetclass_name = $_POST['assetclass_name'];
$assetclassgroup_id = $_POST['assetclassgroup_id'];
// update db
mysql_query("UPDATE assetclass SET assetclass_name='$assetclass_name', assetclassgroup_id='$assetclassgroup_id' WHERE assetclass_id='$assetclass_id'") or die(mysql_error());
// redirect
header_location("assetclassview.php?assetclass_id=" . $assetclass_id);
}
break;
case ("node") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_nodeedit) {
// get variables
$node_id = $_POST['node_id'];
$subnet_id = $_POST['subnet_id'];
$mac = strip_mac($_POST['mac']);
$dns1 = $_POST['dns1'];
$dns2 = $_POST['dns2'];
$node_info = $_POST['node_info'];
// update db
mysql_query("UPDATE node SET subnet_id='$subnet_id', mac='$mac', dns1='$dns1', dns2='$dns2', node_info='$node_info' WHERE node_id='$node_id'") or die(mysql_error());
// redirect
header_location("nodeview.php?node_id=" . $node_id);
}
break;
case ("subnet") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_subnetedit) {
// get variables
$subnet_id = $_POST['subnet_id'];
$subnet_address= $_POST['subnet_address'];
$subnet_mask = $_POST['subnet_mask'];
$vlan_id = $_POST['vlan_id'];
$subnet_info = $_POST['subnet_info'];
// update db
mysql_query("UPDATE subnet SET subnet_address='$subnet_address', subnet_mask='$subnet_mask', vlan_id='$vlan_id', subnet_info='$subnet_info' WHERE subnet_id='$subnet_id'") or die(mysql_error());
// redirect
header_location("subnetview.php?subnet_id=" . $subnet_id);
}
break;
case ("user") :
// get variables
$user_displayname = $_POST['user_displayname'];
$user_mac = $_POST['user_mac'];
$user_lang = $_POST['user_lang'];
//update db
mysql_query("UPDATE user SET user_displayname='$user_displayname', user_mac='$user_mac', user_lang='$user_lang' WHERE user_id='$suser_id'") or die(mysql_error());
// update session
$_SESSION['suser_displayname'] = $user_displayname;
$_SESSION['suser_mac'] = $user_mac;
$_SESSION['suser_lang'] = $user_lang;
// redirect
header_location("options.php");
break;
case ("userpass") :
// check variables
if (trim($_POST['user_passold']) <> "" && trim($_POST['user_passnew1']) && trim($_POST['user_passnew2']) && trim($_POST['user_passnew1']) == trim($_POST['user_passnew2'])) {
// get variables
$user_passold = $_POST['user_passold'];
$user_passnew = md5($_POST['user_passnew1']);
// get current pass
$result = mysql_query("SELECT user_pass FROM user WHERE user_id='$suser_id'") or die(mysql_error());
// check current pass
if(!strcmp(md5($user_passold), mysql_result($result, 0, "user_pass"))) {
// update db
mysql_query("UPDATE user SET user_pass='$user_passnew' WHERE user_id='$suser_id'") or die(mysql_error());
// redirect
header_location("options.php");
}
}
// display error
echo '<b>Error!</b>';
break;
case ("vlan") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_vlanedit) {
// get variables
$vlan_id = $_POST['vlan_id'];
$vlan_name = $_POST['vlan_name'];
$vlan_number = $_POST['vlan_number'];
$vlan_info = $_POST['vlan_info'];
// update db
mysql_query("UPDATE vlan SET vlan_name='$vlan_name', vlan_number='$vlan_number', vlan_info='$vlan_info' WHERE vlan_id='$vlan_id'") or die(mysql_error());
// redirect
header_location("vlanview.php?vlan_id=" . $vlan_id);
}
break;
}
}
if (isset($_POST['del'])) {
switch ($_POST['del']) {
case ("asset") :
if($_SESSION['suser_level'] >= $config_userlevel_assetdel) {
// get variables
$asset_id = $_POST['asset_id'];
// update db
mysql_query("DELETE FROM asset WHERE asset_id='$asset_id'") or die(mysql_error());
mysql_query("DELETE FROM node WHERE asset_id='$asset_id'") or die(mysql_error());
// redirect
header_location("asset.php");
}
break;
case ("assetclass") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_assetclassdel) {
// get variables
$assetclass_id = $_POST['assetclass_id'];
// update db
mysql_query("DELETE FROM assetclass WHERE assetclass_id='$assetclass_id'") or die(mysql_error());
// redirect
header_location("assetclass.php");
}
break;
case ("location") :
if($_SESSION['suser_level'] >= $config_userlevel_locationdel) {
// get variables
$location_id = $_POST['location_id'];
$result = mysql_query("SELECT location_id FROM location WHERE parent='$location_id'") or die(mysql_error());
if (mysql_num_rows($result) == 0) {
// update db
mysql_query("DELETE FROM location WHERE location_id='$location_id'") or die(mysql_error());
// redirect
header_location("location.php");
}
// display error
$error = "locationisparent";
}
break;
case ("node") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_nodedel) {
// get variables
$node_id = $_POST['node_id'];
$asset_id = $_POST['asset_id'];
// update db
mysql_query("DELETE FROM node WHERE node_id='$node_id'") or die(mysql_error());
// redirect
header_location("assetview.php?asset_id=" . $asset_id);
}
break;
case ("subnet") :
if($_SESSION['suser_level'] >= $config_userlevel_subnetdel) {
// get variables
$subnet_id = $_POST['subnet_id'];
// update db
mysql_query("DELETE FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error());
mysql_query("DELETE FROM node WHERE subnet_id='$subnet_id'") or die(mysql_error());
// redirect
header_location("asset.php");
}
break;
case ("vlan") :
// check permission
if($_SESSION['suser_level'] >= $config_userlevel_vlandel) {
// get variables
$vlan_id = $_POST['vlan_id'];
// update db
mysql_query("DELETE FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error());
// redirect
header_location("vlan.php");
}
break;
}
}
}
// still not redirected, check for error
if(empty($error)) {
$error = "notallowed";
}
// redirect
header_location("error.php?error=" . $error);
?>

@ -1,23 +1,25 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>Subnet:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="subnetview.php?subnet_id=' . $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a></td></tr>';
}
?>
</table>
<?php
// set template
$tp = new Template("tpl/subnet.tpl");
// set language variables
$tp->setvars($lang);
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,54 +1,15 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/subnetadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$subnet_address= $_POST['subnet_address'];
$subnet_mask = $_POST['subnet_mask'];
mysql_query("INSERT INTO subnet (subnet_address, subnet_mask) VALUE ('$subnet_address', '$subnet_mask')") or die(mysql_error());
$subnet_id = mysql_insert_id();
header_location("subnetview.php?subnet_id=" . $subnet_id);
}
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="subnetadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new subnet:</b><br>
</td>
</tr>
<tr>
<td>
Subnet Address:
</td>
<td>
<input type="text" name="subnet_address">
</td>
</tr>
<tr>
<td>
Subnet Mask:
</td>
<td>
<input type="text" name="subnet_mask" size="2"> (16-30)
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,34 @@
<?php
include("header.php");
// get id
$subnet_id = $_GET['subnet_id'];
// set template
$tp = new Template("tpl/subnetdel.tpl");
// set language variables
$tp->setvars($lang);
// get subnet info
$result = mysql_query("SELECT subnet_address, subnet_mask FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("subnet_id", $subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
// get node info
$result = mysql_query("SELECT node_id, ip, mac, dns1, dns2, node_info FROM node WHERE subnet_id='$subnet_id' ORDER BY INET_ATON(ip)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("node_id", $row->node_id);
$tp->set("ip", $row->ip);
$tp->parse("noderow");
}
if (($i>0) ? $tp->parse("node") : $tp->hide("node"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,100 +1,39 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
$subnet_id = $_GET['subnet_id'];
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$subnet_id = $_POST['subnet_id'];
$subnet_address= $_POST['subnet_address'];
$subnet_mask = $_POST['subnet_mask'];
$vlan_id = $_POST['vlan_id'];
$subnet_info = $_POST['subnet_info'];
mysql_query("UPDATE subnet SET subnet_address='$subnet_address', subnet_mask='$subnet_mask', vlan_id='$vlan_id', subnet_info='$subnet_info' WHERE subnet_id='$subnet_id'") or die(mysql_error());
header_location("subnetview.php?subnet_id=" . $subnet_id);
}
// set template
$tp = new Template("tpl/subnetedit.tpl");
$subnet_id = $_GET['subnet_id'];
// set language variables
$tp->setvars($lang);
// get current information
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$vlan_id = $row->vlan_id;
$subnet_info = $row->subnet_info;
}
?>
// get subnet information
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$vlan_id = $row->vlan_id;
$tp->set("subnet_id", $subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->set("vlan_id", $vlan_id);
$tp->set("subnet_info", $row->subnet_info);
<form method="POST" action="subnetedit.php">
<input type="hidden" name="subnet_id" value="<?php echo $subnet_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit subnet:</b><br>
</td>
</tr>
<tr>
<td>
Subnet Address:
</td>
<td>
<input type="text" name="subnet_address" value="<?php echo $subnet_address; ?>">
</td>
</tr>
<tr>
<td>
Subnet Mask:
</td>
<td>
<input type="text" name="subnet_mask" size="2" value="<?php echo $subnet_mask; ?>">
</td>
</tr>
<tr>
<td>
VLAN
</td>
<td>
<select name="vlan_id">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number");
while ($row = mysql_fetch_object($result)) {
if ($row->vlan_id==$vlan_id) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $row->vlan_id . '" ' . $selected . '>' . $row->vlan_name . ' ('. $row->vlan_number . ')</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
Subnet info:
</td>
<td>
<textarea name="subnet_info"><?php echo $subnet_info; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get vlan info
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
if (($row->vlan_id==$vlan_id) ? $tp->set("selected", "selected") : $tp->set("selected", ""));
$tp->set("vlan_id", $row->vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->set("vlan_number", $row->vlan_number);
$tp->parse("vlanrow");
}
if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,229 +1,216 @@
<?php
include("header.php");
// get id
$subnet_id = $_GET['subnet_id'];
// get page
if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 0;
}
?>
<script language="javascript">
function linkTo(optVal){
if(optVal=="")
return false;
window.location='subnetview.php?subnet_id='+optVal;
}
</script>
<script type="text/javascript">
function change(id,newtext) {
document.getElementById(id).innerHTML=newtext
}
</script>
<?php
// get all info
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$vlan_id = $row->vlan_id;
$subnet_info = $row->subnet_info;
}
// determine current range
// set template
$tp = new Template("tpl/subnetview.tpl");
// set language variables
$tp->setvars($lang);
// get subnet info
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$tp->set("subnet_id", $subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->set("subnet_info", nl2br($row->subnet_info));
// set needed variables
$subnet_address = $row->subnet_address;
$subnet_mask = $row->subnet_mask;
$vlan_id = $row->vlan_id;
// split up the range
$iprange = explode('.', $subnet_address);
$iprange1 = $iprange[0];
$iprange2 = $iprange[1];
$iprange3 = $iprange[2];
$iprange4 = $iprange[3];
// calculate no. of hosts
$hostcount = pow(2,(32-$subnet_mask));
// is there a need for pagination?
if ($hostcount>256) {
$maxdisplayedip = 256;
// create array for these addresses
$subnet = array();
if ($subnet_mask>=24) {
// Class C
// calculate hosts
$hostcount = pow(2,(32-$subnet_mask));
// calculate broadcast address and create pagination
if ($hostcount>65536) {
// class A subnet
echo 'Class A subnets (>65536 nodes) are not supported';
exit;
} else {
// class B subnet
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($hostcount/256-1) . '.255';
$pagination = 'Page: <select name="pagination" onchange="linkTo(this.options[this.selectedIndex].value);">';
for ($i=0;$i<($hostcount/256);$i++) {
if ($i==$page) {
$selected = ' selected';
} else {
$selected = '';
}
$pagination .= '<option value="' . $subnet_id . '&page=' . $i . '"' . $selected . '>' . $iprange1 . '.' . $iprange2 . '.' . ($i) . '.0</option>';
}
$pagination .= '</select>';
// fill array with addresses we want to see
for($i=0;$i<$hostcount;$i++) {
$ip = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$i);
$subnet[$ip] = array();
}
// calculate broadcast address
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$i-1);
// no pagination needed
$tp->set("pagination", '&nbsp;');
} else if ($subnet_mask>=16) {
// Class B
// which part do we want to see?
if((empty($page)) ? $page=$subnet_address : $page=$page);
$page = explode('.', $page);
$page2 = $page[2];
// fill array with addresses we want to see
for($i=0;$i<256;$i++) {
$ip = $iprange1 . '.' . $iprange2 . '.' . $page2 . '.' . $i;
$subnet[$ip] = array();
}
// calculate broadcast address
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$i-1) . '.255';
// create pagination
$pagination = 'Page:&nbsp;' . $iprange1 . '.' . $iprange2 . '.&nbsp;';
$pagination .= '<select name="pagination" onchange="linkTo(this.options[this.selectedIndex].value);">';
for($i=$iprange3;$i<(pow(2,(32-$subnet_mask))/256);$i++) {
if(($i==$page2) ? $selected='selected' : $selected='');
$pagination .= '<option value="' . $subnet_id . '&page=' . $iprange1 . '.' . $iprange2 . '.' . $i . '.0"' . $selected . '>' . $i . '.0</option>';
}
$pagination .= '</select>';
$tp->set("pagination", $pagination);
} else {
// // class C subnet so no pagination needed, set static variables
$pagination = '&nbsp;';
$page = 0;
$maxdisplayedip = $hostcount;
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$hostcount-1);
}
?>
<table border="0">
<tr>
<td colspan="32">
<b>Subnet: </b><?php echo $subnet_address . '/'. $subnet_mask; ?>
</td>
<td colspan="32" align="right">
<?php echo $pagination; ?>
</td>
</tr>
<?php
echo '<tr>';
// Class A
// which part do we want to see?
if((empty($page)) ? $page=$subnet_address : $page=$page);
$page = explode('.', $page);
$page2 = $page[1];
$page3 = $page[2];
for ($i=1;$i<=$maxdisplayedip;$i++) {
// build current ip
$ip = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$page) . '.' . ($i+$iprange4-1);
// disable subnet_address and broadcast_address
if ($ip==$subnet_address) {
echo '<td><img src="images/cross.jpg" onMouseOver="change(\'remotetext\',\'' . $ip . ' (Subnet address)\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></td>';
} else if ($ip==$broadcast_address) {
echo '<td><img src="images/cross.jpg" onMouseOver="change(\'remotetext\',\'' . $ip . ' (Broadcast address)\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></td>';
} else {
// check for current ip address
$result = mysql_query("SELECT a.asset_name, acg.color, n.node_id FROM asset a, assetclass ac, assetclassgroup acg, node n WHERE n.ip='$ip' AND a.asset_id=n.asset_id AND ac.assetclass_id=a.assetclass_id AND acg.assetclassgroup_id=ac.assetclassgroup_id");
if (mysql_num_rows($result)==0) {
// ip not in use
echo '<td><a href="assigniptonode.php?ip='. $ip . '&subnet_id=' . $subnet_id . '"><img src="images/grey.jpg" border="0" onMouseOver="change(\'remotetext\',\'' . $ip . '\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></a></td>';
} else {
// ip in use
while ($row = mysql_fetch_object($result)) {
$node_id = $row->node_id;
echo '<td><a href="nodeview.php?node_id=' . $node_id . '"><img src="images/' . $row->color . '.jpg" border="0" onMouseOver="change(\'remotetext\',\'' . $ip . '&nbsp;' . $row->asset_name . '\')" onMouseOut="change(\'remotetext\',\'&nbsp;\')"></a></td>';
}
}
}
if ($i%64==0) {
echo '</tr><tr>';
}
// fill array with addresses we want to see
for($i=0;$i<256;$i++) {
$ip = $iprange1 . '.' . $page2 . '.' . $page3 . '.' . $i;
$subnet[$ip] = array();
}
?>
<tr>
<td colspan="64">
<a id="remotetext">&nbsp;</a>
</td>
</tr>
</table>
<table border="0">
<tr>
<td>
<table border="0">
<tr>
<td>
<b>VLAN(s):</b>
</td>
<td>
<?php
// search vlan(s) for this subnet
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan WHERE vlan_id='$vlan_id'");
while ($row = mysql_fetch_object($result)) {
echo '<a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . ' ('. $row->vlan_number . ')</a>';
}
?>
</td>
</tr>
<tr>
<td>
<b>Location(s):</b>
</td>
<td>
<?php
// search location(s) for this subnet
$result = mysql_query("SELECT l.location_id FROM location l INNER JOIN subnetlocation sl ON l.location_id=sl.location_id WHERE sl.subnet_id='$subnet_id'");
while ($row = mysql_fetch_object($result)) {
echo location_name($row->location_id, '') . '<br>';
}
?>
</td>
</tr>
<tr>
<td>
<b>Subnet info:</b>
</td>
<td>
<?php echo nl2br($subnet_info); ?>
</td>
</tr>
</table>
</td>
<td width="100">
&nbsp;
</td>
<td>
<table border="0">
<tr>
<td>
<img src="images/grey.jpg"> Unassigned
</td>
</tr>
</tr>
<?php
// display assetclass(es)
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name, color FROM assetclassgroup ORDER BY assetclassgroup_id");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><img src="images/' . $row->color . '.jpg"> <a href="assetclassgroupview.php?assetclassgroup_id=' . $row->assetclassgroup_id . '">' . $row->assetclassgroup_name . '</a></td></tr>';
}
?>
</table>
</td>
</tr>
</table>
<p>
// calculate broadcast address
$broadcast_address = $iprange1 . '.' . ($iprange+$i-1) . '.255.255';
// create pagination
$pagination = 'Page:&nbsp;';
// selectbox 1
$pagination .= '<select name="pagination" onchange="linkTo(this.options[this.selectedIndex].value);">';
for($i=$iprange2;$i<(pow(2,(24-$subnet_mask))/256);$i++) {
if(($i==$page2) ? $selected='selected' : $selected='');
$pagination .= '<option value="' . $subnet_id . '&page=' . $iprange1 . '.' . $i . '.' . $page3 . '.0"' . $selected . '>' . $iprange1 . '.' . $i . '</option>';
}
$pagination .= '</select><select name="pagination" onchange="linkTo(this.options[this.selectedIndex].value);">';
// selectbox 2
for($i=0;$i<256;$i++) {
if(($i==$page3) ? $selected='selected' : $selected='');
$pagination .= '<option value="' . $subnet_id . '&page=' . $iprange1 . '.' . $page2 . '.' . $i . '.0"' . $selected . '>' . $i . '.0</option>';
}
$pagination .= '</select>';
$tp->set("pagination", $pagination);
}
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="subnetedit.php?subnet_id=<?php echo $subnet_id; ?>">Modify subnet</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assignsubnettolocation.php?subnet_id=<?php echo $subnet_id; ?>">Assign location</a>
</td>
</tr>
<?php
// end display only if admin
// get nodes for this subnet and implement the values into the array
$result = mysql_query("SELECT a.asset_name, acg.color, n.node_id, n.ip FROM asset a, assetclass ac, assetclassgroup acg, node n WHERE n.ip IN ('".implode("','",array_keys($subnet))."') AND n.subnet_id='$subnet_id' AND a.asset_id=n.asset_id AND ac.assetclass_id=a.assetclass_id AND acg.assetclassgroup_id=ac.assetclassgroup_id") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$subnet[$row['ip']] = $row;
}
?>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>">View assigned IP addresses in subnet</a>
</td>
</tr>
</table>
<?php
// replace subnet address (if in array)
if(array_key_exists($subnet_address, $subnet)) {
$subnet[$subnet_address]=array("subnet_address");
}
// replace broadcast address (if in array)
if(array_key_exists($broadcast_address, $subnet)) {
$subnet[$broadcast_address]=array("broadcast_address");
}
// loop array and send to template
$i=1;
foreach($subnet as $ip => $node) {
if(($i%64==0) ? $tr="</tr><tr>" : $tr="");
if(empty($node)) {
$tp->set("url", 'assigniptonode.php?subnet_id=' . $subnet_id . '&ip='. $ip);
$tp->set("remotetext", $ip);
$tp->set("color", 'grey');
} else if ($node[0]=="subnet_address") {
$tp->set("url", "");
$tp->set("remotetext", $ip . '&nbsp;' . $lang['lang_subnet_subnetaddress']);
$tp->set("color", 'cross');
} else if ($node[0]=="broadcast_address") {
$tp->set("url", "");
$tp->set("remotetext", $ip . '&nbsp;' . $lang['lang_subnet_broadcastaddress']);
$tp->set("color", 'cross');
} else {
$tp->set("url", 'nodeview.php?node_id=' . $node['node_id']);
$tp->set("remotetext", $ip . '&nbsp;' . $node['asset_name']);
$tp->set("color", $node['color']);
}
$tp->set("tr", $tr);
$tp->parse("iprow");
$i++;
}
$tp->parse("subnet");
// get vlan info
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("vlan_id", $row->vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->parse("vlanrow");
}
if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan"));
// get location info
$result = mysql_query("SELECT l.location_id, l.location_name FROM location l INNER JOIN subnetlocation sl ON l.location_id=sl.location_id WHERE sl.subnet_id='$subnet_id'") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("location_id", $row->location_id);
$tp->set("location_name", $row->location_name);
$tp->parse("locationrow");
}
if (($i>0) ? $tp->parse("location") : $tp->hide("location"));
// get assetclass info
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name, color FROM assetclassgroup ORDER BY assetclassgroup_id") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("assetclassgroup_id", $row->assetclassgroup_id);
$tp->set("assetclassgroup_name", $row->assetclassgroup_name);
$tp->set("color", $row->color);
$tp->parse("assetclassgrouprow");
}
if (($i>0) ? $tp->parse("assetclassgroup") : $tp->hide("assetclassgroup"));
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assignlocationtosubnet) {
$tp->parse("assignlocationtosubnet");
} else {
$tp->hide("assignlocationtosubnet");
}
if($_SESSION['suser_level'] >= $config_userlevel_assignvlantosubnet) {
$tp->set("vlan_id", $vlan_id);
$tp->parse("assignvlantosubnet");
} else {
$tp->hide("assignvlantosubnet");
}
if($_SESSION['suser_level'] >= $config_userlevel_subnetedit) {
$tp->parse("subnetedit");
} else {
$tp->hide("subnetedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_subnetdel) {
$tp->parse("subnetdel");
} else {
$tp->hide("subnetdel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,16 @@
[BLOCK table AS asset]
<table border="0">
<tr>
<td>
<b>{lang_asset}:</b><br>
</td>
</tr>
[BLOCK assetrow]
<tr>
<td>
<a href="assetview.php?asset_id={asset_id}">{asset_name}</a>
</td>
</tr>
[END assetrow]
</table>
[END table]

@ -0,0 +1,53 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="asset">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_asset_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_asset_name}:
</td>
<td>
<input type="text" name="asset_name">
</td>
</tr>
<tr>
<td>
{lang_hostname}:
</td>
<td>
<input type="text" name="hostname">
</td>
</tr>
[BLOCK table AS assetclass]
<tr>
<td>
{lang_assetclass}:
</td>
<td>
<select name="assetclass_id">
[BLOCK assetclassrow]
<option value="{assetclass_id}">{assetclass_name}</option>
[END assetclassrow]
</select>
</td>
</tr>
[END table]
<tr>
<td>
{lang_asset_info}:
</td>
<td>
<textarea name="asset_info"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,16 @@
[BLOCK table AS assetclass]
<table border="0">
<tr>
<td>
<b>{lang_assetclass}:</b><br>
</td>
</tr>
[BLOCK assetclassrow]
<tr>
<td>
<a href="assetclassview.php?assetclass_id={assetclass_id}">{assetclass_name}</a>
</td>
</tr>
[END assetclassrow]
</table>
[END table]

@ -0,0 +1,37 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="assetclass">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_assetclass_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_assetclass_name}:
</td>
<td>
<input type="text" name="assetclass_name">
</td>
</tr>
[BLOCK table AS assetclassgroup]
<tr>
<td>
{lang_assetclassgroup}:<br>
</td>
<td>
<select name="assetclassgroup_id">
[BLOCK assetclassgrouprow]
<option value="{assetclassgroup_id}">{assetclassgroup_name}</option>
[END assetclassgrouprow]
</select>
</td>
</tr>
[END table]
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,34 @@
<form method="POST" action="submit.php">
<input type="hidden" name="del" value="assetclass">
<input type="hidden" name="assetclass_id" value="{assetclass_id}">
<table border="0">
<tr>
<td>
<b>{lang_assetclass_del}</b><br>
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td>
<b>{lang_assetclass_name}:</b>
</td>
<td>
{assetclass_name}
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td>
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,38 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="assetclass">
<input type="hidden" name="assetclass_id" value="{assetclass_id}">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_assetclass_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_assetclass_name}:
</td>
<td>
<input type="text" name="assetclass_name" value="{assetclass_name}">
</td>
</tr>
[BLOCK table AS assetclassgroup]
<tr>
<td>
{lang_assetclassgroup}:<br>
</td>
<td>
<select name="assetclassgroup_id">
[BLOCK assetclassgrouprow]
<option value="{assetclassgroup_id}" {selected}>{assetclassgroup_name}</option>
[END assetclassgrouprow]
</select>
</td>
</tr>
[END table]
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,49 @@
<table border="0">
<tr>
<td>
<b>Assetclass Groupname:</b>
</td>
<td>
{assetclassgroup_name}
</td>
</tr>
<tr>
<td>
<b>Color:</b>
</td>
<td>
<img src="images/{color}.jpg">
</td>
</tr>
<tr>
<td>
<b>Assetclass(es):</b>
</td>
[BLOCK table AS assetclass]
<td>
[BLOCK assetclassrow]
<a href="assetclassview.php?assetclass_id={assetclass_id}">{assetclass_name}</a><br>
[END assetclassrow]
</td>
[END table]
</tr>
</table>
<p>
<table border="0">
[BLOCK assetclassgroupedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetclassgroupedit.php?assetclassgroup_id={assetclassgroup_id}">{lang_assetclassgroup_edit}</a>
</td>
</tr>
[END assetclassgroupedit]
[BLOCK assetclassgroupdel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetclassgroupdel.php?assetclassgroup_id={assetclassgroup_id}">{lang_assetclassgroup_del}</a>
</td>
</tr>
[END assetclassgroupdel]
</table>

@ -0,0 +1,49 @@
<table border="0">
<tr>
<td>
<b>{lang_assetclass_name}:</b>
</td>
<td>
{assetclass_name}
</td>
</tr>
<tr>
<td>
<b>{lang_assetclassgroup_name}:</b>
</td>
<td>
<a href="assetclassgroupview.php?assetclassgroup_id={assetclassgroup_id}">{assetclassgroup_name}</a>
</td>
</tr>
[BLOCK table AS asset]
<tr>
<td>
<b>{lang_assets}:</b><br>
</td>
<td>
[BLOCK assetrow]
<a href="assetview.php?asset_id={asset_id}">{asset_name}</a><br>
[END assetrow]
</td>
</tr>
[END table]
</table>
<p>
<table border="0">
[BLOCK assetclassedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetclassedit.php?assetclass_id={assetclass_id}">{lang_assetclass_edit}</a>
</td>
</tr>
[END assetclassedit]
[BLOCK assetclassdel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetclassdel.php?assetclass_id={assetclass_id}">{lang_assetclass_del}</a>
</td>
</tr>
[END assetclassdel]
</table>

@ -0,0 +1,51 @@
<form method="POST" action="submit.php">
<input type="hidden" name="del" value="asset">
<input type="hidden" name="asset_id" value="{asset_id}">
<table border="0">
<tr>
<td>
<b>{lang_asset_del}</b><br>
</td>
</tr>
<tr>
<td>
<b>{lang_asset_name}:</b>
</td>
<td>
<a href="assetview.php?asset_id={asset_id}">{asset_name}</a>
</td>
</tr>
</table>
<p>
[BLOCK table AS node]
<table border="0">
<tr>
<td colspan="2">
<img src="images/warning.gif">&nbsp;{lang_warning_asset_del_nodes}
</td>
</tr>
[BLOCK noderow]
<tr>
<td>
<b>{lang_ip}:</b>
</td>
<td>
<a href="nodeview.php?node_id={node_id}">{ip}</a>
</td>
</tr>
[END noderow]
</table>
[END table]
<p>
<table border="0">
<tr>
<td align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,54 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="asset">
<input type="hidden" name="asset_id" value="{asset_id}">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_asset_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_asset_name}:
</td>
<td>
<input type="text" name="asset_name" value="{asset_name}">
</td>
</tr>
<tr>
<td>
{lang_hostname}:
</td>
<td>
<input type="text" name="hostname" value="{hostname}">
</td>
</tr>
[BLOCK table AS assetclass]
<tr>
<td>
{lang_assetclass}:
</td>
<td>
<select name="assetclass_id">
[BLOCK assetclassrow]
<option value="{assetclass_id}" {selected}>{assetclass_name}</option>
[END assetclassrow]
</select>
</td>
</tr>
[END table]
<tr>
<td>
{lang_asset_info}:
</td>
<td>
<textarea name="asset_info">{asset_info}</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,118 @@
<table border="0">
<tr>
<td>
<b>{lang_asset_name}:</b>
</td>
<td>
{asset_name}
</td>
</tr>
<tr>
<td>
<b>{lang_hostname}:</b>
</td>
<td>
{hostname}
</td>
</tr>
<tr>
<td>
<b>{lang_assetclass}:</b>
</td>
<td>
<a href="assetclassview.php?assetclass_id={assetclass_id}">{assetclass_name}</a>
</td>
</tr>
<tr>
<td>
<b>{lang_asset_info}:</b>
</td>
<td>
{asset_info}
</td>
</tr>
</table>
<p>
[BLOCK table AS node]
<table border="0">
[BLOCK noderow]
<tr>
<td>
&nbsp;
</td>
<td>
<b>{lang_node} #{nodecount}</b>
</td>
</tr>
<tr>
<td>
<b>{lang_ip}:</b>
</td>
<td>
<a href="nodeview.php?node_id={node_id}">{ip}</a>
</td>
</tr>
<tr>
<td>
<b>{lang_subnet}:</b>
</td>
<td>
<a href="subnetview.php?subnet_id={subnet_id}&page={ip}">{subnet_address}/{subnet_mask}</a>
</td>
</tr>
<tr>
<td>
<b>{lang_mac}:</b>
</td>
<td>
{mac}
</td>
</tr>
<tr>
<td>
<b>{lang_dns1}:</b>
</td>
<td>
{dns1}
</td>
</tr>
<tr>
<td>
<b>{lang_dns2}:</b>
</td>
<td>
{dns2}
</td>
</tr>
<tr>
<td>
<b>{lang_node_info}:</b>
</td>
<td>
{node_info}
</td>
</tr>
[END noderow]
</table>
[END table]
<p>
<table border="0">
[BLOCK assetedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetedit.php?asset_id={asset_id}">{lang_asset_edit}</a>
</td>
</tr>
[END assetedit]
[BLOCK assetdel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetdel.php?asset_id={asset_id}">{lang_asset_del}</a>
</td>
</tr>
[END assetdel]
</table>

@ -0,0 +1,89 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="assigniptoasset">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_assigniptoasset}:</b>
</td>
</tr>
<tr>
<td>
{lang_ip}:
</td>
<td>
<input type="text" name="ip" value="{ip}">
</td>
</tr>
[BLOCK table AS subnet]
<tr>
<td>
{lang_subnet}:
</td>
<td>
<select name="subnet_id">
[BLOCK subnetrow]
<option value="{subnet_id}" {selected}>{subnet_address}/{subnet_mask}</option>
[END subnetrow]
</select>
</td>
</tr>
[END table]
[BLOCK table AS asset]
<tr>
<td>
{lang_asset_name}:
</td>
<td>
<select name="asset_id">
[BLOCK assetrow]
<option value="{asset_id}">{asset_name}</option>
[END assetrow]
</select>
</td>
</tr>
[END table]
<tr>
<td>
{lang_mac}:
</td>
<td>
<input type="text" name="mac">
</td>
</tr>
<tr>
<td>
{lang_dns1}:
</td>
<td>
<input type="text" name="dns1">
</td>
<td>
<input type="checkbox" name="dns1suffix" checked>{config_dns1suffix}
</td>
</tr>
<tr>
<td>
{lang_dns2}:
</td>
<td>
<input type="text" name="dns2">
</td>
<td>
<input type="checkbox" name="dns2suffix" checked>{config_dns2suffix}
</td>
</tr>
<tr>
<td>
{lang_node_info}:
</td>
<td>
<textarea name="node_info"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,38 @@
<table border="0">
<tr>
<td>
<b>{lang_ip}:</b>
</td>
<td>
{ip}
</td>
</tr>
<tr>
<td>
<b>{lang_subnet}:</b>
</td>
<td>
<a href="subnetview.php?subnet_id={subnet_id}&page={ip}">{subnet_address}/{subnet_mask}</a>
</td>
</tr>
</table>
<p>
<table border="0">
[BLOCK assigniptonode]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assigniptoasset.php?subnet_id={subnet_id}&ip={ip}">{lang_assigniptoasset}</a>
</td>
</tr>
[END assigniptonode]
[BLOCK nodeadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="nodeadd.php?subnet_id={subnet_id}&ip={ip}">{lang_node_new}</a>
</td>
</tr>
[END nodeadd]
</table>

@ -0,0 +1,44 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="assignlocationtosubnet">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_assignlocationtosubnet}:</b>
</td>
</tr>
[BLOCK table AS location]
<tr>
<td>
{lang_location_name}:
</td>
<td>
<select name="location_id">
<option value="0">(none)</option>
[BLOCK locationrow]
<option value="{location_id}" {selected}>{location_name}</option>
[END locationrow]
</select>
</td>
</tr>
[END table]
[BLOCK table AS subnet]
<tr>
<td>
{lang_subnet}:
</td>
<td>
<select name="subnet_id">
[BLOCK subnetrow]
<option value="{subnet_id}" {selected}>{subnet_address}/{subnet_mask}</option>
[END subnetrow]
</select>
</td>
</tr>
[END table]
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,43 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="assignvlantosubnet">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_assignvlantosubnet}:</b><br>
</td>
</tr>
[BLOCK table AS vlan]
<tr>
<td>
{lang_vlan}:
</td>
<td>
<select name="vlan_id">
[BLOCK vlanrow]
<option value="{vlan_id}" {selected}>{vlan_name} ({vlan_id})</option>
[END vlanrow]
</select>
</td>
</tr>
[END table]
[BLOCK table AS subnet]
<tr>
<td>
{lang_subnet}:
</td>
<td>
<select name="subnet_id">
[BLOCK subnetrow]
<option value="{subnet_id}" {selected}>{subnet_address}/{subnet_mask}</option>
[END subnetrow]
</select>
</td>
</tr>
[END table]
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,12 @@
<table border="0">
<tr>
<td>
<img src="images/warning.gif">&nbsp;<b>{lang_error}:</b>&nbsp;{error}<br>
</td>
</tr>
<tr>
<td>
<a href="javascript:history.back();">&lt;&lt;&nbsp;{lang_goback}</a>
</td>
</tr>
</table>

@ -0,0 +1,13 @@
<hr>
<table border="0" width="100%">
<tr>
<td align="center">
<a href="index.php" class="label">IP Reg {config_version}</a>
</td>
</tr>
</table>
</body>
</html>

@ -0,0 +1,31 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>IP Reg</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="tpl/style.css" type="text/css">
</head>
<body>
<form method="POST" action="search.php">
<table border="0" width="100%">
<tr>
<td>
{lang_header_viewby}:&nbsp;<a href="asset.php">{lang_asset}</a> -
<a href="assetclass.php">{lang_assetclass}</a> -
<a href="location.php">{lang_location}</a> -
<a href="subnet.php">{lang_subnet}</a> -
<a href="vlan.php">{lang_vlan}</a>&nbsp;
.:<input type="text" name="search" value="{search}">&nbsp;<input type="submit" value="{lang_search}">
</td>
<td align="right">
{suser_displayname} -
<a href="options.php">{lang_options}</a> -
<a href="logout.php">{lang_logout}</a>
</td>
</tr>
</table>
</form>
<hr>

@ -0,0 +1,57 @@
<table border="0">
<tr>
<td>
<b>IP Reg</b><br>
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td colspan="2">
<b>{lang_statistics}:</b>
</td>
</tr>
<tr>
<td width="100">
{lang_assets}:
</td>
<td align="right">
{assetcount}
</td>
</tr>
<tr>
<td>
{lang_locations}:
</td>
<td align="right">
{locationcount}
</td>
</tr>
<tr>
<td>
{lang_nodes}:
</td>
<td align="right">
{nodecount}
</td>
</tr>
<tr>
<td>
{lang_subnets}:
</td>
<td align="right">
{subnetcount}
</td>
</tr>
<tr>
<td>
{lang_vlans}:
</td>
<td align="right">
{vlancount}
</td>
</tr>
</table>

@ -0,0 +1,16 @@
[BLOCK table AS location]
<table border="0">
<tr>
<td>
<b>{lang_locations}:</b><br>
</td>
</tr>
[BLOCK locationrow]
<tr>
<td>
{nbsp}<a href="locationview.php?location_id={location_id}">{location_name}</a>
</td>
</tr>
[END locationrow]
</table>
[END table]

@ -0,0 +1,38 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="location">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_location_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_location_name}:
</td>
<td>
<input type="text" name="location_name">
</td>
</tr>
[BLOCK table AS location]
<tr>
<td>
{lang_location_parent}:
</td>
<td>
<select name="parent">
<option value="0">(none)</option>
[BLOCK locationrow]
<option value="{location_id}">{location_name}</option>
[END locationrow]
</select>
</td>
</tr>
[END table]
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,29 @@
<form method="POST" action="submit.php">
<input type="hidden" name="del" value="location">
<input type="hidden" name="location_id" value="{location_id}">
<table border="0">
<tr>
<td>
<b>{lang_location_del}</b><br>
</td>
</tr>
<tr>
<td>
<b>{lang_location_name}:</b>
</td>
<td>
<a href="locationview.php?location_id={location_id}">{location_name}</a>
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,47 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="location">
<input type="hidden" name="location_id" value="{location_id}">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_location_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_location_name}:
</td>
<td>
<input type="text" name="location_name" value="{location_name}">
</td>
</tr>
<tr>
<td>
{lang_location_parent}:
</td>
<td>
[BLOCK table AS parent]
<select name="parent">
<option value="0">(none)</option>
[BLOCK parentrow]
<option value="{parent_id}" {selected}>{parent_name}</option>
[END parentrow]
</select>
[END table]
</td>
</tr>
<tr>
<td>
{lang_location_info}:
</td>
<td>
<textarea name="location_info">{location_info}</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,73 @@
<table border="0">
<tr>
<td>
<b>{lang_location_name}:</b>
</td>
<td>
[BLOCK table AS locationcrumb]
[BLOCK locationcrumbrow]
{seperator}<a href="locationview.php?location_id={location_id}">{location_name}</a>
[END locationcrumbrow]
[END table]
</td>
</tr>
<tr>
<td>
<b>{lang_location_info}:</b>
</td>
<td>
{location_info}
</td>
</tr>
<tr>
<td>
<b>{lang_subnets}:</b>
</td>
[BLOCK table AS subnet]
<td>
[BLOCK subnetrow]
<a href="subnetview.php?subnet_id={subnet_id}">{subnet_address}/{subnet_mask}</a><br>
[END subnetrow]
</td>
[END table]
</tr>
<tr>
<td>
<b>{lang_sublocations}:</b>
</td>
[BLOCK table AS sublocation]
<td>
[BLOCK sublocationrow]
<a href="locationview.php?location_id={sublocation_id}">{sublocation_name}</a><br>
[END sublocationrow]
</td>
[END table]
</td>
</tr>
</table>
<p>
<table border="0">
[BLOCK assignlocationtosubnet]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assignlocationtosubnet.php?location_id={location_id}">{lang_assignlocationtosubnet}</a>
</td>
</tr>
[END assignlocationtosubnet]
[BLOCK locationedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="locationedit.php?location_id={location_id}">{lang_location_edit}</a>
</td>
</tr>
[END locationedit]
[BLOCK locationdel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="locationdel.php?location_id={location_id}">{lang_location_del}</a>
</td>
</tr>
[END locationdel]
</table>

@ -0,0 +1,91 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="node">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_node_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_asset_name}:
</td>
<td>
<input type="text" name="asset_name">
</td>
</tr>
<tr>
<td>
{lang_hostname}:
</td>
<td>
<input type="text" name="hostname">
</td>
</tr>
<tr>
<td>
{lang_ip}:
</td>
<td>
<input type="text" name="ip" value="{ip}">
</td>
</tr>
[BLOCK table AS subnet]
<tr>
<td>
{lang_subnet}:
</td>
<td>
<select name="subnet_id">
[BLOCK subnetrow]
<option value="{subnet_id}" {selected}>{subnet_address}/{subnet_mask}</option>
[END subnetrow]
</select>
</td>
</tr>
[END table]
[BLOCK table AS assetclass]
<tr>
<td>
{lang_assetclass}:
</td>
<td>
<select name="assetclass_id">
[BLOCK assetclassrow]
<option value="{assetclass_id}">{assetclass_name}</option>
[END assetclassrow]
</select>
</td>
</tr>
[END table]
<tr>
<td>
{lang_mac}:
</td>
<td>
<input type="text" name="mac">
</td>
</tr>
<tr>
<td>
{lang_dns1}:
</td>
<td>
<input type="text" name="dns1">&nbsp;<input type="checkbox" name="dns1suffix" checked>{config_dns1suffix}
</td>
</tr>
<tr>
<td>
{lang_dns2}:
</td>
<td>
<input type="text" name="dns2">&nbsp;<input type="checkbox" name="dns2suffix" checked>{config_dns2suffix}
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,30 @@
<form method="POST" action="submit.php">
<input type="hidden" name="del" value="node">
<input type="hidden" name="node_id" value="{node_id}">
<input type="hidden" name="asset_id" value="{asset_id}">
<table border="0">
<tr>
<td>
<b>{lang_node_del}</b><br>
</td>
</tr>
<tr>
<td>
<b>{lang_ip}:</b>
</td>
<td>
<a href="nodeview.php?node_id={node_id}">{ip}</a>
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td>
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,78 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="node">
<input type="hidden" name="node_id" value="{node_id}">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_node_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_asset_name}:
</td>
<td>
{asset_name}:
</td>
</tr>
<tr>
<td>
{lang_ip}
</td>
<td>
{ip}
</td>
</tr>
[BLOCK table AS subnet]
<tr>
<td>
{lang_subnet}:
</td>
<td>
<select name="subnet_id">
[BLOCK subnetrow]
<option value="{subnet_id}" {selected}>{subnet_address}/{subnet_mask}</option>
[END subnetrow]
</select>
</td>
</tr>
[END table]
<tr>
<td>
{lang_mac}:
</td>
<td>
<input type="text" name="mac" value="{mac}">
</td>
</tr>
<tr>
<td>
{lang_dns1}:
</td>
<td>
<input type="text" name="dns1" value="{dns1}">
</td>
</tr>
<tr>
<td>
{lang_dns2}:
</td>
<td>
<input type="text" name="dns2" value="{dns2}">
</td>
</tr>
<tr>
<td>
{lang_node_info}:
</td>
<td>
<textarea name="node_info">{node_info}</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,46 @@
[BLOCK table AS node]
<table border="0">
<tr>
<td width="100">
<a href="nodelist.php?subnet_id={subnet_id}&order=ip"><b>{lang_ip}:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id={subnet_id}&order=asset_name"><b>{lang_asset_name}:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id={subnet_id}&order=hostname"><b>{lang_hostname}:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id={subnet_id}&order=mac"><b>{lang_mac}:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id={subnet_id}&order=dns1"><b>{lang_dns1}:</b></a>
</td>
<td width="150">
<a href="nodelist.php?subnet_id={subnet_id}&order=dns2"><b>{lang_dns2}:</b></a>
</td>
</tr>
[BLOCK noderow]
<tr>
<td>
<a href="nodeview.php?node_id={node_id}">{ip}</a>
</td>
<td>
<a href="assetview.php?asset_id={asset_id}">{asset_name}</a>
</td>
<td>
{hostname}
</td>
<td>
{mac}
</td>
<td>
{dns1}
</td>
<td>
{dns2}
</td>
</tr>
[END noderow]
</table>
[END table]

@ -0,0 +1,87 @@
<table border="0">
<tr>
<td>
<b>{lang_ip}:</b>
</td>
<td>
{ip}
</td>
</tr>
<tr>
<td>
<b>{lang_subnet}:</b>
</td>
<td>
<a href="subnetview.php?subnet_id={subnet_id}&page={ip}">{subnet_address}/{subnet_mask}</a>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
<b>{lang_asset_name}:</b>
</td>
<td>
<a href="assetview.php?asset_id={asset_id}">{asset_name}</a>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
<b>{lang_mac}:</b>
</td>
<td>
{mac}
</td>
</tr>
<tr>
<td>
<b>{lang_dns1}:</b>
</td>
<td>
{dns1}
</td>
</tr>
<tr>
<td>
<b>{lang_dns2}:</b>
</td>
<td>
{dns2}
</td>
</tr>
<tr>
<td>
<b>{lang_node_info}:</b>
</td>
<td>
{node_info}
</td>
</tr>
</table>
<p>
<table border="0">
[BLOCK nodeedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="nodeedit.php?node_id={node_id}">{lang_node_edit}</a>
</td>
</tr>
[END nodeedit]
[BLOCK nodedel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="nodedel.php?node_id={node_id}">{lang_node_del}</a>
</td>
</tr>
[END nodedel]
</table>

@ -0,0 +1,102 @@
<table border="0">
<tr>
<td>
<b>{lang_options_ipreg}</b>
</td>
</tr>
[BLOCK assetadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetadd.php">{lang_asset_add}</a>
</td>
</tr>
[END assetadd]
[BLOCK assetclassadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assetclassadd.php">{lang_assetclass_add}</a>
</td>
</tr>
[END assetclassadd]
[BLOCK locationadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="locationadd.php">{lang_location_add}</a>
</td>
</tr>
[END locationadd]
[BLOCK nodeadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="nodeadd.php">{lang_node_add}</a>
</td>
</tr>
[END nodeadd]
[BLOCK subnetadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="subnetadd.php">{lang_subnet_add}</a>
</td>
</tr>
[END subnetadd]
[BLOCK useradd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="useradd.php">{lang_user_add}</a>
</td>
</tr>
[END useradd]
[BLOCK vlanadd]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="vlanadd.php">{lang_vlan_add}</a>
</td>
</tr>
[END vlanadd]
</table>
<p>
<table border="0">
[BLOCK assigniptoasset]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assigniptoasset.php">{lang_assigniptoasset}</a>
</td>
</tr>
[END assigniptoasset]
[BLOCK assignlocationtosubnet]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assignlocationtosubnet.php">{lang_assignlocationtosubnet}</a>
</td>
</tr>
[END assignlocationtosubnet]
[BLOCK assignvlantosubnet]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assignvlantosubnet.php">{lang_assignvlantosubnet}</a>
</td>
</tr>
[END assignvlantosubnet]
</table>
<p>
<table border="0">
<tr>
<td>
<b>{lang_options_personal}</b>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="useredit.php">{lang_options_settings_edit}</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="userpassedit.php">{lang_options_password_edit}</a>
</td>
</tr>
</table>

@ -0,0 +1,41 @@
[BLOCK nosearch]
<table border="0">
<tr>
<td>
<img src="images/warning.gif">&nbsp;{lang_warning_search_nosearch}
</td>
</tr>
</table>
[END nosearch]
[BLOCK table AS asset]
<table border="0">
<tr>
<td>
<b>{item_name}&nbsp;{lang_search_found}&nbsp;({counter}):</b>
</td>
</tr>
[BLOCK row]
<tr>
<td>
<a href="{item}view.php?{item}_id={id}">{name}</a>
</td>
</tr>
[END row]
</table>
[END table]
[REUSE table AS location]
[REUSE table AS node]
[REUSE table AS subnet]
[REUSE table AS vlan]
[BLOCK resultcount]
<table border="0">
<tr>
<td>
<b>{lang_search_results_found}</b>:&nbsp;{resultcounter}
</td>
</tr>
</table>
[END resultcount]

@ -0,0 +1,39 @@
body {
background-color: #FFFFFF;
color: #000000;
font-family: Verdana, Arial, Helvetica, Sans-serif;
margin: 12px;
margin-top: 12px;
font-size: 70%;
}
a {
color: #466A8D;
}
a:hover {
color: #E1B100;
}
input {
font-size: 100%;
position: relative;
top: -2px;
font-family: Verdana, Arial, Helvetica, Sans-serif;
}
select {
font-size: 100%;
font-family: Verdana, Sans-serif;
position: relative;
top: -2px;
}
table {
font-size: 100%;
}
td {
vertical-align: top;
height: 18px;
}

@ -0,0 +1,16 @@
[BLOCK table AS subnet]
<table border="0">
<tr>
<td>
<b>{lang_subnet}:</b><br>
</td>
</tr>
[BLOCK subnetrow]
<tr>
<td>
<a href="subnetview.php?subnet_id={subnet_id}">{subnet_address}/{subnet_mask}</a>
</td>
</tr>
[END subnetrow]
</table>
[END table]

@ -0,0 +1,31 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="subnet">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_subnet_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_subnet_address}:
</td>
<td>
<input type="text" name="subnet_address">
</td>
</tr>
<tr>
<td>
{lang_subnet_mask}:
</td>
<td>
<input type="text" name="subnet_mask" size="2">&nbsp;(8-30)
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_subnet}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,51 @@
<form method="POST" action="submit.php">
<input type="hidden" name="del" value="subnet">
<input type="hidden" name="subnet_id" value="{subnet_id}">
<table border="0">
<tr>
<td>
<b>{lang_subnet_del}</b><br>
</td>
</tr>
<tr>
<td>
<b>{lang_subnet}:</b>
</td>
<td>
<a href="subnetview.php?subnet_id={subnet_id}">{subnet_address}/{subnet_mask}</a>
</td>
</tr>
</table>
<p>
[BLOCK table AS node]
<table border="0">
<tr>
<td colspan="2">
<img src="images/warning.gif">&nbsp;{lang_warning_asset_del_nodes}
</td>
</tr>
[BLOCK noderow]
<tr>
<td>
<b>{lang_ip}:</b>
</td>
<td>
<a href="nodeview.php?node_id={node_id}">{ip}</a>
</td>
</tr>
[END noderow]
</table>
[END table]
<p>
<table border="0">
<tr>
<td align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,55 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="subnet">
<input type="hidden" name="subnet_id" value="{subnet_id}">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_subnet_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_subnet_subnetaddress}:
</td>
<td>
<input type="text" name="subnet_address" value="{subnet_address}">
</td>
</tr>
<tr>
<td>
{lang_subnet_mask}:
</td>
<td>
<input type="text" name="subnet_mask" size="2" value="{subnet_mask}">
</td>
</tr>
<tr>
<td>
{lang_vlan}
</td>
<td>
[BLOCK table AS vlan]
<select name="vlan_id">
<option value="0">(none)</option>
[BLOCK vlanrow]
<option value="{vlan_id}" {selected}>{vlan_name}&nbsp;({vlan_number})</option>
[END vlanrow]
[END table]
</select>
</td>
</tr>
<tr>
<td>
{lang_subnet_info}:
</td>
<td>
<textarea name="subnet_info">{subnet_info}</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,153 @@
<script language="javascript">
function linkTo(optVal){
if(optVal=="")
return false;
window.location='subnetview.php?subnet_id='+optVal;
}
</script>
<script type="text/javascript">
function change(id,newtext) {
document.getElementById(id).innerHTML=newtext
}
</script>
<table border="0">
<tr>
<td>
<table border="0" width="100%">
<tr>
<td>
<b>{lang_subnet}: </b>{subnet_address}/{subnet_mask}
</td>
<td align="right">
{pagination}
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
[BLOCK table AS subnet]
<table border="0">
<tr>
[BLOCK iprow]
<td><a href="{url}" onMouseOver="change('remotetext','{remotetext}')" onMouseOut="change('remotetext','&nbsp;')"><img src="images/{color}.jpg" border="0"></a></td>{tr}
[END iprow]
</tr>
</table>
[END table]
</td>
</tr>
<tr>
<td>
<table border="0">
<tr>
<td>
<a id="remotetext">&nbsp;</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0">
<tr>
<td>
<table border="0">
<tr>
<td>
<b>{lang_vlans}:</b>
</td>
<td>
[BLOCK table AS vlan]
[BLOCK vlanrow]
<a href="vlanview.php?vlan_id={vlan_id}">{vlan_name}</a><br>
[END vlanrow]
[END table]
</td>
</tr>
<tr>
<td>
<b>{lang_locations}:</b>
</td>
<td>
[BLOCK table AS location]
[BLOCK locationrow]
<a href="locationview.php?location_id={location_id}">{location_name}</a><br>
[END locationrow]
[END table]
</td>
</tr>
<tr>
<td>
<b>{lang_subnet_info}:</b>
</td>
<td>
{subnet_info}
</td>
</tr>
</table>
</td>
<td width="100">
&nbsp;
</td>
<td>
[BLOCK table AS assetclassgroup]
<table border="0">
<tr>
<td>
<img src="images/grey.jpg">&nbsp;{lang_unassigned}
</td>
</tr>
[BLOCK assetclassgrouprow]
<tr>
<td>
<img src="images/{color}.jpg">&nbsp;<a href="assetclassgroupview.php?assetclassgroup_id={assetclassgroup_id}">{assetclassgroup_name}</a>
</td>
</tr>
[END assetclassgrouprow]
</table>
[END table]
</td>
</tr>
</table>
<p>
<table border="0">
[BLOCK assignlocationtosubnet]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assignlocationtosubnet.php?subnet_id={subnet_id}">{lang_assignlocationtosubnet}</a>
</td>
</tr>
[END assignlocationtosubnet]
[BLOCK assignvlantosubnet]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assignvlantosubnet.php?vlan_id={vlan_id}">{lang_assignvlantosubnet}</a>
</td>
</tr>
[END assignvlantosubnet]
[BLOCK subnetedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="subnetedit.php?subnet_id={subnet_id}">{lang_subnet_edit}</a>
</td>
</tr>
[END subnetedit]
[BLOCK subnetdel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="subnetdel.php?subnet_id={subnet_id}">{lang_subnet_del}</a>
</td>
</tr>
[END subnetdel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="nodelist.php?subnet_id={subnet_id}">View assigned IP addresses in subnet</a>
</td>
</tr>
</table>

@ -0,0 +1,41 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="user">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_user_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_user_name}:
</td>
<td>
<input type="text" name="user_name">
</td>
</tr>
<tr>
<td>
{lang_user_pass}:
</td>
<td>
{user_pass}
</td>
</tr>
<tr>
<td>
{lang_user_level}:
</td>
<td>
<select name="user_level">
<option value="1">1</option>
<option value="2">2</option>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,46 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="user">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_options_settings_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_user_displayname}:
</td>
<td>
<input type="text" name="user_displayname" value="{user_displayname}">
</td>
</tr>
<tr>
<td>
{lang_mac}:
</td>
<td>
<select name="user_mac">
<option value="0">xxxxxxxxxxxx</option>
<option value="1">xx-xx-xx-xx-xx-xx</option>
<option value="2">xx:xx:xx:xx:xx:xx</option>
<option value="3">xxxxxx-xxxxxx</option>
</select>
</td>
</tr>
<tr>
<td>
{lang_language}:
</td>
<td>
<select name="user_lang">
<option value="en">English</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,39 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="userpass">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_options_password_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_user_passold}:
</td>
<td>
<input type="password" name="user_passold">
</td>
</tr>
<tr>
<td>
{lang_user_passnew1}:
</td>
<td>
<input type="password" name="user_passnew1">
</td>
</tr>
<tr>
<td>
{lang_user_passnew2}:
</td>
<td>
<input type="password" name="user_passnew2">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,16 @@
[BLOCK table AS vlan]
<table border="0">
<tr>
<td>
<b>{lang_vlan}:</b><br>
</td>
</tr>
[BLOCK vlanrow]
<tr>
<td>
<a href="vlanview.php?vlan_id={vlan_id}">{vlan_name}&nbsp;({vlan_number})</a>
</td>
</tr>
[END vlanrow]
</table>
[END table]

@ -0,0 +1,31 @@
<form method="POST" action="submit.php">
<input type="hidden" name="add" value="vlan">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_vlan_add}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_vlan_name}:
</td>
<td>
<input type="text" name="vlan_name">
</td>
</tr>
<tr>
<td>
{lang_vlan_number}:
</td>
<td>
<input type="text" name="vlan_number" size="3">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,29 @@
<form method="POST" action="submit.php">
<input type="hidden" name="del" value="vlan">
<input type="hidden" name="vlan_id" value="{vlan_id}">
<table border="0">
<tr>
<td>
<b>{lang_vlan_del}</b><br>
</td>
</tr>
<tr>
<td>
<b>{lang_vlan_name}:</b>
</td>
<td>
<a href="vlanview.php?vlan_id={vlan_id}">{vlan_name}&nbsp;({vlan_number})</a>
</td>
</tr>
</table>
<p>
<table border="0">
<tr>
<td align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,40 @@
<form method="POST" action="submit.php">
<input type="hidden" name="edit" value="vlan">
<input type="hidden" name="vlan_id" value="{vlan_id}">
<table border="0">
<tr>
<td colspan="2">
<b>{lang_vlan_edit}:</b><br>
</td>
</tr>
<tr>
<td>
{lang_vlan_name}:
</td>
<td>
<input type="text" name="vlan_name" value="{vlan_name}">
</td>
</tr>
<tr>
<td>
{lang_vlan_number}:
</td>
<td>
<input type="text" name="vlan_number" size="3" value="{vlan_number}">
</td>
</tr>
<tr>
<td>
{lang_vlan_info}:
</td>
<td>
<textarea name="vlan_info">{vlan_info}</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="{lang_submit}"><input type="reset" value="{lang_reset}">
</td>
</tr>
</table>
</form>

@ -0,0 +1,64 @@
<table border="0">
<tr>
<td>
<b>{lang_vlan_name}:</b>
</td>
<td>
{vlan_name}
</td>
</tr>
<tr>
<td>
<b>{lang_vlan_number}:</b>
</td>
<td>
{vlan_number}
</td>
</tr>
<tr>
<td>
<b>{lang_vlan_info}:</b>
</td>
<td>
{vlan_info}
</td>
</tr>
<tr>
<td>
<b>{lang_subnets}:</b>
</td>
[BLOCK table AS subnet]
<td>
[BLOCK subnetrow]
<a href="subnetview.php?subnet_id={subnet_id}">{subnet_address}/{subnet_mask}</a><br>
[END subnetrow]
</td>
[END table]
</tr>
</table>
<p>
<table border="0">
[BLOCK assignvlantosubnet]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="assignvlantosubnet.php?vlan_id={vlan_id}">{lang_assignvlantosubnet}</a>
</td>
</tr>
[END assignvlantosubnet]
[BLOCK vlanedit]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="vlanedit.php?vlan_id={vlan_id}">{lang_vlan_edit}</a>
</td>
</tr>
[END vlanedit]
[BLOCK vlandel]
<tr>
<td>
<img src="images/arrow.gif" border="0">&nbsp;<a href="vlandel.php?vlan_id={vlan_id}">{lang_vlan_del}</a>
</td>
</tr>
[END vlandel]
</table>

@ -1,70 +1,17 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/useradd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
// check for unique username
$result = mysql_query("SELECT user_name FROM user WHERE user_name='$user_name'") or die(mysql_error());
if(mysql_num_rows($result) == 0) {
$user_name = $_POST['user_name'];
$user_pass = md5($config_user_pass);
$user_level = $_POST['user_level'];
$displayname = $_POST['user_name'];
mysql_query("INSERT INTO user (user_name, user_pass, user_level, displayname) VALUE ('$user_name', '$user_pass', '$user_level', '$displayname')") or die(mysql_error());
header_location("options.php");
}
echo '<b>Error!</b>';
}
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="useradd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add user:</b><br>
</td>
</tr>
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="user_name">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<?php echo $config_user_pass; ?>
</td>
</tr>
<tr>
<td>
Level:
</td>
<td>
<select name="user_level">
<option value="1">View all</option>
<option value="2">Edit all</option>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
$tp->set("user_pass", $config_user_pass);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -4,44 +4,20 @@
// get user_id
$suser_id = $_SESSION['suser_id'];
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$displayname = $_POST['displayname'];
mysql_query("UPDATE user SET displayname='$displayname' WHERE user_id='$suser_id'") or die(mysql_error());
header_location("options.php");
}
// set template
$tp = new Template("tpl/useredit.tpl");
// get current information
$result = mysql_query("SELECT displayname FROM user WHERE user_id='$suser_id'");
while ($row = mysql_fetch_object($result)) {
$displayname = $row->displayname;
}
?>
<form method="POST" action="useredit.php">
<table border="0">
<tr>
<td colspan="2">
<b>Modify settings:</b><br>
</td>
</tr>
<tr>
<td>
Displayname:
</td>
<td>
<input type="text" name="displayname" value="<?php echo $displayname; ?>">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
// set language variables
$tp->setvars($lang);
<?
// get user information
$tp->set("user_displayname", $_SESSION['suser_displayname']);
$tp->set("user_mac", $_SESSION['suser_mac']);
$tp->set("user_lang", $_SESSION['suser_lang']);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,75 +1,15 @@
<?php
include("header.php");
// get user_id
$suser_id = $_SESSION['suser_id'];
// set template
$tp = new Template("tpl/userpassedit.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
if (trim($_POST['user_passold']) <> "" && trim($_POST['user_passnew1']) && trim($_POST['user_passnew2']) && trim($_POST['user_passnew1']) == trim($_POST['user_passnew2'])) {
$user_passold = $_POST['user_passold'];
$user_passnew = md5($_POST['user_passnew1']);
$result = mysql_query("SELECT user_pass FROM user WHERE user_id='$suser_id'") or die(mysql_error());
// check current pass
if(!strcmp(md5($user_passold), mysql_result($result, 0, "user_pass"))) {
// ok, update pass
mysql_query("UPDATE user SET user_pass='$user_passnew' WHERE user_id='$suser_id'") or die(mysql_error());
header_location("options.php");
}
}
// not ok
echo '<b>Error!</b>';
}
// set language variables
$tp->setvars($lang);
// output
$tp->parse();
$tp->spit();
// get current information
$result = mysql_query("SELECT displayname FROM user WHERE user_id='$suser_id'");
while ($row = mysql_fetch_object($result)) {
$displayname = $row->displayname;
}
?>
<form method="POST" action="userpassedit.php">
<table border="0">
<tr>
<td colspan="2">
<b>Modify settings:</b><br>
</td>
</tr>
<tr>
<td>
Current password:
</td>
<td>
<input type="password" name="user_passold">
</td>
</tr>
<tr>
<td>
New password:
</td>
<td>
<input type="password" name="user_passnew1">
</td>
</tr>
<tr>
<td>
Retype new password:
</td>
<td>
<input type="password" name="user_passnew2">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?
include("footer.php");
?>

@ -1,23 +1,25 @@
<?php
include("header.php");
?>
<table border="0">
<tr>
<td>
<b>VLAN:</b><br>
</td>
</tr>
<?php
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number");
while ($row = mysql_fetch_object($result)) {
echo '<tr><td><a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . ' ('. $row->vlan_number . ')</a></td></tr>';
}
?>
</table>
<?php
// set template
$tp = new Template("tpl/vlan.tpl");
// set language variables
$tp->setvars($lang);
// get vlan info
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan ORDER BY vlan_number") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("vlan_id", $row->vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->set("vlan_number", $row->vlan_number);
$tp->parse("vlanrow");
}
if (($i>0) ? $tp->parse("vlan") : $tp->hide("vlan"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,53 +1,15 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/vlanadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$vlan_name = $_POST['vlan_name'];
$vlan_number= $_POST['vlan_number'];
mysql_query("INSERT INTO vlan (vlan_name, vlan_number) VALUE ('$vlan_name', '$vlan_number')") or die(mysql_error());
// set language variables
$tp->setvars($lang);
header("Location: vlan.php");
}
?>
<form method="POST" action="vlanadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new VLAN:</b><br>
</td>
</tr>
<tr>
<td>
VLAN name:
</td>
<td>
<input type="text" name="vlan_name">
</td>
</tr>
<tr>
<td>
VLAN ID:
</td>
<td>
<input type="text" name="vlan_number" size="3">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,25 @@
<?php
include("header.php");
// get id
$vlan_id = $_GET['vlan_id'];
// set template
$tp = new Template("tpl/vlandel.tpl");
// set language variables
$tp->setvars($lang);
// get vlanclass info
$result = mysql_query("SELECT vlan_id, vlan_name, vlan_number FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error());
$row=mysql_fetch_object($result);
$tp->set("vlan_id", $row->vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->set("vlan_number", $row->vlan_number);
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -1,72 +1,26 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// get id
$vlan_id = $_GET['vlan_id'];
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$vlan_id = $_POST['vlan_id'];
$vlan_name = $_POST['vlan_name'];
$vlan_number = $_POST['vlan_number'];
$vlan_info = $_POST['vlan_info'];
mysql_query("UPDATE vlan SET vlan_name='$vlan_name', vlan_number='$vlan_number', vlan_info='$vlan_info' WHERE vlan_id='$vlan_id'") or die(mysql_error());
header_location("vlanview.php?vlan_id=" . $vlan_id);
}
// set template
$tp = new Template("tpl/vlanedit.tpl");
// get current information
$result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'");
while ($row = mysql_fetch_object($result)) {
$vlan_name = $row->vlan_name;
$vlan_number = $row->vlan_number;
$vlan_info = $row->vlan_info;
}
?>
// set language variables
$tp->setvars($lang);
// get vlan information
$result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$tp->set("vlan_id", $vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->set("vlan_number", $row->vlan_number);
$tp->set("vlan_info", $row->vlan_info);
<form method="POST" action="vlanedit.php">
<input type="hidden" name="vlan_id" value="<?php echo $vlan_id; ?>">
<table border="0">
<tr>
<td colspan="2">
<b>Edit VLAN:</b><br>
</td>
</tr>
<tr>
<td>
VLAN name:
</td>
<td>
<input type="text" name="vlan_name" value="<?php echo $vlan_name; ?>">
</td>
</tr>
<tr>
<td>
VLAN ID:
</td>
<td>
<input type="text" name="vlan_number" size="3" value="<?php echo $vlan_number; ?>">
</td>
</tr>
<tr>
<td>
VLAN info:
</td>
<td>
<textarea name="vlan_info"><?php echo $vlan_info; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -4,80 +4,53 @@
// get id
$vlan_id = $_GET['vlan_id'];
// get vlan info
$result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'");
while ($row = mysql_fetch_object($result)) {
$vlan_name = $row->vlan_name;
$vlan_number = $row->vlan_number;
$vlan_info = $row->vlan_info;
}
?>
<table border="0">
<tr>
<td>
<b>VLAN name:</b>
</td>
<td>
<?php echo $vlan_name; ?>
</td>
</tr>
<tr>
<td>
<b>VLAN ID:</b>
</td>
<td>
<?php echo $vlan_number; ?>
</td>
</tr>
<tr>
<td>
<b>VLAN info:</b>
</td>
<td>
<?php echo nl2br($vlan_info); ?>
</td>
</tr>
<tr>
<td>
<b>Subnet(s):</b>
</td>
<td>
<?php
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address FROM subnet WHERE vlan_id='$vlan_id' ORDER BY INET_ATON(subnet_address)");
while ($row = mysql_fetch_object($result)) {
echo '<a href="subnetview.php?subnet_id=' . $row->subnet_id . '">' . $row->subnet_address . '</a><br>';
}
?>
</td>
</tr>
</table>
// set template
$tp = new Template("tpl/vlanview.tpl");
<?php
// display only if admin
if($_SESSION['suser_level'] >= 2) {
?>
<p>
// set language variables
$tp->setvars($lang);
<table border="0">
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="vlanedit.php?vlan_id=<?php echo $vlan_id; ?>">Modify</a>
</td>
</tr>
<tr>
<td>
<img src="images/arrow.gif" border="0"><a href="assignvlantosubnet.php?vlan_id=<?php echo $vlan_id; ?>">Assign subnet</a>
</td>
</tr>
</table>
// get vlan info
$result = mysql_query("SELECT vlan_name, vlan_number, vlan_info FROM vlan WHERE vlan_id='$vlan_id'") or die(mysql_error());
$row = mysql_fetch_object($result);
$tp->set("vlan_id", $vlan_id);
$tp->set("vlan_name", $row->vlan_name);
$tp->set("vlan_number", $row->vlan_number);
$tp->set("vlan_info", $row->vlan_info);
<?php
// end display only if admin
// get subnet info
$result = mysql_query("SELECT subnet_id, subnet_address, subnet_mask FROM subnet WHERE vlan_id='$vlan_id' ORDER BY INET_ATON(subnet_address)") or die(mysql_error());
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("subnet_id", $row->subnet_id);
$tp->set("subnet_address", $row->subnet_address);
$tp->set("subnet_mask", $row->subnet_mask);
$tp->parse("subnetrow");
}
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
// display options
if($_SESSION['suser_level'] >= $config_userlevel_assignvlantosubnet) {
$tp->set("vlan_id", $vlan_id);
$tp->parse("assignvlantosubnet");
} else {
$tp->hide("assignvlantosubnet");
}
if($_SESSION['suser_level'] >= $config_userlevel_vlanedit) {
$tp->set("vlan_id", $vlan_id);
$tp->parse("vlanedit");
} else {
$tp->hide("vlanedit");
}
if($_SESSION['suser_level'] >= $config_userlevel_vlandel) {
$tp->set("vlan_id", $vlan_id);
$tp->parse("vlandel");
} else {
$tp->hide("vlandel");
}
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>

@ -0,0 +1,483 @@
<?php
/*****************************************************************************
$Id: yapter.php,v 1.24 2006/01/31 07:30:28 nvie Exp $
Yapter 2.14b2 - Yet Another PHP Template Engine ®
Copyright (C) 2001-2003 Vincent Driessen
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For more information, visit http://yapter.sf.net/ or contact us at
nvie@users.sourceforge.net
The full terms of the GNU Lesser General Public License that apply to Yapter
can be found at http://yapter.sf.net/LICENSE
*****************************************************************************/
// Define Yapter's warning levels
define('E_YAPTER_NONE', 0); // Be completely silent
define('E_YAPTER_NOTICE', 1); // Report notices
define('E_YAPTER_WARNING', 2); // Report warnings
define('E_YAPTER_ERROR', 4); // Report errors
define('E_YAPTER_DIE_ON_ERROR', 8); // Die on errors
define('E_YAPTER_ALL', 15); // Report errors, warnings and notices
// Define Yapter's ignore levels
define('E_YAPTER_IGN_UNKNOWN_VARS', 16); // Ignore unknown variables
define('E_YAPTER_AUTO_HIDE_BLOCK', 32); // Automaticly hide unparsed blocks
class Template {
var $_ROOT = '__DOCUMENT_ROOT';
var $parseUnknownVars = false; // Defines whether unknown variables should be removed or left alone
var $blox = array(); // $blox[blockname]['content'] holds the template's content
// $blox[blockname]['numlines'] holds the number of lines in the block
// $blox[blockname]['parsed'] holds an array with the parsed data
// $blox[$_ROOT] always holds the main template
var $blockDefs = array(); // Keeps track of all block-definitions from which multiple blocks...
// ...can be created instances of
var $vars = array(); // This array contains all variables. All are accessible from all blocks.
var $warningLevel; // The level of verbosity Yapter complies with (see the E_* defines above)
var $startTime; // Holds the start time of the script, so that it can compare it to the...
// ...end time to calculate the execution time. (For debugging purposes only.)
var $missing_list; // List of variable names that are declared but never set.
/////////////////////////////////////////////////////////////////////
function error($msg)
{
if ($this->warningLevel & E_YAPTER_ERROR)
if ($this->warningLevel & E_YAPTER_DIE_ON_ERROR )
// if DIE_ON_ERROR is set, then do die on error!
die("<br />\n<b>Yapter error</b>: ".$msg."<br />\n"); // Die here!
else
// else just barf out the message
echo "<br />\n<b>Yapter error</b>: ".$msg."<br />\n";
}
function warning($msg)
{
if ($this->warningLevel & E_YAPTER_WARNING)
echo "<br />\n<b>Yapter warning</b>: ".$msg."<br />\n";
}
function notice($msg)
{
if ($this->warningLevel & E_YAPTER_NOTICE)
echo "<br />\n<b>Yapter notice</b>: ".$msg."<br />\n";
}
function warn_var_not_set($varname)
{
if (!in_array($varname, $this->missing_list) && !($this->warningLevel & E_YAPTER_IGN_UNKNOWN_VARS)) {
$this->missing_list[] = $varname; // Add it to the list...
// ...and print a warning once.
$this->warning('Variable <b>'.htmlspecialchars($varname).'</b> found, but never assigned a value. (This message is shown only once for each variable.)');
}
}
/////////////////////////////////////////////////////////////////////
function Template($file, $level = E_YAPTER_ALL)
{
if (is_bool($level)) {
//
// Rationale:
// =========
// Older Yapter versions had the possibility of turning
// on the so called "debug mode" with a bool parameter
// as the second argument to this constructor.
// However, since debug mode was dropped and the
// warning level support was built in, it was a logical
// step of replacing the second parameter.
//
// However, to prevent people from making mistakes,
// we'll check if the user passed a boolean parameter.
// If so, he or she is probably using debug mode, and
// we'll issue a notice in these cases.
//
// Thanks to Ivo Koster.
//
$this->notice('Debug mode is not supported anymore since Yapter version 2.12.');
$this->warningLevel = E_YAPTER_ALL;
}
else
$this->warningLevel = (int)$level;
$this->startTime = $this->getmicrotime();
$this->addBlockFromFile($this->_ROOT, $file);
$this->missing_list = array();
}
/* setParseMode(): specifies to parse unknown variables or not */
function setParseMode($parseUnknownVars)
{
$this->parseUnknownVars = (bool)$parseUnknownVars;
}
/* setWarningLevel(): sets the level of verbosity which Yapter should obey */
function setWarningLevel($level)
{
$this->warningLevel = $level;
}
/* addBlock(): adds a new block to the blox-array */
function addBlock($blockname, $content)
{
$this->blox[$blockname]['content'] = $content;
$this->blox[$blockname]['numlines'] = sizeof($this->blox[$blockname]['content']);
$this->blox[$blockname]['parsed'] = '';
$this->prepare($blockname);
}
/* addBlockFromFile(): adds a new block, filling it with the specified's file contents */
function addBlockFromFile($blockname, $file)
{
$content = @file($file) or $this->error('Cannot open template file <b>'.htmlspecialchars($file).'</b>!');
//--- eliminate double block def mod -klp
// if ($blockname != $this->_ROOT)
// $this->addBlockDef($blockname, $content);
$this->addBlock($blockname, $content);
}
/* addBlockDef(): adds a block definition to the block-definition array from which other blocks can be copied */
function addBlockDef($blockdef, $content)
{
/* if (isset($this->blockDefs[$blockdef]))
$this->error('Block "'.htmlspecialchars($blockdef).'" allready exists. I cannot create it twice.');
else
$this->blockDefs[$blockdef] = $content;
*/
$this->blockDefs[$blockdef] = $content;
}
/* addBlockFromDef(): copies a block from the block definition array */
function addBlockFromDef($blockname, $blockdef)
{
$this->addBlock($blockname, $this->blockDefs[$blockdef]);
}
/* prepare(): handles subprocessing of templates found in the main template file */
function prepare($blockname)
{
$currblockcontents = array();
$block = &$this->blox[$blockname];
for ($i = 0; $i < $block['numlines']; $i++) {
if (isset($block['content'][$i]))
$line = $block['content'][$i];
else
continue;
// Try to find a tag-definition on this line
if (preg_match('/\[(INCLUDE|BLOCK|END|REUSE|SET) ([A-Za-z0-9_.\/-]+)( AS ([A-Za-z0-9_-]+))?]/', $line, $matches)) {
$type = $matches[1];
$name = (!empty($matches[4])) ? $matches[4] : $matches[2];
if ($type == 'END' && !isset($currblockdef))
$this->error('"[END '.$name.']" found without matching "[BLOCK '.$name.']" or "[SET '.$name.']"');
if ($type == 'END' && $matches[2] == $currblockdef) {
if (isset($matches[4]))
$this->error('Given "AS"-parameter not allowed in END-tags!');
// End the current block definition: add the block to the blox-array
//--- if wrapper mod -klp
if (isset($currblockdef) && isset($currblockcontents) && isset($currblockname)) {
$this->addBlockDef($currblockdef, $currblockcontents);
$this->addBlockFromDef($currblockname, $currblockdef);
}
// Now, try to remove the block from the template definition, replacing it with a var
for ($j = $i; $j >= $currblockstart; $j--) {
if ($j == $currblockstart && $currblocktype == 'BLOCK')
$block['content'][$j] = "{" . $currblockname . "}";
else
unset($block['content'][$j]);
}
// unset these thingies for further preparing
unset($currblocktype);
unset($currblockstart);
unset($currblockname);
unset($currblockdef);
$currblockcontents = array();
} elseif (($type == 'SET' || $type == 'BLOCK') && !isset($currblockname)) {
if ($type == 'BLOCK') {
// Start block definition
$currblocktype = $type;
$currblockstart = $i;
$currblockname = $name;
$currblockdef = $matches[2];
} else { // SET-tag
// Start block definition
if (isset($matches[4]))
$this->error('Given "AS"-parameter not allowed in SET-tags!');
$currblocktype = $type;
$currblockstart = $i;
$currblockname = $matches[2];
$currblockdef = $matches[2];
}
} elseif ($type == 'INCLUDE' && !isset($currblockname)) {
// Make this line a variable...
$block['content'][$i] = "{" . $name . "}\n";
// ...and include the given file...
$this->addBlockFromFile($name, $matches[2]);
} elseif ($type == 'REUSE' && !isset($currblockname)) {
if (!isset($matches[4]))
$this->error('Missing "AS"-parameter in [REUSE <b>$name</b>] tag!');
// Make this line a variable...
$block['content'][$i] = "{" . $matches[4] . "}\n";
// ...and get this REUSE value from the block definition list...
$this->addBlockFromDef($matches[4], $matches[2]);
} elseif ($currblockname != $name) {
if ($currblockname)
$currblockcontents[] = $line;
}
} else {
// No tag-definition... just normal text so do nothing here
if (!empty($currblockname))
$currblockcontents[] = $line;
}
}
}
/* parse(): parses the specified block, filling variables and nested blockdefs */
function parse($blockname = '')
{
if (!$blockname)
$blockname = $this->_ROOT;
if (!isset($this->blox[$blockname]))
$this->error('Block "'.htmlspecialchars($blockname).'" does not exist.');
$block = &$this->blox[$blockname];
$parsed = $block['content'];
// Loop through all the lines of the template and parse variables one-by-one
for ($i = 0; $i < $block['numlines']; $i++) {
if (!isset($parsed[$i]))
continue;
$line = $parsed[$i];
// Look for variables in this line, processing it character-by-character
unset($start);
unset($buffer);
for ($j = 0; $j < strlen($line); $j++) {
$char = $line[$j];
if (!isset($start) && $char == '{')
$start = $j;
elseif (isset($start) && $char == '}') {
// The sequence {} is not a valid variable value
if (!isset($buffer)) {
unset($start);
continue;
} else {
// Gotcha! Now replace this variable with its contents
// First, check to see if it's a variable or a block that has to be parsed
if (isset($this->vars[$buffer]))
$value = $this->vars[$buffer];
elseif (isset($this->blox[$buffer])) {
if ($this->blox[$buffer]['parsed']) {
// The value must be filled with the parsed data from the $buffer block
$value = @implode('', $this->blox[$buffer]['parsed']);
} elseif ($this->warningLevel & E_YAPTER_AUTO_HIDE_BLOCK) {
// Automaticly hide unparsed bloks
$value = "";
} else {
// Make the recursive call now
$value = @implode('', $this->parse($buffer));
}
} else {
// No variable or block name found by the name of $buffer
// First, issue a warning!
$this->warn_var_not_set($buffer);
if ($this->parseUnknownVars) {
// Unable to find variable, replace this one with an empty
// string silently.
$value = '';
} else {
// Unable to find variable, leave this one alone...
unset($start);
unset($buffer);
continue;
}
}
$part1 = substr($line, 0, $start);
$part2 = substr($line, $start + strlen($buffer) + 2);
$line = $part1 . $value . $part2;
$j += strlen($value) - (strlen($buffer) + 2);
unset($start);
unset($buffer);
}
} elseif (isset($start)) {
// Check to see $char is a proper character (range: [A-Za-z0-9_./-])
// In Yapter 2.13b2, I've added the '/' char as well, to support inclusion
// from Unix paths, like '../../foo.tpl'
if (($char >= 'a' && $char <= 'z') || ($char >= '0' && $char <= '9') || ($char >= 'A' && $char <= 'Z') || ($char == '_') || ($char == '.') || ($char == '-') || ($char == '/')) {
if (!empty($buffer))
$buffer .= $char;
else
$buffer = $char;
} else {
unset($start);
unset($buffer);
}
}
}
$parsed[$i] = $line;
}
if (is_array($this->blox[$blockname]['parsed'])) {
$this->blox[$blockname]['parsed'] = array_merge($this->blox[$blockname]['parsed'], $parsed);
} else {
//--- array cast mod -klp
$this->blox[$blockname]['parsed'] = (array) $parsed;
}
return $this->blox[$blockname]['parsed'];
}
/* set(): assigns a value to a variabele inside curly brackets ('{' and '}') */
function set($varname, $value)
{
if (isset($value))
$this->vars[$varname] = $value;
else
$this->warning('Trying to set <b>'.htmlspecialchars($varname).'</b> to NULL. Variable not set.');
}
/* setVars(): assigns values to variables for each element in the given array
Contributed by: Raniz
*/
function setVars($variables)
{
if (!is_array($variables))
$this->error('Value passed to setVars is not an array.');
foreach($variables as $varname => $value)
$this->vars[$varname] = $value;
}
/* setFile(): assigns the contents of a file to a variabele inside curly brackets ('{' and '}') */
function setFile($varname, $filename)
{
if (!file_exists($filename))
$this->error('Cannot open file "'.htmlspecialchars($filename).'" for inclusion in "'.htmlspecialchars($varname).'".');
$value = implode('', file($filename));
$this->set($varname, $value);
}
/* getVar(): returns the value of the 'varname' variable */
function getVar($varname)
{
if ($this->vars[$varname])
return $this->vars[$varname];
else
return false;
}
/* getBlock(): returns the content of the 'blockname' block */
function getBlockContent($blockname)
{
if ($this->$blox[$blockname]['content'])
return @implode('', $this->$blox[$blockname]['content']);
else
return false;
}
/* replace(): replaces the content of one block by another */
function replace($block, $byblock)
{
if (!isset($this->blox[$block]))
$this->error('Block "'.htmlspecialchars($block).'" does not exist.');
if (!isset($this->blox[$byblock]))
$this->error('Block "'.htmlspecialchars($block).'" does not exist.');
$this->blox[$block]['content'] = $this->blox[$byblock]['content'];
$this->blox[$block]['numlines'] = $this->blox[$byblock]['numlines'];
}
/* hide(): hides all the contents of the given block */
function hide($block)
{
if (!isset($this->blox[$block]))
$this->error('Block "'.htmlspecialchars($block).'" does not exist.');
$this->blox[$block]['content'] = array();
$this->blox[$block]['numlines'] = 0;
}
/* clear(): resets the parsed data to an empty string again and defines the block as 'unparsed' */
function clear($blockname)
{
if (!isset($this->blox[$blockname]))
$this->error('Block "'.htmlspecialchars($blockname).'" does not exist.');
$this->blox[$blockname]['parsed'] = '';
unset($this->vars[$blockname]); // often, a variabele is set whenever a block should be discarded...
// ...now reset such a variable to make sure the block is not overriden
}
/* getContents(): gets the final contents to be outputted on the screen */
function getContents($blockname = '')
{
if ($blockname == '') $blockname = $this->_ROOT;
$parsed = $this->blox[$blockname]['parsed'];
if ($parsed)
return implode('', $parsed);
else
return false;
}
/* spit(): ouputs contents to screen */
function spit()
{
echo $this->getContents();
}
function getmicrotime()
{
/* I got this getmicrotime()-function from the PHP.net website, but it seems to be
buggy, while it sometimes displays a negative execution time when you substract
the current time with the starting time of the script... I only noticed it at
my Windows localhost machine, not on *nix servers. Is anybody familiar with this
behaviour? Any information about this is welcome at nvie@users.sourceforge.net
for your co-operation. */
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function execTime()
{
return round($this->getmicrotime() - $this->startTime, 5);
}
function executionTime()
{
echo "<p>\n\nThe execution time is <b>".$this->execTime()."</b> seconds.<br>\n";
}
}
?>