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:
kate522 committed 2026-09-24 19:12:45 +08:00
1 parent bc97c4ddc3
commit ab495854d5
10 files changed
+118 -841

No files matched your search

+7 -13
View File
@@ -1463,6 +1463,10 @@ if (!function_exists('aksrt_get_paid_download_actions_html')) {
continue;
}
$url = (string) ($download['url'] ?? '');
if ($url === '') {
// 直连模式没有可用的原始地址,空源不渲染。
continue;
}
$label = trim((string) ($download['label'] ?? ''));
$service = function_exists('aksrt_detect_cloud_service')
? aksrt_detect_cloud_service($url)
@@ -1470,9 +1474,7 @@ if (!function_exists('aksrt_get_paid_download_actions_html')) {
if ($label === '') {
$label = (string) ($service['name'] ?? __('本地下载', 'aksrt'));
}
$type = sanitize_key((string) ($download['type'] ?? 'direct'));
$extract_code = trim((string) ($download['extract_code'] ?? ''));
$has_extract = $extract_code !== '';
$service_key = sanitize_html_class((string) ($service['key'] ?? 'other')) ?: 'other';
$button_class = trim((string) ($download['class'] ?? ''));
$button_class = $button_class !== '' ? $button_class : 'b-theme ' . $service_key;
@@ -1481,8 +1483,8 @@ if (!function_exists('aksrt_get_paid_download_actions_html')) {
$copy_label = $extract_code !== '' ? $extract_code : ($copy_key !== '' ? $copy_key : __('更多内容', 'aksrt'));
$buttons .= '<div class="but-download flex ac">';
$buttons .= '<button type="button" class="mr10 but ' . esc_attr($button_class) . '" data-action="aksrt-download" data-source-index="' . esc_attr((string) $index) . '" data-source-type="' . esc_attr($type) . '" data-has-extract="' . ($has_extract ? '1' : '0') . '">';
$buttons .= '<i class="fa fas fa-download" aria-hidden="true"></i>' . esc_html($label) . '</button>';
$buttons .= '<a class="mr10 but ' . esc_attr($button_class) . '" href="' . esc_url($url) . '" target="_blank" rel="nofollow noopener">';
$buttons .= '<i class="fa fas fa-download" aria-hidden="true"></i>' . esc_html($label) . '</a>';
if ($copy_value !== '') {
$buttons .= '<button type="button" class="but" data-clipboard-tag="' . esc_attr($copy_key !== '' ? $copy_key : __('内容', 'aksrt')) . '" data-clipboard-text="' . esc_attr($copy_value) . '">' . esc_html($copy_label) . '</button>';
} elseif ($extract_code !== '') {
@@ -1577,21 +1579,14 @@ if (!function_exists('aksrt_get_paid_box_html')) {
$download_box = '';
$root_data = '';
$captcha = '';
if ($pay_type === AKSRT_PAY_TYPE_DOWNLOAD) {
$captcha_active = function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_for('download');
$root_data = ' data-aksrt-download-box data-post-id="' . esc_attr((string) $post->ID) . '" data-captcha="' . ($captcha_active ? '1' : '0') . '"';
$root_data = ' data-aksrt-download-box data-post-id="' . esc_attr((string) $post->ID) . '"';
$download_box = '<div class="hidden-box show"><div class="hidden-text"><i class="fa fas fa-download mr6" aria-hidden="true"></i>' . esc_html__('资源下载', 'aksrt') . '</div>' . aksrt_get_paid_download_actions_html($meta) . '</div>';
$demo = aksrt_get_demo_link_html($post, 'but jb-yellow padding-lg');
if ($demo !== '') {
$download_box .= '<div class="mt10">' . $demo . '</div>';
}
$download_box .= aksrt_get_pay_attributes_html($post, 'pay-attr');
if ($captcha_active && function_exists('aksrt_render_captcha')) {
ob_start();
aksrt_render_captcha('download');
$captcha = '<div class="resource-download-box__captcha resource-download-box__captcha--hidden" data-aksrt-download-captcha>' . (string) ob_get_clean() . '</div>';
}
}
$service = aksrt_get_pay_service_html('inline-block ml10');
@@ -1607,7 +1602,6 @@ if (!function_exists('aksrt_get_paid_box_html')) {
. '<div' . $title_style . '><span class="badg c-red hollow badg-sm mr6">' . esc_html($type_label) . '</span><b>' . esc_html($title) . '</b></div>'
. $download_box
. $service
. $captcha
. '</div></div>';
}
}