editauth.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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. $msg_error = "";
  6. $old_auth_info = get_record_sql($db_link, "SELECT * FROM user_auth WHERE id = ?", [$id]);
  7. if (empty($old_auth_info)) {
  8. header("Location: /admin/");
  9. exit;
  10. }
  11. $parent_id = $old_auth_info['user_id'];
  12. $user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$parent_id]);
  13. $parent_ou_id = $user_info['ou_id'];
  14. $user_enabled = $user_info['enabled'];
  15. // === РЕДАКТИРОВАНИЕ ЗАПИСИ АВТОРИЗАЦИИ ==========================================
  16. if (getPOST("editauth") !== null && !$old_auth_info['deleted']) {
  17. $ip = normalizeIpAddress(substr(trim(getPOST("f_ip", null, '')), 0, 18));
  18. if (!empty($ip)) {
  19. $ip_aton = ip2long($ip);
  20. $mac = mac_dotted(getPOST("f_mac", null, ''));
  21. // Проверка MAC
  22. $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
  23. if (!empty($mac_exists) && ($mac_exists['count'] ?? 0) >= 1 && !in_array($parent_id, $mac_exists['users_id'] ?? [])) {
  24. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$mac_exists['users_id'][0] ?? 0]);
  25. $msg_error = "Mac already exists at another user in this subnet! Skip creating $ip [$mac].<br>Old user id: " . ($dup_info['id'] ?? '') . " login: " . ($dup_info['login'] ?? '');
  26. $_SESSION[$page_url]['msg'] = $msg_error;
  27. LOG_ERROR($db_link, $msg_error);
  28. header("Location: " . $_SERVER["REQUEST_URI"]);
  29. exit;
  30. }
  31. // DHCP для вторичного IP
  32. $f_dhcp = (int)getPOST("f_dhcp", null, 0);
  33. if (!empty($mac_exists) && in_array($parent_id, $mac_exists['users_id'] ?? [])) {
  34. if ($parent_id != ($mac_exists['users_id'][0] ?? null)) {
  35. $f_dhcp = 0;
  36. }
  37. }
  38. // Проверка дубликата IP
  39. $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE ip_int = ? AND id <> ? AND deleted = 0", [$ip_aton, $id]);
  40. if (!empty($dup_ip_record)) {
  41. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$dup_ip_record['user_id']]);
  42. $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
  43. $_SESSION[$page_url]['msg'] = $msg_error;
  44. LOG_ERROR($db_link, $msg_error);
  45. header("Location: " . $_SERVER["REQUEST_URI"]);
  46. exit;
  47. }
  48. $new = [
  49. 'ip' => $ip,
  50. 'ou_id' => $parent_ou_id,
  51. 'ip_int' => $ip_aton,
  52. 'mac' => $mac,
  53. 'description' => trim(getPOST("f_description", null, '')),
  54. 'wikiname' => trim(getPOST("f_wiki", null, ''))
  55. ];
  56. $f_dnsname = trim(getPOST("f_dns_name", null, ''));
  57. $f_dns_ptr_present = (getPOST("f_dns_ptr", null, null) !== null);
  58. if (empty($f_dnsname)) {
  59. $new['dns_ptr_only'] = 0;
  60. $new['dns_name'] = '';
  61. } else {
  62. $new['dns_ptr_only'] = $f_dns_ptr_present ? 1 : 0;
  63. }
  64. // Обновление IP в devices
  65. $device = get_record_sql($db_link, "SELECT * FROM devices WHERE ip_int = ?", [$old_auth_info['ip_int']]);
  66. if (!empty($device)) {
  67. update_record($db_link, "devices", "id = ?", [
  68. 'ip' => $ip,
  69. 'ip_int' => $ip_aton
  70. ], [$device['id']]);
  71. }
  72. // Обработка DNS-имени и алиасов
  73. $dns_alias_count = get_count_records($db_link, 'user_auth_alias', 'auth_id = ?', [$id]);
  74. if (!empty($f_dnsname) && !$new['dns_ptr_only']) {
  75. $domain_zone = ltrim(get_option($db_link, 33), '.');
  76. $escaped_zone = preg_quote($domain_zone, '/');
  77. $f_dnsname = preg_replace('/\.' . $escaped_zone . '$/i', '', $f_dnsname);
  78. $f_dnsname = preg_replace('/\s+/', '-', $f_dnsname);
  79. if ($dns_alias_count > 0 && $f_dnsname !== $old_auth_info['dns_name']) {
  80. $f_dnsname = $old_auth_info['dns_name'];
  81. } else {
  82. $valid_dns = checkValidHostname($f_dnsname);
  83. $uniq_dns = checkUniqHostname($db_link, $id, $f_dnsname);
  84. if ($valid_dns && $uniq_dns) {
  85. $new['dns_name'] = $f_dnsname;
  86. } else {
  87. $msg_error = !$uniq_dns
  88. ? "DNS $f_dnsname already exists at: " . searchHostname($db_link, $id, $f_dnsname) . " Discard changes!"
  89. : "DNS $f_dnsname not valid! Discard changes!";
  90. $_SESSION[$page_url]['msg'] = $msg_error;
  91. LOG_ERROR($db_link, $msg_error);
  92. header("Location: " . $_SERVER["REQUEST_URI"]);
  93. exit;
  94. }
  95. }
  96. }
  97. // Удаление алиасов при отключении DNS
  98. if (empty($f_dnsname) || $new['dns_ptr_only']) {
  99. $new['dns_name'] = '';
  100. $t_user_auth_alias = get_records($db_link, 'user_auth_alias', "auth_id = ? ORDER BY alias", [$id]);
  101. if (!empty($t_user_auth_alias)) {
  102. foreach ($t_user_auth_alias as $row) {
  103. LOG_INFO($db_link, "Remove alias id: " . $row['id'] . " for auth_id: $id :: " . dump_record($db_link, 'user_auth_alias', 'id = ?', [$row['id']]));
  104. delete_record($db_link, 'user_auth_alias', 'id = ?', [$row['id']]);
  105. }
  106. }
  107. }
  108. // PTR-only режим
  109. if ($old_auth_info['dns_ptr_only'] && !$new['dns_ptr_only']) {
  110. $new['dns_name'] = '';
  111. }
  112. if (!empty($f_dnsname) && $new['dns_ptr_only']) {
  113. $domain_zone = ltrim(get_option($db_link, 33), '.');
  114. $escaped_zone = preg_quote($domain_zone, '/');
  115. $f_dnsname = preg_replace('/\.' . $escaped_zone . '$/i', '', $f_dnsname);
  116. $f_dnsname = preg_replace('/\s+/', '-', $f_dnsname);
  117. $new['dns_name'] = $f_dnsname;
  118. }
  119. // Остальные поля
  120. $new['save_traf'] = (int)getPOST("f_save_traf", null, 0);
  121. $new['dhcp_acl'] = trim(getPOST("f_acl", null, ''));
  122. $new['dhcp_option_set'] = trim(getPOST("f_dhcp_option_set", null, ''));
  123. $new['dynamic'] = (int)(getPOST("f_dynamic", null, 0));
  124. if ($new['dynamic']) {
  125. $new['end_life'] = trim(getPOST("f_end_life", null, ''));
  126. }
  127. // Настройки по OU
  128. if (get_const('default_user_ou_id') == $parent_ou_id || get_const('default_hotspot_ou_id') == $parent_ou_id) {
  129. $new += [
  130. 'nagios_handler' => '',
  131. 'enabled' => 0,
  132. 'link_check' => 0,
  133. 'nagios' => 0,
  134. 'blocked' => 0,
  135. 'day_quota' => 0,
  136. 'month_quota' => 0,
  137. 'queue_id' => 0,
  138. 'filter_group_id' => 0
  139. ];
  140. } else {
  141. $new += [
  142. 'nagios_handler' => trim(getPOST("f_handler", null, '')),
  143. 'enabled' => (int)getPOST("f_enabled", null, 0),
  144. 'link_check' => (int)getPOST("f_link", null, 0),
  145. 'nagios' => (int)getPOST("f_nagios", null, 0),
  146. 'dhcp' => $f_dhcp,
  147. 'blocked' => (int)getPOST("f_blocked", null, 0),
  148. 'day_quota' => (int)getPOST("f_day_q", null, 0),
  149. 'month_quota' => (int)getPOST("f_month_q", null, 0),
  150. 'queue_id' => (int)getPOST("f_queue_id", null, 0),
  151. 'filter_group_id' => (int)getPOST("f_group_id", null, 0)
  152. ];
  153. }
  154. if ($new['nagios'] == 0) {
  155. $new['nagios_status'] = 'UP';
  156. }
  157. if (!$user_enabled) {
  158. $new['enabled'] = 0;
  159. }
  160. if (is_auth_bind_changed($db_link, $id, $ip, $mac)) {
  161. $new_id = copy_auth($db_link, $id, $new);
  162. if (!empty($new_id)) {
  163. header("Location: /admin/users/editauth.php?id=" . $new_id, true, 302);
  164. } else {
  165. header("Location: " . $_SERVER["REQUEST_URI"]);
  166. }
  167. exit;
  168. } else {
  169. update_record($db_link, "user_auth", "id = ?", $new, [$id]);
  170. }
  171. } else {
  172. $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx";
  173. $_SESSION[$page_url]['msg'] = $msg_error;
  174. }
  175. header("Location: " . $_SERVER["REQUEST_URI"]);
  176. exit;
  177. }
  178. // === ПЕРЕМЕЩЕНИЕ ЗАПИСИ =========================================================
  179. if (getPOST("moveauth") !== null && !$old_auth_info['deleted']) {
  180. $new_parent_id = (int)getPOST("f_new_parent", null, 0);
  181. $moved_auth = get_record_sql($db_link, "SELECT description FROM user_auth WHERE id = ?", [$id]);
  182. $changes = apply_auth_rule($db_link, $moved_auth, $new_parent_id);
  183. update_record($db_link, "user_auth", "id = ?", $changes, [$id]);
  184. // Удаляем старые правила
  185. delete_records($db_link, "auth_rules", "user_id = ? AND rule = ? AND rule_type = 2", [$old_auth_info["user_id"], $old_auth_info["mac"]]);
  186. delete_records($db_link, "auth_rules", "user_id = ? AND rule = ? AND rule_type = 1", [$old_auth_info["user_id"], $old_auth_info["ip"]]);
  187. header("Location: " . $_SERVER["REQUEST_URI"]);
  188. exit;
  189. }
  190. // === ВОССТАНОВЛЕНИЕ УДАЛЁННОЙ ЗАПИСИ ===========================================
  191. if (getPOST("recovery") !== null && $old_auth_info['deleted']) {
  192. $ip = trim(getPOST("f_ip", null, ''));
  193. if (checkValidIp($ip)) {
  194. $ip_aton = ip2long($ip);
  195. $mac = mac_dotted(getPOST("f_mac", null, ''));
  196. // Проверка MAC
  197. $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
  198. if (!empty($mac_exists) && ($mac_exists['count'] ?? 0) >= 1 && !in_array($parent_id, $mac_exists['users_id'] ?? [])) {
  199. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$mac_exists['users_id'][0] ?? 0]);
  200. $msg_error = "Mac already exists at another user in this subnet! Skip creating $ip [$mac].<br>Old user id: " . ($dup_info['id'] ?? '') . " login: " . ($dup_info['login'] ?? '');
  201. $_SESSION[$page_url]['msg'] = $msg_error;
  202. LOG_ERROR($db_link, $msg_error);
  203. header("Location: " . $_SERVER["REQUEST_URI"]);
  204. exit;
  205. }
  206. // DHCP для вторичного IP
  207. $f_dhcp = (int)getPOST("f_dhcp", null, 0);
  208. if (!empty($mac_exists) && in_array($parent_id, $mac_exists['users_id'] ?? [])) {
  209. if ($parent_id != ($mac_exists['users_id'][0] ?? null)) {
  210. $f_dhcp = 0;
  211. }
  212. }
  213. // Проверка дубликата IP
  214. $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE ip_int = ? AND id <> ? AND deleted = 0", [$ip_aton, $id]);
  215. if (!empty($dup_ip_record)) {
  216. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$dup_ip_record['user_id']]);
  217. $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
  218. $_SESSION[$page_url]['msg'] = $msg_error;
  219. LOG_ERROR($db_link, $msg_error);
  220. header("Location: " . $_SERVER["REQUEST_URI"]);
  221. exit;
  222. }
  223. $new = ['deleted' => 0, 'dynamic' => 0, 'dns_name' => ''];
  224. $old_parent = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$parent_id]);
  225. if (empty($old_parent)) {
  226. $new_user_info = get_new_user_id($db_link, $ip, $mac, null);
  227. $new_user_id = $new_user_info['user_id'] ?? null;
  228. if (empty($new_user_id)) {
  229. $new_user_id = new_user($db_link, $new_user_info);
  230. }
  231. $new['user_id'] = $new_user_id;
  232. }
  233. $new['description'] = $old_parent['description'] ?? '';
  234. // Настройки по OU
  235. if (get_const('default_user_ou_id') == $parent_ou_id || get_const('default_hotspot_ou_id') == $parent_ou_id) {
  236. $new += [
  237. 'nagios_handler' => '',
  238. 'enabled' => 0,
  239. 'link_check' => 0,
  240. 'nagios' => 0,
  241. 'blocked' => 0,
  242. 'day_quota' => 0,
  243. 'month_quota' => 0,
  244. 'queue_id' => 0,
  245. 'filter_group_id' => 0
  246. ];
  247. } else {
  248. $new += [
  249. 'nagios_handler' => trim(getPOST("f_handler", null, '')),
  250. 'enabled' => (int)getPOST("f_enabled", null, 0),
  251. 'link_check' => (int)getPOST("f_link", null, 0),
  252. 'nagios' => (int)getPOST("f_nagios", null, 0),
  253. 'dhcp' => (int)getPOST("f_dhcp", null, 0),
  254. 'blocked' => (int)getPOST("f_blocked", null, 0),
  255. 'day_quota' => (int)getPOST("f_day_q", null, 0),
  256. 'month_quota' => (int)getPOST("f_month_q", null, 0),
  257. 'queue_id' => (int)getPOST("f_queue_id", null, 0),
  258. 'filter_group_id' => (int)getPOST("f_group_id", null, 0)
  259. ];
  260. }
  261. $new = apply_auth_rule($db_link, $new, $new['user_id']);
  262. update_record($db_link, "user_auth", "id = ?", $new, [$id]);
  263. } else {
  264. $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx/xx";
  265. $_SESSION[$page_url]['msg'] = $msg_error;
  266. }
  267. header("Location: " . $_SERVER["REQUEST_URI"]);
  268. exit;
  269. }
  270. unset($_POST);
  271. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  272. $sSQL = "SELECT * FROM user_auth WHERE id=?";
  273. $auth_info = get_record_sql($db_link, $sSQL, [ $id ]);
  274. $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=?", [ $auth_info['user_id'] ]);
  275. $parent_name = get_login($db_link, $auth_info['user_id']);
  276. if (empty($parent_name)) { $parent_name=$auth_info['user_id']; }
  277. if (is_empty_datetime($auth_info['dhcp_time'])) {
  278. $dhcp_str = '';
  279. } else {
  280. $dhcp_str = $auth_info['dhcp_time'] . " (" . $auth_info['dhcp_action'] . ")";
  281. }
  282. if (is_empty_datetime($auth_info['last_found'])) { $auth_info['last_found'] = ''; }
  283. if (is_empty_datetime($auth_info['mac_found'])) { $auth_info['mac_found'] = ''; }
  284. if (is_empty_datetime($auth_info['arp_found'])) { $auth_info['arp_found'] = ''; }
  285. $now = DateTime::createFromFormat("Y-m-d H:i:s",date('Y-m-d H:i:s'));
  286. $created = new DateTime($auth_info['ts']);
  287. if (empty($auth_info['end_life']) || is_empty_datetime($auth_info['end_life'])) {
  288. $now->modify('+1 day');
  289. $auth_info['end_life'] = $now->format('Y-m-d H:i:s');
  290. }
  291. ?>
  292. <div id="cont">
  293. <?php
  294. if (!empty($_SESSION[$page_url]['msg'])) {
  295. print '<div id="msg">' . $_SESSION[$page_url]['msg'] . '</div>';
  296. unset($_SESSION[$page_url]['msg']);
  297. }
  298. print "<b>" . WEB_user_title . "&nbsp<a href=/admin/users/edituser.php?id=" . $auth_info['user_id'] . ">" . $parent_name . "</a> </b>";
  299. $alias_link = '';
  300. if (!empty($auth_info['dns_name']) and !$auth_info['dns_ptr_only']) { $alias_link="/admin/users/edit_alias.php?id=".$id; }
  301. if (empty($auth_info['created_by'])) { $auth_info['created_by'] = '-'; }
  302. $f_dns_ptr = '';
  303. if ($auth_info['dns_ptr_only']) { $f_dns_ptr = 'checked'; }
  304. ?>
  305. <form name="def" action="editauth.php?id=<?php echo $id; ?>" method="post">
  306. <input type="hidden" name="id" value=<?php echo $id; ?>>
  307. <table class="data">
  308. <tr>
  309. <td width=230><?php print WEB_cell_dns_name . " &nbsp | &nbsp "; print_url(WEB_cell_aliases, $alias_link); ?></td>
  310. <td width=200><?php print WEB_cell_description; ?></td>
  311. <td width=70><?php print WEB_cell_enabled; ?></td>
  312. <td><?php print WEB_cell_traf; ?></td>
  313. <td></td>
  314. </tr>
  315. <tr>
  316. <td style="white-space: nowrap;"><input type="text" name="f_dns_name" size="14" value="<?php echo $auth_info['dns_name']; ?>" pattern="^([a-zA-Z0-9-]{1,63})(\.[a-zA-Z0-9-]{1,63})*\.?$">
  317. <input type="checkbox" id="f_dns_ptr" name="f_dns_ptr" value="1" <?php echo $f_dns_ptr; ?>> &nbsp <?php print WEB_cell_ptr_only; ?>
  318. </td>
  319. <td><input type="text" name="f_description" value="<?php echo $auth_info['description']; ?>"></td>
  320. <td><?php print_qa_select('f_enabled', $auth_info['enabled']); ?></td>
  321. <td><?php print_qa_select('f_save_traf', $auth_info['save_traf']); ?></td>
  322. <td></td>
  323. </tr>
  324. <tr>
  325. <td><?php print WEB_cell_ip; ?></td>
  326. <td><?php print WEB_cell_mac; ?></td>
  327. <td><?php print WEB_cell_dhcp; ?></td>
  328. <td><?php print WEB_cell_acl; ?></td>
  329. <td><?php print WEB_cell_option_set; ?></td>
  330. <td></td>
  331. <tr>
  332. <td><input type="text" name="f_ip" value="<?php echo $auth_info['ip']; ?>" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[\.ю]){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"></td>
  333. <td><input type="text" name="f_mac" value="<?php echo $auth_info['mac']; ?>" pattern="^(([0-9A-Fa-f]{2}[\.\:\-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\.\-][0-9a-fA-F]{4}[\.\-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12})$"></td>
  334. <td><?php print_qa_select('f_dhcp', $auth_info['dhcp']); ?></td>
  335. <td><?php print_dhcp_acl_list($db_link,"f_acl",$auth_info['dhcp_acl']); ?></td>
  336. <td><?php print_dhcp_option_set_list($db_link,"f_dhcp_option_set",$auth_info['dhcp_option_set']); ?></td>
  337. </tr>
  338. <tr>
  339. <td><?php print WEB_cell_filter; ?></td>
  340. <td><?php print WEB_cell_shaper; ?></td>
  341. <td><?php print WEB_cell_blocked; ?></td>
  342. <td><?php print WEB_cell_perday; ?></td>
  343. <td><?php print WEB_cell_permonth; ?></td>
  344. </tr>
  345. <tr>
  346. <td><?php print_filter_group_select($db_link, 'f_group_id', $auth_info['filter_group_id']); ?> </td>
  347. <td><?php print_queue_select($db_link, 'f_queue_id', $auth_info['queue_id']); ?> </td>
  348. <td><?php print_qa_select('f_blocked', $auth_info['blocked']); ?></td>
  349. <td><input type="text" name="f_day_q" value="<?php echo $auth_info['day_quota']; ?>" size=5></td>
  350. <td><input type="text" name="f_month_q" value="<?php echo $auth_info['month_quota']; ?>" size=5></td>
  351. </tr>
  352. <tr>
  353. <td><?php print WEB_cell_nagios_handler; ?></td>
  354. <td width=200>
  355. <?php
  356. if (!empty($auth_info['wikiname'])) {
  357. $wiki_url = rtrim(get_option($db_link, 60), '/');
  358. if (preg_match('/127.0.0.1/', $wiki_url)) {
  359. print WEB_cell_wikiname;
  360. } else {
  361. $wiki_web = rtrim(get_option($db_link, 63), '/');
  362. $wiki_web = ltrim($wiki_web, '/');
  363. $wiki_link = $wiki_url . '/' . $wiki_web . '/' . $auth_info['wikiname'];
  364. print_url(WEB_cell_wikiname, $wiki_link);
  365. }
  366. } else {
  367. print WEB_cell_wikiname;
  368. }
  369. $dev_id = get_device_by_auth($db_link, $auth_info['user_id']);
  370. if (isset($dev_id)) {
  371. print "&nbsp|&nbsp";
  372. print_url('Device', '/admin/devices/editdevice.php?id=' . $dev_id);
  373. }
  374. ?>
  375. </td>
  376. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  377. print WEB_cell_nagios;
  378. } ?></td>
  379. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  380. print WEB_cell_link;
  381. } ?></td>
  382. <tr>
  383. <td><input type="text" name="f_handler" value="<?php echo $auth_info['nagios_handler']; ?>"></td>
  384. <td><input type="text" name="f_wiki" value="<?php echo $auth_info['wikiname']; ?>"></td>
  385. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  386. print_qa_select('f_nagios', $auth_info['nagios']);
  387. } ?>
  388. </td>
  389. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  390. print_qa_select('f_link', $auth_info['link_check']);
  391. } ?>
  392. </td>
  393. <td></td>
  394. </tr>
  395. <tr>
  396. <td><?php print WEB_cell_temporary; ?></td>
  397. <?php if ($auth_info['dynamic']) { print "<td>"; } else { print "<td>"; } ?>
  398. <div style="color: #7B1FA2;">
  399. <?php print WEB_cell_end_life; ?>
  400. </div>
  401. </td>
  402. <td></td>
  403. <td></td>
  404. <td></td>
  405. </tr>
  406. <tr>
  407. <td><?php print_qa_select('f_dynamic',$auth_info['dynamic']); ?></td>
  408. <td><input type="datetime-local" id="f_end_life" name="f_end_life" min="<?php print $created->format('Y-m-d H:i:s'); ?>" value="<?php print $auth_info['end_life']; ?>"
  409. <?php if (!$auth_info['dynamic']) { print "disabled"; } ?>
  410. step=1 ></td>
  411. <td></td>
  412. <td></td>
  413. <td></td>
  414. </tr>
  415. <tr>
  416. <td colspan=3><input type="submit" name="moveauth" value=<?php print WEB_btn_move; ?>>
  417. <?php print_login_select($db_link, 'f_new_parent', $auth_info['user_id']); ?></td>
  418. <?php
  419. if ($auth_info['deleted']) {
  420. print "<td ><font color=red>" . WEB_deleted . ": " . $auth_info['changed_time'] . "</font></td>";
  421. print "<td align=right><input type=\"submit\" name=\"recovery\" value='" . WEB_btn_recover . "'></td>";
  422. } else {
  423. print "<td ></td>";
  424. print "<td align=right><input type=\"submit\" name=\"editauth\" value='" . WEB_btn_save . "'></td>";
  425. }
  426. ?>
  427. </tr>
  428. </table>
  429. <table class="data">
  430. <tr>
  431. <td class="data" colspan=2><?php echo WEB_status . ":"; ?></td>
  432. <td align=right ><a href=/admin/logs/authlog.php?auth_id=<?php print $id; ?>><?php print WEB_log; ?></a></td>
  433. <td align=right ><?php print_url(WEB_report_by_day, "/admin/reports/authday.php?id=$id"); ?></td>
  434. </tr>
  435. <tr>
  436. <td ><?php echo WEB_cell_created_by . ":"; ?></td>
  437. <td class="data" ></td>
  438. <td class="data" colspan=2 align=right><?php echo $auth_info['created_by']; ?></td>
  439. </tr>
  440. <tr>
  441. <td><?php print WEB_cell_created; ?></td>
  442. <td class="data" align=right><?php print $auth_info['ts']; ?></td>
  443. <td><?php print WEB_cell_connection . ": "; ?></td>
  444. <td class="data" align=right><?php print get_connection($db_link, $id) ; ?></td>
  445. </tr>
  446. <tr>
  447. <td ><?php print WEB_cell_dhcp_hostname.":"; ?></td>
  448. <td class="data"><?php print $auth_info['dhcp_hostname']; ?></td>
  449. <td ><?php print "Dhcp event: "; ?></td>
  450. <td class="data" align=right><?php print $dhcp_str; ?></td>
  451. </tr>
  452. <tr>
  453. <td ><?php print WEB_cell_arp_found . ": "; ?></td>
  454. <td class="data" align=right><?php print $auth_info['arp_found'] ; ?></td>
  455. <td ><?php print WEB_cell_mac_found . ": "; ?></td>
  456. <td class="data" align=right><?php print $auth_info['mac_found'] ; ?></td>
  457. </tr>
  458. <tr>
  459. </tr>
  460. </table>
  461. <?php
  462. if ($msg_error) {
  463. print "<div id='msg'><b>$msg_error</b></div><br>\n";
  464. }
  465. ?>
  466. </form>
  467. <br>
  468. <script>
  469. document.getElementById('f_dynamic').addEventListener('change', function(event) {
  470. const selectValue = this.value;
  471. const inputField = document.getElementById('f_end_life');
  472. if (selectValue === '1') {
  473. inputField.disabled = false;
  474. } else {
  475. inputField.disabled = true;
  476. }
  477. });
  478. </script>
  479. <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>