editauth.php 24 KB

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