feat(download): switch download buttons to direct source links
The token relay still stood between the button and the file: every click issued a short-lived token URL, so downloads never reached the real source address directly. - Render direct anchors (target=_blank) to the raw source URL in the download box and the paid card, with inline extract-code buttons - Retire the relay: delete Content\Download plus its init wiring, header query-var branch and SEO noindex branch, and drop the dead download-request flow from cms-download.js (cashier, scan-pay and error views stay) - Keep the dl_token table and the download logs page as read-only history; unscheduling of the orphaned cleanup cron is preserved
This commit is contained in:
@@ -55,11 +55,6 @@ $pay_modo = is_array($priced)
|
||||
? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0')
|
||||
: ((($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
|
||||
$user_amount = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
|
||||
$cost = function_exists('aksrt_resource_download_cost') ? (int) aksrt_resource_download_cost($post_id) : 0;
|
||||
|
||||
$captcha_active = function_exists('aksrt_is_captcha_enabled_for')
|
||||
&& aksrt_is_captcha_enabled_for('download');
|
||||
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() ? \AKSRT\Ledger\LedgerService::get_instance()->balance(get_current_user_id(), \AKSRT\Ledger\AssetType::POINTS) : 0));
|
||||
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
|
||||
$vip_url = function_exists('aksrt_get_user_center_tab_url')
|
||||
? aksrt_get_user_center_tab_url('credits')
|
||||
@@ -160,7 +155,6 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
data-pay-limit="<?php echo esc_attr((string) $pay_limit); ?>"
|
||||
data-has-paid="<?php echo $has_paid_access ? '1' : '0'; ?>"
|
||||
data-credit="0"
|
||||
data-captcha="<?php echo $captcha_active ? '1' : '0'; ?>"
|
||||
aria-label="<?php esc_attr_e('下载区', 'aksrt'); ?>">
|
||||
|
||||
<?php if ($has_paid_access && $user_amount > 0) : ?>
|
||||
@@ -345,6 +339,10 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
}
|
||||
$type = isset($row['type']) ? (string) $row['type'] : 'direct';
|
||||
$url = isset($row['url']) ? (string) $row['url'] : '';
|
||||
if ($url === '') {
|
||||
// 直连模式没有可用的原始地址,空源不渲染。
|
||||
continue;
|
||||
}
|
||||
$extract_code = isset($row['extract_code']) ? trim((string) $row['extract_code']) : '';
|
||||
$has_extract = $extract_code !== '';
|
||||
|
||||
@@ -354,27 +352,22 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
}
|
||||
|
||||
if ($is_need_login) {
|
||||
$btn_tag = 'a';
|
||||
$btn_href = $login_url;
|
||||
$btn_text = __('登录后下载', 'aksrt');
|
||||
$btn_icon = 'fa-sign-in-alt';
|
||||
$btn_modifier = ' resource-download-box__btn--login';
|
||||
$btn_action = '';
|
||||
$btn_target = '';
|
||||
$btn_rel = '';
|
||||
} else {
|
||||
$btn_tag = 'button';
|
||||
$btn_href = '';
|
||||
$btn_href = $url;
|
||||
$btn_text = __('立即下载', 'aksrt');
|
||||
$btn_icon = 'fa-download';
|
||||
$btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : '';
|
||||
$btn_action = 'aksrt-download';
|
||||
$btn_target = '';
|
||||
$btn_rel = '';
|
||||
$btn_target = ' target="_blank"';
|
||||
$btn_rel = ' rel="nofollow noopener"';
|
||||
}
|
||||
?>
|
||||
<li class="resource-download-box__item">
|
||||
<?php if ($btn_tag === 'a') : ?>
|
||||
<a
|
||||
class="resource-download-box__btn btn-primary resource-download-box__btn--service-<?php echo esc_attr($service['key']); ?><?php echo esc_attr($btn_modifier); ?>"
|
||||
href="<?php echo esc_url($btn_href); ?>"<?php echo $btn_target; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo $btn_rel; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
@@ -388,25 +381,12 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
<?php echo esc_html($service['name']); ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<button
|
||||
type="button"
|
||||
class="resource-download-box__btn btn-primary resource-download-box__btn--service-<?php echo esc_attr($service['key']); ?><?php echo esc_attr($btn_modifier); ?>"
|
||||
data-action="<?php echo esc_attr($btn_action); ?>"
|
||||
data-source-index="<?php echo esc_attr((string) $idx); ?>"
|
||||
data-source-type="<?php echo esc_attr($type); ?>"
|
||||
data-has-extract="<?php echo $has_extract ? '1' : '0'; ?>"
|
||||
data-balance="<?php echo esc_attr((string) $balance); ?>"
|
||||
data-cost="<?php echo esc_attr((string) $cost); ?>"
|
||||
style="--service-color: <?php echo esc_attr($service['color']); ?>"
|
||||
>
|
||||
<i class="fa <?php echo esc_attr($btn_icon); ?>" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html($btn_text); ?></span>
|
||||
<span class="resource-download-box__service-badge" style="background: <?php echo esc_attr($service['color']); ?>">
|
||||
<?php echo esc_html($service['name']); ?>
|
||||
</span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($has_extract) : ?>
|
||||
<button type="button" class="resource-download-box__btn resource-download-box__btn--extract"
|
||||
data-clipboard-tag="<?php esc_attr_e('提取码', 'aksrt'); ?>"
|
||||
data-clipboard-text="<?php echo esc_attr($extract_code); ?>"
|
||||
><?php echo esc_html($extract_code); ?></button>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
@@ -471,12 +451,6 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($captcha_active && function_exists('aksrt_render_captcha')) : ?>
|
||||
<div class="resource-download-box__captcha resource-download-box__captcha--hidden" data-aksrt-download-captcha>
|
||||
<?php aksrt_render_captcha('download'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<footer class="resource-download-box__footer">
|
||||
<p class="resource-download-box__notice-text">
|
||||
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
|
||||
|
||||
Reference in New Issue
Block a user