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");