forked from Netrvin/CFPMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_record.php
69 lines (61 loc) · 1.68 KB
/
edit_record.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include_once("cf.class.php");
CF::is_login();
function msg($s){
$_SESSION["mng_msg"]=$s;
header("Location: manage_domain.php?domain=".$_POST["domain"]);
exit(0);
}
if (empty($_POST["domain"])){
$_SESSION["msg"]="域名不能为空";
header("Location: domains.php");
exit(0);
}
if (empty($_POST["action"])){
msg("操作不存在");
}
if (empty($_POST["record"])){
msg("记录不能为空");
}
$re=CF::zone_lookup($_POST["domain"]);
if ($re["result"]!="success"){
msg("操作失败:".$re["msg"]);
}
if ($re["response"]["zone_exists"]!=true){
msg("该域名未在Cloudflare接入");
}
if ($re["response"]["zone_hosted"]!=true){
msg("该域名未在".SITE_NAME."接入");
}
$r=CF::remove_zone_name($re["response"]["zone_name"],$re["response"]);
if ($_POST["action"]=="delete")
{
if (!empty($r["hosted_cnames"][$_POST["record"]]))
{
unset($r["hosted_cnames"][$_POST["record"]]);
$result=CF::update_record($r["zone_name"],$r["hosted_cnames"]);
if ($result["result"]=="success")
{
msg("删除成功");
}else{
msg("删除失败:".$result["msg"]);
}
}else{
msg("记录不存在");
}
}elseif($_POST["action"]=="edit")
{
if (!empty($_POST["value"]))
{
$r["hosted_cnames"][$_POST["record"]]=$_POST["value"];
$result=CF::update_record($r["zone_name"],$r["hosted_cnames"]);
if ($result["result"]=="success")
{
msg("更新成功");
}else{
msg("更新失败:".$result["msg"]);
}
}else{
msg("缺少参数");
}
}