$val) { if (isset($val)) { LOG_INFO($db_link, "Remove alias id: $val ".dump_record($db_link,'User_auth_alias','id='.$val)); delete_record($db_link, "User_auth_alias", "id=" . $val); } } header("Location: " . $page_url); exit; } if (isset($_POST['s_save'])) { $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0; $domain_zone = get_option($db_link, 33); $domain_zone = ltrim($domain_zone, '.'); for ($i = 0; $i < $len; $i ++) { $save_id = intval($_POST['s_save'][$i]); $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0; for ($j = 0; $j < $len_all; $j ++) { if (intval($_POST['n_id'][$j]) != $save_id) { continue; } $f_dnsname = trim($_POST['s_alias'][$j]); if (!empty($f_dnsname)) { $f_dnsname = preg_replace('/\.' . str_replace('.', '\.', $domain_zone) . '$/', '', $f_dnsname); // $f_dnsname = preg_replace('/\.$/','',$f_dnsname); $f_dnsname = preg_replace('/\s+/','-',$f_dnsname); // $f_dnsname = preg_replace('/\./','-',$f_dnsname); } if (empty($f_dnsname) or !checkValidHostname($f_dnsname) or !checkUniqHostname($db_link,$id,$f_dnsname)) { continue; } $new['alias'] = $f_dnsname; $new['description'] = trim($_POST['s_comment'][$j]); update_record($db_link, "User_auth_alias", "id='{$save_id}'", $new); } } header("Location: " . $page_url); exit; } if (isset($_POST["s_create"])) { $new_alias = $_POST["s_create_alias"]; if (isset($new_alias)) { $f_dnsname = trim($new_alias); if (!empty($f_dnsname)) { $domain_zone = get_option($db_link, 33); $domain_zone = ltrim($domain_zone, '.'); $f_dnsname = preg_replace('/\.' . str_replace('.', '\.', $domain_zone) . '$/', '', $f_dnsname); // $f_dnsname = preg_replace('/\.$/','',$f_dnsname); $f_dnsname = preg_replace('/\s+/','-',$f_dnsname); // $f_dnsname = preg_replace('/\./','-',$f_dnsname); } if (empty($f_dnsname) or !checkValidHostname($f_dnsname) or !checkUniqHostname($db_link,$id,$f_dnsname)) { $msg_error = "DNS $f_dnsname already exists at: ".searchHostname($db_link,$id,$f_dnsname)." Discard changes!"; $_SESSION[$page_url]['msg'] = $msg_error; LOG_ERROR($db_link, $msg_error); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (empty($f_dnsname)) { $f_dnsname = ''; } $new_rec['alias'] = $f_dnsname; $new_rec['auth_id'] = $id; LOG_INFO($db_link, "Create new alias $new_alias"); insert_record($db_link, "User_auth_alias", $new_rec); } header("Location: " . $page_url); exit; } require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php"); ?>