subdomain去除尾部.

This commit is contained in:
Wayne 2024-03-13 11:13:34 +08:00
parent da866552d1
commit 2f7fee69bb

View File

@ -207,17 +207,16 @@ if ($_REQUEST['act'] == 'edit') {
if (strlen($_POST['domain'])) { if (strlen($_POST['domain'])) {
if (strpos($_POST['domain'], $_CFG['cf_domain']) !== false) { if (strpos($_POST['domain'], $_CFG['cf_domain']) !== false) {
$sub_domain = str_replace($_CFG['cf_domain'], '', $_POST['domain']); $sub_domain = str_replace($_CFG['cf_domain'], '', $_POST['domain']);
// 如果sub_domain最後有.,則去掉 // sub_domain是為.結束,是的話就去掉
if (substr($sub_domain, -1) == '.') { if (substr($sub_domain, -1) == '.') {
$sub_domain = substr($sub_domain, 0, -1); $sub_domain = substr($sub_domain, 0, -1);
} }
include_once(ROOT_PATH . 'back/includes/cls_cloudflare.php'); include_once(ROOT_PATH . 'back/includes/cls_cloudflare.php');
$cf_obj = new cloudflare; $cf_obj = new cloudflare;
$ret = $cf_obj->update_domain($cf['cf_iden'], trim($sub_domain)); $ret = $cf_obj->update_domain($cf['cf_iden'], trim($sub_domain));
if (!$ret) { if (!$ret) {
// sys_msg('網域自動修改失敗,請重新操作',1, array(), false); sys_msg('網域自動修改失敗,請重新操作',1, array(), false);
$cf_iden = 0; // $cf_iden = 0;
} else { } else {
$cf_iden = $ad_ret; $cf_iden = $ad_ret;
} }
@ -228,7 +227,7 @@ if ($_REQUEST['act'] == 'edit') {
if (strlen($_REQUEST['domain'])) { if (strlen($_REQUEST['domain'])) {
if (strpos($_REQUEST['domain'], $_CFG['cf_domain']) !== false) { if (strpos($_REQUEST['domain'], $_CFG['cf_domain']) !== false) {
$sub_domain = str_replace($_CFG['cf_domain'], '', $_REQUEST['domain']); $sub_domain = str_replace($_CFG['cf_domain'], '', $_REQUEST['domain']);
// 如果sub_domain最後有.,則去掉 // sub_domain是為.結束,是的話就去掉
if (substr($sub_domain, -1) == '.') { if (substr($sub_domain, -1) == '.') {
$sub_domain = substr($sub_domain, 0, -1); $sub_domain = substr($sub_domain, 0, -1);
} }
@ -236,8 +235,8 @@ if ($_REQUEST['act'] == 'edit') {
$cf_obj = new cloudflare; $cf_obj = new cloudflare;
$ad_ret = $cf_obj->add_domain(trim($sub_domain)); $ad_ret = $cf_obj->add_domain(trim($sub_domain));
if (!$ad_ret) { if (!$ad_ret) {
// sys_msg('網域自動新增失敗,請重新操作',1, array(), false); sys_msg('網域自動新增失敗,請重新操作',1, array(), false);
$cf_iden = 0; // $cf_iden = 0;
} else { } else {
$cf_iden = $ad_ret; $cf_iden = $ad_ret;
} }