edituser.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. $default_sort = 'ip_int';
  6. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/sortfilter.php");
  7. $msg_error = "";
  8. $sSQL = "SELECT * FROM user_list WHERE id = ?";
  9. $user_info = get_record_sql($db_link, $sSQL, [$id]);
  10. if (empty($user_info)) {
  11. header("Location: /admin/");
  12. exit;
  13. }
  14. // === РЕДАКТИРОВАНИЕ ПОЛЬЗОВАТЕЛЯ ===============================================
  15. if (getPOST("edituser") !== null) {
  16. $new = [];
  17. $f_ou = (int)getPOST("f_ou", null, 0);
  18. if ($f_ou > 0) {
  19. $new["ou_id"] = $f_ou;
  20. }
  21. $new["filter_group_id"] = (int)getPOST("f_filter", null, 0);
  22. $new["queue_id"] = (int)getPOST("f_queue", null, 0);
  23. $user_name = trim(getPOST("f_login", null, $user_info['login']));
  24. if ($user_name !== '') {
  25. $new["login"] = $user_name;
  26. }
  27. $new["description"] = trim(getPOST("f_description", null, ''));
  28. // Настройки по OU
  29. if (get_const('default_user_ou_id') == ($new["ou_id"] ?? 0) ||
  30. get_const('default_hotspot_ou_id') == ($new["ou_id"] ?? 0)) {
  31. $new["enabled"] = 0;
  32. $new["blocked"] = 0;
  33. $new["day_quota"] = 0;
  34. $new["month_quota"] = 0;
  35. $new["permanent"] = 0;
  36. } else {
  37. $new["enabled"] = (int)getPOST("f_enabled", null, 0);
  38. $new["blocked"] = (int)getPOST("f_blocked", null, 0);
  39. $new["day_quota"] = (int)trim(getPOST("f_perday", null, 0));
  40. $new["month_quota"] = (int)trim(getPOST("f_permonth", null, 0));
  41. $new["permanent"] = (int)getPOST("f_permanent", null, 0);
  42. }
  43. $changes = get_diff_rec($db_link, "user_list", "id = ?", $new, 0, [$id]);
  44. if (!empty($changes)) {
  45. LOG_WARNING($db_link, "Changed user id: $id login: " . ($new["login"] ?? '') . ". \r\nApply: $changes");
  46. }
  47. update_record($db_link, "user_list", "id = ?", $new, [$id]);
  48. // Отключаем авторизацию, если пользователь выключен
  49. if (!$new["enabled"]) {
  50. update_records($db_link, 'user_auth', 'user_id = ?', ['enabled' => 0, 'changed' => 1], [$id]);
  51. }
  52. // Обновляем описание в user_auth
  53. if (!empty($new["description"])) {
  54. update_records($db_link, 'user_auth',
  55. "user_id = ? AND deleted = 0 AND (description IS NULL OR description = '' OR description = ?)",
  56. ['description' => $new["description"]],
  57. [$id, $user_info["description"]]
  58. );
  59. }
  60. // Обновление ou_id в user_auth
  61. update_records($db_link, 'user_auth', 'user_id = ? AND deleted = 0', ['ou_id' => $new["ou_id"]], [$id]);
  62. // Обновление device_name в devices
  63. update_record($db_link, 'devices', 'user_id = ?', ['device_name' => $new["login"]], [$id]);
  64. header("Location: " . $_SERVER["REQUEST_URI"]);
  65. exit;
  66. }
  67. // === АВТОПРАВИЛА ПО MAC =========================================================
  68. if (getPOST("addMacRule") !== null) {
  69. $first_auth = get_records_sql($db_link,
  70. "SELECT mac FROM user_auth WHERE user_id = ? AND deleted = 0 AND LENGTH(mac) > 0 ORDER BY id",
  71. [$id]
  72. );
  73. foreach ($first_auth as $row) {
  74. if (!empty($row['mac'])) {
  75. add_auth_rule($db_link, $row['mac'], 2, $id);
  76. }
  77. }
  78. header("Location: " . $_SERVER["REQUEST_URI"]);
  79. exit;
  80. }
  81. if (getPOST("delMacRule") !== null) {
  82. delete_records($db_link, "auth_rules", "user_id = ? AND rule_type = 2", [$id]);
  83. LOG_INFO($db_link, "All autorules removed for id: $id login: " . $user_info["login"] . " by mac");
  84. header("Location: " . $_SERVER["REQUEST_URI"]);
  85. exit;
  86. }
  87. // === АВТОПРАВИЛА ПО IP ==========================================================
  88. if (getPOST("addIPRule") !== null) {
  89. $first_auth = get_records_sql($db_link,
  90. "SELECT ip FROM user_auth WHERE user_id = ? AND deleted = 0 AND ip IS NOT NULL ORDER BY id",
  91. [$id]
  92. );
  93. foreach ($first_auth as $row) {
  94. if (!empty($row['ip'])) {
  95. add_auth_rule($db_link, $row['ip'], 1, $id);
  96. }
  97. }
  98. header("Location: " . $_SERVER["REQUEST_URI"]);
  99. exit;
  100. }
  101. if (getPOST("delIPRule") !== null) {
  102. delete_records($db_link, "auth_rules", "user_id = ? AND rule_type = 1", [$id]);
  103. LOG_INFO($db_link, "Removed all auto rules for id: $id login: " . $user_info["login"] . " by ip");
  104. header("Location: " . $_SERVER["REQUEST_URI"]);
  105. exit;
  106. }
  107. // === СОЗДАНИЕ УСТРОЙСТВА ========================================================
  108. if (getPOST("showDevice") !== null) {
  109. $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id = ?", [$id]);
  110. $auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE user_id = ?", [$id]);
  111. if (empty($device) && !empty($auth)) {
  112. $new = [
  113. 'user_id' => $id,
  114. 'device_name' => $user_info['login'],
  115. 'device_type' => 5,
  116. 'ip' => $auth['ip'],
  117. 'ip_int' => $auth['ip_int'],
  118. 'community' => get_const('snmp_default_community'),
  119. 'snmp_version' => get_const('snmp_default_version'),
  120. 'login' => get_option($db_link, 28),
  121. 'password' => get_option($db_link, 29),
  122. 'protocol' => 0,
  123. 'control_port' => get_option($db_link, 30)
  124. ];
  125. $new_id = insert_record($db_link, "devices", $new);
  126. if (!empty($new_id)) {
  127. LOG_INFO($db_link, "Created device with id: $new_id for auth_id: $id");
  128. header("Location: /admin/devices/editdevice.php?id={$new_id}");
  129. exit;
  130. }
  131. }
  132. if (!empty($device['id'])) {
  133. header("Location: /admin/devices/editdevice.php?id=" . $device['id']);
  134. } else {
  135. header("Location: " . $_SERVER["REQUEST_URI"]);
  136. }
  137. exit;
  138. }
  139. // === ДОБАВЛЕНИЕ ЗАПИСИ АВТОРИЗАЦИИ ==============================================
  140. if (getPOST("addauth") !== null) {
  141. $fip = normalizeIpAddress(substr(trim(getPOST("newip", null, '')), 0, 18));
  142. $fdescription = null;
  143. $fmac = trim(getPOST("newmac", null, ''));
  144. if (!empty($fmac)) {
  145. if (!checkValidMac($fmac)) {
  146. $fdescription = $fmac;
  147. $fmac = null;
  148. } else {
  149. $fmac = mac_dotted($fmac);
  150. }
  151. }
  152. if (!empty($fip)) {
  153. $ip_aton = ip2long($fip);
  154. $f_dhcp = 1;
  155. // Проверка MAC
  156. if (!empty($fmac)) {
  157. $mac_exists = find_mac_in_subnet($db_link, $fip, $fmac);
  158. if (!empty($mac_exists) && ($mac_exists['count'] ?? 0) >= 1 && !in_array($id, $mac_exists['users_id'] ?? [])) {
  159. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$mac_exists['users_id'][0] ?? 0]);
  160. $msg_error = "Mac already exists at another user in this subnet! Skip creating $fip [$fmac].<br>Old user id: " . ($dup_info['id'] ?? '') . " login: " . ($dup_info['login'] ?? '');
  161. $_SESSION[$page_url]['msg'] = $msg_error;
  162. LOG_ERROR($db_link, $msg_error);
  163. header("Location: " . $_SERVER["REQUEST_URI"]);
  164. exit;
  165. }
  166. // DHCP для вторичного IP
  167. if (!empty($mac_exists) && in_array($id, $mac_exists['users_id'] ?? [])) {
  168. $f_dhcp = 0;
  169. }
  170. }
  171. // Проверка дубликата IP
  172. $dup_ip_record = get_record_sql($db_link, "SELECT * FROM user_auth WHERE ip_int = ? AND user_id <> ? AND deleted = 0", [$ip_aton, $id]);
  173. if (!empty($dup_ip_record)) {
  174. $dup_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id = ?", [$dup_ip_record['user_id']]);
  175. $msg_error = "$fip already exists. Skip creating $fip [$fmac].<br>Old user id: " . $dup_info['id'] . " login: " . $dup_info['login'];
  176. $_SESSION[$page_url]['msg'] = $msg_error;
  177. LOG_ERROR($db_link, $msg_error);
  178. header("Location: " . $_SERVER["REQUEST_URI"]);
  179. exit;
  180. }
  181. $fid = new_auth($db_link, $fip, $fmac, $id);
  182. if (!empty($fid)) {
  183. $new_auth = ['dhcp' => $f_dhcp, 'created_by' => 'manual'];
  184. if (!empty($fdescription)) {
  185. $new_auth['description'] = $fdescription;
  186. }
  187. update_record($db_link, "user_auth", "id = ?", $new_auth, [$fid]);
  188. LOG_WARNING($db_link, "Add ip for login: " . $user_info["login"] . ": ip => $fip, mac => $fmac", $fid);
  189. header("Location: /admin/users/editauth.php?id=" . $fid);
  190. exit;
  191. }
  192. } else {
  193. $msg_error = "IP-address format error!";
  194. $_SESSION[$page_url]['msg'] = $msg_error;
  195. }
  196. header("Location: " . $_SERVER["REQUEST_URI"]);
  197. exit;
  198. }
  199. // === УДАЛЕНИЕ ЗАПИСЕЙ АВТОРИЗАЦИИ ==============================================
  200. if (getPOST("removeauth") !== null) {
  201. $auth_id = getPOST("f_auth_id", null, []);
  202. if (!empty($auth_id) && is_array($auth_id)) {
  203. foreach ($auth_id as $val) {
  204. $val = trim($val);
  205. if ($val !== '') {
  206. delete_user_auth($db_link, (int)$val);
  207. }
  208. }
  209. }
  210. header("Location: " . $_SERVER["REQUEST_URI"]);
  211. exit;
  212. }
  213. // === СОЗДАНИЕ НОВОГО ПОЛЬЗОВАТЕЛЯ ИЗ ЗАПИСИ АВТОРИЗАЦИИ =========================
  214. if (getPOST("new_user") !== null) {
  215. $auth_id = getPOST("f_auth_id", null, []);
  216. $save_traf = (int)get_option($db_link, 23);
  217. if (!empty($auth_id) && is_array($auth_id)) {
  218. foreach ($auth_id as $val) {
  219. $val = (int)$val;
  220. if ($val <= 0) continue;
  221. $auth_info = get_record_sql($db_link, "SELECT * FROM user_auth WHERE id = ?", [$val]);
  222. if (empty($auth_info)) continue;
  223. $ou_id = $user_info["ou_id"];
  224. $login = null;
  225. if (!empty($auth_info["dns_name"])) {
  226. $login = $auth_info["dns_name"];
  227. } elseif (!empty($auth_info["description"])) {
  228. $login = transliterate($auth_info["description"]);
  229. } elseif (!empty($auth_info["dhcp_hostname"])) {
  230. $login = $auth_info["dhcp_hostname"];
  231. } elseif (!empty($auth_info["mac"])) {
  232. $login = $auth_info["mac"];
  233. } else {
  234. $login = $auth_info["ip"];
  235. }
  236. $new_user = get_record_sql($db_link, "SELECT * FROM user_list WHERE LOWER(login) = LOWER(?) AND deleted = 0", [$login]);
  237. if (!empty($new_user)) {
  238. // Перенос записи авторизации
  239. $auth_update = [
  240. 'user_id' => $new_user["id"],
  241. 'ou_id' => $new_user["ou_id"],
  242. 'save_traf' => $save_traf
  243. ];
  244. $auth_update = apply_auth_rule($db_link, $auth_update, $new_user["id"]);
  245. update_record($db_link, "user_auth", "id = ?", $auth_update, [$val]);
  246. LOG_WARNING($db_link, "ip from id: $val moved to another user user_id: " . $new_user["id"], $val);
  247. } else {
  248. $new_user_data = [
  249. 'login' => $login,
  250. 'ou_id' => $ou_id
  251. ];
  252. if (!empty($auth_info["description"])) {
  253. $new_user_data["description"] = $auth_info["description"];
  254. } elseif (!empty($auth_info["dns_name"])) {
  255. $new_user_data["description"] = $auth_info["dns_name"];
  256. } elseif (!empty($auth_info["dhcp_hostname"])) {
  257. $new_user_data["description"] = $auth_info["dhcp_hostname"];
  258. }
  259. $new_user_data["enabled"] = $auth_info["enabled"];
  260. $l_id = insert_record($db_link, "user_list", $new_user_data);
  261. if (!empty($l_id)) {
  262. $auth_update = ['user_id' => $l_id, 'save_traf' => $save_traf];
  263. update_record($db_link, "user_auth", "id = ?", $auth_update, [$val]);
  264. LOG_WARNING($db_link, "Create user from ip: login => $login. ip-record auth_id: $val moved to this user.", $val);
  265. }
  266. }
  267. }
  268. }
  269. header("Location: " . $_SERVER["REQUEST_URI"]);
  270. exit;
  271. }
  272. unset($_POST);
  273. require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
  274. ?>
  275. <div id="cont">
  276. <?php
  277. if (!empty($_SESSION[$page_url]['msg'])) {
  278. print '<div id="msg">' . $_SESSION[$page_url]['msg'] . '</div>';
  279. unset($_SESSION[$page_url]['msg']);
  280. }
  281. ?>
  282. <form name="def" action="edituser.php?id=<?php echo $id; ?>" method="post">
  283. <input type="hidden" name="id" value=<?php echo $id; ?>>
  284. <table class="data">
  285. <tr>
  286. <td colspan=2><?php print WEB_cell_login; ?></td>
  287. <td colspan=2><?php print WEB_cell_description; ?></td>
  288. <td colspan=2><?php print WEB_cell_ou; ?></td>
  289. <td ><?php print WEB_user_permanent; ?></td>
  290. </tr>
  291. <tr>
  292. <td colspan=2><input type="text" name="f_login" value="<?php print $user_info["login"]; ?>" size=25></td>
  293. <td colspan=2><input type="text" name="f_description" value="<?php print $user_info["description"]; ?>" size=25></td>
  294. <td colspan=2><?php print_ou_set($db_link, 'f_ou', $user_info["ou_id"]); ?></td>
  295. <td><?php print_qa_select('f_permanent', $user_info["permanent"]); ?></td>
  296. </tr>
  297. <tr>
  298. <td colspan=2><?php print WEB_cell_perday; ?></td>
  299. <td colspan=2><?php print WEB_cell_permonth; ?></td>
  300. <td><?php print WEB_cell_blocked; ?></td>
  301. <td></td>
  302. <td><?php print WEB_cell_enabled; ?></td>
  303. </tr>
  304. <tr>
  305. <td colspan=2><input type="text" name="f_perday" value="<?php echo $user_info["day_quota"]; ?>" size=5></td>
  306. <td colspan=2><input type="text" name="f_permonth" value="<?php echo $user_info["month_quota"]; ?>" size=5></td>
  307. <td><?php print_qa_select('f_blocked', $user_info["blocked"]); ?></td>
  308. <td></td>
  309. <td><?php print_qa_select('f_enabled', $user_info["enabled"]); ?></td>
  310. </tr>
  311. <tr>
  312. <td class=data colspan=7><?php echo WEB_user_rules_for_autoassign; ?>:</td>
  313. </tr>
  314. <tr>
  315. <td colspan=2><?php print WEB_cell_filter; ?></td>
  316. <td colspan=2><?php print WEB_cell_shaper; ?></td>
  317. <td colspan=3></td>
  318. </tr>
  319. <tr>
  320. <td colspan=2><?php print_filter_group_select($db_link, 'f_filter', $user_info["filter_group_id"]); ?></td>
  321. <td colspan=2><?php print_queue_select($db_link, 'f_queue', $user_info["queue_id"]); ?></td>
  322. <td colspan=3></td>
  323. </tr>
  324. <tr>
  325. <?php
  326. print "<td>";
  327. print_url(WEB_user_rule_list, "/admin/users/edit_rules.php?id=$id");
  328. print "</td>";
  329. $rule_count = get_count_records($db_link, "auth_rules", "user_id=?", [ $id ]);
  330. print "<td > Count: " . $rule_count . "</td>";
  331. $first_auth = get_record_sql($db_link, "SELECT id FROM user_auth WHERE user_id=? AND deleted=0 ORDER BY id", [ $id ]);
  332. if (!empty($first_auth)) {
  333. //mac
  334. $mac_rule_count = get_count_records($db_link, "auth_rules", "user_id=? AND rule_type=2", [ $id ]);
  335. if (!empty($mac_rule_count)) {
  336. print "<td><input type=\"submit\" name=\"delMacRule\" value=" . WEB_btn_mac_del . " ></td>";
  337. } else {
  338. print "<td><input type=\"submit\" name=\"addMacRule\" value=" . WEB_btn_mac_add . " ></td>";
  339. }
  340. //ip
  341. $ip_rule_count = get_count_records($db_link, "auth_rules", "user_id=? AND rule_type=1", [ $id ]);
  342. if (!empty($ip_rule_count)) {
  343. print "<td><input type=\"submit\" name=\"delIPRule\" value=" . WEB_btn_ip_del . " ></td>";
  344. } else {
  345. print "<td><input type=\"submit\" name=\"addIPRule\" value=" . WEB_btn_ip_add . " ></td>";
  346. }
  347. } else {
  348. print "<td colspan=2></td>";
  349. }
  350. ?>
  351. <td colspan=3 align=right><?php print WEB_cell_created . ":&nbsp";
  352. print $user_info["ts"]; ?></td>
  353. </tr>
  354. <tr>
  355. <?php print "<td colspan=2>";
  356. print_url(WEB_report_by_day, "/admin/reports/userday.php?id=$id"); ?></td>
  357. <td></td>
  358. <td><input type="submit" name="showDevice" value=<?php print WEB_btn_device; ?>></td>
  359. <td colspan=2></td>
  360. <td align=right><input type="submit" name="edituser" value=<?php print WEB_btn_save; ?>></td>
  361. </tr>
  362. </table>
  363. <?php
  364. if ($msg_error) {
  365. print "<div id='msg'><b>$msg_error</b></div><br>\n";
  366. }
  367. $sort_table = 'user_auth';
  368. $sort_url = "<a href=edituser.php?id=" . $id;
  369. ?>
  370. <br><b><?php echo WEB_user_ip_list; ?></b><br>
  371. <table class="data">
  372. <tr>
  373. <td class="data"><?php echo WEB_user_add_ip; ?>:&nbsp<input type=text name=newip value=""></td>
  374. <td class="data"><?php echo WEB_user_add_mac; ?>:&nbsp<input type=text name=newmac value=""></td>
  375. <td class="data"><input type="submit" name="addauth" value="<?php echo WEB_btn_add; ?>"></td>
  376. <td class="data" align=right><input type="submit" name="new_user" value="<?php echo WEB_btn_transfom; ?>"></td>
  377. </tr>
  378. </table>
  379. <table class="data" width=120%>
  380. <tr align=center>
  381. <td class="data"><input type="checkbox" onClick="checkAll(this.checked);"></td>
  382. <td class="data"><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
  383. <td class="data"><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
  384. <td class="data"><?php print WEB_cell_description; ?></td>
  385. <td class="data"><?php print $sort_url . "&sort=dns_name&order=$new_order>" . WEB_cell_dns_name . "</a>"; ?></td>
  386. <td class="data"><?php print WEB_cell_enabled; ?></td>
  387. <td class="data"><?php print WEB_cell_dhcp; ?></td>
  388. <td class="data"><?php print WEB_cell_filter; ?></td>
  389. <td class="data"><?php print WEB_cell_shaper; ?></td>
  390. <td class="data"><?php print WEB_cell_perday . "/<br>" . WEB_cell_permonth . ", Mb"; ?></td>
  391. <td class="data"><?php print WEB_cell_temporary; ?></td>
  392. <td class="data"><?php print "<input type=\"submit\" onclick=\"return confirm('" . WEB_msg_apply_selected . "?')\" name=\"removeauth\" value=" . WEB_btn_remove . ">"; ?></td>
  393. </tr>
  394. <?php
  395. $flist = get_records($db_link, 'user_auth', "user_id=? and deleted=0 ORDER BY $sort_table.$sort_field $order", [ $id ]);
  396. if (!empty($flist)) {
  397. foreach ($flist as $row) {
  398. $dhcp_str = '';
  399. if ($row["dhcp_time"] !== '0000-00-00 00:00:00') {
  400. if (!empty($row["dhcp_action"])) { $dhcp_str = FormatDateStr('Y.m.d H:m', $row["dhcp_time"]) . " (" . $row["dhcp_action"] . ")"; }
  401. }
  402. if ($row["last_found"] == '0000-00-00 00:00:00') {
  403. $row["last_found"] = '';
  404. }
  405. if ($row["mac_found"] == '0000-00-00 00:00:00') {
  406. $row["mac_found"] = '';
  407. }
  408. if ($row["arp_found"] == '0000-00-00 00:00:00') {
  409. $row["arp_found"] = '';
  410. }
  411. print "<tr align=center>";
  412. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=" . $row["id"] . " ></td>";
  413. print "<td class=\"data\" align=left><a href=editauth.php?id=" . $row["id"] . ">" . $row["ip"] . "</a>";
  414. if (!empty($row["arp_found"])) { print "<p class='ts'>".FormatDateStr('Y.m.d H:i', $row["arp_found"])."</p>"; }
  415. print "</td>";
  416. print "<td class=\"data\" >" . expand_mac($db_link, $row["mac"]);
  417. if (!empty($row["mac_found"])) { print "<p class='ts'>".FormatDateStr('Y.m.d H:i', $row["mac_found"])."</p>"; }
  418. print "</td>";
  419. if (isset($row["dhcp_hostname"]) and strlen($row["dhcp_hostname"]) > 0) {
  420. print "<td class=\"data\" >" . $row["description"] . " [" . $row["dhcp_hostname"] . "]</td>";
  421. } else {
  422. print "<td class=\"data\" >" . $row["description"] . "</td>";
  423. }
  424. $f_dns_type = 'A';
  425. if ($row["dns_ptr_only"]) { $f_dns_type = 'ptr'; }
  426. $f_dns_row = '';
  427. if (!empty($row["dns_name"])) { $f_dns_row = $row["dns_name"]."<hr>".$f_dns_type; }
  428. print "<td class=\"data\" >" . $f_dns_row . "</td>";
  429. $ip_status = 1;
  430. if ($row["blocked"] or !$row["enabled"]) {
  431. $ip_status = 0;
  432. }
  433. print_td_qa($ip_status);
  434. $cl = "data_green";
  435. if (!$row["dhcp"]) { $cl = "data_red"; }
  436. print "<td class=\"$cl\" >" . get_qa($row["dhcp"]);
  437. if (!empty($row["dhcp_acl"]) or !empty($row["dhcp_option_set"])) {
  438. print "<p class='ts'>";
  439. if (!empty($row["dhcp_acl"])) { print $row["dhcp_acl"]; }
  440. if (!empty($row["dhcp_acl"]) and !empty($row["dhcp_option_set"])) { print "&nbsp/&nbsp"; }
  441. if (!empty($row["dhcp_option_set"])) { print $row["dhcp_option_set"]; }
  442. print "</p>";
  443. }
  444. if (!empty($dhcp_str)) { print "<p class='ts'>".$dhcp_str. "</p>"; }
  445. print "</td>";
  446. print "<td class=\"data\" >" . get_group($db_link, $row["filter_group_id"]) . "</td>";
  447. print "<td class=\"data\" >" . get_queue($db_link, $row["queue_id"]) . "</td>";
  448. print "<td class=\"data\" >" . $row["day_quota"] . "/" . $row["month_quota"] . "</td>";
  449. if ($row['dynamic']) { $cl = "data_red"; } else { $cl = "data_green"; }
  450. print "<td class=\"$cl\" >". get_qa($row['dynamic']);
  451. if ($row['dynamic'] and !empty($row["end_life"])) { print "<p class='ts'>".FormatDateStr('Y.m.d H:i', $row["end_life"])."</p>"; } else { print "&nbsp"; }
  452. print "</td>";
  453. print "<td class=\"data\" >";
  454. if (!empty($row["created_by"])) { print $row["created_by"]; } else { print "&nbsp"; }
  455. print "</td>";
  456. print "</tr>";
  457. }
  458. }
  459. ?>
  460. </table>
  461. </form>
  462. <?php
  463. require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/footer.php");
  464. ?>