edit_alias.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. $sSQL = "SELECT * FROM User_auth WHERE id=$id";
  7. $auth_info = get_record_sql($db_link, $sSQL);
  8. if (isset($_POST["s_remove"])) {
  9. $s_id = $_POST["s_id"];
  10. foreach ($s_id as $key => $val) {
  11. if (isset($val)) {
  12. LOG_INFO($db_link, "Remove alias id: $val");
  13. delete_record($db_link, "User_auth_alias", "id=" . $val);
  14. }
  15. }
  16. header("Location: " . $page_url);
  17. exit;
  18. }
  19. if (isset($_POST['s_save'])) {
  20. $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0;
  21. for ($i = 0; $i < $len; $i ++) {
  22. $save_id = intval($_POST['s_save'][$i]);
  23. $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
  24. for ($j = 0; $j < $len_all; $j ++) {
  25. if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
  26. $new['alias'] = trim($_POST['s_alias'][$j]);
  27. $new['description'] = trim($_POST['s_comment'][$j]);
  28. update_record($db_link, "User_auth_alias", "id='{$save_id}'", $new);
  29. }
  30. }
  31. header("Location: " . $page_url);
  32. exit;
  33. }
  34. if (isset($_POST["s_create"])) {
  35. $new_alias = $_POST["s_create_alias"];
  36. if (isset($new_alias)) {
  37. $new_rec['alias'] = trim($new_alias);
  38. $new_rec['auth_id'] = $id;
  39. $new_rec['dns_changed'] = 1;
  40. LOG_INFO($db_link, "Create new alias $new_alias");
  41. insert_record($db_link, "User_auth_alias", $new_rec);
  42. }
  43. header("Location: " . $page_url);
  44. exit;
  45. }
  46. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  47. ?>
  48. <div id="cont">
  49. <br>
  50. <form name="def" action="edit_alias.php?id=<?php echo $id; ?>" method="post">
  51. <b><?php print WEB_user_alias_for."&nbsp"; print_url($auth_info['ip'],"/admin/users/editauth.php?id=$id"); ?></b> <br>
  52. <table class="data">
  53. <tr align="center">
  54. <td></td>
  55. <td width=30><b>id</b></td>
  56. <td><b><?php echo WEB_cell_name; ?></b></td>
  57. <td><b><?php echo WEB_cell_comment; ?></b></td>
  58. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
  59. </tr>
  60. <?php
  61. $t_User_auth_alias = get_records($db_link,'User_auth_alias',"deleted=0 AND auth_id=$id ORDER BY alias");
  62. if (!empty($t_User_auth_alias)) {
  63. foreach ( $t_User_auth_alias as $row ) {
  64. print "<tr align=center>\n";
  65. print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
  66. print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  67. print "<td class=\"data\"><input type=\"text\" name='s_alias[]' value='{$row['alias']}' pattern=\"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$\"></td>\n";
  68. print "<td class=\"data\"><input type=\"text\" name='s_comment[]' value='{$row['description']}'></td>\n";
  69. print "<td class=\"data\"><button name='s_save[]' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";
  70. print "</tr>\n";
  71. }
  72. }
  73. ?>
  74. </table>
  75. <div>
  76. <?php echo WEB_user_dns_add_alias; ?>:
  77. <input type="text" name='s_create_alias' value='' pattern="^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$">
  78. <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
  79. </div>
  80. </form>
  81. <?php
  82. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  83. ?>