feat(vip): add default icons and remove download speed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 17:48:10 +08:00
co-authored by Claude Fable 5
parent 77d54b3b9d
commit 18da39788f
15 changed files with 105 additions and 74 deletions
+5 -22
View File
@@ -295,16 +295,11 @@ class Download {
}
$target_url = esc_url_raw((string) $meta['downloads'][$idx]['url']);
$speed_kb = 0;
$uid_speed = (int) ($row['user_id'] ?? 0);
if ($uid_speed > 0 && function_exists('aksrt_get_user_download_speed')) {
$speed_kb = aksrt_get_user_download_speed($uid_speed);
}
// Local attachment / uploads file: optional throttled stream (Zibll speed limit).
// Local attachment / uploads file: stream without artificial throttling.
$local_path = $this->resolve_local_download_path($target_url);
if ($local_path !== '' && is_readable($local_path)) {
$this->stream_local_file($local_path, $speed_kb);
$this->stream_local_file($local_path);
exit;
}
@@ -347,9 +342,9 @@ class Download {
}
/**
* Stream a local file with optional KB/s throttle.
* Stream a local file.
*/
private function stream_local_file(string $path, int $speed_kb = 0): void {
private function stream_local_file(string $path): void {
$filename = basename($path);
$size = filesize($path);
if ($size === false) {
@@ -364,21 +359,12 @@ class Download {
header('Content-Length: ' . (string) $size);
$chunk = 1024 * 64; // 64KB
$sleep_us = 0;
if ($speed_kb > 0) {
// Emit ~speed_kb KB per second using fixed 64KB chunks when possible.
$bytes_per_sec = max(1024, $speed_kb * 1024);
$chunk = min(1024 * 64, $bytes_per_sec);
$chunk = max(1024, $chunk);
// Sleep so chunk_bytes / second ≈ bytes_per_sec.
$sleep_us = (int) max(0, (int) round(($chunk / $bytes_per_sec) * 1000000) - 1000);
}
$fh = fopen($path, 'rb');
if (!$fh) {
$this->fail_410();
}
// Disable output compression for accurate Content-Length / throttle.
// Disable output compression so Content-Length remains accurate.
if (function_exists('apache_setenv')) {
@apache_setenv('no-gzip', '1');
}
@@ -392,9 +378,6 @@ class Download {
if (function_exists('flush')) {
flush();
}
if ($sleep_us > 0) {
usleep($sleep_us);
}
}
fclose($fh);
}