forked from Netrvin/CFPMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_domain.php
220 lines (200 loc) · 7.63 KB
/
manage_domain.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php
include_once("cf.class.php");
CF::is_login();
function msg($s){
$_SESSION["msg"]=$s;
header("Location: domains.php");
exit(0);
}
if (empty($_GET["domain"]))
{
msg("域名不能为空");
}
$re=CF::zone_lookup($_GET["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"]);
include_once("header.php");
?>
<div style="margin-top:25px" class="mdui-container">
<div class="mdui-row">
<div class="mdui-col-xs-12 mdui-col-sm-12 mdui-col-md-10 mdui-col-offset-md-1">
<div class="mdui-container mdui-typo">
<div style="float:left">
<a href="./">Cloudflare Partners :
<?=SITE_NAME?>
</a> >
<a href="domains.php">域名管理</a> >
<span>
<?=$r["zone_name"]?>
</span>
<br />
<br />
</div>
<div style="float:right">
<?=$_SESSION["email"]?>.
<a href="./">登出</a>
</div>
</div>
<div class="mdui-card mdui-shadow-5">
<div class="mdui-card-content">
<div class="mdui-container mdui-typo">
<div class="mdui-table-fluid">
<table class="mdui-table mdui-table-hoverable">
<thead>
<tr>
<th><button style="display:inline;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-shadow-3" onclick="javascript:add_record()"><i class="mdui-icon material-icons"></i></button></th>
<th>记录</th>
<th>CNAME记录</th>
<th>回源地址</th>
</tr>
</thead>
<tbody>
<?php
foreach ($r["hosted_cnames"] as $record=>$set)
{
$is_ssl=false;
if (substr($set,strlen($set) - 12)=="comodoca.com")
{
$is_ssl=true;
}
echo "<tr>".
'<td><button style="display:inline;" class="mdui-btn mdui-btn-icon mdui-shadow-3 ';
if ($is_ssl)
{
echo 'mdui-color-grey" mdui-tooltip="{content: \'请勿修改SSL配置记录\'}"';
}else{
echo 'mdui-ripple mdui-color-indigo" onclick="javascript:edit_record(\''.$record.'\',\''.$set.'\')"';
}
echo '><i class="mdui-icon material-icons"></i></button><button onclick="javascript:delete_record(\''.$record.'\')" style="display:inline;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-shadow-3 mdui-color-red-900"><i class="mdui-icon material-icons"></i></button></td>'.
"<td>".$record."</td><td>";
if ($is_ssl)
{
echo $set;
}else{
echo $r["forward_tos"][$record];
}
echo "</td><td>".$set.'</td></tr>';
}
?>
</tbody>
</table>
</div>
<p>
注 (1):必须设置一个<strong>www</strong>记录,否则会自动设置一个回源地址为<strong><?=$r["zone_name"]?></strong>的<strong>www</strong>记录。本记录可不在DNS服务商配置
</p>
<p>
注 (2):根据先前的测试(2018-02-15),目前启用Universal SSL无需再专门配置CNAME记录,只需配置所需接入的域名的CNAME记录。证书将在24小时内下发。一切以实际情况为准
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="mdui-dialog" id="delete_record">
<div class="mdui-dialog-title">删除记录</div>
<form method="post" action="edit_record.php" autocomplete="off">
<div class="mdui-dialog-content">
<input type="hidden" value="delete" name="action" />
<input type="hidden" value="<?=$r["zone_name"]?>" name="domain" />
<input type="hidden" value="" name="record" id="delete_record1" /> 你确定要删除记录
<strong>
<span id="delete_record2"></span>
</strong>吗?
</div>
<div class="mdui-dialog-actions">
<button type="button" class="mdui-btn mdui-ripple" mdui-dialog-close>关闭</button>
<input type="submit" class="mdui-btn mdui-ripple mdui-color-red-900" value="确定" />
</div>
</form>
</div>
<div class="mdui-dialog" id="edit_record">
<div class="mdui-dialog-title" id="edit_record_title">修改记录</div>
<form method="post" action="edit_record.php" autocomplete="off">
<div class="mdui-dialog-content">
<input type="hidden" value="edit" name="action" />
<input type="hidden" value="<?=$r["zone_name"]?>" name="domain" />
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">记录</label>
<input class="mdui-textfield-input" id ="edit_record1" name="record" required />
</div>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">回源地址</label>
<input class="mdui-textfield-input" id="edit_record2" name="value" required />
</div>
</div>
<div class="mdui-dialog-actions">
<button type="button" class="mdui-btn mdui-ripple" mdui-dialog-close>关闭</button>
<input type="submit" class="mdui-btn mdui-ripple mdui-color-green mdui-text-color-white" value="确定" />
</div>
</form>
</div>
<script>
function delete_record(record) { document.getElementById("delete_record2").innerHTML = record;
document.getElementById("delete_record1").value = record;
var inst = new mdui.Dialog("#delete_record", {
history: false
});
inst.open();
}
function add_record(){
document.getElementById("edit_record_title").innerHTML = "添加记录";
document.getElementById("edit_record1").value = "";
document.getElementById("edit_record2").value = "";
mdui.updateTextFields();
var inst = new mdui.Dialog("#edit_record", {
history: false
});
inst.open();
}
function edit_record(record,value){
document.getElementById("edit_record_title").innerHTML = "修改记录";
document.getElementById("edit_record1").value = record;
document.getElementById("edit_record2").value = value;
mdui.updateTextFields();
var inst = new mdui.Dialog("#edit_record", {
history: false
});
inst.open();
}
</script>
<div class="mdui-dialog" id="msg_dialog">
<div class="mdui-dialog-content">
<?php
if (!empty($_SESSION["mng_msg"]))
{
echo $_SESSION["mng_msg"];
}
?>
</div>
<div class="mdui-dialog-actions">
<button class="mdui-btn mdui-ripple" mdui-dialog-close>关闭</button>
</div>
</div>
<?php
$msg_script=<<<SCRIPT
<script>
var inst = new mdui.Dialog("#msg_dialog",{
history: false
});
inst.open();
</script>
SCRIPT;
if (!empty($_SESSION["mng_msg"]))
{
echo $msg_script;
unset($_SESSION["mng_msg"]);
}
include_once("footer.php");
?>