1
0

edit_l3int.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
  5. $device=get_record($db_link,'devices',"id=".$id);
  6. $user_info = get_record_sql($db_link,"SELECT * FROM User_list WHERE id=".$device['user_id']);
  7. if (isset($_POST["s_remove"])) {
  8. $s_id = $_POST["s_id"];
  9. foreach ($s_id as $key => $val) {
  10. if (isset($val)) {
  11. LOG_INFO($db_link, "Remove l3_interface id: $val");
  12. delete_record($db_link, "device_l3_interfaces", "id=" . $val);
  13. }
  14. }
  15. header("Location: " . $_SERVER["REQUEST_URI"]);
  16. exit;
  17. }
  18. if (isset($_POST['s_save'])) {
  19. $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0;
  20. for ($i = 0; $i < $len; $i ++) {
  21. $save_id = intval($_POST['s_save'][$i]);
  22. $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
  23. for ($j = 0; $j < $len_all; $j ++) {
  24. if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
  25. $new['name'] = trim($_POST['s_name'][$j]);
  26. $new['interface_type'] = $_POST['s_type'][$j]*1;
  27. update_record($db_link, "device_l3_interfaces", "id='{$save_id}'", $new);
  28. }
  29. }
  30. header("Location: " . $_SERVER["REQUEST_URI"]);
  31. exit;
  32. }
  33. if (isset($_POST["s_create"])) {
  34. if (!empty($_POST["s_create_name"])) {
  35. $new['name'] = trim($_POST["s_create_name"]);
  36. $new['device_id'] = $id;
  37. $new['interface_type'] = 0;
  38. LOG_INFO($db_link, "Create new l3_interface ".$new['name']." as local");
  39. insert_record($db_link, "device_l3_interfaces", $new);
  40. }
  41. header("Location: " . $_SERVER["REQUEST_URI"]);
  42. exit;
  43. }
  44. unset($_POST);
  45. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  46. print_device_submenu($page_url);
  47. print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login']);
  48. ?>
  49. <div id="contsubmenu">
  50. <br>
  51. <?php print "<form name=def action='edit_l3int.php?id=".$id."' method=post>"; ?>
  52. <?php print WEB_list_l3_interfaces."<b>"; print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
  53. </b> <br>
  54. <table class="data">
  55. <tr align="center">
  56. <td></td>
  57. <td width=30><b>id</b></td>
  58. <td><b><?php echo WEB_cell_name; ?></b></td>
  59. <td><b><?php echo WEB_cell_type; ?></b></td>
  60. <td>
  61. <input type="submit" onclick="return confirm('<?php print WEB_msg_delete; ?>?')" name="s_remove" value="<?php print WEB_btn_remove; ?>">
  62. </td>
  63. </tr>
  64. <?php
  65. $t_l3_interface = get_records($db_link,'device_l3_interfaces',"device_id=$id ORDER BY name");
  66. foreach ( $t_l3_interface as $row ) {
  67. print "<tr align=center>\n";
  68. print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
  69. print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  70. print "<td class=\"data\"><input type=\"text\" name='s_name[]' value='{$row['name']}'></td>\n";
  71. print "<td class=\"data\">"; print_qa_l3int_select('s_type[]',$row['interface_type']); print "</td>\n";
  72. print "<td class=\"data\"><button name='s_save[]' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";
  73. print "</tr>\n";
  74. }
  75. ?>
  76. <tr>
  77. <td colspan=4><?php print WEB_l3_interface_add; print "&nbsp:<input type=\"text\" name='s_create_name' value=''";?>
  78. </td>
  79. <td>
  80. <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
  81. </td>
  82. </tr>
  83. </table>
  84. </form>
  85. <?php
  86. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  87. ?>