修复国家设置,允许不设置任何国家,不做判断
This commit is contained in:
+39
-4
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/cong.php';
|
||||
require_once __DIR__ . '/admin/bootstrap.php';
|
||||
require_once __DIR__ . '/lib/Cloak/CountryAllowlist.php';
|
||||
require_once __DIR__ . '/admin/ConfigWriter.php';
|
||||
require_once __DIR__ . '/lib/Cloak/DomainRepository.php';
|
||||
require_once __DIR__ . '/lib/CloakAdSourceGuard.php';
|
||||
@@ -83,7 +84,9 @@ if (!empty($_REQUEST["action"]) && $_REQUEST["action"] == "setuvi") {
|
||||
if (!empty($_REQUEST["action"]) && $_REQUEST["action"] == "submit") {
|
||||
$check_name = trim($_REQUEST["check_name"]);
|
||||
$methods = trim($_REQUEST["methods"]);
|
||||
$country = trim($_REQUEST["country"]);
|
||||
$country_on = in_array(strtoupper(trim($_REQUEST['country_on'] ?? '')), ['ON']) ? 'ON' : 'OFF';
|
||||
$country_raw = $country_on === 'ON' ? (string) ($_REQUEST['country'] ?? '') : '';
|
||||
$country = $country_on === 'ON' ? CountryAllowlist::formatForConfig($country_raw) : '';
|
||||
$blacklist_group_id = (int)($_REQUEST["blacklist_group_id"] ?? 0);
|
||||
$whitelist_group_id = (int)($_REQUEST["whitelist_group_id"] ?? 0);
|
||||
try {
|
||||
@@ -148,6 +151,11 @@ if (!empty($_REQUEST["action"]) && $_REQUEST["action"] == "submit") {
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($country_on === 'ON' && $country === '') {
|
||||
echo "<script>alert('已开启国家条件,请填写允许的国家代码(如 US,GB,CA)。');history.back();</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!empty($methods)) {
|
||||
ConfigWriter::save($check_name, [
|
||||
'methods' => $methods,
|
||||
@@ -889,9 +897,26 @@ $_d = function($name, $default) { return defined($name) ? constant($name) : $def
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="form-label-cell">指定国家访问真实页(逗号分隔国家代码)</td>
|
||||
<td class="form-val-cell"><input type="text" name="country" class="form-control form-control-sm" value="<?php echo SHOW_SITE_COUNTRY; ?>" placeholder="如:US,GB,CA(请用英文逗号)" style="max-width:300px;"></td>
|
||||
</tr>
|
||||
<td class="form-label-cell">
|
||||
国家条件<br>
|
||||
<small class="text-muted">开启后仅允许填写的国家访问真实页;关闭则不做国家拦截。</small>
|
||||
</td>
|
||||
<td class="form-val-cell">
|
||||
<?php
|
||||
$countryCodesVal = defined('SHOW_SITE_COUNTRY')
|
||||
? CountryAllowlist::formatForConfig((string) SHOW_SITE_COUNTRY)
|
||||
: '';
|
||||
$countryOnVal = $countryCodesVal !== '' ? 'ON' : 'OFF';
|
||||
echo onoff_radio('country_on', $countryOnVal, '开启', '关闭');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="countryCodesRow"<?php echo $countryOnVal === 'ON' ? '' : ' style="display:none;"'; ?>>
|
||||
<td class="form-label-cell">允许的国家代码(多个使用英文逗号隔开)</td>
|
||||
<td class="form-val-cell">
|
||||
<input type="text" name="country" class="form-control form-control-sm" value="<?php echo htmlspecialchars($countryCodesVal); ?>" placeholder="如:US,GB,CA(小写会自动转大写;支持中英文逗号、分号)" style="max-width:360px;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="form-label-cell">广告策略 ID</td>
|
||||
<td class="form-val-cell"><input type="text" name="costm_ip_score" class="form-control form-control-sm" value="<?php echo COSTM_IP_SCORE; ?>" style="max-width:360px;"></td>
|
||||
@@ -1210,6 +1235,16 @@ $_d = function($name, $default) { return defined($name) ? constant($name) : $def
|
||||
$(target).slideToggle(180);
|
||||
});
|
||||
|
||||
function syncCountryCodesRow() {
|
||||
var on = $('input[name="country_on"]:checked').val() === 'ON';
|
||||
$('#countryCodesRow').toggle(on);
|
||||
if (!on) {
|
||||
$('input[name="country"]').val('');
|
||||
}
|
||||
}
|
||||
$(document).on('change', 'input[name="country_on"]', syncCountryCodesRow);
|
||||
syncCountryCodesRow();
|
||||
|
||||
// 动态添加链接
|
||||
var linkIdx = 1;
|
||||
$(document).on('click', '#addNewLinkBtn', function() {
|
||||
|
||||
Reference in New Issue
Block a user