editauth.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. // Применение изменений
  161. $changes = get_diff_rec($db_link, "user_auth", "id = ?", $new, 0, [$id]);
  162. if (!empty($changes)) {
  163. LOG_WARNING($db_link, "Changed record for $ip! Log: " . $changes, $id);
  164. }
  165. if (is_auth_bind_changed($db_link, $id, $ip, $mac)) {
  166. $new_id = copy_auth($db_link, $id, $new);
  167. if (!empty($new_id)) {
  168. header("Location: /admin/users/editauth.php?id=" . $new_id, true, 302);
  169. } else {
  170. header("Location: " . $_SERVER["REQUEST_URI"]);
  171. }
  172. exit;
  173. } else {
  174. update_record($db_link, "user_auth", "id = ?", $new, [$id]);
  175. }
  176. } else {
  177. $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx";
  178. $_SESSION[$page_url]['msg'] = $msg_error;
  179. }
  180. header("Location: " . $_SERVER["REQUEST_URI"]);
  181. exit;
  182. }
  183. // === ПЕРЕМЕЩЕНИЕ ЗАПИСИ =========================================================
  184. if (getPOST("moveauth") !== null && !$old_auth_info['deleted']) {
  185. $new_parent_id = (int)getPOST("f_new_parent", null, 0);
  186. $moved_auth = get_record_sql($db_link, "SELECT description FROM user_auth WHERE id = ?", [$id]);
  187. $changes = apply_auth_rule($db_link, $moved_auth, $new_parent_id);
  188. update_record($db_link, "user_auth", "id = ?", $changes, [$id]);
  189. LOG_WARNING($db_link, "IP-address moved to another user! Applyed: " . hash_to_text($changes), $id);
  190. // Удаляем старые правила
  191. delete_records($db_link, "auth_rules", "user_id = ? AND rule = ? AND rule_type = 2", [$old_auth_info["user_id"], $old_auth_info["mac"]]);
  192. delete_records($db_link, "auth_rules", "user_id = ? AND rule = ? AND rule_type = 1", [$old_auth_info["user_id"], $old_auth_info["ip"]]);
  193. LOG_INFO($db_link, "Autorules removed for user_id: " . $old_auth_info["user_id"] . " login: " . $user_info["login"] . " by mac and ip");
  194. header("Location: " . $_SERVER["REQUEST_URI"]);
  195. exit;
  196. }
  197. // === ВОССТАНОВЛЕНИЕ УДАЛЁННОЙ ЗАПИСИ ===========================================
  198. if (getPOST("recovery") !== null && $old_auth_info['deleted']) {
  199. $ip = trim(getPOST("f_ip", null, ''));
  200. if (checkValidIp($ip)) {
  201. $ip_aton = ip2long($ip);
  202. $mac = mac_dotted(getPOST("f_mac", null, ''));
  203. // Проверка MAC
  204. $mac_exists = find_mac_in_subnet($db_link, $ip, $mac);
  205. if (!empty($mac_exists) && ($mac_exists['count'] ?? 0) >= 1 && !in_array($parent_id, $mac_exists['users_id'] ?? [])) {
  206. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$mac_exists['users_id'][0] ?? 0]);
  207. $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'] ?? '');
  208. $_SESSION[$page_url]['msg'] = $msg_error;
  209. LOG_ERROR($db_link, $msg_error);
  210. header("Location: " . $_SERVER["REQUEST_URI"]);
  211. exit;
  212. }
  213. // DHCP для вторичного IP
  214. $f_dhcp = (int)getPOST("f_dhcp", null, 0);
  215. if (!empty($mac_exists) && in_array($parent_id, $mac_exists['users_id'] ?? [])) {
  216. if ($parent_id != ($mac_exists['users_id'][0] ?? null)) {
  217. $f_dhcp = 0;
  218. }
  219. }
  220. // Проверка дубликата IP
  221. $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE ip_int = ? AND id <> ? AND deleted = 0", [$ip_aton, $id]);
  222. if (!empty($dup_ip_record)) {
  223. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$dup_ip_record['user_id']]);
  224. $msg_error = "$ip already exists. Skip creating $ip [$mac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
  225. $_SESSION[$page_url]['msg'] = $msg_error;
  226. LOG_ERROR($db_link, $msg_error);
  227. header("Location: " . $_SERVER["REQUEST_URI"]);
  228. exit;
  229. }
  230. $new = ['deleted' => 0, 'dynamic' => 0, 'dns_name' => ''];
  231. $old_parent = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$parent_id]);
  232. if (empty($old_parent)) {
  233. $new_user_info = get_new_user_id($db_link, $ip, $mac, null);
  234. $new_user_id = $new_user_info['user_id'] ?? null;
  235. if (empty($new_user_id)) {
  236. $new_user_id = new_user($db_link, $new_user_info);
  237. }
  238. $new['user_id'] = $new_user_id;
  239. }
  240. $new['description'] = $old_parent['description'] ?? '';
  241. // Настройки по OU
  242. if (get_const('default_user_ou_id') == $parent_ou_id || get_const('default_hotspot_ou_id') == $parent_ou_id) {
  243. $new += [
  244. 'nagios_handler' => '',
  245. 'enabled' => 0,
  246. 'link_check' => 0,
  247. 'nagios' => 0,
  248. 'blocked' => 0,
  249. 'day_quota' => 0,
  250. 'month_quota' => 0,
  251. 'queue_id' => 0,
  252. 'filter_group_id' => 0
  253. ];
  254. } else {
  255. $new += [
  256. 'nagios_handler' => trim(getPOST("f_handler", null, '')),
  257. 'enabled' => (int)getPOST("f_enabled", null, 0),
  258. 'link_check' => (int)getPOST("f_link", null, 0),
  259. 'nagios' => (int)getPOST("f_nagios", null, 0),
  260. 'dhcp' => (int)getPOST("f_dhcp", null, 0),
  261. 'blocked' => (int)getPOST("f_blocked", null, 0),
  262. 'day_quota' => (int)getPOST("f_day_q", null, 0),
  263. 'month_quota' => (int)getPOST("f_month_q", null, 0),
  264. 'queue_id' => (int)getPOST("f_queue_id", null, 0),
  265. 'filter_group_id' => (int)getPOST("f_group_id", null, 0)
  266. ];
  267. }
  268. $changes = get_diff_rec($db_link, "user_auth", "id = ?", $new, 0, [$id]);
  269. if (!empty($changes)) {
  270. LOG_WARNING($db_link, "Recovered ip-address. Applyed: $changes", $id);
  271. }
  272. $new = apply_auth_rule($db_link, $new, $new['user_id']);
  273. update_record($db_link, "user_auth", "id = ?", $new, [$id]);
  274. } else {
  275. $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx/xx";
  276. $_SESSION[$page_url]['msg'] = $msg_error;
  277. }
  278. header("Location: " . $_SERVER["REQUEST_URI"]);
  279. exit;
  280. }
  281. unset($_POST);
  282. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  283. $sSQL = "SELECT * FROM user_auth WHERE id=?";
  284. $auth_info = get_record_sql($db_link, $sSQL, [ $id ]);
  285. $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=?", [ $auth_info['user_id'] ]);
  286. $parent_name = get_login($db_link, $auth_info['user_id']);
  287. if (empty($parent_name)) { $parent_name=$auth_info['user_id']; }
  288. if ($auth_info['dhcp_time'] == '0000-00-00 00:00:00') {
  289. $dhcp_str = '';
  290. } else {
  291. $dhcp_str = $auth_info['dhcp_time'] . " (" . $auth_info['dhcp_action'] . ")";
  292. }
  293. if ($auth_info['last_found'] == '0000-00-00 00:00:00') { $auth_info['last_found'] = ''; }
  294. if ($auth_info['mac_found'] == '0000-00-00 00:00:00') { $auth_info['mac_found'] = ''; }
  295. if ($auth_info['arp_found'] == '0000-00-00 00:00:00') { $auth_info['arp_found'] = ''; }
  296. $now = DateTime::createFromFormat("Y-m-d H:i:s",date('Y-m-d H:i:s'));
  297. $created = new DateTime($auth_info['ts']);
  298. if (empty($auth_info['end_life']) or $auth_info['end_life'] == '0000-00-00 00:00:00') {
  299. $now->modify('+1 day');
  300. $auth_info['end_life'] = $now->format('Y-m-d H:i:s');
  301. }
  302. ?>
  303. <div id="cont">
  304. <?php
  305. if (!empty($_SESSION[$page_url]['msg'])) {
  306. print '<div id="msg">' . $_SESSION[$page_url]['msg'] . '</div>';
  307. unset($_SESSION[$page_url]['msg']);
  308. }
  309. print "<b>" . WEB_user_title . "&nbsp<a href=/admin/users/edituser.php?id=" . $auth_info['user_id'] . ">" . $parent_name . "</a> </b>";
  310. $alias_link = '';
  311. if (!empty($auth_info['dns_name']) and !$auth_info['dns_ptr_only']) { $alias_link="/admin/users/edit_alias.php?id=".$id; }
  312. if (empty($auth_info['created_by'])) { $auth_info['created_by'] = '-'; }
  313. $f_dns_ptr = '';
  314. if ($auth_info['dns_ptr_only']) { $f_dns_ptr = 'checked'; }
  315. ?>
  316. <form name="def" action="editauth.php?id=<?php echo $id; ?>" method="post">
  317. <input type="hidden" name="id" value=<?php echo $id; ?>>
  318. <table class="data">
  319. <tr>
  320. <td width=230><?php print WEB_cell_dns_name . " &nbsp | &nbsp "; print_url(WEB_cell_aliases, $alias_link); ?></td>
  321. <td width=200><?php print WEB_cell_description; ?></td>
  322. <td width=70><?php print WEB_cell_enabled; ?></td>
  323. <td><?php print WEB_cell_traf; ?></td>
  324. <td></td>
  325. </tr>
  326. <tr>
  327. <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})*\.?$">
  328. <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; ?>
  329. </td>
  330. <td><input type="text" name="f_description" value="<?php echo $auth_info['description']; ?>"></td>
  331. <td><?php print_qa_select('f_enabled', $auth_info['enabled']); ?></td>
  332. <td><?php print_qa_select('f_save_traf', $auth_info['save_traf']); ?></td>
  333. <td></td>
  334. </tr>
  335. <tr>
  336. <td><?php print WEB_cell_ip; ?></td>
  337. <td><?php print WEB_cell_mac; ?></td>
  338. <td><?php print WEB_cell_dhcp; ?></td>
  339. <td><?php print WEB_cell_acl; ?></td>
  340. <td><?php print WEB_cell_option_set; ?></td>
  341. <td></td>
  342. <tr>
  343. <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>
  344. <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>
  345. <td><?php print_qa_select('f_dhcp', $auth_info['dhcp']); ?></td>
  346. <td><?php print_dhcp_acl_list($db_link,"f_acl",$auth_info['dhcp_acl']); ?></td>
  347. <td><?php print_dhcp_option_set_list($db_link,"f_dhcp_option_set",$auth_info['dhcp_option_set']); ?></td>
  348. </tr>
  349. <tr>
  350. <td><?php print WEB_cell_filter; ?></td>
  351. <td><?php print WEB_cell_shaper; ?></td>
  352. <td><?php print WEB_cell_blocked; ?></td>
  353. <td><?php print WEB_cell_perday; ?></td>
  354. <td><?php print WEB_cell_permonth; ?></td>
  355. </tr>
  356. <tr>
  357. <td><?php print_filter_group_select($db_link, 'f_group_id', $auth_info['filter_group_id']); ?> </td>
  358. <td><?php print_queue_select($db_link, 'f_queue_id', $auth_info['queue_id']); ?> </td>
  359. <td><?php print_qa_select('f_blocked', $auth_info['blocked']); ?></td>
  360. <td><input type="text" name="f_day_q" value="<?php echo $auth_info['day_quota']; ?>" size=5></td>
  361. <td><input type="text" name="f_month_q" value="<?php echo $auth_info['month_quota']; ?>" size=5></td>
  362. </tr>
  363. <tr>
  364. <td><?php print WEB_cell_nagios_handler; ?></td>
  365. <td width=200>
  366. <?php
  367. if (!empty($auth_info['WikiName'])) {
  368. $wiki_url = rtrim(get_option($db_link, 60), '/');
  369. if (preg_match('/127.0.0.1/', $wiki_url)) {
  370. print WEB_cell_wikiname;
  371. } else {
  372. $wiki_web = rtrim(get_option($db_link, 63), '/');
  373. $wiki_web = ltrim($wiki_web, '/');
  374. $wiki_link = $wiki_url . '/' . $wiki_web . '/' . $auth_info['WikiName'];
  375. print_url(WEB_cell_wikiname, $wiki_link);
  376. }
  377. } else {
  378. print WEB_cell_wikiname;
  379. }
  380. $dev_id = get_device_by_auth($db_link, $auth_info['user_id']);
  381. if (isset($dev_id)) {
  382. print "&nbsp|&nbsp";
  383. print_url('Device', '/admin/devices/editdevice.php?id=' . $dev_id);
  384. }
  385. ?>
  386. </td>
  387. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  388. print WEB_cell_nagios;
  389. } ?></td>
  390. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  391. print WEB_cell_link;
  392. } ?></td>
  393. <tr>
  394. <td><input type="text" name="f_handler" value="<?php echo $auth_info['nagios_handler']; ?>"></td>
  395. <td><input type="text" name="f_wiki" value="<?php echo $auth_info['WikiName']; ?>"></td>
  396. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  397. print_qa_select('f_nagios', $auth_info['nagios']);
  398. } ?>
  399. </td>
  400. <td><?php if (empty($device) or (!empty($device) and $device['device_type'] > 2)) {
  401. print_qa_select('f_link', $auth_info['link_check']);
  402. } ?>
  403. </td>
  404. <td></td>
  405. </tr>
  406. <tr>
  407. <td><?php print WEB_cell_temporary; ?></td>
  408. <?php if ($auth_info['dynamic']) { print "<td>"; } else { print "<td>"; } ?>
  409. <div style="color: #7B1FA2;">
  410. <?php print WEB_cell_end_life; ?>
  411. </div>
  412. </td>
  413. <td></td>
  414. <td></td>
  415. <td></td>
  416. </tr>
  417. <tr>
  418. <td><?php print_qa_select('f_dynamic',$auth_info['dynamic']); ?></td>
  419. <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']; ?>"
  420. <?php if (!$auth_info['dynamic']) { print "disabled"; } ?>
  421. step=1 ></td>
  422. <td></td>
  423. <td></td>
  424. <td></td>
  425. </tr>
  426. <tr>
  427. <td colspan=3><input type="submit" name="moveauth" value=<?php print WEB_btn_move; ?>>
  428. <?php print_login_select($db_link, 'f_new_parent', $auth_info['user_id']); ?></td>
  429. <?php
  430. if ($auth_info['deleted']) {
  431. print "<td ><font color=red>" . WEB_deleted . ": " . $auth_info['changed_time'] . "</font></td>";
  432. print "<td align=right><input type=\"submit\" name=\"recovery\" value='" . WEB_btn_recover . "'></td>";
  433. } else {
  434. print "<td ></td>";
  435. print "<td align=right><input type=\"submit\" name=\"editauth\" value='" . WEB_btn_save . "'></td>";
  436. }
  437. ?>
  438. </tr>
  439. </table>
  440. <table class="data">
  441. <tr>
  442. <td class="data" colspan=2><?php echo WEB_status . ":"; ?></td>
  443. <td align=right ><a href=/admin/logs/authlog.php?auth_id=<?php print $id; ?>><?php print WEB_log; ?></a></td>
  444. <td align=right ><?php print_url(WEB_report_by_day, "/admin/reports/authday.php?id=$id"); ?></td>
  445. </tr>
  446. <tr>
  447. <td ><?php echo WEB_cell_created_by . ":"; ?></td>
  448. <td class="data" ></td>
  449. <td class="data" colspan=2 align=right><?php echo $auth_info['created_by']; ?></td>
  450. </tr>
  451. <tr>
  452. <td><?php print WEB_cell_created; ?></td>
  453. <td class="data" align=right><?php print $auth_info['ts']; ?></td>
  454. <td><?php print WEB_cell_connection . ": "; ?></td>
  455. <td class="data" align=right><?php print get_connection($db_link, $id) ; ?></td>
  456. </tr>
  457. <tr>
  458. <td ><?php print WEB_cell_dhcp_hostname.":"; ?></td>
  459. <td class="data"><?php print $auth_info['dhcp_hostname']; ?></td>
  460. <td ><?php print "Dhcp event: "; ?></td>
  461. <td class="data" align=right><?php print $dhcp_str; ?></td>
  462. </tr>
  463. <tr>
  464. <td ><?php print WEB_cell_arp_found . ": "; ?></td>
  465. <td class="data" align=right><?php print $auth_info['arp_found'] ; ?></td>
  466. <td ><?php print WEB_cell_mac_found . ": "; ?></td>
  467. <td class="data" align=right><?php print $auth_info['mac_found'] ; ?></td>
  468. </tr>
  469. <tr>
  470. </tr>
  471. </table>
  472. <?php
  473. if ($msg_error) {
  474. print "<div id='msg'><b>$msg_error</b></div><br>\n";
  475. }
  476. ?>
  477. </form>
  478. <br>
  479. <script>
  480. document.getElementById('f_dynamic').addEventListener('change', function(event) {
  481. const selectValue = this.value;
  482. const inputField = document.getElementById('f_end_life');
  483. if (selectValue === '1') {
  484. inputField.disabled = false;
  485. } else {
  486. inputField.disabled = true;
  487. }
  488. });
  489. </script>
  490. <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php"); ?>